제출 #401929

#제출 시각아이디문제언어결과실행 시간메모리
401929faresbasbs벽 칠하기 (APIO20_paint)C++14
0 / 100
5 ms5248 KiB
#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; if(m == 1 && vals[c[0]].size()){ all.push_back(0); } 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}); } if(m == 1 && vals[c[i]].size()){ all.push_back(i); } 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; }

컴파일 시 표준 에러 (stderr) 메시지

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:45:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  for(int i = 0 ; i < all.size() ; i += 1){
      |                  ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...