Submission #716388

# Submission time Handle Problem Language Result Execution time Memory
716388 2023-03-30T02:07:45 Z myrcella Vision Program (IOI19_vision) C++17
100 / 100
41 ms 4528 KB
//by szh
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
#include "vision.h"

vector <int> leftdiag,rightdiag;
int cnt = 0;

int check(int x) {
	add_xor(leftdiag); //1 -> same left diagnal
	vector <int> q;
	q.pb(cnt);
	cnt++;
	rep(i,0,SZ(leftdiag)) {
		if (i+x >= SZ(leftdiag)) break;
		vector <int> tmp;
		rep(j,i,i+x+1) {
			tmp.pb(leftdiag[j]);
		}
		add_or(tmp);
		add_xor(tmp);
		add_not(cnt+1);
		add_and({cnt,cnt+2});
		q.pb(cnt+3);
		cnt+=4;
	}
	add_or(q);
	int id1 = cnt++;
	
	add_xor(rightdiag); //1 -> same right diagnal
	while (!q.empty()) q.pop_back();
	q.pb(cnt);
	cnt++;
	rep(i,0,SZ(rightdiag)) {
		if (i+x >= SZ(rightdiag)) break;
		vector <int> tmp;
		rep(j,i,i+x+1) {
			tmp.pb(rightdiag[j]);
		}
		add_or(tmp);
		add_xor(tmp);
		add_not(cnt+1);
		add_and({cnt,cnt+2});
		q.pb(cnt+3);
		cnt+=4;
	}
	add_or(q);
	int id2 = cnt++;
	add_and({id1,id2});
	return cnt++;
}

void construct_network(int H, int W, int K) {
	cnt = H*W;
	for (int i=H-1;i>0;i--) {
		int x = i,y = 0;
		vector <int> tmp;
		while (x<H and y<W) {
			tmp.pb(x*W+y);
			x++,y++;
		}
		leftdiag.pb(cnt);
		add_or(tmp);
		cnt++;
	}
	for (int i=0;i<W;i++) {
		int x = 0,y = i;
		vector <int> tmp;
		while (x<H and y<W) {
			tmp.pb(x*W+y);
			x++,y++;
		}
		leftdiag.pb(cnt);
		add_or(tmp);
		cnt++;
	}
	rep(i,0,W) {
		int x = 0,y = i;
		vector <int> tmp;
		while (x<H and y>=0) {
			tmp.pb(x*W+y);
			x++,y--;
		}
		rightdiag.pb(cnt);
		add_or(tmp);
		cnt++;
	}
	rep(i,1,H) {
		int x = i,y = W-1;
		vector <int> tmp;
		while (x<H and y>=0) {
			tmp.pb(x*W+y);
			x++,y--;
		}
		rightdiag.pb(cnt);
		add_or(tmp);
		cnt++;
	}
	int id1 = check(K-1);
	int id2 = check(K);
	add_not(id1);
	add_and({id2,id2+1});
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 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 0 ms 212 KB Output is correct
14 Correct 1 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 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 0 ms 212 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 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 0 ms 212 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 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 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 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 2 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 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 0 ms 212 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 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 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 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 2 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 9 ms 1156 KB Output is correct
39 Correct 3 ms 468 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 3 ms 636 KB Output is correct
42 Correct 2 ms 428 KB Output is correct
43 Correct 4 ms 684 KB Output is correct
44 Correct 9 ms 1280 KB Output is correct
45 Correct 10 ms 1308 KB Output is correct
46 Correct 9 ms 1108 KB Output is correct
47 Correct 3 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 8 ms 1064 KB Output is correct
3 Correct 8 ms 984 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 2 ms 600 KB Output is correct
6 Correct 8 ms 984 KB Output is correct
7 Correct 7 ms 872 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 7 ms 984 KB Output is correct
11 Correct 8 ms 984 KB Output is correct
12 Correct 8 ms 992 KB Output is correct
13 Correct 6 ms 864 KB Output is correct
14 Correct 1 ms 356 KB Output is correct
15 Correct 2 ms 608 KB Output is correct
16 Correct 8 ms 904 KB Output is correct
17 Correct 8 ms 984 KB Output is correct
18 Correct 8 ms 1064 KB Output is correct
19 Correct 6 ms 776 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 220 KB Output is correct
22 Correct 1 ms 220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 220 KB Output is correct
2 Correct 1 ms 220 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 4 ms 608 KB Output is correct
5 Correct 4 ms 672 KB Output is correct
6 Correct 3 ms 608 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 7 ms 980 KB Output is correct
10 Correct 8 ms 980 KB Output is correct
11 Correct 6 ms 812 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Correct 7 ms 980 KB Output is correct
15 Correct 7 ms 944 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 596 KB Output is correct
18 Correct 8 ms 980 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 7 ms 1104 KB Output is correct
21 Correct 20 ms 2508 KB Output is correct
22 Correct 19 ms 2420 KB Output is correct
23 Correct 5 ms 696 KB Output is correct
24 Correct 6 ms 1104 KB Output is correct
25 Correct 21 ms 2576 KB Output is correct
26 Correct 6 ms 732 KB Output is correct
27 Correct 12 ms 1580 KB Output is correct
28 Correct 30 ms 3836 KB Output is correct
29 Correct 37 ms 4428 KB Output is correct
30 Correct 29 ms 3656 KB Output is correct
31 Correct 9 ms 1108 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1596 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 7 ms 1104 KB Output is correct
8 Correct 7 ms 1072 KB Output is correct
9 Correct 11 ms 1616 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 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 0 ms 212 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 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 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 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 2 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 9 ms 1156 KB Output is correct
39 Correct 3 ms 468 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 3 ms 636 KB Output is correct
42 Correct 2 ms 428 KB Output is correct
43 Correct 4 ms 684 KB Output is correct
44 Correct 9 ms 1280 KB Output is correct
45 Correct 10 ms 1308 KB Output is correct
46 Correct 9 ms 1108 KB Output is correct
47 Correct 3 ms 436 KB Output is correct
48 Correct 2 ms 600 KB Output is correct
49 Correct 8 ms 1064 KB Output is correct
50 Correct 8 ms 984 KB Output is correct
51 Correct 1 ms 344 KB Output is correct
52 Correct 2 ms 600 KB Output is correct
53 Correct 8 ms 984 KB Output is correct
54 Correct 7 ms 872 KB Output is correct
55 Correct 1 ms 344 KB Output is correct
56 Correct 2 ms 600 KB Output is correct
57 Correct 7 ms 984 KB Output is correct
58 Correct 8 ms 984 KB Output is correct
59 Correct 8 ms 992 KB Output is correct
60 Correct 6 ms 864 KB Output is correct
61 Correct 1 ms 356 KB Output is correct
62 Correct 2 ms 608 KB Output is correct
63 Correct 8 ms 904 KB Output is correct
64 Correct 8 ms 984 KB Output is correct
65 Correct 8 ms 1064 KB Output is correct
66 Correct 6 ms 776 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 0 ms 220 KB Output is correct
69 Correct 1 ms 220 KB Output is correct
70 Correct 0 ms 220 KB Output is correct
71 Correct 1 ms 220 KB Output is correct
72 Correct 2 ms 468 KB Output is correct
73 Correct 4 ms 608 KB Output is correct
74 Correct 4 ms 672 KB Output is correct
75 Correct 3 ms 608 KB Output is correct
76 Correct 1 ms 340 KB Output is correct
77 Correct 3 ms 596 KB Output is correct
78 Correct 7 ms 980 KB Output is correct
79 Correct 8 ms 980 KB Output is correct
80 Correct 6 ms 812 KB Output is correct
81 Correct 2 ms 340 KB Output is correct
82 Correct 2 ms 596 KB Output is correct
83 Correct 7 ms 980 KB Output is correct
84 Correct 7 ms 944 KB Output is correct
85 Correct 1 ms 340 KB Output is correct
86 Correct 2 ms 596 KB Output is correct
87 Correct 8 ms 980 KB Output is correct
88 Correct 1 ms 340 KB Output is correct
89 Correct 7 ms 1104 KB Output is correct
90 Correct 20 ms 2508 KB Output is correct
91 Correct 19 ms 2420 KB Output is correct
92 Correct 5 ms 696 KB Output is correct
93 Correct 6 ms 1104 KB Output is correct
94 Correct 21 ms 2576 KB Output is correct
95 Correct 6 ms 732 KB Output is correct
96 Correct 12 ms 1580 KB Output is correct
97 Correct 30 ms 3836 KB Output is correct
98 Correct 37 ms 4428 KB Output is correct
99 Correct 29 ms 3656 KB Output is correct
100 Correct 9 ms 1108 KB Output is correct
101 Correct 0 ms 212 KB Output is correct
102 Correct 1 ms 296 KB Output is correct
103 Correct 13 ms 1596 KB Output is correct
104 Correct 1 ms 212 KB Output is correct
105 Correct 2 ms 596 KB Output is correct
106 Correct 3 ms 596 KB Output is correct
107 Correct 3 ms 596 KB Output is correct
108 Correct 2 ms 596 KB Output is correct
109 Correct 7 ms 1104 KB Output is correct
110 Correct 7 ms 1072 KB Output is correct
111 Correct 11 ms 1616 KB Output is correct
112 Correct 1 ms 212 KB Output is correct
113 Correct 1 ms 212 KB Output is correct
114 Correct 33 ms 3748 KB Output is correct
115 Correct 1 ms 344 KB Output is correct
116 Correct 2 ms 560 KB Output is correct
117 Correct 13 ms 1752 KB Output is correct
118 Correct 17 ms 1956 KB Output is correct
119 Correct 36 ms 4436 KB Output is correct
120 Correct 37 ms 4436 KB Output is correct
121 Correct 40 ms 4520 KB Output is correct
122 Correct 36 ms 4516 KB Output is correct
123 Correct 11 ms 1676 KB Output is correct
124 Correct 32 ms 3880 KB Output is correct
125 Correct 37 ms 4528 KB Output is correct
126 Correct 41 ms 4440 KB Output is correct
127 Correct 29 ms 3632 KB Output is correct
128 Correct 8 ms 1120 KB Output is correct