Submission #291355

#TimeUsernameProblemLanguageResultExecution timeMemory
291355mohammadVision Program (IOI19_vision)C++14
33 / 100
65 ms21868 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] , ask[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]++; } } } } for(int i = 0 ; i < H ; ++i) for(int j = 0 ; j < W ; ++j){ v[d[i][j]].push_back({i , j}); } for(int k = 400 ; k ; --k){ while(v[k].size()){ int i = v[k].back().first , j = v[k].back().second; v[k].erase(v[k].begin() + v[k].size() - 1); if(d[i][j] != k) continue ; int vl = i * W + j; Ns.clear(); 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 && !ask[vl][vl1]){ ask[vl][vl1] = 1; ask[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]--; 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 && !ask[vl][vl1]){ ask[vl][vl1] = 1; ask[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]--; 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 && !ask[vl][vl1]){ ask[vl][vl1] = 1; ask[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]--; 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 && !ask[vl][vl1]){ ask[vl][vl1] = 1; ask[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]--; v[d[nx][ny]].push_back({nx , ny}); Ns.push_back(vl1); } } } if(d[i][j] > 2){ //cout << Ns.size() << endl; 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...