Submission #28186

#TimeUsernameProblemLanguageResultExecution timeMemory
28186대회할수있으려나 (#71)The Ant and The Bitcoin (FXCUP2_ant)C++98
0 / 1
0 ms6712 KiB
#include <bits/stdc++.h> using namespace std; struct info { int pos, idx, newidx; char dir; }; bool cmp1(info a, info b) {return a.pos < b.pos;} bool cmp2(info a, info b) {return a.idx < b.idx;} info arr[200009]; pair<int, int> res[200009]; int main() { int n,l,t; scanf("%d %d %d",&n,&l,&t); for(int i=1; i<=n; i++) { scanf("%d %c", &arr[i].pos, &arr[i].dir); arr[i].idx = i; } sort(arr+1, arr+n+1, cmp1); for(int i=1; i<=n; i++) arr[i].newidx = i; sort(arr+1, arr+n+1, cmp2); for(int i=1; i<=n; i++) { int pos = arr[i].pos; char dir = arr[i].dir; if(dir == 'L') pos -= t; if(dir == 'R') pos += t; if(pos < 0) pos = -pos; if(pos / l % 2) res[i].first = l - pos%l; else res[i].first = pos%l; } int bit, bitRes; scanf("%d",&bit); bitRes = res[bit].first; sort(res+1, res+n+1); for(int i=1; i<=n; i++) if(bitRes == res[i].first) return !printf("%d", arr[i].newidx); return 0; }

Compilation message (stderr)

ant.cpp: In function 'int main()':
ant.cpp:19:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d",&n,&l,&t);
                               ^
ant.cpp:21:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %c", &arr[i].pos, &arr[i].dir);
                                                 ^
ant.cpp:40:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&bit);
                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...