# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
293360 | 2020-09-08T00:36:20 Z | daniel920712 | 벽 칠하기 (APIO20_paint) | C++14 | 4 ms | 5120 KB |
#include "paint.h" #include <vector> #include <stdio.h> using namespace std; bool can[2005][100005]={0}; bool use[2005][100005]={0}; int r[2005][100005]; bool have[200005]={0}; int DP[200005]; vector < int > all; vector < int > how[200005]; int N,M; int F(int here) { int ok=0,ok2,i,j; if(have[here]) return DP[here]; if(here==N) return 0; have[here]=1; if(here+M>N) { DP[here]=1e9; return 1e9; } for(i=0;i<M;i++) if(r[i][here]>=here+M-1) ok=1; DP[here]=1e9; if(ok) for(i=1;i<=M;i++) DP[here]=min(DP[here],F(here+i)+1); return DP[here]; } int F2(int N,int M) { if(N==::N) return N; if(use[M][N]) return r[M][N]; use[M][N]=1; if(can[M][all[N]]==0) r[M][N]=-1e9; else r[M][N]=max(N,F2(N+1,(M+1)%(::M))); return r[M][N]; } int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A,vector< vector<int> > B) { int i,j; all=C; ::N=N; ::M=M; for(i=0;i<M;i++) { for(j=0;j<A[i];j++) { can[i][B[i][j]]=1; how[B[i][j]].push_back(i); } } for(i=N;i>=0;i--) { for(j=M-1;j>=0;j--) { if(i==N) r[j][i]=N; else if(can[j][all[i]]==0) r[j][i]=-1e9; else r[j][i]=max(N,r[(j+1)%M][i+1]); } } int t=F(0); if(t>=1000000000) return -1; return t; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 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 | Correct | 4 ms | 4992 KB | Output is correct |
6 | Correct | 4 ms | 4992 KB | Output is correct |
7 | Correct | 3 ms | 5120 KB | Output is correct |
8 | Correct | 3 ms | 4992 KB | Output is correct |
9 | Incorrect | 4 ms | 5120 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4992 KB | Output is correct |
2 | Incorrect | 3 ms | 4992 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4992 KB | Output is correct |
2 | Incorrect | 3 ms | 4992 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4992 KB | Output is correct |
2 | Incorrect | 3 ms | 4992 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4992 KB | Output is correct |
2 | Incorrect | 3 ms | 4992 KB | Output isn't correct |