#include "paint.h"
#include <bits/stdc++.h>
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << #i << " " << q << " " << #p << endl;
#define show4(x,y) for(auto it:x) cout << it << " "; cout << #y << endl;
using namespace std;
int arr[100005];
int n,m,k;
unordered_set<int>check[500005];
vector<int>color[100005];
int minimumInstructions(int N, int M, int K, vector<int>C, vector<int>A, vector<vector<int>>B){
n=N; m=M; k=K;
for(int x=0;x<n;x++){
arr[x]=C[x];
}
for(int x=0;x<m;x++){
for(int y=0;y<A[x];y++){
check[x].insert(B[x][y]);
check[x+m].insert(B[x][y]);
color[B[x][y]].push_back(x);
}
}
int pos=color[arr[0]][0];
bool amos=true;
for(int x=0;x<n;x++){
if(check[pos].find(arr[x])==check[pos].end()) amos=false;
pos=(pos+1)%m;
}
if(amos){
return (n+m-1)/m;
}
else return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
30040 KB |
Output is correct |
2 |
Correct |
7 ms |
30044 KB |
Output is correct |
3 |
Correct |
8 ms |
30172 KB |
Output is correct |
4 |
Correct |
7 ms |
30040 KB |
Output is correct |
5 |
Correct |
7 ms |
30044 KB |
Output is correct |
6 |
Correct |
7 ms |
30176 KB |
Output is correct |
7 |
Correct |
7 ms |
30040 KB |
Output is correct |
8 |
Correct |
7 ms |
30040 KB |
Output is correct |
9 |
Correct |
7 ms |
30196 KB |
Output is correct |
10 |
Correct |
9 ms |
30044 KB |
Output is correct |
11 |
Correct |
7 ms |
30048 KB |
Output is correct |
12 |
Correct |
7 ms |
30164 KB |
Output is correct |
13 |
Correct |
7 ms |
30300 KB |
Output is correct |
14 |
Correct |
8 ms |
30300 KB |
Output is correct |
15 |
Correct |
8 ms |
30296 KB |
Output is correct |
16 |
Correct |
7 ms |
30300 KB |
Output is correct |
17 |
Correct |
7 ms |
30304 KB |
Output is correct |
18 |
Correct |
7 ms |
30276 KB |
Output is correct |
19 |
Runtime error |
28 ms |
60980 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
30040 KB |
Output is correct |
2 |
Correct |
7 ms |
30044 KB |
Output is correct |
3 |
Correct |
8 ms |
30172 KB |
Output is correct |
4 |
Correct |
7 ms |
30040 KB |
Output is correct |
5 |
Correct |
7 ms |
30044 KB |
Output is correct |
6 |
Correct |
7 ms |
30176 KB |
Output is correct |
7 |
Correct |
7 ms |
30040 KB |
Output is correct |
8 |
Correct |
7 ms |
30040 KB |
Output is correct |
9 |
Correct |
7 ms |
30196 KB |
Output is correct |
10 |
Correct |
9 ms |
30044 KB |
Output is correct |
11 |
Correct |
7 ms |
30048 KB |
Output is correct |
12 |
Correct |
7 ms |
30164 KB |
Output is correct |
13 |
Correct |
7 ms |
30300 KB |
Output is correct |
14 |
Correct |
8 ms |
30300 KB |
Output is correct |
15 |
Correct |
8 ms |
30296 KB |
Output is correct |
16 |
Correct |
7 ms |
30300 KB |
Output is correct |
17 |
Correct |
7 ms |
30304 KB |
Output is correct |
18 |
Correct |
7 ms |
30276 KB |
Output is correct |
19 |
Runtime error |
28 ms |
60980 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
30040 KB |
Output is correct |
2 |
Correct |
7 ms |
30044 KB |
Output is correct |
3 |
Correct |
8 ms |
30172 KB |
Output is correct |
4 |
Correct |
7 ms |
30040 KB |
Output is correct |
5 |
Correct |
7 ms |
30044 KB |
Output is correct |
6 |
Correct |
7 ms |
30176 KB |
Output is correct |
7 |
Correct |
7 ms |
30040 KB |
Output is correct |
8 |
Correct |
7 ms |
30040 KB |
Output is correct |
9 |
Correct |
7 ms |
30196 KB |
Output is correct |
10 |
Correct |
9 ms |
30044 KB |
Output is correct |
11 |
Correct |
7 ms |
30048 KB |
Output is correct |
12 |
Correct |
7 ms |
30164 KB |
Output is correct |
13 |
Correct |
7 ms |
30300 KB |
Output is correct |
14 |
Correct |
8 ms |
30300 KB |
Output is correct |
15 |
Correct |
8 ms |
30296 KB |
Output is correct |
16 |
Correct |
7 ms |
30300 KB |
Output is correct |
17 |
Correct |
7 ms |
30304 KB |
Output is correct |
18 |
Correct |
7 ms |
30276 KB |
Output is correct |
19 |
Runtime error |
28 ms |
60980 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
30040 KB |
Output is correct |
2 |
Correct |
7 ms |
30044 KB |
Output is correct |
3 |
Correct |
8 ms |
30172 KB |
Output is correct |
4 |
Correct |
7 ms |
30040 KB |
Output is correct |
5 |
Correct |
7 ms |
30044 KB |
Output is correct |
6 |
Correct |
7 ms |
30176 KB |
Output is correct |
7 |
Correct |
7 ms |
30040 KB |
Output is correct |
8 |
Correct |
7 ms |
30040 KB |
Output is correct |
9 |
Correct |
7 ms |
30196 KB |
Output is correct |
10 |
Correct |
9 ms |
30044 KB |
Output is correct |
11 |
Correct |
7 ms |
30048 KB |
Output is correct |
12 |
Correct |
7 ms |
30164 KB |
Output is correct |
13 |
Correct |
7 ms |
30300 KB |
Output is correct |
14 |
Correct |
8 ms |
30300 KB |
Output is correct |
15 |
Correct |
8 ms |
30296 KB |
Output is correct |
16 |
Correct |
7 ms |
30300 KB |
Output is correct |
17 |
Correct |
7 ms |
30304 KB |
Output is correct |
18 |
Correct |
7 ms |
30276 KB |
Output is correct |
19 |
Runtime error |
28 ms |
60980 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
30040 KB |
Output is correct |
2 |
Correct |
7 ms |
30044 KB |
Output is correct |
3 |
Correct |
8 ms |
30172 KB |
Output is correct |
4 |
Correct |
7 ms |
30040 KB |
Output is correct |
5 |
Correct |
7 ms |
30044 KB |
Output is correct |
6 |
Correct |
7 ms |
30176 KB |
Output is correct |
7 |
Correct |
7 ms |
30040 KB |
Output is correct |
8 |
Correct |
7 ms |
30040 KB |
Output is correct |
9 |
Correct |
7 ms |
30196 KB |
Output is correct |
10 |
Correct |
9 ms |
30044 KB |
Output is correct |
11 |
Correct |
7 ms |
30048 KB |
Output is correct |
12 |
Correct |
7 ms |
30164 KB |
Output is correct |
13 |
Correct |
7 ms |
30300 KB |
Output is correct |
14 |
Correct |
8 ms |
30300 KB |
Output is correct |
15 |
Correct |
8 ms |
30296 KB |
Output is correct |
16 |
Correct |
7 ms |
30300 KB |
Output is correct |
17 |
Correct |
7 ms |
30304 KB |
Output is correct |
18 |
Correct |
7 ms |
30276 KB |
Output is correct |
19 |
Runtime error |
28 ms |
60980 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |