QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#377378 | #7995. 图 | Dva | WA | 1ms | 7684kb | C++14 | 2.9kb | 2024-04-05 12:58:43 | 2024-04-05 12:58:43 |
Judging History
answer
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define f(i, n, m) for (long long i = n; i <= m; ++i)
#define unf(i, n, m) for (long long i = n; i >= m; --i)
#define kong NULL
#define debug cout << "sss" << endl;
using ll = long long;
using ull = unsigned long long;
using point_t = double; // 计算几何的默认类型
const double e = exp(1.0);
const double pi = acos(-1.0);
constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
constexpr ll maxx = 0x3f3f3f3f3f3f3f3f;
constexpr ll minn = 0xc0c0c0c0c0c0c0c0;
#define endl '\n'
constexpr char blank = ' ';
constexpr ll mod = (ll)998244353;
constexpr size_t N = (size_t)1e6 + 6;
#ifdef _DEBUG
#define Crash(...) (__debugbreak(), 0)
#define Debug(...) (__debugbreak(), 0)
#else
#define Crash(...) (exit(-1), 0)
#define Debug(...) ((void)0)
#endif // _DEBUG
#define ensure(expression) (void)(!!(expression) || Crash())
inline void setaccuracy(const std::streamsize &accuracy)
{
std::cout << std::fixed << std::setprecision(accuracy);
}
#define int long long
using namespace std;
int n;
int mp[510][510];
int dp[510][510];
int dp2[510][510];
void bfs(int x, int fa, int wo)
{
vector<int> check(510, 0);
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
que.push({0, x});
while (!que.empty())
{
auto it = que.top();
que.pop();
if (check[it.second])
continue;
check[it.second] = 1;
f(i, 1, n)
{
if (i == it.second)
continue;
if (it.first + mp[it.second][i] < dp[wo][i])
{
dp[wo][i] = it.first + mp[it.second][i];
que.push({dp[wo][i], i});
}
}
}
}
void solve()
{
cin >> n;
f(i, 1, n)
{
f(j, 1, n)
{
cin >> mp[i][j];
dp[i][j] = maxx;
}
}
f(i, 1, n) bfs(i, 0, i);
int cnt = 0;
f(i, 1, n)
{
f(j, 1, n)
{
if (i == j)
{
dp2[i][j] = 0;
continue;
}
int ff = 0;
if (j == 3)
{
int o = 1;
}
f(k, 1, n)
{
if (k == i || k == j)
{
if (dp[i][k] + dp[k][j] < mp[i][j])
{
dp2[i][j] = 0;
ff = 1;
continue;
}
}
else if (dp[i][k] + dp[k][j] <= mp[i][j])
{
dp2[i][j] = 0;
ff = 1;
continue;
}
}
if (ff == 0)
dp2[i][j] = 1;
}
cout << endl;
}
f(i, 1, n)
{
f(j, 1, n) cout << dp2[i][j];
if (i != n)
cout << endl;
}
// std::cout<< minn<<endl;
}
signed main()
{
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int T = 1;
// cin >> T;
// scanf(" %d", &T);
// std::cin >> T;
// for (int q = 1; q <= T; q++) {
// while (T--) {
solve();
// }
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7684kb
input:
4 0 3 2 100 3 0 8 100 2 8 0 10 100 100 10 0
output:
0110 1000 1001 0010
result:
wrong answer 1st lines differ - expected: '0110', found: ''