ICPC 2024 Asia Yokohama Regionalã«TECHNICOLORZã§åå ãã¦42ä½(/55)ã§ããã
ã¡ã³ãã¼
- Qitoy : AtCoderéè²ã§å¦å ã§ä¸çªratingãé«ãã
- Kei83 : èªåãå é±AtCoderæ°´è²ã«ãªã£ãã
- haruki4936 : AtCoderéè²ã§èªåã®å¦ç§ã®å 輩ã
ã³ã³ãã¹ãå
èªåãPCã®ã»ããã£ã³ã°ããã¦ï¼ABãharukiããã¨Qitoyããã§åæ ãããã¨ã«ãã¾ããããã¯ãä½æ¦ãã©ãããããã¾ãããï¼Qitoyããã®DPåãæããã«æãã¦ããã®ã§ï¼DPã½ãåé¡ã¯Qitoyããã«ãã£ã¦ããããã¨ã«ãã¾ãããï¼èªåãããã®ãå®å ¨ã«ç¡é§ã«ãªããããæ©ãï¼
ã³ã³ãã¹ã
åé¡æã¯ãã
å°çãéãã¦ï¼ãã¹ã¯ã¼ããå
¥åãã¾ãããªãã¼ãµã«ã§ã¯ï¼èªåã¯ãããªãã£ãã®ã§ï¼ãã®pwãæã¦ã°ãããã§ãããï¼ã¨harukiããã«ç¢ºèªãã¦ãã°ã¤ã³ãã¾ãããå
ãã¯ï¼.bashrcãéãã¦ã³ã³ãã¤ã«ã®aliasãè¨å®ãã¾ããã
alias g=âg++ -Wall -Wconversion -Wfatal-errors -g -std=gnu++20 -fsanitize=undefined,addressâ
次ã«ï¼ãã¼ã ã®ã©ã¤ãã©ãªã¯kactlã使ç¨ãããã¨ã«ãªã£ã¦ããã®ã§ï¼ãã®ãã³ãã¬ã¼ããæ¸ãã¾ããã
#include<bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() using ll = long long; using pii = pair<int, int>; using vi = vector<int>; int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); }
å¾ã¯ï¼VSCodiumã®auto saveããªã³ã«ãã¦ï¼PCã®ã»ããã£ã³ã°ã¯çµããã¾ãããã¤ãã§ã«ï¼èªåã¯ã¤ã³ãã³ãå¹
2ã好ã¿ãªã®ã§ï¼Tab sizeã2ã«ãã¦ããã¾ããã
大ä½ããã§10åãããããã£ããããªæ°ããã¾ãã
äºäººãA, Bãèªãã§è§£ãã¦ããã®ã§ï¼ä»ã®åé¡ãèªã¿ã«è¡ããã¨ã«ãã¾ãããã©ãããèªãã§ãè¯ãã£ãã®ã§ããï¼ã¨ããããDããèªããã¨ã«ãã¾ãããDã¯èªãã®ã«ãæéãçµæ§ããã£ã¦ï¼åé¡æãåãã£ã¦ã解ããããªæãã¯å ¨ãããªãã£ãã®ã§ï¼ã¹ã«ã¼ãã¦ï¼æ¬¡ã«Eãèªã¿ã«è¡ãã¾ãããEåé¡ãèªã¿ï¼å°ãèãã¦ãããï¼ã¡ããã©ABãã©ã£ã¡ãACãããããã§ï¼ãªãã ã解ããããªæãã®Eåé¡ãäºäººã¨å ±æãã¾ããã
ããã§Eåé¡ã¯ï¼harukiãããæ¸ããã¨ã«ãªã£ã¦ï¼ãããã¾ãå¥ã®åé¡ãèªããããªã¨æã£ã¦ï¼é ä½è¡¨ãè¦ã¦è§£ããã¦ããåé¡ã確èªãã¦Kãèªã¿ã«è¡ãã¾ãããè¦ãç®çã«ã¯ï¼çµæ§è§£ããããããªãããªã¼ã¨ãæã£ããã§ããï¼çµå±å ·ä½çãªæ¹éãç«ããªãã¾ã¾æéã使ããã¨ã«ãªãã¾ããããã®éä¸ã§harukiãããEã®ãµã³ãã«ãåãï¼æåºãããREã ã£ãã®ã§ï¼èªåããã®ã³ã¼ããè¦ããã¨ã«ãã¾ããã
dfsã®ã³ã¼ããï¼ãããªæãã§æ¥ãæ¹åã«æ»ããªãããã«ãã¦ããã¨ããã§ï¼æ ¹ã®æã«predir = -1ã¨ãã¦ããããã«ï¼(-1 + 3 == 2)ã¨ãªã£ã¦continueãã¦ãã°ããã¨ã«æ°ä»ãã¾ãããæ¬å½ã«ãããç´ãã ãã§éã£ã¦ã³ã£ãããã¾ããã
dfs(座æ¨, int predir) { for (int nowdir = 0; nowdir < 4; nowdir++) { if (predir + nowdir == 2) continue; å¦ç~~ } }
EãACããå¾ã¯ï¼F, Hãã¨ããããèªãã ããã¾ãããï¼è§£ããããªæãã¯å ¨ããã¾ããã§ãããèªåã¯ç¹ã«é²å±ããªãã¾ã¾æéãçµéãï¼ãã¤ã®éã«ãQitoyãããCãéãã¦ãã¾ããããã®å¾ã¯èªåãKãèãã¦ï¼QitoyãããIãèãã¦ãã¦ï¼ã©ã¡ãããã¾ãé²ãã§ããªãããã ã£ãã®ã§ï¼èªåãIãèãã¦ã¿ããã¨ã«ãã¾ããã
Moã§åºæ¥ãªãããªã¼ã¨æãã¨ï¼Aã®ç´æ°dã«é¢ãã¦ï¼è¿½å ã¯cnt[d]++
, åé¤ã¯cnt[d]â
ã¨ããã°ï¼ãã®åºéã®æ大ã®GCDã¯cnt[i]ã2以ä¸ã®ã¨ãªãiä¸ã§æ大ã®å¤ã¨ããã°ããï¼çµæ§åç´ã«åºæ¥ããã§ãããcnt[i]ã2ã«ãªã£ãæã«iãsetã«å
¥ãã¦ï¼æ大ãåãåºãå®è£
ã«ãã¦æåºããã¨TLEãã¾ãããã¨ããããvectorãçé
åã«åºæ¥ãã¨ããã¯å
¨é¨çé
åã«ãã¦ï¼#pragma GCC target("avx2")
ãä»ããããã¦ã¿ã¦ï¼ä½åãæåºãã¦ã¿ã¾ãããå¤ãããTLEã§ãããï¼AOJã ã¨3.6 secã§ACã ã£ãã®ã§æ¬çªã®ç°å¢ã¯ã¡ãã£ã¨é
ãããæåºï¼
çµå±setã使ããªãæ¹æ³ã«ããªãã¨ï¼ã©ãã«ããªããªããã¨ãã£ã話ãQitoyããã¨ãã¦ãã¾ãããèªåã¯ã»ã°æ¨ã§ä½ã¨ããªããªãããªã¼ã¨ãæã£ã¦ãã¾ãããï¼QitoyãããBITã¨äºåæ¢ç´¢ã§åºæ¥ãããªãã¨ã«æ°ä»ãï¼æãã¦ãããã¨åºæ¥ããã§ããããã®æharukiãããGã¨æ ¼éãã¦ããã®ã§ï¼ã²ã¨æ®µè½ããã¾ã§ã«å®è£ ã®è©³ç´°ã確èªãã¦ãã¾ããã
kactlã®fenwicktreeã«lower_boundãä»ãã¦ãã¦ï¼ãã¼ã¾ãã«ããã欲ããã¦å©ããï½ã¨ãªã£ã¦ãã¾ãããharukiããã«PCã空ãã¦ãããï¼æ¸ãã¦æå ã§ãé度ã確èªããã¨ï¼ç¸å½æ©ããªã£ã¦ãã¦ãããã«ããã¯ãããããããªããã¨æã£ã¦æåºããã¨éãã¾ãããï¼AOJã ã¨1.08 secã§3å以ä¸æ©ããªã£ã¦ãã¾ãããæåºï¼
æ®ãã¯harukiãããGã¨æ ¼éããªããï¼èªåã¯Qitoyããã¨Kã«ã¤ãã¦è©±ãã¦ãã¦æå¾ã¾ã§è§£ãåããã¨ã¯åºæ¥ãã«çµäºã§ããã
çµäº15ååãããã«ããããã°åºæ¥ããã ãã¨Qitoyããã¨è©±ãã¦ãããã¨ãï¼çµãã£ã¦ããæ¸ãã¦ã¿ããACåºæ¥ãã®ã§ï¼ãããã¡ããã¨æ¸ãã¦éããããã°ãªã¨ãã£ãæãã§ããã(ããã§ãããããå ¨é¨ç«ã£ã¦ãããã¤ã¨å ´ååãã®æ¼ãã§3WAãã¾ãããæåº)
çµããã«
ç°¡åæ ã®ABããäºæ¹ã«è§£ãã¦ããããã¨ã«ããããï¼èªåã®å®åçã«ã¯ï¼æ®ã£ãåé¡ãã©ããå ¨ãåãããªãå¯è½æ§ã¯å ¨ç¶ãããªã¨æã£ã¦ããã®ã§ï¼5æéæ¤ åã温ãããããªç¶æ³ã¯åé¿ã§ãã¦ï¼æªããªãã£ãã®ã§ã¯ãªããã¨æã£ã¦ãã¾ãã ã¾ãï¼Mo's algorithmã¯JAGå¤å宿day1ã®Aåé¡ï¼Static Range Mode Queryï¼ã§åãã¦è¦ã¦ï¼ãããã使ããããã«ãªã£ãã®ã§ï¼ICPCã«åããç·´ç¿ã®ææãåºãããããªæ°ããã¦ï¼ãã®ç¹å人çã«ã¯æºè¶³ãã¦ãã¾ãã èªåã¯ãã¨2åï¼ICPCã«åå ã§ããã¨æãã®ã§ï¼ãã1å横æµã«è¡ããããããªï½ã
ãã¾ã
Yokomaha Regionalã«åå ããã«ããã£ã¦ï¼ã¨ããããä¼å ´ã«è¿ãããã«ã«æ³ã¾ããã¨æã£ã¦ï¼ããã«JALã·ãã£é¢å 横æµã¨ããä¼å ´ããå¾æ©3åã®ã¨ããã«ããããã«ã«å®¿æ³ãã¾ãããæ8æ30åãããã«ä¼å ´ã«å°çããããã¨ãèããã¨ï¼æã£ããããæãæ©ãã¦ï¼è¿ãããã«ã«ãã¦ããã¦è¯ãã£ããªã¨æãã¾ããããã®ããã«ã¯æé£ã7æããé£ã¹ããã¨ãåºæ¥ã¦ï¼çµæ§ç¾å³ããã£ãã®ã§ï¼æé£ããã£ããé£ã¹ãã人ã«ã¯ããããã§ãã