Submission #15316

#TimeUsernameProblemLanguageResultExecution timeMemory
15316gs14004통로 위의 개미 (kriii3_X)C++14
30 / 85
220 ms1212 KiB
#include <cstdio> #include <vector> #include <algorithm> using namespace std; typedef long long lint; typedef pair<int, lint> ants; vector<ants> v; int l, q; int ants_kth[1005]; int main(){ scanf("%d %d",&l,&q); int piv = 1; for(int i=0; i<q; i++){ lint t; int p; scanf("%lld %d",&t,&p); if(p == 1){ int pos, dx; scanf("%d %d",&pos, &dx); ants tx = ants(dx, pos - 1ll * dx * t); int k = 1; for(auto &i : v){ lint p = i.second + t * i.first; p %= 2 * l; p += 2 * l; p %= 2 * l; if(p > l) p = 2 * l - p; if(p < pos) k++; } for(int i=1; i<piv; i++){ if(ants_kth[i] >= k){ ants_kth[i]++; } } ants_kth[piv++] = k; v.push_back(tx); } else{ int x; scanf("%d",&x); x = ants_kth[x]; vector<int> v2; for(auto &i : v){ lint pos = i.second + t * i.first; pos %= 2 * l; pos += 2 * l; pos %= 2 * l; if(pos > l) v2.push_back(2 * l - pos); else v2.push_back(pos); } sort(v2.begin(), v2.end()); printf("%d\n",v2[x - 1]); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...