답안 #28186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28186 2017-07-15T14:24:48 Z 대회할수있으려나(#1213, onjo0127) 개미와 비트코인 (FXCUP2_ant) C++
0 / 1
0 ms 6712 KB
#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

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);
                     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6712 KB Output is correct
2 Incorrect 0 ms 6712 KB Output isn't correct
3 Halted 0 ms 0 KB -