Submission #496320

#TimeUsernameProblemLanguageResultExecution timeMemory
496320mansurMeteors (POI11_met)C++17
24 / 100
6042 ms65540 KiB
#include<bits/stdc++.h> #pragma optimize ("g",on) #pragma GCC optimize ("inline") #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("03") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native") #pragma comment(linker, "/stack:200000000") //01001101 01100001 01101011 01101000 01100001 01100111 01100001 01111001 using namespace std; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define ll long long #define pb push_back #define sz(a) a.size() #define nl '\n' #define popb pop_back() #define ld double #define ull unsigned long long #define ff first #define ss second #define fix fixed << setprecision #define pii pair<int, int> #define E exit (0) const int inf = 1e9, N = 3e5 + 1, mod = 998244353; vector<pii> dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; int ans[N], a[N], b[N]; int cnt[301][N], add[301], n, m; set<pii> s[301]; const int bl = 1000; void f(int l, int r, int x, int i) { int tl = l / bl, tr = r / bl; if (tl == tr) { for (int j = l; j <= r; j++) { if (ans[b[j]]) continue; if (a[b[j]] <= x + add[tl] * cnt[tl][b[j]]) { s[tl].erase({(a[b[j]] + cnt[tl][b[j]] - 1) / cnt[tl][b[j]], b[j]}); a[b[j]] = 0; ans[b[j]] = i; }else { s[tl].erase({(a[b[j]] + cnt[tl][b[j]] - 1) / cnt[tl][b[j]], b[j]}); a[b[j]] -= x; s[tl].insert({(a[b[j]] + cnt[tl][b[j]] - 1) / cnt[tl][b[j]], b[j]}); } } }else { for (int j = tl + 1; j < tr; j++) { add[j] += x; while (!s[j].empty()) { pii z = *s[j].begin(); if (z.ff <= add[j]) { s[j].erase(s[j].begin()); if (ans[z.ss]) continue; ans[z.ss] = i; }else break; } } for (int j = l; j < min(m, (tl + 1) * bl); j++) { if (ans[b[j]]) continue; if (a[b[j]] <= x + add[tl] * cnt[tl][b[j]]) { s[tl].erase({(a[b[j]] + cnt[tl][b[j]] - 1) / cnt[tl][b[j]], b[j]}); a[b[j]] = 0; ans[b[j]] = i; }else { s[tl].erase({(a[b[j]] + cnt[tl][b[j]] - 1) / cnt[tl][b[j]], b[j]}); a[b[j]] -= x; s[tl].insert({(a[b[j]] + cnt[tl][b[j]] - 1) / cnt[tl][b[j]], b[j]}); } } for (int j = tr * bl; j <= r; j++) { if (ans[b[j]]) continue; if (a[b[j]] <= x + add[tr] * cnt[tr][b[j]]) { s[tr].erase({(a[b[j]] + cnt[tr][b[j]] - 1) / cnt[tr][b[j]], b[j]}); a[b[j]] = 0; ans[b[j]] = i; }else { s[tr].erase({(a[b[j]] + cnt[tr][b[j]] - 1) / cnt[tr][b[j]], b[j]}); a[b[j]] -= x; s[tr].insert({(a[b[j]] + cnt[tr][b[j]] - 1) / cnt[tr][b[j]], b[j]}); } } } } main() { //freopen("cowrect.in", "r", stdin); //freopen("cowrect.out", "w", stdout); ios_base::sync_with_stdio(NULL); cin.tie(NULL); cin >> n >> m; for (int i = 0; i < m; i++) cin >> b[i]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) { b[i]--; cnt[i / bl][b[i]]++; } for (int i = 0; i < n; i++) { for (int j = 0; j <= (m - 1) / bl; j++) { if (cnt[j][i] == 0) continue; s[j].insert({(a[i] + cnt[j][i] - 1) / cnt[j][i], i}); } } int k; cin >> k; for (int i = 1; i <= k; i++) { int l, r, x; cin >> l >> r >> x; l--, r--; if (l <= r) { f(l, r, x, i); }else { f(0, r, x, i); f(l, m - 1, x, i); } } for (int i = 0; i < n; i++) { if (!ans[i]) cout << "NIE" << nl; else cout << ans[i] << nl; } }

Compilation message (stderr)

met.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize ("g",on)
      | 
met.cpp:9: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    9 | #pragma comment(linker, "/stack:200000000")
      | 
met.cpp:96:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   96 | main() {
      | ^~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...