# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
293385 | 2020-09-08T01:41:24 Z | daniel920712 | 벽 칠하기 (APIO20_paint) | C++14 | 5 ms | 5120 KB |
#include "paint.h" #include <vector> #include <stdio.h> #include <queue> #include <unordered_map> using namespace std; unordered_map < int , int > r[5]; int rr[100005]; int DP[100005]; int cha[100005]; vector < int > all; vector < int > how[100005]; 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; ::N=N; ::M=M; for(i=0;i<M;i++) for(j=0;j<A[i];j++) how[B[i][j]].push_back(i); for(i=N-1;i>=0;i--) { rr[i]=-1e9; r[i%2].clear(); for(auto j:how[C[i]]) { r[i][j]=i; if(i!=N-1&&r[1-i%2].find((j+1)%M)!=r[1-i%2].end()) r[i%2][j]=max(i,r[1-i%2][(j+1)%M]); rr[i]=max(rr[i],r[i%2][j]); } } 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 | 2 ms | 2688 KB | Output is correct |
2 | Correct | 2 ms | 2688 KB | Output is correct |
3 | Correct | 2 ms | 2688 KB | Output is correct |
4 | Correct | 2 ms | 2688 KB | Output is correct |
5 | Correct | 2 ms | 2688 KB | Output is correct |
6 | Incorrect | 2 ms | 2688 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 5120 KB | Execution killed with signal 8 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 5120 KB | Execution killed with signal 8 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 5120 KB | Execution killed with signal 8 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 5 ms | 5120 KB | Execution killed with signal 8 |
2 | Halted | 0 ms | 0 KB | - |