QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#339811#895. ColorXttttrWA 1ms3648kbC++141.5kb2024-02-27 21:42:552024-02-27 21:42:56

Judging History

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

  • [2024-02-27 21:42:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3648kb
  • [2024-02-27 21:42:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=207;
int n,m;
bool e[N][N];
int p[N],ans[N][N],match[N];
bool vis[N];
inline bool dfs(int x){
    vis[x]=1;
    for(int i=1;i<=n;i++)if(!e[x][i]){
        if(!match[i]||(!vis[match[i]]&&dfs(match[i]))){
            match[i]=x;
            return 1;
        }
    }
    return 0;
}
inline bool check(){
    for(int i=1;i<=m;i++){
        if(n-2*p[i]>m-n+1)return 1;
    }
    return 0;
}
inline bool check(int i){return !(m+1+2*p[i]-2*n);}
inline void solve(){
    memset(e,0,sizeof(e));
    memset(p,0,sizeof(p));
    cin>>n>>m;
    for(int i=1;i<n;i++)for(int j=i+1;j<=n;j++){
        cin>>ans[i][j];
        p[ans[i][j]]++;
        e[ans[i][j]][i]=e[ans[i][j]][j]=1;
    }
    if(!(m&1)||check()){
        cout<<"No"<<endl;
        return;
    }
    cout<<"Yes"<<endl;
    while(n<=m){
        for(int i=1;i<=m;i++)if(check(i)){
            memset(vis,0,sizeof(vis));
            dfs(i);
        }
        for(int i=1;i<=m;i++)if(!check(i)){
            memset(vis,0,sizeof(vis));
            dfs(i);
        }
        for(int i=1;i<=n;i++){
            ans[i][n+1]=match[i];
            p[ans[i][n+1]]++;
            e[ans[i][n+1]][i]=e[ans[i][n+1]][n+1]=1;
        }
        n++;
        memset(match,0,sizeof(match));
    }
    for(int i=1;i<=m;i++)for(int j=i+1;j<=m+1;j++)cout<<ans[i][j]<<" \n"[j==m+1];
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
    int T=1;
    cin>>T;
    while(T--)solve();    
    return 0;
}

詳細信息

Test #1:

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

input:

3 5
1 2
4

output:

No
No
No

result:

wrong answer Jury has the answer but participant has not