Submission #974861

#TimeUsernameProblemLanguageResultExecution timeMemory
974861oolimryMars (APIO22_mars)C++17
0 / 100
1 ms432 KiB
#include <bits/stdc++.h> using namespace std; #define sz(x) (int) (x).size() #define all(x) (x).begin(), (x).end() #define show(x) cerr << #x << " is " << x << endl; #define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl; #define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl; #define showlist(x) cerr << #x << " is "; for(auto p : x) cerr << p << " "; cerr << endl; typedef pair<int,int> ii; ///attempt 2: each position be a bit in the 100 bit string ///but we store only for the positions (i mod 2) (j mod 2) - 4 color checkboard ///we can store up to 400 bits, so a 19x19 grid max --> 29 points i think ///probably if you ignore some cells you can optimize to 21x21 /// stuff for dfs int grid[45][45]; void dfs(int i, int j){ if(i < 0 or j < 0) return; if(grid[i][j] == 0) return; grid[i][j] = 0; dfs(i+1,j); dfs(i-1,j); dfs(i,j+1); dfs(i,j-1); } int cellToBit(int i, int j){ return (i/2) * 10 + (j/2); } string process(vector <vector<string>> a, int I, int J, int K, int n){ //cerr << I << " " << J << " " << K << endl; string res = string(100 ,'0'); if(K == 0){ ///first run for(int i = 0;i <= 2;i += 2){ for(int j = 0;j <= 2;j += 2){ int pos = cellToBit(i+I, j+J); if(a[i][j][0] == '1') res[pos] = '1'; } } } else{ for(int i = 0;i <= 2;i += 2){ ///+=2 for same color for(int j = 0;j <= 2;j += 2){ for(int p = 0;p < 100;p++){ if(a[i][j][p] == '1') res[p] = '1'; } } } } if(K == n-1){ ///last phase --> convert to binary for(int i = 0;i < 45;i++) for(int j = 0;j < 45;j++) grid[i][j] = 0; for(int io = 0;io <= 1;io += 1){ for(int jo = 0;jo <= 1;jo += 1){ for(int p = 0;p < 100;p++){ if(a[io][jo][p] == '1'){ int i = (p / 10) * 2 + (io % 2); int j = (p % 10) * 2 + (jo % 2); grid[i][j] = 1; } } } } if(n == 1){ ///annoying edge case for(int i = 0;i <= 2;i++){ for(int j = 0;j <= 2;j++){ if(a[i][j][0] == '1') grid[i][j] = 1; } } } for(int i = 0;i < 2*n+1;i++){ for(int j = 0;j < 2*n+1;j++) cerr << grid[i][j]; cerr << endl; } ///count no. of connected components via dfs int cnt = 0; for(int i = 0;i < 45;i++) for(int j = 0;j < 45;j++){ if(grid[i][j]){ cnt++; dfs(i,j); } } //cerr << cnt << endl; res = string(100 ,'0'); for(int p = 0;p < 100;p++){ if(cnt % 2 == 1) res[p] = '1'; cnt /= 2; } } //cerr << res << endl; return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...