QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#407370#4513. Slide ParadeJryno10 1299ms90192kbC++141.8kb2024-05-08 16:50:062024-05-08 16:50:07

Judging History

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

  • [2024-05-08 16:50:07]
  • 评测
  • 测评结果:0
  • 用时:1299ms
  • 内存:90192kb
  • [2024-05-08 16:50:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;
vector<int>G[maxn],ed[maxn];
int p[maxn],vis[maxn],n,m,U[maxn],V[maxn];
bool hun(int x){
    if(vis[x])return false;
    vis[x]=1;
    for(auto v:ed[x]){
        if(!p[v]||hun(p[v])){
            p[v]=x;
            return true;
        }
    }
    return false;
}
int S;
bool adj(int x){
    vis[x]=1;
    if(p[x]==S)return true;
    for(auto v:ed[p[x]]){
        if(vis[v]||!adj(v))continue;
        p[v]=p[x],p[x]=S;
        return true;
    }
    return false;
}
vector<int>ans;
void dfs(int x){
    while(G[x].size()){
        int v=G[x].back();
        G[x].pop_back(),dfs(v);
        ans.push_back(x);
    }
}
int fl;
void sol(){
    cin>>n>>m;
    ans.clear();
    for(int i=1;i<=n;i++)ed[i].clear(),G[i].clear(),p[i]=0;
    for(int i=1;i<=m;i++){
        cin>>U[i]>>V[i];
        if(fl)cout<<U[i]<<" "<<V[i]<<"\n";
        ed[U[i]].push_back(V[i]);
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)vis[j]=0;
        if(hun(i))cnt++;
    }
    if(cnt<n){
        if(fl)cout<<"IMPOSSIBLE"<<"\n";
        return;
    }
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++)vis[j]=0;
        S=U[i];
        if(!adj(V[i])){
            if(fl)cout<<"IMPOSSIBLE"<<"\n";
            return;
        }
        for(int j=1;j<=n;j++)G[p[j]].push_back(j);
    }
    ans.push_back(1),dfs(1),reverse(ans.begin(),ans.end());
    if(fl)cout<<ans.size()<<"\n";
    if(fl)for(auto v:ans)cout<<v<<" ";
    if(fl)cout<<"\n";
}
int main(){
    cin.tie(0),cout.tie(0),ios::sync_with_stdio(false);
    int tc;
    cin>>tc;
    for(int i=1;i<=tc;i++){
        if(i==25)fl=1;
        else fl=0;
        if(fl)cout<<"Case #"<<i<<": ";
        sol();
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 33776kb

input:

100
5 8
1 2
1 3
1 4
1 5
2 1
3 1
4 1
5 1
5 10
1 3
1 4
2 3
2 5
3 1
3 4
3 5
4 2
5 1
5 3
5 10
1 4
2 3
2 5
3 1
3 5
4 2
4 3
4 5
5 1
5 2
3 6
1 2
1 3
2 1
2 3
3 1
3 2
5 10
1 2
1 5
2 3
2 4
3 1
4 3
4 5
5 2
5 3
5 4
4 10
1 2
1 3
1 4
2 1
2 3
2 4
3 1
3 4
4 2
4 3
5 10
1 2
1 3
2 1
2 4
3 1
3 5
4 2
4 5
5 3
5 4
5 10
1 ...

output:

Case #25: 1 6
2 1
3 4
4 5
5 3
6 2
19
1 6 2 1 6 2 1 6 2 1 6 2 1 6 2 1 6 2 1 

result:

wrong output format Expected '#1:' but found '#25:' (test case 1)

Test #2:

score: 0
Wrong Answer
time: 1299ms
memory: 90192kb

input:

100
199 4980
1 95
1 96
1 105
1 124
1 130
1 131
1 135
1 137
1 139
1 140
1 141
1 147
1 155
1 172
1 174
1 179
1 183
1 188
1 193
1 196
1 197
2 3
2 5
2 13
2 14
2 17
2 20
2 24
2 26
2 30
2 41
2 44
2 45
2 52
2 56
2 67
2 70
2 71
2 74
2 78
2 84
2 85
2 90
2 92
2 93
2 97
2 107
2 111
2 113
2 122
2 124
2 128
2 13...

output:

Case #25: 1 99
1 104
2 3
2 11
2 20
2 21
2 32
2 33
2 34
2 35
2 37
2 47
2 49
2 50
2 55
2 59
2 66
2 71
2 72
2 74
2 77
2 82
2 85
2 87
2 88
2 89
2 91
2 92
2 93
2 97
2 99
2 102
2 108
2 109
2 112
2 113
2 114
2 115
2 120
2 121
2 131
2 136
2 143
2 145
2 152
2 156
2 158
2 159
2 162
2 163
2 177
2 188
2 198
3 5...

result:

wrong output format Expected '#1:' but found '#25:' (test case 1)