Submission #899185

#TimeUsernameProblemLanguageResultExecution timeMemory
899185LCJLYPainting Walls (APIO20_paint)C++14
0 / 100
28 ms60980 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...