답안 #379353

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
379353 2021-03-18T02:41:09 Z Thistle Vision Program (IOI19_vision) C++14
0 / 100
31 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);
				}
			}
			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:38:3: note: in expansion of macro 'rep'
   38 |   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:40:4: note: in expansion of macro 'rep'
   40 |    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:43:3: note: in expansion of macro 'rep'
   43 |   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:45:4: note: in expansion of macro 'rep'
   45 |    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:51:3: note: in expansion of macro 'rep'
   51 |   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:61:3: note: in expansion of macro 'rng'
   61 |   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:67:3: note: in expansion of macro 'rep'
   67 |   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:77:3: note: in expansion of macro 'rng'
   77 |   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:90:3: note: in expansion of macro 'rng'
   90 |   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:97:3: note: in expansion of macro 'rep'
   97 |   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:104:3: note: in expansion of macro 'rep'
  104 |   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:111:3: note: in expansion of macro 'rng'
  111 |   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:123:3: note: in expansion of macro 'rep'
  123 |   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:123:11: note: in expansion of macro 'rep'
  123 |   rep(i,h)rep(j,w){
      |           ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 16 ms 872 KB Output is correct
4 Correct 31 ms 1896 KB Output is correct
5 Correct 24 ms 1384 KB Output is correct
6 Incorrect 3 ms 492 KB WA in grader: Instruction with no inputs
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 3048 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 16 ms 872 KB Output is correct
4 Incorrect 6 ms 876 KB on inputs (5, 126), (6, 127), expected 0, but computed 1
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB WA in grader: Instruction with no inputs
3 Halted 0 ms 0 KB -