QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#858990 | #9677. 基础博弈练习题 | xcyyyyy | 20 | 67ms | 70692kb | C++14 | 1.4kb | 2025-01-17 11:39:35 | 2025-01-17 11:39:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define N 1000005
int n,m,k,a[N],b[N];
vector<int> G[N],F[N];
namespace sol1{
bool f[3005][3005],vis[N];
void dfs(int i,int u){
for(int v:F[u]){
if(f[i][v])continue;
f[i][v]=1;
dfs(i,v);
}
}
void work(){
for(int i=k;i;i--){
for(int t=1;t<=n;t++)if(!f[i+1][t]&&a[t]==b[i])
dfs(i,t);
}
for(int s=1;s<=n;s++){
bool fg=false;
for(int i=1;i<=k;i++)if(f[i][s]){
fg=true;
printf("%d ",i-1);
break;
}
if(!fg)printf("-1 ");
}
}
}
namespace sol2{
int mn[N],ans[N],g[N];
void work(){
for(int i=1;i<=n;i++)mn[i]=1e9,g[i]=1;
// for(int v:G[1])cout<<v<<" ";puts("");
for(int u=n;u;u--){
for(int v:G[u])mn[u]=min({mn[u],a[v],mn[v]});
for(int v:G[u]){
if(mn[v]==mn[u])g[u]=min(g[u],g[v]);
if(a[v]==mn[u])g[u]=min(g[u],ans[v]);
}
ans[u]=!g[u];
}
// for(int i=1;i<=n;i++)
// printf("%d ",mn[i]);
for(int i=1;i<=n;i++)
printf("%d ",mn[i]==1e9?-1:(!ans[i])+mn[i]-1);
}
}
int main(){
// freopen("ans.in","r",stdin);
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
for(int i=1;i<=k;i++)scanf("%d",&b[i]);
for(int i=1,u,v;i<=m;i++)scanf("%d%d",&u,&v),G[u].push_back(v),F[v].push_back(u);
// cout<<G[1].size()<<endl;
// sol2::work();
if(n<=3000)sol1::work();
else sol2::work();
}
详细
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 4ms
memory: 55120kb
input:
83 93 13 8 9 10 7 7 7 6 3 1 10 6 2 5 7 1 3 4 2 1 10 7 4 8 9 2 2 1 9 2 5 1 7 8 6 1 9 9 10 4 1 2 9 2 3 4 2 9 10 8 1 4 1 8 4 1 4 4 7 4 8 2 9 2 5 2 2 3 3 8 5 2 9 3 10 8 8 1 6 6 1 6 7 10 7 5 10 3 2 2 7 4 8 7 6 6 5 56 36 33 41 32 62 37 7 6 53 41 13 9 36 44 77 38 62 76 16 72 5 40 13 55 60 5 78 72 45 13 44 ...
output:
0 -1 -1 -1 2 0 -1 7 0 -1 3 -1 0 0 1 -1 0 -1 0 0 -1 0 -1 2 -1 -1 -1 -1 -1 -1 0 0 0 -1 0 -1 3 0 0 0 0 0 -1 -1 -1 -1 0 0 0 -1 0 0 3 0 0 0 -1 -1 3 -1 0 0 0 0 0 8 -1 -1 1 -1 -1 0 3 4 -1 3 -1 3 -1 0 0 0 -1
result:
ok 83 numbers
Test #2:
score: 10
Accepted
time: 6ms
memory: 54996kb
input:
95 33 40 1 1 1 1 3 3 1 1 2 1 1 2 3 3 2 2 2 1 2 3 1 2 1 2 2 1 2 2 3 3 1 1 2 3 1 2 1 3 2 1 1 1 3 2 1 1 1 2 3 2 3 1 1 3 2 3 1 2 1 3 1 2 1 1 1 1 2 1 2 3 1 1 3 3 2 1 3 3 3 1 2 3 1 2 2 1 3 2 1 1 1 2 2 3 1 2 2 3 1 3 3 2 3 3 2 2 2 2 1 1 1 1 2 1 1 1 1 1 2 3 1 3 2 2 3 1 3 3 1 2 2 3 2 1 3 11 95 57 80 22 89 56 ...
output:
2 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 3 -1 -1 -1 -1 -1 -1 -1 3 -1 3 -1 -1 0 -1 3 3 -1 0 0 -1 2 -1 -1 0 -1 -1 -1 -1 -1 -1 3 -1 -1 -1 -1 -1 0 -1 -1 2 -1 -1 -1 3 3 -1 -1 -1 0 -1 -1 -1 -1 3 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 3 -1 -1 -1 -1 -1 -1 3 0 -1 -1 -1 -1 2 -1 0 0
result:
ok 95 numbers
Test #3:
score: 10
Accepted
time: 3ms
memory: 55248kb
input:
94 34 89 20 7 5 8 18 12 5 15 19 1 15 7 5 6 14 19 9 19 11 11 16 20 17 5 12 8 14 2 10 19 10 1 1 6 19 18 9 14 19 16 1 6 8 10 18 8 1 17 3 9 17 9 1 16 9 15 1 15 20 10 6 14 11 9 5 18 14 20 13 18 13 18 8 1 1 8 10 5 14 5 8 16 1 14 9 7 3 20 9 20 18 17 11 18 14 2 20 16 9 12 9 4 15 4 9 20 16 18 20 7 18 19 15 5...
output:
-1 19 -1 -1 -1 -1 -1 13 -1 -1 17 -1 -1 -1 26 -1 -1 2 -1 13 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 33 2 -1 33 -1 -1 42 -1 -1 -1 -1 2 -1 -1 39 -1 -1 33 8 -1 -1 -1 -1 -1 -1 19 -1 -1 -1 4 15 1 -1 26 61 4 -1 -1 2 -1 -1 3 13 -1 13 -1 -1 -1 -1 -1 0 -1 -1 -1 8 -1 -1 61 -1 -1 2 -1 -1
result:
ok 94 numbers
Subtask #2:
score: 10
Accepted
Dependency #1:
100%
Accepted
Test #4:
score: 10
Accepted
time: 15ms
memory: 60368kb
input:
2498 1795 2498 63 29 161 58 131 5 165 91 155 175 6 60 113 130 5 114 127 138 143 161 1 53 6 168 21 7 120 88 141 2 126 117 128 156 140 3 138 66 102 77 23 58 1 53 167 64 84 9 65 4 39 162 155 140 137 139 159 140 150 149 69 85 22 102 2 35 87 89 171 162 18 93 151 22 96 98 98 101 51 108 10 98 59 87 65 94 7...
output:
-1 -1 1599 -1 -1 0 1599 -1 -1 -1 0 -1 -1 -1 0 -1 1200 -1 -1 -1 0 -1 -1 1599 -1 0 -1 -1 -1 -1 1199 -1 -1 -1 1299 0 1299 -1 -1 -1 200 499 0 499 -1 -1 -1 -1 -1 -1 -1 -1 -1 1299 1299 -1 -1 -1 -1 1400 599 -1 -1 -1 -1 300 -1 -1 -1 -1 -1 900 -1 -1 900 -1 899 -1 -1 999 0 -1 -1 -1 -1 -1 -1 899 -1 -1 -1 1699 ...
result:
ok 2498 numbers
Test #5:
score: 10
Accepted
time: 11ms
memory: 59088kb
input:
1961 1528 1335 104 130 189 185 82 97 103 4 48 66 45 152 92 199 141 190 62 54 54 19 160 131 14 133 76 70 104 140 53 98 127 20 36 144 130 110 14 177 69 49 162 139 99 91 163 2 178 79 38 55 157 196 162 81 97 134 124 154 132 86 176 92 129 168 34 73 140 74 108 160 98 184 11 176 48 185 106 195 78 87 172 16...
output:
13 -1 8 -1 71 5 -1 43 -1 31 -1 29 -1 532 27 47 42 -1 -1 -1 4 623 15 -1 -1 -1 71 463 -1 7 2 -1 7 83 -1 532 -1 -1 16 -1 143 107 -1 47 -1 -1 -1 6 16 -1 -1 67 1 -1 315 255 -1 -1 38 -1 67 -1 -1 58 -1 304 -1 -1 3 -1 58 152 -1 96 -1 -1 48 1 -1 351 -1 -1 7 -1 -1 -1 46 -1 49 31 -1 -1 -1 -1 -1 -1 -1 15 42 140...
result:
ok 1961 numbers
Subtask #3:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 67ms
memory: 70692kb
input:
100000 355071 10000 5 7 4 7 4 1 10 5 9 4 9 4 3 10 5 4 9 1 7 10 1 6 10 3 10 9 8 4 6 3 10 8 6 8 3 5 10 9 7 7 1 3 8 8 6 2 8 4 2 9 1 10 3 6 3 8 9 10 5 7 3 2 1 5 7 4 3 4 6 4 2 7 2 5 5 6 4 6 7 4 4 6 4 2 3 9 9 9 10 8 1 6 7 2 9 8 2 3 1 6 9 4 10 3 10 1 2 3 3 4 1 1 1 5 8 6 8 3 1 6 2 9 5 9 4 7 2 10 7 5 2 2 7 4...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 ...
result:
wrong answer 143rd numbers differ - expected: '0', found: '1'
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%