Submission #290815

# Submission time Handle Problem Language Result Execution time Memory
290815 2020-09-04T13:17:11 Z gs14004 CATS (NOI14_cats) C++17
12 / 25
1500 ms 40056 KB
#include <cstdio>
#include <cstring>
using lint = long long;

struct cat_stack{
	int stack[5000005], sz;
	int top(){
		if(sz == 0) return 0;
		return stack[sz-1];
	}
	void pop(){
		if(sz != 0) sz--;
	}
	void push(int x){
		stack[sz++] = x;
	}
}s1;

int main(){
	int q;
	scanf("%d",&q);
	while (q--) {
		lint x, l, n;
		scanf("%lld %lld %lld",&x,&l,&n);
		x--;
		if(l / (2 * n + 1) <= 61){
			lint Q = l / (2 * n) + 1;
			x %= (1ll << (Q + 1));
		}
		int s2 = 0;
		s1.sz = 0;
		int g = 0;
		while (x>=0) {
			s2 = s1.top() ^ g;
			s1.pop();
			g ^= 1;
			if(s2 > l){
				x--;
			//	printf("%d,", s2);
				if(x < 0){
					printf("%d\n",s2);
					break;
				}
			}
			else{
				s2 += 2*n;
				s1.push(s2^g);
				s1.push(s2^g);
			}
		}
	}
}

Compilation message

cats.cpp: In function 'int main()':
cats.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  scanf("%d",&q);
      |  ~~~~~^~~~~~~~~
cats.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |   scanf("%lld %lld %lld",&x,&l,&n);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 174 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1584 ms 1272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 57 ms 40056 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 60 ms 40056 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -