Submission #379355

# Submission time Handle Problem Language Result Execution time Memory
379355 2021-03-18T02:43:17 Z Thistle Vision Program (IOI19_vision) C++14
0 / 100
32 ms 3048 KB
#include "vision.h"
#include<bits/stdc++.h>
#include<fstream>
using namespace std;

using ll=long long;
using H=pair<ll, ll>;
using vi=vector<ll>;
#define vec vector
#define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) rng((i),(0),(n))
#define fs first
#define sc second
#define all(a) (a).begin(),(a).end()
#define siz(a) ll((a).size())
#define pb emplace_back

void construct_network(int H, int W, int K) {
	int h=H,w=W,k=K;
	int num=h*w;
	if(H*W*2+1<=10000){
		vec<int>tmp;
		rep(i,h)rep(j,w){
			//kyori ga k no chouten wo rekkyo
			vec<int>v;
			rep(x,h)rep(y,w){
				if(abs(x-i)+abs(y-j)==k){
					v.pb(x*w+y);
				}
			}
			if(siz(v)==0){
				add_xor(v);num++;
				add_and(vec<int>{num-1,i*w+j});num++;
				tmp.pb(num-1);
			}
		}
		add_or(tmp);
	}
	else if(K==1){
		rep(i,h){
			vec<int>v;
			rep(j,w) v.pb(i*w+j);
			add_or(v);num++;
		}
		rep(j,w){
			vec<int>v;
			rep(i,h) v.pb(i*w+j);
			add_or(v);num++;
		}

		int t=num;
		vec<int>tmp;
		rep(i,h){
			vec<int>v;v.pb(h*w+i);
			if(i!=0) v.pb(num-1);
			add_or(v);num++;
		}
		for(int i=h-1;i>=0;i--){
			vec<int>v;v.pb(h*w+i);
			if(i!=h-1) v.pb(num-1);
			add_or(v);num++;
		}
		rng(i,1,h-1){
			add_and({t+i-1,t+h+(h-i-2)});num++;
			tmp.pb(num-1);
		}

		t=num;
		rep(i,w){
			vec<int>v;v.pb(h*w+h+i);
			if(i!=0) v.pb(num-1);
			add_or(v);num++;
		}
		for(int i=w-1;i>=0;i--){
			vec<int>v;v.pb(h*w+h+i);
			if(i!=w-1) v.pb(num-1);
			add_or(v);num++;
		}
		rng(i,1,w-1){
			add_and({t+i-1,t+w+(w-i-2)});num++;
			tmp.pb(num-1);
		}

		t=num;
		auto F=[&](vec<int>v){
			add_xor(v);num++;
			add_not(num-1);num++;
			add_or(v);num++;
			add_and({num-1,num-2});num++;
			tmp.pb(num-1);
		};
		rng(i,1,h){
			vec<int>v;
			for(int k=0;k<w&&i-k>=0;k++){
				v.pb((i-k)*w+k);
			}
			F(v);
		}
		rep(i,w-1){
			vec<int>v;
			for(int k=0;h-1-k>=0&&i+k<w;k++){
				v.pb((h-1-k)*w+(i+k));
			}
			F(v);
		}
		rep(i,h-1){
			vec<int>v;
			for(int k=0;i+k<h&&k<w;k++){
				v.pb((i+k)*w+k);
			}
			F(v);
		}
		rng(i,1,w){
			vec<int>v;
			for(int k=0;h-1-k>=0&&i-k>=0;k++){
				v.pb((h-1-k)*w+(i-k));
			}
			F(v);
		}
		add_or(tmp);num++;
		add_not(num-1);
	}
	else{
		vec<int>v;
		rep(i,h)rep(j,w){
			if(i+j==k) v.pb(i*w+j);
		}
		add_or(v);
	}

}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:23:3: note: in expansion of macro 'rep'
   23 |   rep(i,h)rep(j,w){
      |   ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:23:11: note: in expansion of macro 'rep'
   23 |   rep(i,h)rep(j,w){
      |           ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'x' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:26:4: note: in expansion of macro 'rep'
   26 |    rep(x,h)rep(y,w){
      |    ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'y' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:26:12: note: in expansion of macro 'rep'
   26 |    rep(x,h)rep(y,w){
      |            ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:40:3: note: in expansion of macro 'rep'
   40 |   rep(i,h){
      |   ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:42:4: note: in expansion of macro 'rep'
   42 |    rep(j,w) v.pb(i*w+j);
      |    ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:45:3: note: in expansion of macro 'rep'
   45 |   rep(j,w){
      |   ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:47:4: note: in expansion of macro 'rep'
   47 |    rep(i,h) v.pb(i*w+j);
      |    ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:53:3: note: in expansion of macro 'rep'
   53 |   rep(i,h){
      |   ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:63:3: note: in expansion of macro 'rng'
   63 |   rng(i,1,h-1){
      |   ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:69:3: note: in expansion of macro 'rep'
   69 |   rep(i,w){
      |   ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:79:3: note: in expansion of macro 'rng'
   79 |   rng(i,1,w-1){
      |   ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:92:3: note: in expansion of macro 'rng'
   92 |   rng(i,1,h){
      |   ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:99:3: note: in expansion of macro 'rep'
   99 |   rep(i,w-1){
      |   ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:106:3: note: in expansion of macro 'rep'
  106 |   rep(i,h-1){
      |   ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:113:3: note: in expansion of macro 'rng'
  113 |   rng(i,1,w){
      |   ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:125:3: note: in expansion of macro 'rep'
  125 |   rep(i,h)rep(j,w){
      |   ^~~
vision.cpp:10:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   10 | #define rng(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                            ^
vision.cpp:11:18: note: in expansion of macro 'rng'
   11 | #define rep(i,n) rng((i),(0),(n))
      |                  ^~~
vision.cpp:125:11: note: in expansion of macro 'rep'
  125 |   rep(i,h)rep(j,w){
      |           ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 3048 KB Output is correct
2 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -