Submission #411389

#TimeUsernameProblemLanguageResultExecution timeMemory
411389ismoilovVision Program (IOI19_vision)C++14
10 / 100
6 ms1224 KiB
#include "vision.h" #include<bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //#define int ll #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++) #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++) #define fv(a, c) for(int (a) = (1); (a) <= (c); (a)++) #define fz(a, c) for(int (a) = (0); (a) < (c); (a)++) #define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--) #define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--) #define pb push_back #define in insert #define ss second #define ff first #define vi vector <int> #define fa(a, v) for(auto (a) : (v)) #define mnel(a) *min_element(all(a)) #define mxel(a) *max_element(all(a)) #define si set<int> #define sov(a) sort(all((a))) void construct_network(int h, int w, int K) { vector<int> ss; if(K == 1){ vector <vi> d(h, vector <int> (w, 0)); fp(i,0,h){ fp(j,0,w){ int x = i*w+j; vi n; if(i == 0 && j == 0 ||i == 0 && j == w-1 || i == h-1 && j == 0 || i == h-1 && j == w-1){ fpp(k,-1,1){ int i1 = i + k, j1 = j + (abs(k) - K); int i2 = i + k, j2 = j - (abs(k) - K); if(i1 >= 0 && i1 < h && j1 >= 0 && j1 < w) n.pb(i1*w + j1); if(i2 >= 0 && i2 < h && j2 >= 0 && j2 < w) n.pb(i2*w + j2); } ss.pb(add_and({x, add_or(n)})); continue; } if(i > 0 && j > 0 && d[i][j] == 0){ fpp(k,-1,1){ int i1 = i + k, j1 = j + (abs(k) - K); int i2 = i + k, j2 = j - (abs(k) - K); if(i1 >= 0 && i1 < h && j1 >= 0 && j1 < w) n.pb(i1*w + j1), d[i1][j1] = 1; if(i2 >= 0 && i2 < h && j2 >= 0 && j2 < w) n.pb(i2*w + j2), d[i2][j2] = 1; } ss.pb(add_and({x, add_or(n)})); } } } add_or(ss); return; } if(max(h, w) > 10 && min(h, w) != 1){ int i = 0, j = 0; int x = i*w + j; fpp(k,-K, K){ int ii = i + k, jj = j + (abs(k) - K); if(ii >= 0 && ii < h && jj >= 0 && jj < w) ss.pb(add_and({x, ii*w +jj})); ii = i + k, jj = j - (abs(k) - K); if(ii >= 0 && ii < h && jj >= 0 && jj < w) ss.pb(add_and({x, ii*w +jj})); } } else{ fp(i,0,h){ fp(j,0,w){ int x = i*w + j; fpp(k,-K, K){ int ii = i + k, jj = j + (abs(k) - K); if(ii >= 0 && ii < h && jj >= 0 && jj < w) ss.pb(add_and({x, ii*w +jj})); ii = i + k, jj = j - (abs(k) - K); if(ii >= 0 && ii < h && jj >= 0 && jj < w) ss.pb(add_and({x, ii*w +jj})); } } } } add_or(ss); }

Compilation message (stderr)

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:14:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   14 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
vision.cpp:34:3: note: in expansion of macro 'fp'
   34 |   fp(i,0,h){
      |   ^~
vision.cpp:14:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   14 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
vision.cpp:35:4: note: in expansion of macro 'fp'
   35 |    fp(j,0,w){
      |    ^~
vision.cpp:38:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   38 |     if(i == 0 && j == 0 ||i == 0 && j == w-1 || i == h-1 && j == 0 || i == h-1 && j == w-1){
      |        ~~~~~~~^~~~~~~~~
vision.cpp:38:58: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   38 |     if(i == 0 && j == 0 ||i == 0 && j == w-1 || i == h-1 && j == 0 || i == h-1 && j == w-1){
      |                                                 ~~~~~~~~~^~~~~~~~~
vision.cpp:38:80: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   38 |     if(i == 0 && j == 0 ||i == 0 && j == w-1 || i == h-1 && j == 0 || i == h-1 && j == w-1){
      |                                                                       ~~~~~~~~~^~~~~~~~~~~
vision.cpp:15:28: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
   15 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
vision.cpp:39:6: note: in expansion of macro 'fpp'
   39 |      fpp(k,-1,1){
      |      ^~~
vision.cpp:15:28: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
   15 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
vision.cpp:51:6: note: in expansion of macro 'fpp'
   51 |      fpp(k,-1,1){
      |      ^~~
vision.cpp:15:28: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
   15 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
vision.cpp:69:4: note: in expansion of macro 'fpp'
   69 |    fpp(k,-K, K){
      |    ^~~
vision.cpp:14:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   14 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
vision.cpp:79:3: note: in expansion of macro 'fp'
   79 |   fp(i,0,h){
      |   ^~
vision.cpp:14:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   14 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
vision.cpp:80:4: note: in expansion of macro 'fp'
   80 |    fp(j,0,w){
      |    ^~
vision.cpp:15:28: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
   15 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
vision.cpp:82:5: note: in expansion of macro 'fpp'
   82 |     fpp(k,-K, K){
      |     ^~~
#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...