Submission #63505253


Source Code Expand

Copy
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
const int N=105;
int n,a[N],op,x,tp;
int main() {
scanf("%d",&n);
while(n--) {
scanf("%d",&op);
if(op==1) {
scanf("%d",&x);
a[++tp]=x;
} else {
if(tp==0) printf("0\n");
else printf("%d\n",a[tp--]);
}
}
return 0;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
const int N=105;
int n,a[N],op,x,tp;
int main() {
	scanf("%d",&n);
	while(n--) {
		scanf("%d",&op);
		if(op==1) {
			scanf("%d",&x);
			a[++tp]=x;
		} else {
			if(tp==0) printf("0\n");
			else printf("%d\n",a[tp--]);
		}
	}
	return 0;
} 

Submission Info

Submission Time
Task B - Card Pile
User wanglongye1
Language C++ 17 (gcc 12.2)
Score 200
Code Size 352 Byte
Status AC
Exec Time 1 ms
Memory 3876 KB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
Main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf("%d",&op);
      |                 ~~~~~^~~~~~~~~~
Main.cpp:13:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |                         scanf("%d",&x);
      |                         ~~~~~^~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 23
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3648 KB
00_sample_01.txt AC 1 ms 3692 KB
01_handmade_00.txt AC 1 ms 3652 KB
01_handmade_01.txt AC 1 ms 3688 KB
01_handmade_02.txt AC 1 ms 3876 KB
01_handmade_03.txt AC 1 ms 3612 KB
01_handmade_04.txt AC 1 ms 3672 KB
01_handmade_05.txt AC 1 ms 3768 KB
02_random_00.txt AC 1 ms 3876 KB
02_random_01.txt AC 1 ms 3628 KB
02_random_02.txt AC 1 ms 3756 KB
02_random_03.txt AC 1 ms 3684 KB
02_random_04.txt AC 1 ms 3628 KB
02_random_05.txt AC 1 ms 3756 KB
02_random_06.txt AC 1 ms 3640 KB
02_random_07.txt AC 1 ms 3752 KB
02_random_08.txt AC 1 ms 3584 KB
02_random_09.txt AC 1 ms 3752 KB
02_random_10.txt AC 1 ms 3756 KB
02_random_11.txt AC 1 ms 3640 KB
02_random_12.txt AC 1 ms 3756 KB
02_random_13.txt AC 1 ms 3872 KB
02_random_14.txt AC 1 ms 3688 KB


2025-04-11 (Fri)
19:54:20 +00:00