답안 #965908

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
965908 2024-04-19T07:50:28 Z pcc 벽 칠하기 (APIO20_paint) C++17
28 / 100
1500 ms 154344 KB
#include "paint.h"

#include <vector>
#include <bits/stdc++.h>
using namespace std;

const int mxn = 1e5+10;
#define pii pair<int,int>
#define fs first
#define sc second
set<int> col[mxn];
bitset<mxn> able;
int N,M,K;
int arr[mxn];

bool check(int s){
	bool re = false;
	for(auto i:col[arr[s]]){
		int now = s;
		bool f = true;
		for(int j = 0;j<M;j++){
			if(col[arr[now]].find(i) == col[arr[now]].end()){
				f = false;
				break;
			}
			now++;
			i = (i+1)%M;
		}
		if(f)re = true;
	}
	return re;
}

namespace GRAPH{
	vector<int> paths[mxn];
	int dist[mxn];
	queue<int> q;
	void bfs(int s){
		memset(dist,-1,sizeof(dist));
		q.push(s);
		dist[s] = 0;
		while(!q.empty()){
			auto now = q.front();
			q.pop();
			for(auto nxt:paths[now]){
				if(dist[nxt] == -1){
					dist[nxt] = dist[now]+1;
					q.push(nxt);
				}
			}
		}
		return;
	}

	int GO(){
		for(int i = 0;i<N;i++){
			if(able[i]){
				for(int j = 1;j<=M;j++)paths[i].push_back(i+j);
			}
		}
		bfs(0);
		return dist[N];
	}
}

int minimumInstructions(
    int NN, int MM, int K, std::vector<int> C,
    std::vector<int> A, std::vector<std::vector<int>> B) {
	N = NN,M = MM;
	for(int i = 0;i<M;i++){
		for(int j = 0;j<A[i];j++)col[B[i][j]].insert(i);
	}
	for(int i = 0;i<N;i++)arr[i] = C[i];
	for(int i = 0;i+M<=N;i++)able[i] = check(i);
	return GRAPH::GO();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8028 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Correct 2 ms 8028 KB Output is correct
4 Correct 2 ms 8028 KB Output is correct
5 Correct 3 ms 8028 KB Output is correct
6 Correct 3 ms 8028 KB Output is correct
7 Correct 3 ms 8284 KB Output is correct
8 Correct 2 ms 8284 KB Output is correct
9 Correct 2 ms 8284 KB Output is correct
10 Correct 2 ms 8284 KB Output is correct
11 Correct 2 ms 8284 KB Output is correct
12 Correct 3 ms 8432 KB Output is correct
13 Correct 4 ms 8540 KB Output is correct
14 Correct 3 ms 8540 KB Output is correct
15 Correct 3 ms 8540 KB Output is correct
16 Correct 3 ms 8536 KB Output is correct
17 Correct 3 ms 8540 KB Output is correct
18 Correct 3 ms 8540 KB Output is correct
19 Correct 2 ms 8284 KB Output is correct
20 Correct 2 ms 8352 KB Output is correct
21 Correct 3 ms 8348 KB Output is correct
22 Correct 23 ms 13656 KB Output is correct
23 Correct 23 ms 13660 KB Output is correct
24 Correct 23 ms 13716 KB Output is correct
25 Correct 6 ms 9316 KB Output is correct
26 Correct 4 ms 9052 KB Output is correct
27 Correct 5 ms 8544 KB Output is correct
28 Correct 4 ms 8284 KB Output is correct
29 Correct 5 ms 8452 KB Output is correct
30 Correct 4 ms 8296 KB Output is correct
31 Correct 425 ms 154140 KB Output is correct
32 Correct 382 ms 154116 KB Output is correct
33 Correct 402 ms 154132 KB Output is correct
34 Correct 400 ms 154136 KB Output is correct
35 Correct 357 ms 154116 KB Output is correct
36 Correct 362 ms 154344 KB Output is correct
37 Correct 22 ms 14016 KB Output is correct
38 Correct 18 ms 13916 KB Output is correct
39 Correct 31 ms 14164 KB Output is correct
40 Correct 15 ms 11612 KB Output is correct
41 Correct 9 ms 10328 KB Output is correct
42 Correct 15 ms 10556 KB Output is correct
43 Correct 9 ms 8796 KB Output is correct
44 Correct 7 ms 8540 KB Output is correct
45 Correct 13 ms 9064 KB Output is correct
46 Execution timed out 1561 ms 18516 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8028 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Correct 2 ms 8028 KB Output is correct
4 Correct 2 ms 8028 KB Output is correct
5 Correct 3 ms 8028 KB Output is correct
6 Correct 3 ms 8028 KB Output is correct
7 Correct 3 ms 8284 KB Output is correct
8 Correct 2 ms 8284 KB Output is correct
9 Correct 2 ms 8284 KB Output is correct
10 Correct 2 ms 8284 KB Output is correct
11 Correct 2 ms 8284 KB Output is correct
12 Correct 3 ms 8432 KB Output is correct
13 Correct 4 ms 8540 KB Output is correct
14 Correct 3 ms 8540 KB Output is correct
15 Correct 3 ms 8540 KB Output is correct
16 Correct 3 ms 8536 KB Output is correct
17 Correct 3 ms 8540 KB Output is correct
18 Correct 3 ms 8540 KB Output is correct
19 Correct 2 ms 8284 KB Output is correct
20 Correct 2 ms 8352 KB Output is correct
21 Correct 3 ms 8348 KB Output is correct
22 Correct 2 ms 8280 KB Output is correct
23 Correct 2 ms 8028 KB Output is correct
24 Correct 3 ms 8028 KB Output is correct
25 Correct 2 ms 8028 KB Output is correct
26 Correct 2 ms 8284 KB Output is correct
27 Correct 3 ms 8284 KB Output is correct
28 Correct 5 ms 8328 KB Output is correct
29 Correct 3 ms 8040 KB Output is correct
30 Correct 2 ms 8284 KB Output is correct
31 Correct 2 ms 8120 KB Output is correct
32 Correct 2 ms 8284 KB Output is correct
33 Correct 3 ms 8540 KB Output is correct
34 Correct 3 ms 8540 KB Output is correct
35 Correct 2 ms 8392 KB Output is correct
36 Correct 2 ms 8540 KB Output is correct
37 Correct 3 ms 8284 KB Output is correct
38 Correct 2 ms 8120 KB Output is correct
39 Correct 2 ms 8284 KB Output is correct
40 Correct 3 ms 8284 KB Output is correct
41 Correct 3 ms 8280 KB Output is correct
42 Correct 2 ms 8284 KB Output is correct
43 Correct 2 ms 8284 KB Output is correct
44 Correct 2 ms 8284 KB Output is correct
45 Correct 6 ms 8116 KB Output is correct
46 Correct 2 ms 8284 KB Output is correct
47 Correct 2 ms 8280 KB Output is correct
48 Correct 2 ms 8284 KB Output is correct
49 Correct 2 ms 8284 KB Output is correct
50 Correct 3 ms 8540 KB Output is correct
51 Correct 3 ms 8540 KB Output is correct
52 Correct 3 ms 8540 KB Output is correct
53 Correct 3 ms 8536 KB Output is correct
54 Correct 3 ms 8540 KB Output is correct
55 Correct 3 ms 8536 KB Output is correct
56 Correct 3 ms 8284 KB Output is correct
57 Correct 3 ms 8536 KB Output is correct
58 Correct 2 ms 8124 KB Output is correct
59 Correct 3 ms 8540 KB Output is correct
60 Correct 2 ms 8280 KB Output is correct
61 Correct 3 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8280 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Correct 3 ms 8028 KB Output is correct
4 Correct 2 ms 8028 KB Output is correct
5 Correct 2 ms 8028 KB Output is correct
6 Correct 2 ms 8028 KB Output is correct
7 Correct 3 ms 8028 KB Output is correct
8 Correct 3 ms 8028 KB Output is correct
9 Correct 3 ms 8284 KB Output is correct
10 Correct 2 ms 8284 KB Output is correct
11 Correct 2 ms 8284 KB Output is correct
12 Correct 2 ms 8284 KB Output is correct
13 Correct 2 ms 8284 KB Output is correct
14 Correct 3 ms 8432 KB Output is correct
15 Correct 4 ms 8540 KB Output is correct
16 Correct 3 ms 8540 KB Output is correct
17 Correct 3 ms 8540 KB Output is correct
18 Correct 3 ms 8536 KB Output is correct
19 Correct 3 ms 8540 KB Output is correct
20 Correct 3 ms 8540 KB Output is correct
21 Correct 2 ms 8284 KB Output is correct
22 Correct 2 ms 8352 KB Output is correct
23 Correct 3 ms 8348 KB Output is correct
24 Correct 23 ms 13656 KB Output is correct
25 Correct 23 ms 13660 KB Output is correct
26 Correct 23 ms 13716 KB Output is correct
27 Correct 3 ms 8028 KB Output is correct
28 Correct 2 ms 8028 KB Output is correct
29 Correct 2 ms 8284 KB Output is correct
30 Correct 3 ms 8284 KB Output is correct
31 Correct 5 ms 8328 KB Output is correct
32 Correct 3 ms 8040 KB Output is correct
33 Correct 2 ms 8284 KB Output is correct
34 Correct 2 ms 8120 KB Output is correct
35 Correct 2 ms 8284 KB Output is correct
36 Correct 3 ms 8540 KB Output is correct
37 Correct 3 ms 8540 KB Output is correct
38 Correct 2 ms 8392 KB Output is correct
39 Correct 2 ms 8540 KB Output is correct
40 Correct 3 ms 8284 KB Output is correct
41 Correct 2 ms 8120 KB Output is correct
42 Correct 2 ms 8284 KB Output is correct
43 Correct 3 ms 8284 KB Output is correct
44 Correct 3 ms 8280 KB Output is correct
45 Correct 2 ms 8284 KB Output is correct
46 Correct 2 ms 8284 KB Output is correct
47 Correct 2 ms 8284 KB Output is correct
48 Correct 6 ms 8116 KB Output is correct
49 Correct 2 ms 8284 KB Output is correct
50 Correct 2 ms 8280 KB Output is correct
51 Correct 2 ms 8284 KB Output is correct
52 Correct 2 ms 8284 KB Output is correct
53 Correct 3 ms 8540 KB Output is correct
54 Correct 3 ms 8540 KB Output is correct
55 Correct 3 ms 8540 KB Output is correct
56 Correct 3 ms 8536 KB Output is correct
57 Correct 3 ms 8540 KB Output is correct
58 Correct 3 ms 8536 KB Output is correct
59 Correct 3 ms 8284 KB Output is correct
60 Correct 3 ms 8536 KB Output is correct
61 Correct 2 ms 8124 KB Output is correct
62 Correct 3 ms 8540 KB Output is correct
63 Correct 2 ms 8280 KB Output is correct
64 Correct 3 ms 8540 KB Output is correct
65 Correct 28 ms 8276 KB Output is correct
66 Correct 8 ms 8280 KB Output is correct
67 Correct 74 ms 8272 KB Output is correct
68 Correct 26 ms 8280 KB Output is correct
69 Correct 47 ms 8404 KB Output is correct
70 Correct 13 ms 9052 KB Output is correct
71 Correct 18 ms 9052 KB Output is correct
72 Correct 10 ms 8796 KB Output is correct
73 Correct 3 ms 8540 KB Output is correct
74 Correct 12 ms 8796 KB Output is correct
75 Correct 11 ms 8776 KB Output is correct
76 Correct 21 ms 14380 KB Output is correct
77 Correct 18 ms 14940 KB Output is correct
78 Correct 40 ms 15952 KB Output is correct
79 Correct 133 ms 8528 KB Output is correct
80 Correct 163 ms 8532 KB Output is correct
81 Correct 151 ms 8396 KB Output is correct
82 Correct 136 ms 8528 KB Output is correct
83 Correct 144 ms 8416 KB Output is correct
84 Correct 21 ms 9156 KB Output is correct
85 Correct 20 ms 9144 KB Output is correct
86 Correct 23 ms 9308 KB Output is correct
87 Correct 22 ms 9152 KB Output is correct
88 Correct 21 ms 9152 KB Output is correct
89 Correct 21 ms 9308 KB Output is correct
90 Correct 39 ms 16728 KB Output is correct
91 Correct 32 ms 16720 KB Output is correct
92 Correct 28 ms 16720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8280 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Correct 3 ms 8028 KB Output is correct
4 Correct 2 ms 8028 KB Output is correct
5 Correct 2 ms 8028 KB Output is correct
6 Correct 2 ms 8028 KB Output is correct
7 Correct 3 ms 8028 KB Output is correct
8 Correct 3 ms 8028 KB Output is correct
9 Correct 3 ms 8284 KB Output is correct
10 Correct 2 ms 8284 KB Output is correct
11 Correct 2 ms 8284 KB Output is correct
12 Correct 2 ms 8284 KB Output is correct
13 Correct 2 ms 8284 KB Output is correct
14 Correct 3 ms 8432 KB Output is correct
15 Correct 4 ms 8540 KB Output is correct
16 Correct 3 ms 8540 KB Output is correct
17 Correct 3 ms 8540 KB Output is correct
18 Correct 3 ms 8536 KB Output is correct
19 Correct 3 ms 8540 KB Output is correct
20 Correct 3 ms 8540 KB Output is correct
21 Correct 2 ms 8284 KB Output is correct
22 Correct 2 ms 8352 KB Output is correct
23 Correct 3 ms 8348 KB Output is correct
24 Correct 23 ms 13656 KB Output is correct
25 Correct 23 ms 13660 KB Output is correct
26 Correct 23 ms 13716 KB Output is correct
27 Correct 6 ms 9316 KB Output is correct
28 Correct 4 ms 9052 KB Output is correct
29 Correct 5 ms 8544 KB Output is correct
30 Correct 4 ms 8284 KB Output is correct
31 Correct 5 ms 8452 KB Output is correct
32 Correct 4 ms 8296 KB Output is correct
33 Correct 425 ms 154140 KB Output is correct
34 Correct 382 ms 154116 KB Output is correct
35 Correct 402 ms 154132 KB Output is correct
36 Correct 400 ms 154136 KB Output is correct
37 Correct 357 ms 154116 KB Output is correct
38 Correct 362 ms 154344 KB Output is correct
39 Correct 22 ms 14016 KB Output is correct
40 Correct 18 ms 13916 KB Output is correct
41 Correct 31 ms 14164 KB Output is correct
42 Correct 3 ms 8028 KB Output is correct
43 Correct 2 ms 8028 KB Output is correct
44 Correct 2 ms 8284 KB Output is correct
45 Correct 3 ms 8284 KB Output is correct
46 Correct 5 ms 8328 KB Output is correct
47 Correct 3 ms 8040 KB Output is correct
48 Correct 2 ms 8284 KB Output is correct
49 Correct 2 ms 8120 KB Output is correct
50 Correct 2 ms 8284 KB Output is correct
51 Correct 3 ms 8540 KB Output is correct
52 Correct 3 ms 8540 KB Output is correct
53 Correct 2 ms 8392 KB Output is correct
54 Correct 2 ms 8540 KB Output is correct
55 Correct 3 ms 8284 KB Output is correct
56 Correct 2 ms 8120 KB Output is correct
57 Correct 2 ms 8284 KB Output is correct
58 Correct 3 ms 8284 KB Output is correct
59 Correct 3 ms 8280 KB Output is correct
60 Correct 2 ms 8284 KB Output is correct
61 Correct 2 ms 8284 KB Output is correct
62 Correct 2 ms 8284 KB Output is correct
63 Correct 6 ms 8116 KB Output is correct
64 Correct 2 ms 8284 KB Output is correct
65 Correct 2 ms 8280 KB Output is correct
66 Correct 2 ms 8284 KB Output is correct
67 Correct 2 ms 8284 KB Output is correct
68 Correct 3 ms 8540 KB Output is correct
69 Correct 3 ms 8540 KB Output is correct
70 Correct 3 ms 8540 KB Output is correct
71 Correct 3 ms 8536 KB Output is correct
72 Correct 3 ms 8540 KB Output is correct
73 Correct 3 ms 8536 KB Output is correct
74 Correct 3 ms 8284 KB Output is correct
75 Correct 3 ms 8536 KB Output is correct
76 Correct 2 ms 8124 KB Output is correct
77 Correct 3 ms 8540 KB Output is correct
78 Correct 2 ms 8280 KB Output is correct
79 Correct 3 ms 8540 KB Output is correct
80 Correct 28 ms 8276 KB Output is correct
81 Correct 8 ms 8280 KB Output is correct
82 Correct 74 ms 8272 KB Output is correct
83 Correct 26 ms 8280 KB Output is correct
84 Correct 47 ms 8404 KB Output is correct
85 Correct 13 ms 9052 KB Output is correct
86 Correct 18 ms 9052 KB Output is correct
87 Correct 10 ms 8796 KB Output is correct
88 Correct 3 ms 8540 KB Output is correct
89 Correct 12 ms 8796 KB Output is correct
90 Correct 11 ms 8776 KB Output is correct
91 Correct 21 ms 14380 KB Output is correct
92 Correct 18 ms 14940 KB Output is correct
93 Correct 40 ms 15952 KB Output is correct
94 Correct 133 ms 8528 KB Output is correct
95 Correct 163 ms 8532 KB Output is correct
96 Correct 151 ms 8396 KB Output is correct
97 Correct 136 ms 8528 KB Output is correct
98 Correct 144 ms 8416 KB Output is correct
99 Correct 21 ms 9156 KB Output is correct
100 Correct 20 ms 9144 KB Output is correct
101 Correct 23 ms 9308 KB Output is correct
102 Correct 22 ms 9152 KB Output is correct
103 Correct 21 ms 9152 KB Output is correct
104 Correct 21 ms 9308 KB Output is correct
105 Correct 39 ms 16728 KB Output is correct
106 Correct 32 ms 16720 KB Output is correct
107 Correct 28 ms 16720 KB Output is correct
108 Correct 5 ms 9052 KB Output is correct
109 Execution timed out 1589 ms 8284 KB Time limit exceeded
110 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8280 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Correct 3 ms 8028 KB Output is correct
4 Correct 2 ms 8028 KB Output is correct
5 Correct 2 ms 8028 KB Output is correct
6 Correct 2 ms 8028 KB Output is correct
7 Correct 3 ms 8028 KB Output is correct
8 Correct 3 ms 8028 KB Output is correct
9 Correct 3 ms 8284 KB Output is correct
10 Correct 2 ms 8284 KB Output is correct
11 Correct 2 ms 8284 KB Output is correct
12 Correct 2 ms 8284 KB Output is correct
13 Correct 2 ms 8284 KB Output is correct
14 Correct 3 ms 8432 KB Output is correct
15 Correct 4 ms 8540 KB Output is correct
16 Correct 3 ms 8540 KB Output is correct
17 Correct 3 ms 8540 KB Output is correct
18 Correct 3 ms 8536 KB Output is correct
19 Correct 3 ms 8540 KB Output is correct
20 Correct 3 ms 8540 KB Output is correct
21 Correct 2 ms 8284 KB Output is correct
22 Correct 2 ms 8352 KB Output is correct
23 Correct 3 ms 8348 KB Output is correct
24 Correct 23 ms 13656 KB Output is correct
25 Correct 23 ms 13660 KB Output is correct
26 Correct 23 ms 13716 KB Output is correct
27 Correct 6 ms 9316 KB Output is correct
28 Correct 4 ms 9052 KB Output is correct
29 Correct 5 ms 8544 KB Output is correct
30 Correct 4 ms 8284 KB Output is correct
31 Correct 5 ms 8452 KB Output is correct
32 Correct 4 ms 8296 KB Output is correct
33 Correct 425 ms 154140 KB Output is correct
34 Correct 382 ms 154116 KB Output is correct
35 Correct 402 ms 154132 KB Output is correct
36 Correct 400 ms 154136 KB Output is correct
37 Correct 357 ms 154116 KB Output is correct
38 Correct 362 ms 154344 KB Output is correct
39 Correct 22 ms 14016 KB Output is correct
40 Correct 18 ms 13916 KB Output is correct
41 Correct 31 ms 14164 KB Output is correct
42 Correct 15 ms 11612 KB Output is correct
43 Correct 9 ms 10328 KB Output is correct
44 Correct 15 ms 10556 KB Output is correct
45 Correct 9 ms 8796 KB Output is correct
46 Correct 7 ms 8540 KB Output is correct
47 Correct 13 ms 9064 KB Output is correct
48 Execution timed out 1561 ms 18516 KB Time limit exceeded
49 Halted 0 ms 0 KB -