제출 #736396

#제출 시각아이디문제언어결과실행 시간메모리
736396minhcool벽 칠하기 (APIO20_paint)C++17
100 / 100
1161 ms22148 KiB
#include "paint.h" #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; const int N = 4e5 + 5; const int oo = 1e18 + 7, mod = 1e9 + 7; int n, m, k; int arr[N]; vector<int> like[N]; int total[N]; bool okay[N]; int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B){ n = N, m = M, k = K; for(int i = 0; i < n; i++) arr[i + 1] = C[i] + 1; for(int i = 0; i < m; i++){ for(auto it : B[i]) like[it + 1].pb(i + 1); } for(int i = 1; i <= k; i++) assert(like[i].size() <= 700); for(int i = 1; i <= m; i++){ for(auto it : like[arr[i]]){ int temp = (it - (i - 1) + 2 * m) % m; if(!temp) temp = m; total[temp]++; //okay[1] |= (total[temp] == m); } } int cnt = 0; for(int i = 1; i <= m; i++) cnt += (total[i] == m); okay[1] = (cnt != 0); int tempp = (n / m) + 1; tempp *= m; for(int i = m + 1; i <= n; i++){ for(auto it : like[arr[i - m]]){ int temp = (it - i + 1 + tempp) % m; // assert(temp >= 0); // cout << i << " " << temp << "\n"; if(!temp) temp = m; if(total[temp] == m) cnt--; //cnt[total[temp]]--; total[temp]--; //cnt[total[temp]]++; //total[temp]++; } for(auto it : like[arr[i]]){ int temp = (it - i + 1 + tempp) % m; // assert(temp >= 0); if(!temp) temp = m; //cnt[total[temp]]--; total[temp]++; if(total[temp] == m) cnt++; //cnt[total[temp]]++; } okay[i - m + 1] = (cnt != 0); } //for(int i = 1; i <= (n - m + 1); i++) cout << okay[i] << " "; //cout << "\n"; if(!okay[1]) return -1; vector<int> okays; for(int i = 1; i <= n - m + 1; i++) if(okay[i]) okays.pb(i); int ans = 1, itr = m; while(itr < n){ //cout << itr << "\n"; vector<int>::iterator it = lower_bound(okays.begin(), okays.end(), itr + 2); assert(it != okays.begin()); it--; int temp = ((*it) + m - 1); if(temp <= itr) return -1; itr = temp; ans++; } return ans; }

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

paint.cpp:16:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   16 | const int oo = 1e18 + 7, mod = 1e9 + 7;
      |                ~~~~~^~~
#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...