QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#414128#7995. 图AcetaminophenWA 3ms4796kbC++111.1kb2024-05-18 15:34:412024-05-18 15:34:42

Judging History

你现在查看的是最新测评结果

  • [2024-05-18 15:34:42]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:4796kb
  • [2024-05-18 15:34:41]
  • 提交

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){
			}
        }
        if(i!=n){
        	cout << endl;
		}
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 4612kb

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: 4612kb

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: -100
Wrong Answer
time: 3ms
memory: 4796kb

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:

0001000000000000000000000000000000000010010100000000100001001100101000000001000000000000000000010010
0011000000100000000001000000100000000000000000000000000000100000000001001000000001000000010000000100
01001000011000000000000000001000000000000000000000001000001011000010010010000000010000000100000001...

result:

wrong answer 1st lines differ - expected: '000000000000000000000000000000...0000001000000000000000000000010', found: '000100000000000000000000000000...0000001000000000000000000010010'