제출 #397352

#제출 시각아이디문제언어결과실행 시간메모리
397352rocks03벽 칠하기 (APIO20_paint)C++14
0 / 100
1 ms204 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define SZ(x) ((int)(x).size()) #define all(x) x.begin(), x.end() #define debug(x) cout << #x << ": " << x << " " #define nl cout << "\n" #define rep(i, a, b) for(int i = (a); i < (b); i++) #define per(i, a, b) for(int i = (a); i >= (b); i--) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B){ vector<int> pos[K + 1]; rep(i, 0, N) pos[C[i]].pb(i); vector<int> workers[N + 1]; rep(i, 0, M){ for(int col : B[i]){ for(int p : pos[col]){ workers[p].pb(i); } } } vector<bool> v(N + 1, false); vector<pii> work[N + 1]; for(int x : workers[0]){ work[0].pb({x, 0}); } rep(y, 1, N + 1){ for(auto [x, old_y] : work[y - 1]){ int i = (x + 1) % M, l = y - old_y, j = y; auto it = lower_bound(all(B[i]), C[j]); if(it != B[i].end() && *it == C[j]){ if(l + 1 == M - 1){ v[old_y] = true; } else{ work[y].pb({i, l + 1}); } } } if(y < N - M + 1){ for(int x : workers[y]){ work[y].pb({x, y}); } } } if(!v[0]) return -1; vector<int> dp(N, INT_MAX); dp[0] = 1; multiset<int> s, ms[N + 1]; rep(i, 0, N){ for(int x : ms[i]){ s.erase(s.find(x)); } if(SZ(s)){ dp[i] = *s.begin() + 1; } if(dp[i] == INT_MAX) return -1; if(v[i]){ s.insert(dp[i]); int r = min(N - 1, i + M) + 1; ms[r].insert(dp[i]); if(i + M - 1 >= N - 1) return dp[i]; } } 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:34:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   34 |         for(auto [x, old_y] : work[y - 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...