# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28107 | EyeOfSol (#71) | The Ant and The Bitcoin (FXCUP2_ant) | C++11 | 63 ms | 5208 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, l, t;
ll mokx(ll a, ll b) {
if (a>=0) return a/b;
return (a-b+1)/b;
}
ll loc(ll a, ll dir, ll t) {
ll v = a+t*dir;
if (mokx(v,l)%2) return l-(v%l+l)%l;
return (v%l+l)%l;
}
ll arr[100100], ord[100100];
vector<ll> vec;
int main() {
ll i;
scanf("%lld%lld%lld",&n,&l,&t);
for (i=0;i<n;i++) {
char ch;
ord[i] = i;
scanf("%lld %c",&arr[i],&ch);
if (ch=='L') vec.push_back(loc(arr[i],-1,t));
else vec.push_back(loc(arr[i],1,t));
}
sort(ord,ord+n,[&](ll a, ll b){return arr[a]<arr[b];});
ll id;
scanf("%lld",&id); id--;
ll v = vec[id];
sort(vec.begin(),vec.end());
for (i=0;i<vec.size();i++) {
if (vec[i]==v) {
printf("%lld\n",ord[i]+1);
break;
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |