Submission #291367

#TimeUsernameProblemLanguageResultExecution timeMemory
291367mohammadVision Program (IOI19_vision)C++14
44 / 100
1101 ms99532 KiB
#include "vision.h" #include<bits/stdc++.h> using namespace std; #define endl "\n" // #define int long long typedef long long ll ; const ll ooo = 1e14 ; const ll oo = 2e9 ; const double PI = acos(-1) ; const ll M = 1e9 + 7 ; const int N = 10000010 ; map<pair<int , int> , int > mp , use; vector<pair<int,int>> v[410] ; int d[222][222] ; void construct_network(int H, int W, int K) { vector<int> Ns , f; for(int i = 0 ; i < H ; ++i){ for(int j = 0 ; j < W ; ++j){ for(int l = 0 ; l <= K ; l++){ int u = K - l ; int nx = i + l , ny = j + u ; int vl = i * W + j , vl1 = nx * W + ny; if(min(nx , ny) >= 0 && nx < H && ny < W && !mp[{vl , vl1}]){ mp[{vl , vl1}] = 1; mp[{vl1 , vl}] = 1; d[nx][ny]++; d[i][j]++; } nx = i - l , ny = j + u; vl1 = nx * W + ny; if(min(nx , ny) >= 0 && nx < H && ny < W && !mp[{vl , vl1}]){ mp[{vl , vl1}] = 1; mp[{vl1 , vl}] = 1; d[nx][ny]++; d[i][j]++; } nx = i - l , ny = j - u; vl1 = nx * W + ny; if(min(nx , ny) >= 0 && nx < H && ny < W && !mp[{vl , vl1}]){ mp[{vl , vl1}] = 1; mp[{vl1 , vl}] = 1; d[nx][ny]++; d[i][j]++; } nx = i + l , ny = j - u; vl1 = nx * W + ny; if(min(nx , ny) >= 0 && nx < H && ny < W && !mp[{vl , vl1}]){ mp[{vl , vl1}] = 1; mp[{vl1 , vl}] = 1; d[nx][ny]++; d[i][j]++; } } } } int mx = 0 ; for(int i = 0 ; i < H ; ++i) for(int j = 0 ; j < W ; ++j){ v[d[i][j]].push_back({i , j}); mx = max(mx , d[i][j]); } for(int k = mx ; k ; --k){ while(v[k].size()){ int i = v[k].back().first , j = v[k].back().second; // cout << i << ' ' << j << endl; v[k].erase(v[k].begin() + v[k].size() - 1); if(d[i][j] != k) continue ; int vl = i * W + j; Ns.clear(); // cout << i << ' ' << j << endl; for(int l = 0 ; l <= K ; l++){ int u = K - l ; int nx = i + l , ny = j + u ; int vl1 = nx * W + ny; if(min(nx , ny) >= 0 && nx < H && ny < W && !use[{vl,vl1}]){ use[{vl,vl1}] = 1; use[{vl1,vl}] = 1; if(d[i][j] <= 2){ Ns = {vl , vl1}; //cout << Ns[0] << ' ' << Ns[1] << endl; int a = add_and(Ns); f.push_back(a); }else{ d[nx][ny]--; if(d[nx][ny] > 0) v[d[nx][ny]].push_back({nx , ny}); Ns.push_back(vl1); } } nx = i - l , ny = j + u; vl1 = nx * W + ny; if(min(nx , ny) >= 0 && nx < H && ny < W && !use[{vl,vl1}]){ use[{vl,vl1}] = 1; use[{vl1,vl}] = 1; if(d[i][j] <= 2){ Ns = {vl , vl1}; //cout << Ns[0] << ' ' << Ns[1] << endl; int a = add_and(Ns); f.push_back(a); }else{ d[nx][ny]--; if(d[nx][ny] > 0) v[d[nx][ny]].push_back({nx , ny}); Ns.push_back(vl1); } } nx = i - l , ny = j - u; vl1 = nx * W + ny; if(min(nx , ny) >= 0 && nx < H && ny < W && !use[{vl,vl1}]){ use[{vl,vl1}] = 1; use[{vl1,vl}] = 1; if(d[i][j] <= 2){ Ns = {vl , vl1}; //cout << Ns[0] << ' ' << Ns[1] << endl; int a = add_and(Ns); f.push_back(a); }else{ d[nx][ny]--; if(d[nx][ny] > 0) v[d[nx][ny]].push_back({nx , ny}); Ns.push_back(vl1); } } nx = i + l , ny = j - u; vl1 = nx * W + ny; if(min(nx , ny) >= 0 && nx < H && ny < W && !use[{vl,vl1}]){ use[{vl,vl1}] = 1; use[{vl1,vl}] = 1; if(d[i][j] <= 2){ Ns = {vl , vl1}; //cout << Ns[0] << ' ' << Ns[1] << endl; int a = add_and(Ns); f.push_back(a); }else{ d[nx][ny]--; if(d[nx][ny] > 0) v[d[nx][ny]].push_back({nx , ny}); Ns.push_back(vl1); } } } if(d[i][j] > 2){ int a = add_or(Ns); Ns = {vl , a}; a = add_and(Ns); f.push_back(a); } d[i][j] = 0; } } //cout << f.size() << endl; add_or(f); return ; } // freopen("C:\\Users\\mhmdsa\\Documents\\c++\\input.txt" , "r" , stdin ); // freopen("C:\\Users\\mhmdsa\\Documents\\c++\\output.txt" , "w" , stdout );
#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...