QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#596901#7640. Colorful Cyclesrotcar07WA 2ms7644kbC++201.2kb2024-09-28 16:40:172024-09-28 16:40:20

Judging History

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

  • [2024-09-28 16:40:20]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:7644kb
  • [2024-09-28 16:40:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int maxn=1e6+5;
int n,m;
vector<pair<int,int>> e[maxn];
int dfn[maxn],tqm,low[maxn];
bool vis[maxn];
int col[maxn];
void dfs(int p){
    dfn[p]=low[p]=++tqm;
    for(auto [x,y]:e[p]){
        if(!dfn[x]) dfs(x),low[p]=min(low[p],low[x]);
        else low[p]=min(low[p],dfn[x]);
        if(dfn[p]<low[x]) vis[y]=1,cout<<y<<'\n';
    }
    cout<<p<<' '<<dfn[p]<<' '<<low[p]<<'\n';
}
int mask,cnt;
void dfs2(int p){
    if(!dfn[p]) dfn[p]=1;
    else return;
    int w=0;
    for(auto [x,y]:e[p])if(!vis[y]){
        w|=1<<col[y]-1;
        dfs2(x);
    }
    mask|=w,cnt+=(__builtin_popcount(w)>1);
}
inline void solve(){
    cin>>n>>m;tqm=0;
    for(int i=1;i<=n;i++) e[i].clear(),dfn[i]=low[i]=0;
    for(int i=1,u,v;i<=m;i++) cin>>u>>v>>col[i],e[u].emplace_back(v,i),e[v].emplace_back(u,i),vis[i]=0;
    for(int i=1;i<=n;i++) if(!dfn[i]) dfs(i);
    for(int i=1;i<=n;i++) dfn[i]=0;
    for(int i=1;i<=n;i++) if(!dfn[i]){
        mask=cnt=0;
        dfs2(i);
        if(mask==7&&cnt>=3) return puts("Yes"),void();
    }
    puts("No");
}
int main(){
    int t;cin>>t;
    while(t--) solve();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 7644kb

input:

2
3 3
1 2 3
2 3 1
1 3 2
5 6
1 2 1
2 3 1
1 3 2
3 4 3
3 5 3
4 5 3

output:

3 3 1
2 2 1
1 1 1
Yes
5 5 3
4 4 3
3 3 1
2 2 1
1 1 1
No

result:

wrong output format YES or NO expected, but 3 found [1st token]