Submission #290805

#TimeUsernameProblemLanguageResultExecution timeMemory
290805gs14004CATS (NOI14_cats)C++17
12 / 25
1581 ms40092 KiB
#include <cstdio>
#include <cstring>

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--) {
		int x,l,n;
		scanf("%d %d %d",&x,&l,&n);
		int s2 = 0;
		s1.sz = 0;
		int g = 0;
		while (x) {
			s2 = s1.top() ^ g;
			s1.pop();
			g ^= 1;
			if(s2 > l){
				x--;
				if(x == 0){
					printf("%d\n",s2);
					break;
				}
			}
			else{
				s2 += 2*n;
				s1.push(s2^g);
				s1.push(s2^g);
			}
		}
	}
}

Compilation message (stderr)

cats.cpp: In function 'int main()':
cats.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |  scanf("%d",&q);
      |  ~~~~~^~~~~~~~~
cats.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |   scanf("%d %d %d",&x,&l,&n);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...