QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#491221#8509. Expanding STACKS!prime-idealWA 0ms3612kbC++201.7kb2024-07-25 17:46:302024-07-25 17:46:31

Judging History

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

  • [2024-07-25 17:46:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-07-25 17:46:30]
  • 提交

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(vis[x]!=c^2){putchar('*');exit(0);}
    else if(vis[x]==0)dfs(x,c^2);
  }
}
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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
+2 +1 -1 -2

output:

GG

result:

ok correct

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3536kb

input:

2
+1 +2 -1 -2

output:

*

result:

wrong answer team and jury output doesn't agree on whether there's an assignment