QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#491240#8509. Expanding STACKS!prime-idealWA 0ms3820kbC++201.5kb2024-07-25 17:57:092024-07-25 17:57:10

Judging History

你现在查看的是最新测评结果

  • [2024-07-25 17:57:10]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-07-25 17:57:09]
  • 提交

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){
    putchar((vis[i]==1)?'G':'S');
  }
  RN 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

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: 3820kb

input:

3
+1 +2 +3 -1 -2 -3

output:

*

result:

ok correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3740kb

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: 3736kb

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