# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28130 | (#71) | The Ant and The Bitcoin (FXCUP2_ant) | C++11 | 56 ms | 3072 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 <cstdio>
#include <utility>
#include <algorithm>
using namespace std;
struct ant{
int i, x, d;
bool operator< (const ant& rhs) const {
return x < rhs.x;
}
};
ant p[100010];
pair<int, int> s[100010];
int main(){
int N, L, T; scanf("%d%d%d", &N, &L, &T);
for(int i = 1; i <= N; i++){
char c; scanf("%d %c", &p[i].x, &c);
p[i].i = i; p[i].d = (c == 'L' ? -1 : 1);
}
int I; scanf("%d", &I);
for(int i = 1; i <= N; i++){
int r = p[i].x + p[i].d * T;
r %= 2 * L; if(r < 0) r += 2 * L;
if(r > L) r = 2 * L - r;
s[i].first = r; s[i].second = i;
}
sort(s + 1, s + N + 1);
sort(p + 1, p + N + 1);
for(int i = 1; i <= N; i++){
if(s[i].second == I){ printf("%d\n", p[i].i); break; }
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |