Submission #567437

# Submission time Handle Problem Language Result Execution time Memory
567437 2022-05-23T12:57:11 Z hhhhaura Painting Walls (APIO20_paint) C++14
28 / 100
1500 ms 8172 KB
#include "paint.h"

#include <vector>
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i --)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))
#define ll long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)
using namespace std;
#ifdef wiwihorz
#define print(a...)cerr<<"Line "<<__LINE__<<":",kout("["+string(#a)+"] = ", a)
void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
void kout() { cerr << endl; }
template<class T1,class ... T2>void kout(T1 a,T2 ... e){cerr<<a<<" ",kout(e...);}
#else
#define print(...) 0
#define vprint(...) 0
#endif
using namespace std;
int minimumInstructions(int N, int M, int K, vector<int> C, 
	vector<int> A, vector<vector<int>> B) {
	vector<unordered_set<int>> col(M, unordered_set<int>());
	rep(i, 0, M - 1) {
		for(auto j : B[i]) col[i].insert(j);
	}
	vector<int> to(N, 0);
	rep(i, 0, M - 1) rep(j, 0, N - M) {
		if(to[j]) continue;
		bool yes = 1;
		rep(l, 0, M - 1) {
			int cur = (i + l) % M;
			yes &= (col[cur].find(C[j + l]) != col[cur].end());
		}
		to[j] = yes; 
	} 
	int cnt = 0, cur = 0;
	set<int> s;
	rep(i, 0, N - 1) if(to[i]) s.insert(i);
	while(cur < N) {
		auto it = s.upper_bound(cur);
		if(it == s.begin()) return -1;
		it = prev(it);
		if(*it + M <= cur) return -1;
		cur = *it + M;
		cnt ++;
	}
	return cnt;
}

Compilation message

paint.cpp:8: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    8 | #pragma loop-opt(on)
      | 
paint.cpp:23:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   23 | void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
      |             ^~~~
paint.cpp:23:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   23 | void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
      |                    ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 1 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 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 100 ms 364 KB Output is correct
14 Correct 108 ms 348 KB Output is correct
15 Correct 109 ms 352 KB Output is correct
16 Correct 111 ms 348 KB Output is correct
17 Correct 112 ms 352 KB Output is correct
18 Correct 115 ms 348 KB Output is correct
19 Correct 264 ms 368 KB Output is correct
20 Correct 271 ms 380 KB Output is correct
21 Correct 275 ms 368 KB Output is correct
22 Correct 560 ms 5112 KB Output is correct
23 Correct 570 ms 5100 KB Output is correct
24 Correct 485 ms 5120 KB Output is correct
25 Correct 8 ms 1364 KB Output is correct
26 Correct 10 ms 1468 KB Output is correct
27 Correct 6 ms 980 KB Output is correct
28 Correct 5 ms 596 KB Output is correct
29 Correct 8 ms 468 KB Output is correct
30 Correct 9 ms 528 KB Output is correct
31 Execution timed out 1588 ms 1748 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 1 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 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 100 ms 364 KB Output is correct
14 Correct 108 ms 348 KB Output is correct
15 Correct 109 ms 352 KB Output is correct
16 Correct 111 ms 348 KB Output is correct
17 Correct 112 ms 352 KB Output is correct
18 Correct 115 ms 348 KB Output is correct
19 Correct 264 ms 368 KB Output is correct
20 Correct 271 ms 380 KB Output is correct
21 Correct 275 ms 368 KB Output is correct
22 Correct 0 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 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 4 ms 308 KB Output is correct
30 Correct 5 ms 304 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 11 ms 212 KB Output is correct
33 Correct 49 ms 340 KB Output is correct
34 Correct 60 ms 344 KB Output is correct
35 Correct 23 ms 332 KB Output is correct
36 Correct 42 ms 344 KB Output is correct
37 Correct 39 ms 352 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 101 ms 340 KB Output is correct
41 Correct 31 ms 340 KB Output is correct
42 Correct 60 ms 340 KB Output is correct
43 Correct 16 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 14 ms 212 KB Output is correct
47 Correct 18 ms 212 KB Output is correct
48 Correct 20 ms 316 KB Output is correct
49 Correct 23 ms 212 KB Output is correct
50 Correct 118 ms 356 KB Output is correct
51 Correct 94 ms 352 KB Output is correct
52 Correct 94 ms 348 KB Output is correct
53 Correct 116 ms 352 KB Output is correct
54 Correct 105 ms 352 KB Output is correct
55 Correct 98 ms 368 KB Output is correct
56 Correct 273 ms 372 KB Output is correct
57 Correct 83 ms 340 KB Output is correct
58 Correct 266 ms 372 KB Output is correct
59 Correct 96 ms 356 KB Output is correct
60 Correct 270 ms 368 KB Output is correct
61 Correct 109 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 1 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 1 ms 212 KB Output is correct
15 Correct 100 ms 364 KB Output is correct
16 Correct 108 ms 348 KB Output is correct
17 Correct 109 ms 352 KB Output is correct
18 Correct 111 ms 348 KB Output is correct
19 Correct 112 ms 352 KB Output is correct
20 Correct 115 ms 348 KB Output is correct
21 Correct 264 ms 368 KB Output is correct
22 Correct 271 ms 380 KB Output is correct
23 Correct 275 ms 368 KB Output is correct
24 Correct 560 ms 5112 KB Output is correct
25 Correct 570 ms 5100 KB Output is correct
26 Correct 485 ms 5120 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 4 ms 308 KB Output is correct
33 Correct 5 ms 304 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 11 ms 212 KB Output is correct
36 Correct 49 ms 340 KB Output is correct
37 Correct 60 ms 344 KB Output is correct
38 Correct 23 ms 332 KB Output is correct
39 Correct 42 ms 344 KB Output is correct
40 Correct 39 ms 352 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 101 ms 340 KB Output is correct
44 Correct 31 ms 340 KB Output is correct
45 Correct 60 ms 340 KB Output is correct
46 Correct 16 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 14 ms 212 KB Output is correct
50 Correct 18 ms 212 KB Output is correct
51 Correct 20 ms 316 KB Output is correct
52 Correct 23 ms 212 KB Output is correct
53 Correct 118 ms 356 KB Output is correct
54 Correct 94 ms 352 KB Output is correct
55 Correct 94 ms 348 KB Output is correct
56 Correct 116 ms 352 KB Output is correct
57 Correct 105 ms 352 KB Output is correct
58 Correct 98 ms 368 KB Output is correct
59 Correct 273 ms 372 KB Output is correct
60 Correct 83 ms 340 KB Output is correct
61 Correct 266 ms 372 KB Output is correct
62 Correct 96 ms 356 KB Output is correct
63 Correct 270 ms 368 KB Output is correct
64 Correct 109 ms 364 KB Output is correct
65 Correct 1 ms 340 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 1 ms 276 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 64 ms 828 KB Output is correct
71 Correct 30 ms 912 KB Output is correct
72 Correct 9 ms 852 KB Output is correct
73 Correct 3 ms 596 KB Output is correct
74 Correct 9 ms 848 KB Output is correct
75 Correct 46 ms 724 KB Output is correct
76 Correct 112 ms 5588 KB Output is correct
77 Correct 23 ms 6028 KB Output is correct
78 Correct 47 ms 7240 KB Output is correct
79 Correct 2 ms 340 KB Output is correct
80 Correct 2 ms 340 KB Output is correct
81 Correct 1 ms 340 KB Output is correct
82 Correct 2 ms 340 KB Output is correct
83 Correct 1 ms 340 KB Output is correct
84 Correct 46 ms 980 KB Output is correct
85 Correct 69 ms 1056 KB Output is correct
86 Correct 58 ms 1068 KB Output is correct
87 Correct 63 ms 1056 KB Output is correct
88 Correct 42 ms 1056 KB Output is correct
89 Correct 53 ms 980 KB Output is correct
90 Correct 611 ms 8172 KB Output is correct
91 Correct 653 ms 8156 KB Output is correct
92 Correct 584 ms 8168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 1 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 1 ms 212 KB Output is correct
15 Correct 100 ms 364 KB Output is correct
16 Correct 108 ms 348 KB Output is correct
17 Correct 109 ms 352 KB Output is correct
18 Correct 111 ms 348 KB Output is correct
19 Correct 112 ms 352 KB Output is correct
20 Correct 115 ms 348 KB Output is correct
21 Correct 264 ms 368 KB Output is correct
22 Correct 271 ms 380 KB Output is correct
23 Correct 275 ms 368 KB Output is correct
24 Correct 560 ms 5112 KB Output is correct
25 Correct 570 ms 5100 KB Output is correct
26 Correct 485 ms 5120 KB Output is correct
27 Correct 8 ms 1364 KB Output is correct
28 Correct 10 ms 1468 KB Output is correct
29 Correct 6 ms 980 KB Output is correct
30 Correct 5 ms 596 KB Output is correct
31 Correct 8 ms 468 KB Output is correct
32 Correct 9 ms 528 KB Output is correct
33 Execution timed out 1588 ms 1748 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 1 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 1 ms 212 KB Output is correct
15 Correct 100 ms 364 KB Output is correct
16 Correct 108 ms 348 KB Output is correct
17 Correct 109 ms 352 KB Output is correct
18 Correct 111 ms 348 KB Output is correct
19 Correct 112 ms 352 KB Output is correct
20 Correct 115 ms 348 KB Output is correct
21 Correct 264 ms 368 KB Output is correct
22 Correct 271 ms 380 KB Output is correct
23 Correct 275 ms 368 KB Output is correct
24 Correct 560 ms 5112 KB Output is correct
25 Correct 570 ms 5100 KB Output is correct
26 Correct 485 ms 5120 KB Output is correct
27 Correct 8 ms 1364 KB Output is correct
28 Correct 10 ms 1468 KB Output is correct
29 Correct 6 ms 980 KB Output is correct
30 Correct 5 ms 596 KB Output is correct
31 Correct 8 ms 468 KB Output is correct
32 Correct 9 ms 528 KB Output is correct
33 Execution timed out 1588 ms 1748 KB Time limit exceeded
34 Halted 0 ms 0 KB -