QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#371374 | #8509. Expanding STACKS! | Mo_Han136# | WA | 0ms | 3848kb | C++20 | 1.0kb | 2024-03-30 09:30:07 | 2024-03-30 09:30:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1010;
int sta1[N],sta2[N],tot1=0,tot2=0,a[N],sta[N],tot=0;
int main()
{
int n;scanf("%d",&n);
for(int i=1;i<=2*n;i++){
int x;scanf("%d",&x);
if(x>0){
a[x]=1;sta1[++tot1]=x;
}
else{
x=-x;
if(a[x]==1){
tot=0;
while(sta1[tot1]!=x){
sta[++tot]=sta1[tot1];
tot1--;
}
tot1--;
while(tot){
a[sta[tot]]=2;
sta2[++tot2]=sta[tot];
tot--;
}
}
else{
if(sta2[tot2]!=x){
printf("*\n");
return 0;
}
tot2--;
}
}
}
for(int i=1;i<=n;i++){
if(a[i]==1) putchar('G');
else putchar('S');
}
putchar('\n');
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
2 +2 +1 -1 -2
output:
GG
result:
ok correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
2 +1 +2 -1 -2
output:
GS
result:
ok correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
3 +1 +2 +3 -1 -2 -3
output:
*
result:
ok correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
10 +3 -3 +4 -4 +6 +2 -2 -6 +7 -7 +5 -5 +10 +1 +9 +8 -8 -9 -1 -10
output:
GGGGGGGGGG
result:
ok correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
10 +8 -8 +2 +10 -2 -10 +7 -7 +1 -1 +6 -6 +5 +3 +4 +9 -9 -4 -3 -5
output:
GGGGGGGGGS
result:
ok correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
42 +26 -26 +12 +8 -12 -8 +30 +5 +22 +3 -3 +2 -30 +10 -10 -2 -22 +23 +39 -39 +17 -17 -23 +38 +24 -24 +27 +29 -29 -27 -38 -5 +37 -37 +21 +16 +28 -28 +6 +40 +14 +19 -19 -14 +11 +35 -35 -11 +4 +25 -25 -4 -40 -6 +13 +20 +1 -1 +33 +34 +7 -7 -34 +41 -41 +36 +31 -31 -36 +42 +32 -32 +15 +18 -18 -15 +9 -9 -42...
output:
GSGGSGGSGGGGGGGGGGGGGSGGGGGGGGGGGGGGGGGGGG
result:
ok correct
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3848kb
input:
42 +40 +18 +42 +2 +1 +21 +33 -2 +8 -33 -8 +14 -40 +34 +30 +31 -31 -30 +5 -5 +4 -34 +13 +3 -13 -3 -4 +28 -28 +17 -17 +35 +10 -10 +16 +39 +36 +37 -37 -36 -39 +25 +6 +41 -41 +20 +12 +32 -32 -25 -12 -16 -35 +38 -20 -38 -14 +15 -15 +9 +26 +23 -21 -1 +7 -23 +22 +24 -7 -24 -42 -18 -22 -26 -9 -6 +27 +29 -29...
output:
*
result:
wrong answer team and jury output doesn't agree on whether there's an assignment