답안 #28184

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28184 2017-07-15T14:19:59 Z 대회할수있으려나(#1213, onjo0127) 개미와 비트코인 (FXCUP2_ant) C++
0 / 1
0 ms 5928 KB
#include <bits/stdc++.h>
using namespace std;

struct info
{
    int pos, idx;
    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);
    }
    sort(arr+1, arr+n+1, cmp1);
    for(int i=1; i<=n; i++) arr[i].idx = 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].idx);
    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:39: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 5928 KB Output is correct
2 Incorrect 0 ms 5928 KB Output isn't correct
3 Halted 0 ms 0 KB -