QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#361635 | #8509. Expanding STACKS! | ucup-team2443# | WA | 14ms | 69400kb | C++20 | 1.6kb | 2024-03-23 12:19:30 | 2024-03-23 12:19:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1919810;
ll n,m,k;
int a[N],b[N];
int cnt[N];
ll ans;
string s[N];
int dp[N][3];//选了前i个 现在有j个连续辅音
map<char,int> mp;
stack<int> st1,st2;
int tf[N];
int gao(string s){
int sum=0;
for(int i=0;i<s.size();i++){
int t=s[i]-'0';
sum=sum*10+t;
}
return sum;
}
void __(){
cin>>n;
for(int i=1;i<=n*2;i++) cin>>s[i];
for(int i=1;i<=n*2;i++){
int num=gao(s[i].substr(1));
if(s[i][0]=='+'){
st1.push(num);
}else{
if(st1.top()==num){
tf[num]=1;
st1.pop();
continue;
}
while(st1.top()!=num){
st2.push(st1.top());
st1.pop();
}
tf[num]=2;
st1.pop();
while(st2.size()){
st1.push(st2.top());
st2.pop();
}
}
}
while(st1.size()) st1.pop();
while(st2.size()) st2.pop();
// st1.clear(),st2.clear();
for(int i=1;i<=n*2;i++){
int num=gao(s[i].substr(1));
if(tf[num]==1) continue;
if(s[i][0]=='+'){
st1.push(num);
}else{
if(st1.top()!=num){
puts("*");
return;
}
st1.pop();
}
}
for(int i=1;i<=n;i++){
if(tf[i]==1) printf("G");
else printf("S");
}
}
int main()
{
int _=1;
// cin>>_;
while(_--){
__();
}
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 69216kb
input:
2 +2 +1 -1 -2
output:
GG
result:
ok correct
Test #2:
score: 0
Accepted
time: 3ms
memory: 69400kb
input:
2 +1 +2 -1 -2
output:
SG
result:
ok correct
Test #3:
score: 0
Accepted
time: 3ms
memory: 66976kb
input:
3 +1 +2 +3 -1 -2 -3
output:
*
result:
ok correct
Test #4:
score: 0
Accepted
time: 4ms
memory: 67128kb
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: 9ms
memory: 67120kb
input:
10 +8 -8 +2 +10 -2 -10 +7 -7 +1 -1 +6 -6 +5 +3 +4 +9 -9 -4 -3 -5
output:
GSGGGGGGGG
result:
ok correct
Test #6:
score: 0
Accepted
time: 14ms
memory: 67432kb
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:
GGGGGGGGGGGSGGGGGGGGGGGGGGGGGSGGGGGGGGGGGG
result:
ok correct
Test #7:
score: -100
Wrong Answer
time: 8ms
memory: 67044kb
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