QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#411359 | #7995. 图 | XiaoMuchen | RE | 0ms | 0kb | C++20 | 1.5kb | 2024-05-15 12:08:41 | 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