답안 #332676

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
332676 2020-12-03T02:39:50 Z nicholask Vision Program (IOI19_vision) C++14
47 / 100
10 ms 2152 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
/*
int h,w,k;
vector <int> t;
int current;
int calls=0;
void add_or(vector <int> v){
	cout<<"Call No. "<<calls<<": requested ";
	for (auto&i:v) cout<<i<<' ';
	cout<<endl;
	calls++;
	int n=v.size();
	if (n>10001){
		cout<<"Too many instructions on call and_or\n";
		exit(0);
	}
	for (int i=0; i<n; i++){
		if (v[i]<0||v[i]>=current){
			cout<<"Invalid index provided on call and_or: "<<i<<"th element requested for "<<v[i];
			exit(0);
		}
	}
	int res=0;
	for (int i=0; i<n; i++){
		if (t[v[i]]==1){
			res=1;
			break;
		}
	}
	t.push_back(res);
	current++;
}
*/
void construct_network(int H,int W,int K){
	if (K==1){
		for (int i=0; i<H; i++){
			vector <int> v;
			for (int j=0; j<W; j++) v.push_back(i*W+j);
			add_or(v);
		}
		for (int j=0; j<W; j++){
			vector <int> v;
			for (int i=0; i<H; i++) v.push_back(i*W+j);
			add_or(v);
		}
		for (int i=0; i<H-1; i++){
			vector <int> v;
			v.push_back(H*W+i);
			v.push_back(H*W+i+1);
			add_and(v);
		}
		for (int i=0; i<W-1; i++){
			vector <int> v;
			v.push_back(H*W+H+i);
			v.push_back(H*W+H+i+1);
			add_and(v);
		}
		vector <int> vv;
		for (int i=0; i<H+W-2; i++) vv.push_back(H*W+H+W+i);
		add_or(vv);
		vector <int> ww;
		for (int i=0; i<H+W; i++) ww.push_back(H*W+i);
		add_xor(ww);
		vector <int> xx;
		xx.push_back(H*W+H+W+H+W-2);
		xx.push_back(H*W+H+W+H+W-1);
		add_and(xx);
		return;
	}
	int cnt=0;
	map <pair <int,int>,bool> p;
	for (int i=0; i<H; i++){
		for (int j=0; j<W; j++){
			for (int xp=i,yp=j-K; xp!=i-K&&yp!=j; xp--,yp++){
				if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
					add_and({i*W+j,xp*W+yp});
					cnt++;
					p[{i*W+j,xp*W+yp}]=1;
				}
			}
			for (int xp=i-K,yp=j; xp!=i&&yp!=j+K; xp++,yp++){
				if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
					add_and({i*W+j,xp*W+yp});
					cnt++;
					p[{i*W+j,xp*W+yp}]=1;
				}
			}
			for (int xp=i,yp=j+K; xp!=i+K&&yp!=j; xp++,yp--){
				if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
					add_and({i*W+j,xp*W+yp});
					cnt++;
					p[{i*W+j,xp*W+yp}]=1;
				}
			}
			for (int xp=i+K,yp=j; xp!=i&&yp!=j-K; xp--,yp--){
				if (xp>=0&&xp<H&&yp>=0&&yp<W&&!p[{i*W+j,xp*W+yp}]&&!p[{xp*W+yp,i*W+j}]){
					add_and({i*W+j,xp*W+yp});
					cnt++;
					p[{i*W+j,xp*W+yp}]=1;
				}
			}
		}
	}
	if (cnt==1) return;
	//cnt results stored in [h*w,h*w+cnt)
	vector <int> v;
	int curpr=0,cnt1=0;
	for (int i=0; i<cnt; i++){
		v.push_back(H*W+i);
		curpr++;
		if (i==cnt-1){
			add_or(v);
			v.clear();
			cnt1++;
			curpr=0;
		}
	}
	if (cnt1==1) return;
	//cnt1 results stored in [h*w+cnt,h*w+cnt+cnt1)
	v.clear();
	for (int i=H*W+cnt; i<H*W+cnt+cnt1; i++){
		v.push_back(i);
	}
	add_or(v);
	return;
}
/*
int main(){
	cin>>h>>w>>k;
	for (int i=0; i<h*w; i++){
		int v;
		cin>>v;
		t.push_back(v);
	}
	current=h*w;
	construct_network(h,w,k);
	for (auto&i:t) cout<<i<<' ';
	cout<<endl;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 3 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 3 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Incorrect 10 ms 2152 KB WA in grader: Too many instructions
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 3 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Incorrect 10 ms 2152 KB WA in grader: Too many instructions
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 396 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 380 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 8 ms 2152 KB WA in grader: Too many instructions
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1132 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 7 ms 748 KB Output is correct
8 Correct 6 ms 748 KB Output is correct
9 Correct 10 ms 1132 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 3 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Incorrect 10 ms 2152 KB WA in grader: Too many instructions
29 Halted 0 ms 0 KB -