답안 #615982

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
615982 2022-07-31T17:11:03 Z amunduzbaev Vision Program (IOI19_vision) C++17
100 / 100
45 ms 5204 KB
#include "bits/stdc++.h"
using namespace std;
#include "vision.h"

#ifndef EVAL
#include "grader.cpp"
#endif

#define ar array
#define sow cout<<"here"<<endl;

void construct_network(int n, int m, int k) {
	vector<vector<int>> a(n + m, vector<int>(n + m, -1));
	
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			a[i + j][i - j + m] = i * m + j;
		}
	}
	
	n += m;
	int r1 = -1, r2 = -1;
	{
		vector<int> idr(n, -1), idc(n, -1), xc(n, -1), T;
		
		for(int i=0;i<n;i++){
			vector<int> t;
			for(int j=0;j<n;j++){
				if(~a[i][j]) t.push_back(a[i][j]);
			}
			
			if(!t.empty()) idr[i] = add_or(t);
			t.clear();
			for(int j=0;j<n;j++){
				if(~a[j][i]) t.push_back(a[j][i]);
			}
			
			if(!t.empty()) idc[i] = add_or(t), xc[i] = add_xor(t);
		}
		vector<int> tmp(n, -1);
		for(int i=0;i<n;i++){
			if(i >= k && ~idr[i] && ~idr[i - k]){
				tmp[i] = add_and({idr[i], idr[i-k]});
				T.push_back(tmp[i]);
			}
		}
		int v = -1;
		if(!T.empty()) v = add_or(T);
		T.clear();
		for(int i=0;i<n;i++){
			vector<int> t;
			for(int j=max(0, i-k);j<i;j++){
				if(~idc[j]) t.push_back(idc[j]);
			}
			
			int X = -1, Y = -1;
			if(!t.empty() && ~idc[i]){
				int j = add_or(t);
				X = add_and({j, idc[i]});
			}
			if(~idc[i] && ~xc[i]){
				Y = add_and({idc[i], add_not(xc[i])});
			}
			
			if(~X) T.push_back(X);
			if(~Y) T.push_back(Y);
		}
		
		int v2 = -1;
		if(!T.empty()) v2 = add_or(T);
		if(~v && ~v2) r1 = add_and({v, v2});
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++){
			swap(a[i][j], a[j][i]);
		}
	}
	
	{
		vector<int> idr(n, -1), idc(n, -1), xc(n, -1), T;
		
		for(int i=0;i<n;i++){
			vector<int> t;
			for(int j=0;j<n;j++){
				if(~a[i][j]) t.push_back(a[i][j]);
			}
			
			if(!t.empty()) idr[i] = add_or(t);
			t.clear();
			for(int j=0;j<n;j++){
				if(~a[j][i]) t.push_back(a[j][i]);
			}
			
			if(!t.empty()) idc[i] = add_or(t), xc[i] = add_xor(t);
		}
		
		vector<int> tmp(n, -1);
		for(int i=0;i<n;i++){
			if(i >= k && ~idr[i] && ~idr[i - k]){
				tmp[i] = add_and({idr[i], idr[i-k]});
				T.push_back(tmp[i]);
			}
		}
		int v = -1;
		if(!T.empty()) v = add_or(T);
		T.clear();
		for(int i=0;i<n;i++){
			vector<int> t;
			for(int j=max(0, i-k);j<i;j++){
				if(~idc[j]) t.push_back(idc[j]);
			}
			
			int X = -1, Y = -1;
			if(!t.empty() && ~idc[i]){
				int j = add_or(t);
				X = add_and({j, idc[i]});
			}
			if(~idc[i] && ~xc[i]){
				Y = add_and({idc[i], add_not(xc[i])});
			}
			
			if(~X) T.push_back(X);
			if(~Y) T.push_back(Y);
		}
		
		int v2 = -1;
		if(!T.empty()) v2 = add_or(T);
		if(~v && ~v2) r2 = add_and({v, v2});
	}
	
	if(~r1 && ~r2){
		add_or({r1, r2});
	} else if(~r1){
		add_or({r1});
	} else if(~r2){
		add_or({r2});
	} else {
		if(k < m){
			add_and({0, k});
		} else {
			add_and({0, (k - m + 1) * m + m - 1});
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
38 Correct 13 ms 1344 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 2 ms 468 KB Output is correct
41 Correct 5 ms 852 KB Output is correct
42 Correct 8 ms 980 KB Output is correct
43 Correct 9 ms 1352 KB Output is correct
44 Correct 9 ms 1364 KB Output is correct
45 Correct 9 ms 1492 KB Output is correct
46 Correct 10 ms 1492 KB Output is correct
47 Correct 10 ms 1588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 5 ms 852 KB Output is correct
3 Correct 5 ms 860 KB Output is correct
4 Correct 5 ms 980 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 4 ms 852 KB Output is correct
7 Correct 5 ms 980 KB Output is correct
8 Correct 5 ms 980 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 4 ms 724 KB Output is correct
11 Correct 5 ms 852 KB Output is correct
12 Correct 5 ms 852 KB Output is correct
13 Correct 5 ms 980 KB Output is correct
14 Correct 5 ms 1000 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 5 ms 908 KB Output is correct
18 Correct 4 ms 852 KB Output is correct
19 Correct 5 ms 980 KB Output is correct
20 Correct 5 ms 980 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 3 ms 724 KB Output is correct
4 Correct 4 ms 596 KB Output is correct
5 Correct 6 ms 724 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 5 ms 712 KB Output is correct
8 Correct 5 ms 980 KB Output is correct
9 Correct 6 ms 1060 KB Output is correct
10 Correct 7 ms 1060 KB Output is correct
11 Correct 7 ms 1108 KB Output is correct
12 Correct 9 ms 1120 KB Output is correct
13 Correct 2 ms 724 KB Output is correct
14 Correct 4 ms 852 KB Output is correct
15 Correct 6 ms 980 KB Output is correct
16 Correct 5 ms 980 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 4 ms 852 KB Output is correct
19 Correct 5 ms 1016 KB Output is correct
20 Correct 13 ms 2148 KB Output is correct
21 Correct 18 ms 2492 KB Output is correct
22 Correct 21 ms 2896 KB Output is correct
23 Correct 21 ms 2912 KB Output is correct
24 Correct 13 ms 2128 KB Output is correct
25 Correct 20 ms 2724 KB Output is correct
26 Correct 21 ms 2920 KB Output is correct
27 Correct 26 ms 3688 KB Output is correct
28 Correct 31 ms 4336 KB Output is correct
29 Correct 38 ms 4820 KB Output is correct
30 Correct 39 ms 5140 KB Output is correct
31 Correct 39 ms 5176 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 3656 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 724 KB Output is correct
4 Correct 5 ms 980 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 13 ms 2092 KB Output is correct
8 Correct 13 ms 2056 KB Output is correct
9 Correct 27 ms 3720 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
38 Correct 13 ms 1344 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 2 ms 468 KB Output is correct
41 Correct 5 ms 852 KB Output is correct
42 Correct 8 ms 980 KB Output is correct
43 Correct 9 ms 1352 KB Output is correct
44 Correct 9 ms 1364 KB Output is correct
45 Correct 9 ms 1492 KB Output is correct
46 Correct 10 ms 1492 KB Output is correct
47 Correct 10 ms 1588 KB Output is correct
48 Correct 3 ms 724 KB Output is correct
49 Correct 5 ms 852 KB Output is correct
50 Correct 5 ms 860 KB Output is correct
51 Correct 5 ms 980 KB Output is correct
52 Correct 2 ms 724 KB Output is correct
53 Correct 4 ms 852 KB Output is correct
54 Correct 5 ms 980 KB Output is correct
55 Correct 5 ms 980 KB Output is correct
56 Correct 2 ms 724 KB Output is correct
57 Correct 4 ms 724 KB Output is correct
58 Correct 5 ms 852 KB Output is correct
59 Correct 5 ms 852 KB Output is correct
60 Correct 5 ms 980 KB Output is correct
61 Correct 5 ms 1000 KB Output is correct
62 Correct 2 ms 724 KB Output is correct
63 Correct 4 ms 852 KB Output is correct
64 Correct 5 ms 908 KB Output is correct
65 Correct 4 ms 852 KB Output is correct
66 Correct 5 ms 980 KB Output is correct
67 Correct 5 ms 980 KB Output is correct
68 Correct 0 ms 212 KB Output is correct
69 Correct 0 ms 212 KB Output is correct
70 Correct 0 ms 212 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 3 ms 724 KB Output is correct
73 Correct 4 ms 596 KB Output is correct
74 Correct 6 ms 724 KB Output is correct
75 Correct 4 ms 724 KB Output is correct
76 Correct 5 ms 712 KB Output is correct
77 Correct 5 ms 980 KB Output is correct
78 Correct 6 ms 1060 KB Output is correct
79 Correct 7 ms 1060 KB Output is correct
80 Correct 7 ms 1108 KB Output is correct
81 Correct 9 ms 1120 KB Output is correct
82 Correct 2 ms 724 KB Output is correct
83 Correct 4 ms 852 KB Output is correct
84 Correct 6 ms 980 KB Output is correct
85 Correct 5 ms 980 KB Output is correct
86 Correct 2 ms 724 KB Output is correct
87 Correct 4 ms 852 KB Output is correct
88 Correct 5 ms 1016 KB Output is correct
89 Correct 13 ms 2148 KB Output is correct
90 Correct 18 ms 2492 KB Output is correct
91 Correct 21 ms 2896 KB Output is correct
92 Correct 21 ms 2912 KB Output is correct
93 Correct 13 ms 2128 KB Output is correct
94 Correct 20 ms 2724 KB Output is correct
95 Correct 21 ms 2920 KB Output is correct
96 Correct 26 ms 3688 KB Output is correct
97 Correct 31 ms 4336 KB Output is correct
98 Correct 38 ms 4820 KB Output is correct
99 Correct 39 ms 5140 KB Output is correct
100 Correct 39 ms 5176 KB Output is correct
101 Correct 1 ms 212 KB Output is correct
102 Correct 0 ms 212 KB Output is correct
103 Correct 31 ms 3656 KB Output is correct
104 Correct 0 ms 212 KB Output is correct
105 Correct 4 ms 724 KB Output is correct
106 Correct 5 ms 980 KB Output is correct
107 Correct 2 ms 724 KB Output is correct
108 Correct 2 ms 724 KB Output is correct
109 Correct 13 ms 2092 KB Output is correct
110 Correct 13 ms 2056 KB Output is correct
111 Correct 27 ms 3720 KB Output is correct
112 Correct 0 ms 212 KB Output is correct
113 Correct 1 ms 212 KB Output is correct
114 Correct 45 ms 4324 KB Output is correct
115 Correct 6 ms 980 KB Output is correct
116 Correct 2 ms 724 KB Output is correct
117 Correct 21 ms 2916 KB Output is correct
118 Correct 15 ms 2324 KB Output is correct
119 Correct 42 ms 4724 KB Output is correct
120 Correct 36 ms 4792 KB Output is correct
121 Correct 34 ms 4796 KB Output is correct
122 Correct 40 ms 4844 KB Output is correct
123 Correct 35 ms 3692 KB Output is correct
124 Correct 31 ms 4352 KB Output is correct
125 Correct 35 ms 4756 KB Output is correct
126 Correct 37 ms 4868 KB Output is correct
127 Correct 37 ms 5068 KB Output is correct
128 Correct 37 ms 5204 KB Output is correct