QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#393911 | #7995. 图 | OOBMABTRAMS# | WA | 1ms | 6072kb | C++17 | 1.1kb | 2024-04-19 16:45:24 | 2024-04-19 16:45:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
const int N=502;
ll a[N][N];
ll dis[N][N][2];
void upd(int i,int j,ll v){
if(dis[i][j][0]>=v)dis[i][j][1]=dis[i][j][0],dis[i][j][0]=v;
else if(dis[i][j][1]>=v)dis[i][j][1]=v;
}
void solve(){
int n;
cin>>n;
memset(dis,63,sizeof dis);
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)cin>>dis[i][j][0],a[i][j]=dis[i][j][0];
for(int i=1;i<=n;i++)dis[i][i][0]=dis[i][i][1];
for(int k=1;k<=n;k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
upd(i,j,dis[i][k][0]+dis[k][j][0]);
upd(i,j,dis[i][k][1]+dis[k][j][0]);
upd(i,j,dis[i][k][0]+dis[k][j][1]);
}
for(int i=1;i<=n;i++,cout<<'\n')for(int j=1;j<=n;j++)cout<<dis[i][j][0]<<' ';
for(int i=1;i<=n;i++,cout<<'\n')for(int j=1;j<=n;j++)cout<<dis[i][j][1]<<' ';
for(int i=1;i<=n;cout<<'\n',i++)for(int j=1;j<=n;j++){
cout<<(i!=j&&dis[i][j][0]!=dis[i][j][1]&&a[i][j]==dis[i][j][0]);
}
}
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: 0
Wrong Answer
time: 1ms
memory: 6072kb
input:
4 0 3 2 100 3 0 8 100 2 8 0 10 100 100 10 0
output:
4 3 2 12 3 6 5 15 2 5 4 10 12 15 10 20 6 7 6 16 7 10 8 18 6 8 8 14 16 18 14 24 0110 1000 1001 0010
result:
wrong answer 1st lines differ - expected: '0110', found: '4 3 2 12 '