Submission #996471

# Submission time Handle Problem Language Result Execution time Memory
996471 2024-06-10T16:39:53 Z Dan4Life Painting Walls (APIO20_paint) C++17
0 / 100
3 ms 9820 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define sz(a) (int)a.size()
#define pb push_back

const int mxN = (int)2e5+10; 
int n, m, k;
bool work[mxN];
vector<int> c, a;
set<int> b[mxN];

bool check(int i){
	for(int st = 0; st < m; st++){
		int x = st, y = i, flag = 1;
		for(int i = 0; i < m and flag; i++){
			if(!b[x].count(c[y])) flag = 0;
			x++; if(x==m) x=0;
			y++; if(y==n) break;
		}
		if(flag) return true;
	}
	return false;
}

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(auto u : C) c.pb(u);
	for(auto u : A) a.pb(u);
	for(int i = 0; i < m; i++)
		for(auto u : B[i]) b[i].insert(u);
	memset(work,0,sizeof(work));
	for(int i = 0; i <= n-m; i++) work[i] = check(i);
	if(!work[0] or !work[n-m]) return -1;
	
	int tot = 1;
	for(int i = 0; i < n-m;){
		int j;
		for(j = i+m; j>=i; j--)
			if(work[j]) break;
		if(j==i) return false;
		tot++;
		i = j;
	}
	return tot;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 9820 KB Output is correct
2 Correct 2 ms 9820 KB Output is correct
3 Correct 2 ms 9820 KB Output is correct
4 Correct 2 ms 9820 KB Output is correct
5 Correct 2 ms 9820 KB Output is correct
6 Correct 2 ms 9820 KB Output is correct
7 Correct 2 ms 9820 KB Output is correct
8 Correct 3 ms 9820 KB Output is correct
9 Incorrect 2 ms 9820 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 9820 KB Output is correct
2 Correct 2 ms 9820 KB Output is correct
3 Correct 2 ms 9820 KB Output is correct
4 Correct 2 ms 9820 KB Output is correct
5 Correct 2 ms 9820 KB Output is correct
6 Correct 2 ms 9820 KB Output is correct
7 Correct 2 ms 9820 KB Output is correct
8 Correct 3 ms 9820 KB Output is correct
9 Incorrect 2 ms 9820 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 9820 KB Output is correct
2 Correct 2 ms 9820 KB Output is correct
3 Correct 2 ms 9820 KB Output is correct
4 Correct 2 ms 9820 KB Output is correct
5 Correct 2 ms 9820 KB Output is correct
6 Correct 2 ms 9820 KB Output is correct
7 Correct 2 ms 9820 KB Output is correct
8 Correct 3 ms 9820 KB Output is correct
9 Incorrect 2 ms 9820 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 9820 KB Output is correct
2 Correct 2 ms 9820 KB Output is correct
3 Correct 2 ms 9820 KB Output is correct
4 Correct 2 ms 9820 KB Output is correct
5 Correct 2 ms 9820 KB Output is correct
6 Correct 2 ms 9820 KB Output is correct
7 Correct 2 ms 9820 KB Output is correct
8 Correct 3 ms 9820 KB Output is correct
9 Incorrect 2 ms 9820 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 9820 KB Output is correct
2 Correct 2 ms 9820 KB Output is correct
3 Correct 2 ms 9820 KB Output is correct
4 Correct 2 ms 9820 KB Output is correct
5 Correct 2 ms 9820 KB Output is correct
6 Correct 2 ms 9820 KB Output is correct
7 Correct 2 ms 9820 KB Output is correct
8 Correct 3 ms 9820 KB Output is correct
9 Incorrect 2 ms 9820 KB Output isn't correct
10 Halted 0 ms 0 KB -