QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#666870 | #7158. Carnival General | Warinchai_s# | 11 | 23ms | 18628kb | C++14 | 1.3kb | 2024-10-22 20:16:11 | 2024-10-22 20:16:12 |
Judging History
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});
}
while(!pq.empty()){
auto [a,b]=pq.top();
pq.pop();
vis[b]=1;
dfs(b);
while(st!=-1){
cout<<st<<" ";
st=bf[st];
}
break;
}
}
详细
Subtask #1:
score: 11
Accepted
Test #1:
score: 11
Accepted
time: 0ms
memory: 5724kb
input:
2 0
output:
1 0
result:
ok correct
Test #2:
score: 11
Accepted
time: 0ms
memory: 9964kb
input:
99 0 1 0 2 1 0 3 2 1 0 4 3 2 1 0 5 4 3 2 1 0 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 10 9 8 7 6 5 4 3 2 1 0 11 10 9 8 7 6 5 4 3 2 1 0 12 11 10 9 8 7 6 5 4 3 2 1 0 13 12 11 10 9 8 7 6 5 4 3 2 1 0 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 16 1...
output:
98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
result:
ok correct
Test #3:
score: 11
Accepted
time: 23ms
memory: 18628kb
input:
1000 0 1 0 2 1 0 3 2 1 0 4 3 2 1 0 5 4 3 2 1 0 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 10 9 8 7 6 5 4 3 2 1 0 11 10 9 8 7 6 5 4 3 2 1 0 12 11 10 9 8 7 6 5 4 3 2 1 0 13 12 11 10 9 8 7 6 5 4 3 2 1 0 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 16...
output:
999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 ...
result:
ok correct
Test #4:
score: 11
Accepted
time: 1ms
memory: 5684kb
input:
8 0 1 0 2 1 0 3 2 1 0 4 3 2 1 0 5 4 3 2 1 0 6 5 4 3 2 1 0
output:
7 6 5 4 3 2 1 0
result:
ok correct
Test #5:
score: 11
Accepted
time: 1ms
memory: 5688kb
input:
6 0 1 0 2 1 0 3 2 1 0 4 3 2 1 0
output:
5 4 3 2 1 0
result:
ok correct
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 23
Accepted
time: 1ms
memory: 5768kb
input:
2 0
output:
1 0
result:
ok correct
Test #7:
score: 0
Wrong Answer
time: 1ms
memory: 6208kb
input:
99 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0 1 2 3 4 5 0 1 2 3 4 5 6 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10 11 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 6 7 8 9 10 11 12 13 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 ...
output:
98 1 0 97 2 96 3 95 7 4 8 94 9 5 10 93 11 6 12 92 13 91 14 90 15 89 16 88 17 87 18 86 19 85 20 84 21 83 22 82 23 81 24 80 25 79 26 78 27 77 38 76 39 28 75 40 37 74 41 29 73 42 36 72 43 30 71 44 35 70 45 31 69 46 34 68 47 32 67 48 33 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49
result:
wrong answer Enemies 8 and 5 are next to each other
Subtask #3:
score: 0
Wrong Answer
Test #12:
score: 29
Accepted
time: 1ms
memory: 5728kb
input:
2 0
output:
1 0
result:
ok correct
Test #13:
score: 29
Accepted
time: 0ms
memory: 5688kb
input:
8 0 1 0 2 1 0 3 2 1 0 4 3 2 1 0 5 4 3 2 1 0 6 5 4 3 2 1 0
output:
7 6 5 4 3 2 1 0
result:
ok correct
Test #14:
score: 0
Wrong Answer
time: 1ms
memory: 5732kb
input:
8 0 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0 1 2 3 4 5 0 1 2 3 4 5 6
output:
7 1 0 6 3 2 5 4
result:
wrong answer Enemies 7 and 4 are next to each other
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%