Submission #28130

# Submission time Handle Problem Language Result Execution time Memory
28130 2017-07-15T11:52:54 Z (#1210, xdoju) The Ant and The Bitcoin (FXCUP2_ant) C++11
1 / 1
56 ms 3072 KB
#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

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 time Memory Grader output
1 Correct 0 ms 3072 KB Output is correct
2 Correct 0 ms 3072 KB Output is correct
3 Correct 0 ms 3072 KB Output is correct
4 Correct 0 ms 3072 KB Output is correct
5 Correct 0 ms 3072 KB Output is correct
6 Correct 0 ms 3072 KB Output is correct
7 Correct 0 ms 3072 KB Output is correct
8 Correct 0 ms 3072 KB Output is correct
9 Correct 0 ms 3072 KB Output is correct
10 Correct 0 ms 3072 KB Output is correct
11 Correct 0 ms 3072 KB Output is correct
12 Correct 0 ms 3072 KB Output is correct
13 Correct 46 ms 3072 KB Output is correct
14 Correct 39 ms 3072 KB Output is correct
15 Correct 39 ms 3072 KB Output is correct
16 Correct 49 ms 3072 KB Output is correct
17 Correct 43 ms 3072 KB Output is correct
18 Correct 43 ms 3072 KB Output is correct
19 Correct 56 ms 3072 KB Output is correct
20 Correct 39 ms 3072 KB Output is correct