Submission #676580

#TimeUsernameProblemLanguageResultExecution timeMemory
676580fatemetmhrPainting Walls (APIO20_paint)C++17
51 / 100
435 ms165092 KiB
// ~~ Be name khoda ~~ #include "paint.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) x.begin(), x.end() #define pb push_back #define fi first #define se second const int maxn5 = 1e5 + 10; const int maxn = 2e4 + 10; const int maxm = 2e3 + 10; int have[maxn][maxm]; vector <int> out; bool mark[maxn5]; int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B){ int n = N, m = M; for(int i = 0; i < m; i++){ memset(mark, false, sizeof mark); for(auto u : B[i]) mark[u] = true; for(int j = 0; j < n; j++) have[j][i] = mark[C[j]]; } if(m == 1){ bool re = true; for(int i = 0; i < n; i++) re &= have[i][0]; return (re ? n : -1); } out.pb(-1); for(int i = 1; i < n; i++){ bool good = false; for(int j = 0; j < m; j++) if(have[i][j]){ have[i][j] = have[i - 1][j == 0 ? m - 1 : j - 1] + 1; good |= (have[i][j] >= m); } if(good){ while(out.size() > 1 && i - out[out.size() - 2] <= m) out.pop_back(); if(i - out.back() > m) return -1; out.pb(i); } //cout << i << ' ' << good << ' ' << out.size() << endl; } if(out.back() != n - 1) return -1; return out.size() - 1; } // hen?
#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...