Submission #960287

#TimeUsernameProblemLanguageResultExecution timeMemory
960287WansurMars (APIO22_mars)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #define f first #define s second #define ent '\n' //#define int long long #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("Ofast,unroll-loops,fast-math,O3") const int dx[]={-1, 1, 0, 0, 0}; const int dy[]={0, 0, 1, -1, 0}; typedef long long ll; using namespace std; const int mx=50+12; const int mod=998244353; const bool T=1; bool used[mx][mx]; int c[mx][mx]; void dfs(int x,int y,int n){ used[x][y]=1; for(int i=0;i<4;i++){ int x1=dx[i]+x; int y1=dy[i]+y; if(x1>=0 && y1>=0 && x1<n && y1<n && !used[x1][y1]){ dfs(x1, y1, n); } } } string gn(int n) { int cnt = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cout<<used[i][j]<<' '; used[i][j] ^= 1; } cout<<ent; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (!used[i][j]){ dfs(i, j, n); cnt++; } } } string ans=""; for(int i=0;i<20;i++){ if((cnt&(1<<i))){ ans+='1'; } else{ ans+='0'; } } while(ans.size()<100){ ans+='0'; } return ans; } pair<int,int> opt(int l,int r,int k, int n){ int tl = l * (2 * n + 1) / (2 * (n - k) + 1); int tr = (l+1) * (2 * n + 1) / (2 * (n - k) + 1)-1; return {tl, tr}; } void upd(string s,int i,int j,int k, int n){ auto [tli, tri] = opt(i, i+2*k, k, n); auto [tlj, trj] = opt(j, j+2*k, k, n); int pos=0; for(int i=tli;i<=tri;i++){ for(int j=tlj;j<=trj;j++){ used[i][j] = (s[pos] == '1'); pos++; } } } string process(vector<vector<string> > a,int x,int y,int k,int n){ k++; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ upd(a[i][j], x+i, y+j, k-1, n); } } auto [tli, tri] = opt(x, x+2*k, min(n-1, k), n); auto [tlj, trj] = opt(y, y+2*k, min(n-1, k), n); string ans=""; for(int i=tli;i<=tri;i++){ for(int j=tlj;j<=trj;j++){ ans += char(used[i][j] + '0'); } } while(ans.size() < 100){ ans+='0'; } if(n==k){ return gn(n * 2 + 1); } return ans; }
#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...