QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#411359#7995. 图XiaoMuchenRE 0ms0kbC++201.5kb2024-05-15 12:08:412024-05-15 12:08:41

Judging History

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

  • [2024-05-15 12:08:41]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-05-15 12:08:41]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define lld long long int
#define pii pair<int, int>
#define pff pair<double, double>

const int dinf = 1e9;
const lld ldinf = 1e18;

const int N = 5e2 + 10;
const int M = 998244353;

lld n, g[N][N], dp[N][N], ok[N][N];

void solve()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            cin >> g[i][j], dp[i][j] = ldinf, ok[i][j] = (i != j);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            dp[i][j] = g[i][j];
    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
            {
                if (i == j || j == k || i == k) continue;
                if (dp[i][j] >= dp[i][k] + dp[k][j])
                {
                    if (dp[i][j] != ldinf)
                        ok[i][j] = 0;
                    dp[i][j] = dp[i][k] + dp[k][j];
                }
            }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
            cout << (ok[i][j] ? 1 : 0);
        cout << endl;
    }
}

#define debug 1
int main()
{
#if debug
    clock_t start = clock();
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
#endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T--)
    {
        solve();
    }

#if debug
    cout << endl << "time: " << clock() - start << endl;
#endif
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

4
0 3 2 100
3 0 8 100
2 8 0 10
100 100 10 0

output:


result: