QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#414123#7995. 图AcetaminophenWA 1ms4592kbC++111.2kb2024-05-18 15:30:182024-05-18 15:30:19

Judging History

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

  • [2024-05-18 15:30:19]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4592kb
  • [2024-05-18 15:30:18]
  • 提交

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'