QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#666903 | #7158. Carnival General | Warinchai_s# | 0 | 1ms | 7632kb | C++14 | 1.3kb | 2024-10-22 20:22:00 | 2024-10-22 20:22:14 |
answer
#include<bits/stdc++.h>
using namespace std;
int r[1005][1005];
int no[1005][1005];
vector<int>adj[1005];
vector<int>rv[1005];
int in[1005];
int vis[1005];
int bf[1005];
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;
int st=0;
int cnt=0;
int n;
void dfs(int u,int p=-1){
bf[u]=p;
st=u;
cnt++;
int mn=1e4,id=-1;
for(auto x:adj[u])if(x!=p)if(!vis[x]&&in[x]<mn)mn=in[x],id=x;
if(id==-1){
assert(cnt==n);
return;
}
vis[id]=1;
dfs(id,u);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=0;i<n;i++){
//cerr<<"i:"<<i<<"\n";
for(int j=0;j<i;j++){
cin>>r[i][j];
if(j>(i/2)){
no[i][r[i][j]]=1;
}
}
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i==j)continue;
if(!no[i][j])adj[i].push_back(j),rv[j].push_back(i),in[j]++;
}
}
for(int i=0;i<n;i++){
pq.push({in[i],i});
}
auto [a,b]=pq.top();
pq.pop();
vis[b]=1;
dfs(b);
int x=0;
vector<int>v;
while(st!=-1){
//cout<<st<<" ";
v.push_back(st);
st=bf[st];
}
assert(v.size()==n);
for(int i=1;i<n;i++){
assert(no[v[i]][v[i-1]]==0);
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5724kb
input:
2 0
output:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 1ms
memory: 5624kb
input:
2 0
output:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #3:
score: 0
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 1ms
memory: 7632kb
input:
2 0
output:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #4:
score: 0
Skipped
Dependency #1:
0%