# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
401928 | 2021-05-11T02:30:27 Z | faresbasbs | 벽 칠하기 (APIO20_paint) | C++14 | 2 ms | 2636 KB |
#include <bits/stdc++.h> #include "paint.h" using namespace std; vector<int> vals[100001]; int minimumInstructions(int n , int m , int K , vector<int> c , vector<int> A , vector<vector<int>> B){ for(int i = 0 ; i < m ; i += 1){ for(auto j : B[i]){ vals[j].push_back(i); } } vector<pair<int,int>> q,q2; for(int i : vals[c[0]]){ q.push_back({i,1}); } vector<int> all; for(int i = 1 ; i < n ; i += 1){ q2.clear(); for(auto j : q){ if(j.second == m){ continue; } if(*lower_bound(vals[c[i]].begin(),vals[c[i]].end(),(j.first+1)%m) == (j.first+1)%m){ q2.push_back({(j.first+1)%m,j.second+1}); if(j.second == m-1){ all.push_back(i-m+1); } } } for(auto j : vals[c[i]]){ q2.push_back({j,1}); } swap(q,q2); } if(all.size() == 0 || all[0] != 0){ return -1; } int pre = 0 , mx = 0 , cnt = 1; for(int i = 0 ; i < all.size() ; i += 1){ if(pre+m >= all[i]){ mx = all[i]; continue; } if(mx == pre){ return -1; } cnt += 1 , pre = mx; i -= 1; } if(pre+m == n){ return cnt; } pre = mx , cnt += 1; if(pre+m == n){ return cnt; } return -1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2636 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2636 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2636 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2636 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2636 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |