QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#377428#7990. 广播plutosWA 0ms3632kbC++171.4kb2024-04-05 13:30:312024-04-05 13:30:32

Judging History

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

  • [2024-04-05 13:30:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3632kb
  • [2024-04-05 13:30:31]
  • 提交

answer

#include <bits/stdc++.h>

void Yes() {
    std::cout << "YES" << "\n";
    return;
}

void No() {
    std::cout << "NO" << "\n";
    return;
}

template<typename T>
void out(T x) { std::cout << x << "\n"; }

using namespace std;
using ll = long long;
using PII = pair<ll, ll>;

const ll N = 2e5 + 10;
ll dp[505][505];
ll ans[505][505];

void Solve() {
    ll n;
    cin >> n;
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= n; j++) {
            cin >> dp[i][j], ans[i][j] = 1;
            if(i == j)
                ans[i][j] = 0;
        }
    }

    for (ll k = 1; k <= n; k++) {
        for (ll i = 1; i <= n; i++) {
            for (ll j = 1; j <= n; j++)
            {
                if (dp[i][k] + dp[k][j] < dp[i][j]) {
                    ans[i][j] = ans[j][i] = 0;
                    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
                }
                if (dp[i][k] + dp[k][j] == dp[i][j] && (i!=k && j!=k)) {
                    ans[i][j] = ans[j][i] = 0;
                    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
                }


            }
        }
    }
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= n; j++) {
            cout<<ans[i][j];
        }
        cout<<"\n";
    }

}

signed main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll 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: 0ms
memory: 3632kb

input:

4 2
2 1 3 2
4 2

output:

0000
0000
0000
0000

result:

wrong answer 1st lines differ - expected: '1', found: '0000'