QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#339811 | #895. Color | Xttttr | WA | 1ms | 3648kb | C++14 | 1.5kb | 2024-02-27 21:42:55 | 2024-02-27 21:42:56 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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