QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#471927#5504. Flower Gardenmsk_samaCompile Error//C++203.1kb2024-07-11 11:37:082024-07-11 11:37:08

Judging History

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

  • [2024-07-11 11:37:08]
  • 评测
  • [2024-07-11 11:37:08]
  • 提交

answer

#include <bits/stdc++.h>
#define MISAKA main
#define ll long long
using namespace std;
inline int read(){
    char ch=getchar();int f=1,x=0;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return x*f;
}
const double eps=1e-9;
const int N=8e6+10,inf=1e9,mod=998244353;
int n,m,w[N],sum[N],dfn[N],low[N],scc[N],s[N],cl[N],deg[N],top=0,cnt=0,tim=0,idx=0,_count=0;
vector<int> g[N],G[2][N];queue<int> q;
struct node{int l,r,in,out;}t[N];
inline void link(int x,int y){g[x].push_back(y);}
void build(int now,int l,int r){
    t[now].l=l,t[now].r=r;int mid=l+r>>1;
    if(l==r){t[now].in=t[now].out=l;return;}
    t[now].in=++idx,t[now].out=++idx;
    build(2*now,l,mid);build(2*now+1,mid+1,r);
    link(t[now].in,t[2*now].in);link(t[now].in,t[2*now+1].in);
    link(t[2*now].out,t[now].out);link(t[2*now+1].out,t[now].out);
}
void link(int now,int l,int r,int x,int tp){
    if(t[now].l>r||t[now].r<l) return;
    if(l<=t[now].l&&t[now].r<=r){
        if(tp) link(x,t[now].in);
        else link(t[now].out,x);
        return;
    }
    link(2*now,l,r,x,tp);link(2*now+1,l,r,x,tp);
}
void tarjan(int u){
	dfn[u]=low[u]=++tim;s[++top]=u;
	for(int v:g[u]){
		if(!dfn[v]){
			tarjan(v);
			low[u]=min(low[u],low[v]);
		}else if(!scc[v]) low[u]=min(low[u],dfn[v]);
	}
	if(dfn[u]==low[u]){
		cnt++;
		while(s[top+1]!=u) scc[s[top]]=cnt,top--;
	}
}
void dfs(int u){_count++;if(_count>idx){puts("yes");exit(0);}cl[u]=1;for(int v:G[1][u])dfs(v);}
void misaka(){
    for(int i=1;i<=idx;i++) g[i].clear(),G[0][i].clear(),G[1][i].clear(),sum[i]=s[i]=scc[i]=cl[i]=dfn[i]=low[i]=w[i]=deg[i]=0;while(!q.empty())q.pop();
    n=read(),m=read();top=cnt=tim=;idx=3*n;
    build(1,1,3*n);
    for(int i=1;i<=3*n;i++) w[i]=1; 
    for(int i=1;i<=m;i++){
        int l1=read(),r1=read(),l2=read(),r2=read();
        int a=++idx;link(1,l1,r1,a,0);link(1,l2,r2,a,1);
    }
    for(int i=1;i<=idx;i++)if(!dfn[i]) tarjan(i);
    for(int i=1;i<=idx;i++) sum[scc[i]]+=w[i];
    for(int i=1;i<=idx;i++)for(int j:g[i]){
        int u=scc[i],v=scc[j];
        if(u==v) continue;deg[u]++;
        G[1][u].push_back(v);
        G[0][v].push_back(u);
    }
    for(int i=1;i<=cnt;i++)if(!deg[i]) q.push(i);
    int all=0;
    while(!q.empty()){
        int u=q.front();q.pop();
        if(sum[u]>n) continue;
        cl[u]=1;all+=sum[u];
        if(all>=n) break;
        for(int v:G[0][u])if(--deg[v]==0) q.push(v);
    }
    if(all>=n){
        puts("TAK");
        for(int i=1;i<=3*n;i++) putchar(cl[scc[i]]?'F':'R');
        puts("");return;
    }
    for(int id=1;id<=cnt;id++)if(sum[id]>n){
        for(int i=1;i<=cnt;i++) cl[i]=0;
        all=_count=0;dfs(id);
        for(int i=1;i<=cnt;i++) all+=sum[i]*cl[i];
        if(all<=2*n){
            puts("TAK");
            for(int i=1;i<=3*n;i++) putchar(cl[scc[i]]?'F':'R');
            puts("");return;
        }
    }
    puts("NIE");
    if(m==99999) exit(0);
}
signed MISAKA(){
    int T=read();
    while(T--) misaka();
    return 0;
}

Details

answer.code: In function ‘void misaka()’:
answer.code:50:35: error: expected primary-expression before ‘;’ token
   50 |     n=read(),m=read();top=cnt=tim=;idx=3*n;
      |                                   ^