Submission #28082

# Submission time Handle Problem Language Result Execution time Memory
28082 2017-07-15T10:17:41 Z EyeOfSol(#1198, tlwpdus) The Ant and The Bitcoin (FXCUP2_ant) C++11
0 / 1
0 ms 2020 KB
#include <bits/stdc++.h>

using namespace std;

int n, l, t;

int mokx(int a, int b) {
	if (a>=0) return a/b;
	return (a-b+1)/b;
}

int loc(int a, int dir, int t) {
	int v = a*dir+t;
	if (mokx(v,l)%2) return l-(v%l+l)%l;
	return (v%l+l)%l;
}

vector<int> vec;

int main() {
	int i;
	scanf("%d%d%d",&n,&l,&t);
	for (i=0;i<n;i++) {
		int a; char ch;
		scanf("%d %c",&a,&ch);
		if (ch=='L') vec.push_back(loc(a,-1,t));
		else vec.push_back(loc(a,1,t));
	}
	int id;
	scanf("%d",&id); id--;
	int v = vec[id];
	sort(vec.begin(),vec.end());
	for (i=0;i<vec.size();i++) {
		if (vec[i]==v) printf("%d\n",i+1);
	}

    return 0;
}

Compilation message

ant.cpp: In function 'int main()':
ant.cpp:33:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i=0;i<vec.size();i++) {
            ^
ant.cpp:22:26: 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:25:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %c",&a,&ch);
                        ^
ant.cpp:30:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&id); id--;
                 ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Incorrect 0 ms 2020 KB Output isn't correct
3 Halted 0 ms 0 KB -