QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#611849#8544. Colorful Graph 2ucup-team3651WA 1ms5632kbC++201.5kb2024-10-04 23:15:332024-10-04 23:15:35

Judging History

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

  • [2024-10-04 23:15:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5632kb
  • [2024-10-04 23:15:33]
  • 提交

answer


#include<bits/stdc++.h>

#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define cpy(x,y,s) memcpy(x,y,sizeof(x[0])*(s))
#define mset(x,v,s) memset(x,v,sizeof(x[0])*(s))
#define all(x) begin(x),end(x)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ary array
#define IL inline

#define mod 998244353
#define N 200005

using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9')f=(ch=='-'?-1:f),ch=getchar();
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return x*f;
}
void write(int x){
    if(x<0)x=-x,putchar('-');
    if(x/10)write(x/10);
    putchar(x%10+'0');
}

int vis[N];
vi e[N];
queue<int> q;

void solve(){
    int n=read(),m=read();
    for(int i=0;i<n;i++)e[i].clear(),vis[i]=0;
    for(int i=0;i<n;i++)e[i].pb((i+1)%n),e[(i+1)%n].pb(i);
    for(int i=1;i<=m;i++){
        int u=read(),v=read();
        e[u].pb(v);e[v].pb(u);
    }
    q.push(1);vis[1]=1;
    while(q.size()){
        int u=q.front();q.pop();
        for(auto v:e[u]){
            if(vis[v])continue;
            vis[v]=(vis[u]==1?2:1);q.push(v);
        }
    }
    for(int i=1;i<=n;i++)putchar(vis[i]==1?'B':'R');
    putchar('\n');
}

int main(){
    #ifdef EAST_CLOUD
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    #endif

    int T=read();while(T--)solve();
    return 0;
}
//cerr<<fabs(&Med-&Mbe)/1048576.0<<"MB\n";
//cerr<<"\n"<<clock()*1.0/CLOCKS_PER_SEC*1000<<"ms\n";

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5632kb

input:

3
3 0
4 1
1 3
6 3
0 2
2 4
4 0

output:

BRR
BRRR
BRBBBR

result:

wrong answer cycle detected (test case 2)