Submission #28130

#TimeUsernameProblemLanguageResultExecution timeMemory
28130 (#71)The Ant and The Bitcoin (FXCUP2_ant)C++11
1 / 1
56 ms3072 KiB
#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)

ant.cpp: In function 'int main()':
ant.cpp:17:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int N, L, T; scanf("%d%d%d", &N, &L, &T);
                                           ^
ant.cpp:20:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     char c; scanf("%d %c", &p[i].x, &c);
                                        ^
ant.cpp:24:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int I; scanf("%d", &I);
                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...