Submission #144186

#TimeUsernameProblemLanguageResultExecution timeMemory
144186SamAndSegway (COI19_segway)C++17
100 / 100
228 ms13436 KiB
#include <bits/stdc++.h> using namespace std; #define m_p make_pair const int N = 20004, M = 305; struct ban { int x, y, z; }; struct ban1 { int i, x, q; ban1(){} ban1(int i, int x, int q) { this->i = i; this->x = x; this->q = q; } }; int n; ban a[N]; int m; bool c[M]; queue<ban1> q[M * 50]; int t[M]; void ubd(int x, int y) { ++x; while (x < M) { t[x] += y; x += (x & (-x)); } } int qry(int l, int r) { int ans = 0; ++r; while (r > 0) { ans += t[r]; r -= (r & (-r)); } while (l > 0) { ans -= t[l]; l -= (l & (-l)); } return ans; } int qq[M]; int ans[N]; int main() { //freopen("input.txt", "r", stdin); scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z); } scanf("%d", &m); for (int i = 0; i < m; ++i) { int x; scanf("%d", &x); c[x] = true; } for (int i = 1; i <= n; ++i) { q[0].push(ban1(i, 0, 0)); ubd(0, 1); } for (int i = 0; i < M * 50; ++i) { memset(qq, 0, sizeof qq); while (!q[i].empty()) { ban1 t = q[i].front(); q[i].pop(); if (t.x == 300) { ans[t.i] = i; continue; } ubd(t.x, -1); if (!t.q && c[t.x]) { t.q = ((qry(t.x + 1, 300) - qq[t.x]) % 20); } int d; if (t.q) { d = i + 1; } else { if (t.x >= 200) d = i + a[t.i].z; else if (t.x >= 100) d = i + a[t.i].y; else d = i + a[t.i].x; } qq[t.x]++; if (t.q) { --t.q; ++t.x; } else { ++t.x; } q[d].push(t); ubd(t.x, 1); } } for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]); return 0; }

Compilation message (stderr)

segway.cpp: In function 'int main()':
segway.cpp:62:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
segway.cpp:65:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
segway.cpp:67:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &m);
     ~~~~~^~~~~~~~~~
segway.cpp:71:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...