QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#692464#7738. Equivalent RewritingtravelWA 1ms5948kbC++141.3kb2024-10-31 14:33:022024-10-31 14:33:03

Judging History

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

  • [2024-10-31 14:33:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5948kb
  • [2024-10-31 14:33:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> PII;
#define endl "\n"
#define ft first
#define sd second
#define pb push_back
const int MOD = 1e9 + 7,N = 1e5 + 10;
vector<int> e[N];
int d[N];
void solve() {
    int n,m; cin>>n>>m;
    map<int,int> mp;
    for(int i = 1;i <= n;i++)
    {
        d[i] = 0;
        e[i].clear();
    }
    for(int i = 1;i <= n;i++){
        int x; cin>>x;
        for(int j = 1;j <= x;j++){
            int y; cin>>y;
            if(mp.count(y)){
                e[mp[y]].pb(i);
                d[i]++;
            }
            else mp[y] = i;
        }
    }
    queue<int> q;
    for(int i = 1;i <= n;i++)
        if(!d[i] && i != 1) q.push(i);
    q.push(1);
    if(q.size() == 1)
        cout<<"No\n";
    else {
        cout<<"Yes\n";
        while(q.size()){
            int t = q.front(); q.pop();
            cout<<t<<' ';
            for(int v : e[t]){
                if(--d[v] == 0)
                    q.push(v);
            }
        }
        cout<<"\n";
    }
    return ;
}
signed main() {
//    ios::sync_with_stdio(0);
//    cin.tie(0);
//    cout.tie(0);
    int T = 1;
    cin>>T;
    while(T--)
        solve();
    return 0;
}
/*
3
3 6
3 3 1 5
2 5 3
2 2 6
2 3
3 1 3 2
2 3 1
1 3
2 2 1

 */

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5948kb

input:

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

output:

Yes
3 1 2 
No
No

result:

ok OK. (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 5828kb

input:

1
10 5
2 2 4
4 1 3 4 2
1 2
3 2 1 4
4 5 2 4 3
3 2 5 4
3 5 4 2
3 1 3 2
5 1 4 2 3 5
1 4

output:

No

result:

wrong answer jury found an answer but participant did not (test case 1)