Koying

@Koying

Joined on Dec 23, 2021

  • Implementation A. Load balancing 設定兩個變數 batch_x, batch_y,代表 x, y 軸的 batch size,並依照 iters 參數分成兩種情況: iters > 10000:每個像素點會進行多次迭代,但因為有些點會在還沒有迭代到指定步數就跳出(x^2 + y^2 >= 4),會造成多個點計算量的不平均。在這個情況下,將 batch_x 設定為 max(1, (int)(width / num_threads / 4)),並將 batch _y 設定為 1,利用更小的 batch size 來提升 load balancing 的效果 iters <= 10000:將 batch_x 設定為 width / num_threads, batch_y 設定為 width / num_threads / 12,也就是平均每個 thread 會分到 num_threads * 12 塊區域。 分配工作 首先宣告以下物件:
     Like  Bookmark
  • Implementation Input 首先是輸入的部分,因為兩個節點在交換資料並 merge 的時候,在長度一樣的情況下會比較好實作,因此首先將每個節點的資料都設定為 $chunksize = \left \lceil \frac{n}{size} \right \rceil$,最後一個節點如果資料不夠,就以 infinity 填充。 此外,由於資料量過小時,將其分散到不同 process 反而會降低其效能,因此我將每個 process 的最小 batch size 設定為 65536,如果低於 65536 就不再使用其他 process。 接著建立三個足夠大的 float 陣列:a, b, recv_data,並建立兩個 float 指標:data[0] = a, data[1] = b,將 data[0] 作為目前使用的資料。 最後呼叫 MPI 的 read api 將對應到的資料讀到 data[0][1] ~ data[0][chunksize],並將 data[0][0], data[0][chunksize + 1] 設定為 infinity。
     Like  Bookmark
  • 14449 - Big orange cat's puzzle II 希望大家不要討厭大橘 QQ 為了跟程式碼比較接近,接下來的敘述會以 0-based 為主 題意 找到一個最小的合法區間 $[l, r]$,然後輸出從 $B_l \sim B_r$ 拿出一些字元重新排列後,有辦法組出 $A$ 的最小字典序解 Subtask 1
     Like  Bookmark
  • Key points: How to determine + construct the solution. You've already written the determination part in HW4, so how do we construct the solution? In HW4, you probably used an array to record how many times each character appeared. In other words, that array recorded which characters you need. We can make good use of this property. One hint is that Big Orange is very lazy and wants to take from the front. Therefore, we can start directly from the left, adding each needed letter to the answer as we encounter it, then decrementing the corresponding position in the array by 1. Finally, if we've collected the same number of characters as in $A_i$, it means we can construct the solution. As for the lexicographically smallest order, since you're trying to take from the leftmost side, this approach naturally results in the lexicographically smallest order. Subtask 1 $A$ and $B$ are of equal length and each is sorted in ascending lexicographical order. This means you only need to directly check if the two strings are equal. If they are equal, simply output all indices.
     Like  Bookmark
  • $\mathcal{O}()$:用來描述一個函數的「上界」,在競程中用來表示時間複雜度 $\displaystyle\sum_{i = 1}^{n}{i}$:求和符號(此例子表示 $1 \sim n$ 的和) $\displaystyle\prod_{i = 1}^{n}{i}$:連乘符號,運作原理與求和符號相似,不過把加改成乘 $\lceil \frac{a}{b} \rceil$:$\frac{a}{b}$ 取上高斯(小數點無條件進位) $\lfloor \frac{a}{b} \rfloor$:$\frac{a}{b}$ 取下高斯(小數點無條件捨去) $a \bmod b$:$a$ 除以 $b$ 的餘數 $a \equiv b \pmod{P}$:$a$ 與 $b$ 在 $\bmod P$ 的環境下同餘 $a \mid b$:$a$ 整除 $b$,$a \equiv 0 \pmod{b}$ $\gcd(a, b)$:$a, b$ 的最大公因數 $\text{lcm}(a, b)$:$a, b$ 的最小公倍數
     Like 2 Bookmark
  • 競賽資訊 比賽名稱:NHDK Ten Point Round #32 (Div. 2, based on NHDK APCS 模擬賽 #1) 比賽時間:12/18 13:40 ~ 16:10 使用平台:CMS(非 APCS 使用平台,當天早上 9:00 開放登入) 報名時間:即日起至 12/17 18:00 報名表單:https://forms.gle/NHSdUbhCHtCbzuBX9 競賽連結:將與帳號密碼一同寄至參賽者的信箱中 賽後 mirror 連結:https://codeforces.com/contestInvitation/64f22787871cc25f6aead746556959c5708480d3 賽制
     Like 1 Bookmark
  • 圖片來源:小白 以 nhdktpr@gmail.com 為例:
     Like  Bookmark
  • [TOC] Discord 功能介紹 程式碼區塊 相信許多人在貼程式碼的時候常常會莫名其妙跑版,這是因為程式碼中的許多符號恰巧跟 markdown 的語法重疊,進而觸發了特殊文字效果,這時候就需要用到程式碼區塊的功能 使用方式: #include <iostream>
     Like 23 Bookmark
  • 2022 新化高中 x 嘉義高中 x 薇閣高中 資研社聯合暑期培訓營 報名截止時間:6/30 23:59 活動日期:7/4~7/17 上課:7/4 ~ 7/8、7/11 ~ 7/15 練習賽:7/10、7/17 活動地點 線上 (Discord + Google Meet)
     Like  Bookmark
  • P1 數字遊戲 題敘 給三個正整數,求眾數以及去重之後從大排到小的順序 解題思路 用任意方法將其排序之後,找到出現最多次的將其輸出 若排序後 $a_i \neq a_i-1$ 則將 $a_i$ 輸出 參考程式
     Like  Bookmark
  • NHDK TPR #17 (Div.1+2, Sponsored by YTP) 題解 特別感謝 AA 競程 YTP 少年圖靈計畫
     Like  Bookmark
  • 比賽時間:4/2 14:00 ~ 17:00 比賽分級:Div.1 + 2 賽制:OI制 (IOI 2017,有部分分、子任務聯集) 題數:8 出題者: Colten、Koying 驗題者: sam571128、penguin71630、franklee1015、btlllbill、dreamoon、littlecube、Fysty、SFeather、wcwu、Darren、user1519、KTK2538、amano_hina 競賽網站
     Like  Bookmark
  • (Div. 3, based on 台南女中資訊研究社 期末測驗) 賽後題解 Problem A. 社團旅遊的策略 出題者:ColtenOuO 首殺:Darren0724 - 01:03 一年級可以免費參加的人數為 $\lfloor \frac{k_1}{3} \rfloor$
     Like  Bookmark
  • 記分板 怕哪天記分板不見,所以補個截圖 成績: 418/900 (AC * 3) PA 65/100: 一開始看到題目稍微遲疑了一下能不能離散化,想了一下子之後發現我是智障,比例根本就會變,我果然不會數學,隨後便用 set 去做,隨後拿到 65 分,一開始在想是不是某個地方常數太大,所以拿不到滿分,然後就花了一點時間在優化常數,到開賽一小時前都斷斷續續的有送出 submit (看到PB的紀錄我也不知道我甚麼時候去寫PB的了),結果還是想不到能夠優化到滿分的方法,在結束前一小時回去看了一下,發現好像可以試著用 unordered_set 優化看看,結果還是被 TLE 揍成智障,後來就沒想法了.w. 賽後才發現只要排序四次就可以,我果然是智障 :TLEThinking:
     Like  Bookmark
  • 3/18 Educational Codeforces Round 106 (Rated for Div. 2) 3/29 CodeCraft-21 and Codeforces Round #711 (Div. 2)
     Like  Bookmark
  • 競賽連結 PA Domino on Windowsill 題目連結 題敘: 給定一個長度為2格,寬度為n個的區塊,其中第一行的前k1以及第二行的前k2格為白色,其餘為黑色,問w個白色骨牌以及b個黑色骨牌(每個骨牌皆佔兩格)是否能全部放入相對應顏色的區域中 題解: PB Binary Removals 題目連結
     Like  Bookmark
  • PA GCD Sum 題目連結 題敘: 有一函式gcdSum(x)=gcd(x,sum of digitials of x),意指x與其每一位數之和的最大公因數,求不小於n的整數中符合gcdSum(x)>1之最小x 解法: 這題主要有兩個部分:x每一位數字和的的計算(sum of digitials of x)以及其與x之最小公倍數之計算,因此我們只要寫一個函式sum(x)去求x的每位數字和並使用c++內建函式__gcd求得gcdSum(x)即可,最後從n開始枚舉直到gcdSum(x)>1 程式碼: int f(int x) //算出x的每位數字和 { int sum=0; while(x)
     Like 1 Bookmark