QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#414106 | #7995. 图 | Acetaminophen | WA | 1ms | 4604kb | C++11 | 1.1kb | 2024-05-18 15:23:38 | 2024-05-18 15:23:38 |
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"<<" ";
}
}
cout << endl;
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4604kb
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 '