Submission #27194

# Submission time Handle Problem Language Result Execution time Memory
27194 2017-07-10T09:50:37 Z 검수컵(#1129) The Ant and The Bitcoin (FXCUP2_ant) C++
0 / 1
0 ms 2304 KB
#include<stdio.h>
#include<algorithm>
using namespace std;

struct ant {
	int x, nx, ix;
	bool operator< (const ant& c) const { return x < c.x; }
} ba[101010];

bool comp(const ant &x, const ant &y){ return x.nx < y.nx; }

int N, L, T, B, th;

int main(){
	scanf("%d%d%d", &N, &L, &T);
	for(int i=0; i<N; i++){
		char dir;
		ba[i].ix = i+1; scanf("%d %c", &ba[i].x, &dir);
		if(dir == 'R') ba[i].nx = (ba[i].x + T) % (2*L);
		if(dir == 'L') ba[i].nx = (ba[i].x - T) % (2*L);
		if(ba[i].nx < 0) ba[i].nx += 2*L;
		if(ba[i].nx > L) ba[i].nx = 2*L - ba[i].nx;
	}
	scanf("%d", &B);
	sort(ba, ba+N);
	for(int i=0; i<N; i++){
		if(ba[i].ix == B) th = i;
	}
	sort(ba, ba+N, comp);
	printf("%d\n", ba[th].ix);
	return 0;
}

Compilation message

ant.cpp: In function 'int main()':
ant.cpp:15:29: 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:18:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   ba[i].ix = i+1; scanf("%d %c", &ba[i].x, &dir);
                                                 ^
ant.cpp:24:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &B);
                 ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2304 KB Output is correct
2 Correct 0 ms 2304 KB Output is correct
3 Incorrect 0 ms 2304 KB Output isn't correct
4 Halted 0 ms 0 KB -