QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#491229 | #8509. Expanding STACKS! | prime-ideal | WA | 0ms | 3812kb | C++20 | 1.7kb | 2024-07-25 17:53:06 | 2024-07-25 17:53:06 |
Judging History
answer
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
#define RN return
#define forw(_,l,r) for(auto _=(l);_<(r);++_)
#define fors(_,r,l) for(auto _=(r);_>(l);--_)
// #define DEBUG if((cout<<"line:"<<__LINE__<<'\n'), 1)
#define DEBUG if(0)
// #define int ll
#define fastio cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
#define DEBUG if(0)
void read(){}
template<typename T,typename...Types>
void read(T& x, Types&...args){
x=0; char c=' '; bool sgn=0;
while(isspace(c))c=getchar();
// if(c=='-')c=getchar(),sgn=1;
while(isdigit(c))x=10*x+c-'0',c=getchar();
if(sgn)x=-x;
read(args...);
}
const int NUM=1010;
char vis[NUM]={};
struct seg{
int l,r;
bool operator^(seg b){
if(l<b.l && b.l<r && r<b.r)RN 1;
if(b.l<l && l<b.r && b.r<r)RN 1;
RN 0;
}
bool operator<(const seg b)const {RN l>b.l;}
};
vector<seg> segs={{}};//!
int seq[NUM]={},tim[NUM*2]={};
bitset<NUM> adj[NUM];
int n;
void dfs(int x,char c){
vis[x]=c;
forw(i,1,n+1)if(adj[x][i]){
if(i==x)continue;//!
if(vis[i]==0)dfs(i,c^2);
else if(vis[i]!=(c^2)){putchar('*');exit(0);}//!
}
}
priority_queue<seg> q0,q1;
int main()
{
read(n);
forw(i,1,2*n+1){
int x; read(x,x);
tim[i]=x;
if(seq[x]!=0)segs.push_back({seq[x],i});
else seq[x]=i;
}
forw(i,1,n+1)forw(j,1,n+1)adj[i][j]=segs[i]^segs[j];
forw(i,1,n+1)if(vis[i]==0)dfs(i,1);
forw(i,1,n+1){
if(vis[i]==1)q0.push(segs[i]);
else if(vis[i]==3)q1.push(segs[i]);
// else assert(0);
}
forw(i,1,2*n+1){
if(!q0.empty())
if(q0.top().l==i){q0.pop();putchar('G');}//!
if(!q1.empty())
if(q1.top().l==i){q1.pop();putchar('S');}//!
}
RN 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
2 +2 +1 -1 -2
output:
GG
result:
ok correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
2 +1 +2 -1 -2
output:
GS
result:
ok correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
3 +1 +2 +3 -1 -2 -3
output:
*
result:
ok correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3596kb
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: -100
Wrong Answer
time: 0ms
memory: 3812kb
input:
10 +8 -8 +2 +10 -2 -10 +7 -7 +1 -1 +6 -6 +5 +3 +4 +9 -9 -4 -3 -5
output:
GGSGGGGGGG
result:
wrong answer client leaving is not the top of its stack