Submission #1245561

#TimeUsernameProblemLanguageResultExecution timeMemory
1245561quannnguyen2009Painting Walls (APIO20_paint)C++20
40 / 100
1570 ms418804 KiB
#include "paint.h" #include<bits/stdc++.h> #define fi first #define se second #define pb push_back #define ii pair<int, int> #define sz(v) (int)v.size() #define all(v) v.begin(), v.end() using namespace std; const int N = 1e5+5, K = 1e5+5, mod = 1e9+7, inf = 1e18; map<int, int> mx[N]; vector<int> lst[K]; bool bl[N]; 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++) { for (int j=0; j<a[i]; j++) lst[b[i][j]].pb(i); } for (int i=0; i<n; i++) { for (int j=0; j<sz(lst[c[i]]); j++) { mx[lst[c[i]][j]][i] = mx[(lst[c[i]][j]-1+m)%m][(i-1+n)%n]+1; if (mx[lst[c[i]][j]][i]>=m) bl[i] = 1; } } for (int i=0; i<n; i++) { for (int j=0; j<sz(lst[c[i]]); j++) { mx[lst[c[i]][j]][i] = mx[(lst[c[i]][j]-1+m)%m][(i-1+n)%n]+1; if (mx[lst[c[i]][j]][i]>=m) bl[i] = 1; } } int ans = 0, idx = 0; while (idx<n) { bool ok = 0; for (int i=min(n, idx+m)-1; i>=idx; i--) { if (bl[i]) { ok = 1; idx = i+1; break; } } if (!ok) return -1; ans++; } return ans; }

Compilation message (stderr)

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