Submission #15480

#TimeUsernameProblemLanguageResultExecution timeMemory
15480myungwoo통로 위의 개미 (kriii3_X)C++14
0 / 85
34 ms7976 KiB
#include <bits/stdc++.h> using namespace std; #define MAXM 200005 #define pb push_back typedef long long lld; int L, M, N; lld pos[MAXM]; struct Z{ lld t; int p, x, d; } Q[MAXM]; int main() { scanf("%d%d", &L, &M); for (int i=1;i<=M;i++){ scanf("%d%d%d", &Q[i].t, &Q[i].p, &Q[i].x); if (Q[i].p == 1) scanf("%d", &Q[i].d); } sort(Q+1, Q+M+1, [](const Z &a, const Z &b){ return a.t < b.t; }); vector <int> ord(1, 0); for (int qq=1;qq<=M;qq++){ Z &q = Q[qq]; vector <lld> arr(N+1, 0); for (int i=1;i<=N;i++){ arr[i] = (pos[i] + q.t) % (L+L); if (arr[i] > L) arr[i] = L - (arr[i] - L); } sort(arr.begin()+1, arr.end()); if (q.p == 1){ if (q.d == 1){ pos[++N] = q.x - q.t; }else{ pos[++N] = L+L - q.x - q.t; } int t = 0; for (int i=1;i<N;i++) if (arr[i] < q.x) t = i; ord.pb(0); for (int i=N-1;i>t;i--) ord[i+1] = ord[i]; ord[t+1] = N; }else{ for (int i=1;i<=N;i++) if (ord[i] == q.x) printf("%lld\n", arr[i]); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...