QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#549725 | #6807. Travel Dream | Tobo | WA | 11ms | 5108kb | C++20 | 2.0kb | 2024-09-06 20:20:23 | 2024-09-06 20:20:24 |
Judging History
answer
#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
using i64 = long long;
using namespace std;
const int N = 3e2 + 1;
int n, m, k;
vector<pair<int, int>> adj[N];
int ans, dp[N][1 << 10], c[N];
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m >> k;
for (int i = 1, u, v, w; i <= m; i++)
{
cin >> u >> v >> w;
adj[u].push_back({v, w});
adj[v].push_back({u, w});
}
ans = -2e9;
mt19937 rnd(time(0));
clock_t cur = clock();
int all = (1 << k) - 1;
do
{
for (int i = 1; i <= n; i++)
c[i] = rnd() % k;
for (int i = 1; i <= n; i++)
{
memset(dp, -0x7f, sizeof(dp));
dp[i][0] = 0;
for (int s = 0; s < all; s++)
{
for (int j = 1; j <= n; j++)
{
if (dp[j][s] < 0) continue;
for (auto [to, w] : adj[j])
dp[to][s ^ (1 << c[to])] = max(dp[j][s] + w, dp[to][s ^ (1 << c[to])]);
}
}
ans = max(ans, dp[i][all]);
}
} while (clock() - cur <= 3000);
if (ans < 0) cout << "impossible\n";
else cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 4980kb
input:
5 7 4 1 2 2 1 3 3 2 3 4 4 3 1 5 3 7 4 5 6 2 5 9
output:
21
result:
ok single line: '21'
Test #2:
score: 0
Accepted
time: 4ms
memory: 5036kb
input:
5 4 5 1 2 1 2 3 6 3 1 5 4 5 2
output:
impossible
result:
ok single line: 'impossible'
Test #3:
score: 0
Accepted
time: 4ms
memory: 4900kb
input:
25 300 3 2 1 99999998 3 1 99999998 3 2 100000000 4 1 99999998 4 2 100000000 4 3 99999998 5 1 99999999 5 2 99999998 5 3 99999998 5 4 99999998 6 1 99999998 6 2 99999998 6 3 99999998 6 4 100000000 6 5 100000000 7 1 100000000 7 2 99999998 7 3 99999998 7 4 100000000 7 5 99999999 7 6 100000000 8 1 1000000...
output:
300000000
result:
ok single line: '300000000'
Test #4:
score: 0
Accepted
time: 3ms
memory: 4980kb
input:
25 300 4 2 1 99999998 3 1 99999999 3 2 100000000 4 1 100000000 4 2 99999999 4 3 100000000 5 1 100000000 5 2 99999998 5 3 100000000 5 4 99999998 6 1 100000000 6 2 100000000 6 3 100000000 6 4 99999999 6 5 99999999 7 1 99999998 7 2 99999999 7 3 99999998 7 4 100000000 7 5 99999998 7 6 100000000 8 1 1000...
output:
400000000
result:
ok single line: '400000000'
Test #5:
score: 0
Accepted
time: 4ms
memory: 4932kb
input:
25 300 5 2 1 100000000 3 1 100000000 3 2 99999999 4 1 99999998 4 2 99999999 4 3 100000000 5 1 100000000 5 2 100000000 5 3 99999999 5 4 99999999 6 1 99999998 6 2 100000000 6 3 99999998 6 4 100000000 6 5 100000000 7 1 99999999 7 2 99999998 7 3 100000000 7 4 99999999 7 5 99999998 7 6 100000000 8 1 1000...
output:
500000000
result:
ok single line: '500000000'
Test #6:
score: 0
Accepted
time: 7ms
memory: 4848kb
input:
25 300 6 2 1 99999998 3 1 99999999 3 2 99999998 4 1 100000000 4 2 99999998 4 3 100000000 5 1 99999998 5 2 99999999 5 3 100000000 5 4 99999999 6 1 100000000 6 2 99999998 6 3 99999998 6 4 99999998 6 5 99999998 7 1 100000000 7 2 99999998 7 3 99999998 7 4 99999998 7 5 99999999 7 6 99999999 8 1 99999999 ...
output:
600000000
result:
ok single line: '600000000'
Test #7:
score: 0
Accepted
time: 2ms
memory: 4996kb
input:
25 300 7 2 1 99999999 3 1 99999998 3 2 100000000 4 1 100000000 4 2 99999998 4 3 100000000 5 1 99999999 5 2 99999999 5 3 99999998 5 4 99999998 6 1 99999998 6 2 99999999 6 3 99999998 6 4 99999999 6 5 99999998 7 1 99999999 7 2 100000000 7 3 99999999 7 4 100000000 7 5 99999999 7 6 100000000 8 1 99999998...
output:
700000000
result:
ok single line: '700000000'
Test #8:
score: 0
Accepted
time: 9ms
memory: 4996kb
input:
25 300 8 2 1 100000000 3 1 99999999 3 2 99999999 4 1 99999999 4 2 99999999 4 3 99999998 5 1 99999999 5 2 99999998 5 3 99999998 5 4 99999999 6 1 99999999 6 2 100000000 6 3 100000000 6 4 100000000 6 5 100000000 7 1 100000000 7 2 99999998 7 3 100000000 7 4 100000000 7 5 99999998 7 6 100000000 8 1 99999...
output:
800000000
result:
ok single line: '800000000'
Test #9:
score: 0
Accepted
time: 10ms
memory: 5000kb
input:
25 300 9 2 1 100000000 3 1 100000000 3 2 99999998 4 1 100000000 4 2 99999999 4 3 100000000 5 1 100000000 5 2 99999998 5 3 99999999 5 4 100000000 6 1 99999999 6 2 99999998 6 3 99999998 6 4 100000000 6 5 99999999 7 1 99999999 7 2 99999998 7 3 99999999 7 4 99999999 7 5 99999998 7 6 100000000 8 1 100000...
output:
900000000
result:
ok single line: '900000000'
Test #10:
score: 0
Accepted
time: 11ms
memory: 5048kb
input:
25 300 10 2 1 100000000 3 1 100000000 3 2 99999998 4 1 99999998 4 2 99999998 4 3 100000000 5 1 99999999 5 2 99999999 5 3 100000000 5 4 100000000 6 1 99999999 6 2 99999999 6 3 100000000 6 4 99999999 6 5 99999998 7 1 99999999 7 2 100000000 7 3 99999998 7 4 99999999 7 5 100000000 7 6 99999999 8 1 99999...
output:
1000000000
result:
ok single line: '1000000000'
Test #11:
score: 0
Accepted
time: 11ms
memory: 4932kb
input:
25 300 10 2 1 99999998 3 1 99999999 3 2 100000000 4 1 99999998 4 2 100000000 4 3 100000000 5 1 99999999 5 2 99999999 5 3 100000000 5 4 100000000 6 1 100000000 6 2 99999998 6 3 99999999 6 4 100000000 6 5 99999999 7 1 99999999 7 2 100000000 7 3 99999999 7 4 99999998 7 5 99999998 7 6 99999999 8 1 99999...
output:
1000000000
result:
ok single line: '1000000000'
Test #12:
score: 0
Accepted
time: 7ms
memory: 5108kb
input:
25 300 10 2 1 99999998 3 1 99999999 3 2 99999999 4 1 99999999 4 2 99999999 4 3 100000000 5 1 99999999 5 2 99999999 5 3 99999998 5 4 99999998 6 1 99999999 6 2 100000000 6 3 100000000 6 4 99999998 6 5 99999998 7 1 99999998 7 2 99999999 7 3 100000000 7 4 100000000 7 5 100000000 7 6 99999999 8 1 9999999...
output:
1000000000
result:
ok single line: '1000000000'
Test #13:
score: 0
Accepted
time: 11ms
memory: 4864kb
input:
25 300 10 2 1 100000000 3 1 99999998 3 2 99999998 4 1 99999999 4 2 99999999 4 3 100000000 5 1 100000000 5 2 99999999 5 3 99999998 5 4 99999998 6 1 100000000 6 2 99999998 6 3 100000000 6 4 100000000 6 5 99999998 7 1 99999999 7 2 99999999 7 3 99999998 7 4 99999999 7 5 99999998 7 6 99999999 8 1 1000000...
output:
1000000000
result:
ok single line: '1000000000'
Test #14:
score: -100
Wrong Answer
time: 7ms
memory: 5052kb
input:
200 300 7 158 4 19455984 49 17 41490257 164 20 34015263 165 81 59517833 100 43 9035359 95 87 65603323 21 4 93967028 188 100 27640444 155 30 23870278 5 4 9389586 146 143 17531415 173 24 96302901 120 38 67662324 180 74 31349370 159 80 90566938 157 94 17571038 179 60 3747316 184 159 88847169 148 143 46...
output:
341599994
result:
wrong answer 1st lines differ - expected: '512464840', found: '341599994'