답안 #290686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
290686 2020-09-04T10:29:54 Z TadijaSebez 벽 칠하기 (APIO20_paint) C++11
0 / 100
0 ms 256 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pb push_back

int minimumInstructions(int n,int m,int k,vector<int> c,vector<int> a,vector<vector<int>> b){
	vector<set<int>> can(k);
	for(int i=0;i<m;i++)for(int j=0;j<a[i];j++)can[b[i][j]].insert(i);
	vector<int> r(n,0),l(n,0);
	for(int i=0;i<n;i++){
		while(i+r[i]<n&&can[c[i+r[i]]].count(r[i]))r[i]++;
		while(i-l[i]>=0&&can[c[i-l[i]]].count(m-l[i]-1))l[i]++;
		//printf("%i %i %i\n",i,l[i],r[i]);
	}
	vector<bool> seg(n);
	for(int i=0;i<n-1;i++){
		if(l[i]+r[i+1]>=m){
			int sz=l[i]+r[i+1]-m+1;
			for(int j=1;j<=sz;j++)seg[i-l[i]+j]=1;
		}
	}
	vector<pii> ans;
	ans.pb({-1,-1});
	for(int i=0;i<n;i++){
		if(seg[i]){
			int sz=ans.size();
			if(sz>1&&ans[sz-2].second+1>=i)ans.pop_back();
			if(ans.back().second+1<i)return -1;
			ans.pb({i,i+m-1});
			//printf("%i %i\n",i,i+m-1);
		}
	}
	if(ans.back().second<n-1)return -1;
	return ans.size()-1;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -