QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#393898 | #7995. 图 | OOBMABTRAMS# | WA | 3ms | 8272kb | C++17 | 948b | 2024-04-19 16:34:24 | 2024-04-19 16:34:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=503;
ll a[N][N];
ll dis[N][N];
ll ans[N][N];
void solve(){
int n;
cin>>n;
vector<tuple<int,int,int>>eg;
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
cin>>a[i][j];
if(i>j)eg.emplace_back(a[i][j],i,j);
}
memset(dis,63,sizeof dis);
for(int i=1;i<=n;i++)dis[i][i]=0;
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(i!=j)ans[i][j]=1;
sort(eg.begin(), eg.end());
for(auto[l,x,y]:eg){
if(l>=dis[x][y])ans[x][y]=ans[y][x]=0;
for(int i=1;i<=n;i++)dis[i][x]=dis[x][i]=min(dis[i][y]+l,dis[x][i]);
for(int i=1;i<=n;i++)dis[i][y]=dis[y][i]=min(dis[i][x]+l,dis[y][i]);
}
for(int i=1;i<=n;i++,cout<<'\n')for(int j=1;j<=n;j++)cout<<ans[i][j];
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T=1;
//cin>>T;
while(T--)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7756kb
input:
4 0 3 2 100 3 0 8 100 2 8 0 10 100 100 10 0
output:
0110 1000 1001 0010
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 7696kb
input:
4 0 3 2 100 3 0 8 100 2 8 0 10 100 100 10 0
output:
0110 1000 1001 0010
result:
ok 4 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 8272kb
input:
100 0 41659 61282 49636 67326 48035 29694 46438 87384 82143 38685 66540 48746 29800 91786 54931 56232 61941 53423 75707 45135 69244 53802 89998 64199 63778 75825 31745 66975 44537 35793 55663 72647 60768 80884 46657 54066 84568 6266 48213 78216 50369 66761 54861 67607 38509 52250 54210 71135 56840 5...
output:
0000000000000000000000000000000000000010000100000000100001001000000000000001000000000000000000000010 0011000000100000000000000000000000000000000000000000000000100000000000000000000000000000000000000000 01001000010000000000000000000000000000000000000000001000000010000000000010000000010000000000000000...
result:
ok 100 lines
Test #4:
score: -100
Wrong Answer
time: 3ms
memory: 8268kb
input:
100 0 81722 50546 79959 47292 51747 54712 7396 58005 52529 61319 66453 61823 76359 55454 60837 29465 61066 66711 75051 58395 38189 44176 32315 39742 46514 23229 27872 59119 39600 81204 45383 59424 40396 51094 74411 16551 30485 42587 18676 82697 76869 48206 41961 44633 59558 41795 57384 59943 18175 4...
output:
0000000100000000000000000000000000000000000000000100000000000001000000000000000100000000000000000000 0000000000000001010100000000000000000000000000000000000100000000001000000000000000000000000000000000 00000000001000001000000000001000000000000000000000000000000000000000100000001000000001000000000000...
result:
wrong answer 21st lines differ - expected: '000000000000001000000000010000...0000000000010000000000000000000', found: '000000000000001000000000010000...0000000000010000000000000000000'