#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]);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
1212 KB |
Output is correct |
2 |
Correct |
21 ms |
1212 KB |
Output is correct |
3 |
Correct |
20 ms |
1212 KB |
Output is correct |
4 |
Correct |
20 ms |
1212 KB |
Output is correct |
5 |
Correct |
15 ms |
1212 KB |
Output is correct |
6 |
Correct |
18 ms |
1212 KB |
Output is correct |
7 |
Correct |
19 ms |
1212 KB |
Output is correct |
8 |
Correct |
16 ms |
1212 KB |
Output is correct |
9 |
Correct |
19 ms |
1212 KB |
Output is correct |
10 |
Correct |
19 ms |
1212 KB |
Output is correct |
11 |
Correct |
14 ms |
1212 KB |
Output is correct |
12 |
Correct |
17 ms |
1212 KB |
Output is correct |
13 |
Correct |
11 ms |
1212 KB |
Output is correct |
14 |
Correct |
13 ms |
1212 KB |
Output is correct |
15 |
Correct |
11 ms |
1212 KB |
Output is correct |
16 |
Correct |
20 ms |
1212 KB |
Output is correct |
17 |
Correct |
18 ms |
1212 KB |
Output is correct |
18 |
Correct |
18 ms |
1212 KB |
Output is correct |
19 |
Correct |
13 ms |
1212 KB |
Output is correct |
20 |
Correct |
17 ms |
1212 KB |
Output is correct |
21 |
Correct |
11 ms |
1212 KB |
Output is correct |
22 |
Correct |
12 ms |
1212 KB |
Output is correct |
23 |
Correct |
23 ms |
1212 KB |
Output is correct |
24 |
Correct |
16 ms |
1212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
220 ms |
1212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |