QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#55766 | #1972. JJ Rally | triplem5ds | Compile Error | / | / | C++ | 2.8kb | 2022-10-15 01:14:30 | 2022-10-15 01:14:30 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-10-15 01:14:30]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-10-15 01:14:30]
- 提交
answer
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define ll long long
#define ld double
using namespace std;
const int N = 500 + 5, M = (1 << 20), mod = 998244353;
ll dp[M + 5][25][2], f[M + 5];
int n, mp[30], s1, s2, t1, t2, cnt[M + 5], dis[30][30], Edge[30][30];
ll solve(int mask, int last, bool t) {
int lastNode = mp[last], target = t1;
if(t == 1) target = t2;
if(cnt[mask] == 0) {
if(dis[lastNode][target] == Edge[lastNode][target]) return 1;
return 0;
}
if(dp[mask][last][t] != -1) return dp[mask][last][t];
ll ans = 0;
for(int bit = 0; bit < (n - 4); bit++) {
if(mask >> bit & 1) {
int curNode = mp[bit];
if(dis[lastNode][target] == Edge[lastNode][curNode] + dis[curNode][target]) {
ans += solve(mask ^ (1 << bit), bit, t);
}
}
}
return dp[mask][last][t] = ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int m;
cin >> n >> m;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
Edge[i][j] = dis[i][j] = mod;
}
}
for(int i = 0; i < m; i++) {
int u, v, c;
cin >> u >> v >> c;
u--; v--;
dis[u][v] = dis[v][u] = Edge[u][v] = Edge[v][u] = min(dis[u][v], c);
}
cin >> s1 >> t1 >> s2 >> t2;
s1--; t1--;
s2--; t2--;
for(int k = 0; k < n; k++) {
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
}
}
}
for(int i = 1; i < (1 << (n - 4)); i++) {
cnt[i] = __builtin_popcount(i);
}
// cout << dis[0][1] << ' ' << dis[2][3] << '\n';
int curId = 0;
for(int i = 0; i < n; i++) {
if(i == s1 || i == s2 || i == t1 || i == t2) continue;
mp[curId] = i;
curId++;
}
mp[n - 4] = s1;
mp[n - 3] = s2;
mp[n - 2] = t1;
mp[n - 1] = t2;
memset(dp, -1, sizeof dp);
for(int mask = (1 << (n - 4)) - 1; mask >= 0; mask--) {
f[mask] = solve(mask, n - 4, 0);
}
for(int bit = 0; bit < (n - 4); bit++) {
for(int mask = 0; mask < (1 << (n - 4)); mask++) {
if(mask >> bit & 1) {
f[mask] += f[mask ^ (1 << bit)];
}
}
}
ll ans = 0;
for(int mask = 0; mask < (1 << (n - 4)); mask++) {
int compMask = (1 << (n - 4)) - 1 - mask;
// cout << "Answer: " << solve(mask, mp[s2], 1) << ' ' << f[compMask] << '\n';
ans += solve(mask, n - 3, 1) * f[compMask];
}
cout << ans;
return 0;
}
Details
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/gthr.h:148, from /usr/include/c++/11/ext/atomicity.h:35, from /usr/include/c++/11/bits/ios_base.h:39, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:5: /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 102 | __gthrw(pthread_once) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 103 | __gthrw(pthread_getspecific) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 104 | __gthrw(pthread_setspecific) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 106 | __gthrw(pthread_create) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 107 | __gthrw(pthread_join) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 108 | __gthrw(pthread_equal) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 109 | __gthrw(pthread_self) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 110 | __gthrw(pthread_detach) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 112 | __gthrw(pthread_cancel) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 114 | __gthrw(sched_yield) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 116 | __gthrw(pthread_mutex_lock) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:117:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 117 | __gthrw(pthread_mutex_trylock) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:117:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:119:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 119 | __gthrw(pthread_mutex_timedlock) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:119:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/...