# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
293377 | 2020-09-08T01:13:19 Z | daniel920712 | 벽 칠하기 (APIO20_paint) | C++14 | 4 ms | 4992 KB |
#include "paint.h" #include <vector> #include <stdio.h> #include <queue> using namespace std; bool can[2005][20005]={0}; int r[2005][20005]; int rr[20005]; int DP[20005]; int cha[100005]; vector < int > all; vector < int > how[200005]; int N,M; queue < pair < int , int > > now; int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A,vector< vector<int> > B) { int i,j,ok; //C=C; ::N=N; ::M=M; for(i=0;i<K;i++) for(i=0;i<N;i++) cha[C[i]]=N+1; for(i=0;i<M;i++) { for(j=0;j<A[i];j++) { can[i][cha[B[i][j]]]=1; //how[B[i][j]].push_back(i); } } for(j=M-1;j>=0;j--) r[j][N]=N; for(i=N-1;i>=0;i--) { rr[i]=-1e9; for(j=M-1;j>=0;j--) { if(can[j][cha[C[i]]]==0) r[j][i]=-1e9; else r[j][i]=max(i,r[(j+1)%M][i+1]); rr[i]=max(rr[i],r[j][i]); } } now.push(make_pair(0,N)); for(i=N-1;i>=0;i--) { ok=0; DP[i]=1e9; while(!now.empty()&&now.front().second-i>M) now.pop(); if(i+M>N) continue; else { if(rr[i]>=i+M-1) { if(now.empty()) DP[i]=1e9; else { DP[i]=now.front().first+1; now.push(make_pair(DP[i],i)); } } } } int t=DP[0]; if(t>=1000000000) return -1; return t; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Incorrect | 4 ms | 4992 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Incorrect | 4 ms | 4992 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Incorrect | 4 ms | 4992 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Incorrect | 4 ms | 4992 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Incorrect | 4 ms | 4992 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |