Submission #733734

# Submission time Handle Problem Language Result Execution time Memory
733734 2023-05-01T08:38:12 Z sentheta Vision Program (IOI19_vision) C++17
59 / 100
33 ms 4280 KB
#include "vision.h"
// author : sentheta aka vanwij
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<random>
#include<chrono>
#include<cmath>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;

#define Int long long
#define V vector
#define pii pair<int,int>
#define ff first
#define ss second

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pow2(x) (1LL<<(x))
#define msb(x) (63-__builtin_clzll(x))
#define bitcnt(x) (__builtin_popcountll(x))

#define nl '\n'
#define _ << ' ' <<
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define dbg(x) if(1) cout << "?" << #x << " : " << (x) << endl << flush;


int h, w;
int f(int i,int j){
	return i*w+j;
}

V<int> v[2][500];
int one[2][500], two[2][500];

// check if distance is <=k
int solve(int k){
	// +/- diagonals
	int ret[2];
	rep(t,0,2){
		V<int> results;
		for(int l=0,r=k; r<h+w; l++,r++){
			bool allempty = 1;
			rep(i,l,r+1) allempty &= v[t][i].empty();
			if(allempty) continue;

			// pixels in different diags
			V<int> tmp;
			rep(i,l,r+1) if(!v[t][i].empty()){
				tmp.push_back(one[t][i]);
			}
			int a = add_or(tmp);
			int b = add_xor(tmp);
			// a and not b
			int nb = add_not(b);
			int c = add_and({a, nb});
			results.push_back(c);

			// pixels in same diags
			tmp.clear();
			rep(i,l,r+1) if(!v[t][i].empty()){
				tmp.push_back(two[t][i]);
			}
			int d = add_or(tmp);
			results.push_back(d);
		}

		ret[t] = add_or(results);
		cout << nl;
	}

	return add_and({ret[0], ret[1]});
}

void construct_network(int _h,int _w,int _k){
	h = _h; w = _w; int k = _k;

	// group by diagonals
	rep(t,0,2){
		rep(i,0,h) rep(j,0,w){
			if(t==0) v[t][i+j].push_back(f(i,j));
			else v[t][i-j+w-1].push_back(f(i,j));
		}

		rep(i,0,h+w) if(!v[t][i].empty()){
			// dbg(i);
			// for(int x : v[t][i]) cout << x << " ";
			// cout << nl;

			one[t][i] = add_or(v[t][i]);
			
			int tmp = add_xor(v[t][i]);
			tmp = add_not(tmp);

			two[t][i] = add_and({one[t][i], tmp});
		}
	}

	int a = solve(k);
	// dbg(a);
	// cout << nl << nl;
	int b = solve(k-1);
	// dbg(b);

	// a and (not b)
	int nb = add_not(b);
	int c = add_and({a, nb});
	return;

	// V<int> Ns;
	// Ns = {0, 1};
	// int a = add_and(Ns);
	// Ns = {0, a};
	// int b = add_or(Ns);
	// Ns = {0, 1, b};
	// int c = add_xor(Ns);
	// add_not(c);
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:117:6: warning: unused variable 'c' [-Wunused-variable]
  117 |  int c = add_and({a, nb});
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 2 ms 456 KB Output is correct
34 Correct 3 ms 464 KB Output is correct
35 Correct 2 ms 460 KB Output is correct
36 Correct 2 ms 460 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 2 ms 456 KB Output is correct
34 Correct 3 ms 464 KB Output is correct
35 Correct 2 ms 460 KB Output is correct
36 Correct 2 ms 460 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
38 Correct 13 ms 2000 KB Output is correct
39 Correct 4 ms 716 KB Output is correct
40 Correct 3 ms 584 KB Output is correct
41 Correct 4 ms 848 KB Output is correct
42 Correct 3 ms 596 KB Output is correct
43 Correct 7 ms 1220 KB Output is correct
44 Correct 15 ms 2024 KB Output is correct
45 Correct 17 ms 2156 KB Output is correct
46 Correct 13 ms 1864 KB Output is correct
47 Correct 5 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 12 ms 1620 KB Output is correct
3 Correct 11 ms 1616 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 3 ms 724 KB Output is correct
6 Correct 11 ms 1524 KB Output is correct
7 Correct 11 ms 1364 KB Output is correct
8 Correct 2 ms 468 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 10 ms 1360 KB Output is correct
11 Correct 12 ms 1620 KB Output is correct
12 Correct 11 ms 1620 KB Output is correct
13 Correct 11 ms 1236 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 3 ms 724 KB Output is correct
16 Correct 13 ms 1360 KB Output is correct
17 Correct 14 ms 1568 KB Output is correct
18 Correct 12 ms 1620 KB Output is correct
19 Correct 9 ms 1284 KB Output is correct
20 Correct 2 ms 460 KB Output is correct
21 Correct 1 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 3 ms 708 KB Output is correct
4 Correct 6 ms 980 KB Output is correct
5 Correct 7 ms 1016 KB Output is correct
6 Correct 6 ms 852 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 5 ms 976 KB Output is correct
9 Correct 9 ms 1448 KB Output is correct
10 Correct 13 ms 1636 KB Output is correct
11 Correct 9 ms 1352 KB Output is correct
12 Correct 3 ms 724 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 11 ms 1480 KB Output is correct
15 Correct 10 ms 1368 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 3 ms 724 KB Output is correct
18 Correct 12 ms 1620 KB Output is correct
19 Correct 2 ms 460 KB Output is correct
20 Correct 16 ms 1856 KB Output is correct
21 Correct 30 ms 4068 KB Output is correct
22 Correct 32 ms 3944 KB Output is correct
23 Correct 9 ms 1492 KB Output is correct
24 Correct 11 ms 1868 KB Output is correct
25 Correct 33 ms 4280 KB Output is correct
26 Correct 9 ms 1492 KB Output is correct
27 Incorrect 3 ms 2128 KB WA in grader: Too many instructions
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2120 KB WA in grader: Too many instructions
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 2 ms 456 KB Output is correct
34 Correct 3 ms 464 KB Output is correct
35 Correct 2 ms 460 KB Output is correct
36 Correct 2 ms 460 KB Output is correct
37 Correct 2 ms 340 KB Output is correct
38 Correct 13 ms 2000 KB Output is correct
39 Correct 4 ms 716 KB Output is correct
40 Correct 3 ms 584 KB Output is correct
41 Correct 4 ms 848 KB Output is correct
42 Correct 3 ms 596 KB Output is correct
43 Correct 7 ms 1220 KB Output is correct
44 Correct 15 ms 2024 KB Output is correct
45 Correct 17 ms 2156 KB Output is correct
46 Correct 13 ms 1864 KB Output is correct
47 Correct 5 ms 852 KB Output is correct
48 Correct 3 ms 724 KB Output is correct
49 Correct 12 ms 1620 KB Output is correct
50 Correct 11 ms 1616 KB Output is correct
51 Correct 2 ms 460 KB Output is correct
52 Correct 3 ms 724 KB Output is correct
53 Correct 11 ms 1524 KB Output is correct
54 Correct 11 ms 1364 KB Output is correct
55 Correct 2 ms 468 KB Output is correct
56 Correct 3 ms 724 KB Output is correct
57 Correct 10 ms 1360 KB Output is correct
58 Correct 12 ms 1620 KB Output is correct
59 Correct 11 ms 1620 KB Output is correct
60 Correct 11 ms 1236 KB Output is correct
61 Correct 3 ms 468 KB Output is correct
62 Correct 3 ms 724 KB Output is correct
63 Correct 13 ms 1360 KB Output is correct
64 Correct 14 ms 1568 KB Output is correct
65 Correct 12 ms 1620 KB Output is correct
66 Correct 9 ms 1284 KB Output is correct
67 Correct 2 ms 460 KB Output is correct
68 Correct 1 ms 328 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Correct 1 ms 336 KB Output is correct
72 Correct 3 ms 708 KB Output is correct
73 Correct 6 ms 980 KB Output is correct
74 Correct 7 ms 1016 KB Output is correct
75 Correct 6 ms 852 KB Output is correct
76 Correct 2 ms 468 KB Output is correct
77 Correct 5 ms 976 KB Output is correct
78 Correct 9 ms 1448 KB Output is correct
79 Correct 13 ms 1636 KB Output is correct
80 Correct 9 ms 1352 KB Output is correct
81 Correct 3 ms 724 KB Output is correct
82 Correct 3 ms 724 KB Output is correct
83 Correct 11 ms 1480 KB Output is correct
84 Correct 10 ms 1368 KB Output is correct
85 Correct 2 ms 468 KB Output is correct
86 Correct 3 ms 724 KB Output is correct
87 Correct 12 ms 1620 KB Output is correct
88 Correct 2 ms 460 KB Output is correct
89 Correct 16 ms 1856 KB Output is correct
90 Correct 30 ms 4068 KB Output is correct
91 Correct 32 ms 3944 KB Output is correct
92 Correct 9 ms 1492 KB Output is correct
93 Correct 11 ms 1868 KB Output is correct
94 Correct 33 ms 4280 KB Output is correct
95 Correct 9 ms 1492 KB Output is correct
96 Incorrect 3 ms 2128 KB WA in grader: Too many instructions
97 Halted 0 ms 0 KB -