QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#414123 | #7995. 图 | Acetaminophen | WA | 1ms | 4592kb | C++11 | 1.2kb | 2024-05-18 15:30:18 | 2024-05-18 15:30:19 |
Judging History
answer
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 505; // 假设最大节点数为105
int dist[N][N]; // 存储两点间最短距离
int s[N][N];
void init() {
memset(dist, 0x3f, sizeof(dist)); // 将dist数组初始化为一个很大的数
for (int i = 1; i < N; i++) {
dist[i][i] = 0; // 自己到自己距离为0
}
}
int main() {
int n;
cin >> n;
init();
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
int x;
cin>>x;
s[i][j]=x;
dist[i][j] = min(dist[i][j], x);
}
}
for (int k = 1; k <= n; k++) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if(s[i][j]==dist[i][j]&&i!=j){
cout<<"1";
}
else{
cout<<"0";
}
if(j!=n){
cout<<" ";
}
}
if(i!=n){
cout << endl;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4592kb
input:
4 0 3 2 100 3 0 8 100 2 8 0 10 100 100 10 0
output:
0 1 1 0 1 0 0 0 1 0 0 1 0 0 1 0
result:
wrong answer 1st lines differ - expected: '0110', found: '0 1 1 0'