QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#119998 | #4357. School Road | lmeowdn# | 0 | 31ms | 46068kb | C++14 | 1.9kb | 2023-07-06 10:14:08 | 2024-07-04 00:20:56 |
Judging History
answer
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
int x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
return x*w;
}
const int N=2e5+5,inf=0x3f3f3f3f;
int n,m,f[(1<<18)+5][25][2],d[25][25],ans;
vp e[N];
signed main() {
n=read(), m=read();
rep(i,1,n) rep(j,1,n) d[i][j]=inf;
rep(i,1,m) {
int u=read(), v=read(), w=read();
e[u].eb(v,w), e[v].eb(u,w);
chmin(d[u][v],w), chmin(d[v][u],w);
}
rep(i,1,n) d[i][i]=0;
rep(k,1,n) rep(i,1,n) rep(j,1,n) chmin(d[i][j],d[i][k]+d[k][j]);
f[1][1][0]=1; int S=(1<<n)-1;
rep(s,1,S) {
rep(u,1,n) if(s&(1<<u-1)) {
rep(k,0,1) if(f[s][u][k]) {
for(auto [v,w]:e[u]) if(!(s&(1<<v-1))) {
f[s|(1<<v-1)][v][k|(d[1][u]+w>d[1][v])]=1;
}
if(u==n&&k==1) ans=1;
}
}
}
printf("%d\n",ans);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 11788kb
input:
14 40 8 12 570429827 6 10 592780730 13 14 299807355 4 10 729771483 4 10 729771483 6 9 746405411 2 3 696576351 12 14 192640790 4 13 284900209 1 2 857968292 12 14 192640790 8 12 570429827 6 10 592780730 6 9 746405411 9 11 329648726 4 13 284900209 2 3 696576351 4 10 729771483 5 11 101819611 3 7 1824073...
output:
1
result:
wrong answer 1st lines differ - expected: '0', found: '1'
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 15
Accepted
time: 17ms
memory: 30552kb
input:
18 40 3 10 26965732 5 15 67047331 3 17 42474964 13 15 129212204 9 18 142540287 2 14 27157962 5 15 67047331 5 15 67047331 5 15 67047331 4 16 212978971 6 12 51548223 4 18 192438222 13 16 60052417 16 17 162364835 6 17 55527270 9 11 58810843 3 7 95393586 13 15 129212204 2 17 67824762 5 15 67047331 15 16...
output:
0
result:
ok single line: '0'
Test #12:
score: -15
Wrong Answer
time: 15ms
memory: 23096kb
input:
18 51 5 16 489370441 7 8 674383722 8 11 602435525 1 10 856666364 13 18 650829027 11 14 198398173 3 4 613940394 15 17 123758204 8 11 602435525 3 6 567757815 13 18 650829027 14 15 236674174 3 4 613940394 5 18 956980171 6 16 887883755 3 6 567757815 6 16 887883755 5 18 956980171 4 10 339471731 11 14 198...
output:
1
result:
wrong answer 1st lines differ - expected: '0', found: '1'
Subtask #3:
score: 0
Time Limit Exceeded
Test #18:
score: 0
Time Limit Exceeded
input:
100000 99999 42115 93495 19881095 21969 68351 161710 7405 86343 27129 37307 45676 320013 30388 71545 117761 22026 68957 65332 77949 81644 2281387 24865 95079 341488 9849 98496 2548159 53911 79572 4962105 24880 62622 1678564 15943 22168 1524688 67424 78323 2450655 32175 74893 1908332 35640 39305 1043...
output:
result:
Subtask #4:
score: 0
Time Limit Exceeded
Test #57:
score: 35
Accepted
time: 23ms
memory: 41112kb
input:
18 400 11 18 145314505 1 18 242896789 1 18 242896789 5 13 31030812 13 18 93451080 1 18 242896789 1 7 123378068 1 18 242896789 1 18 242896789 1 18 242896789 1 18 242896789 1 18 242896789 1 18 242896789 1 3 42183985 1 18 242896789 13 18 93451080 1 18 242896789 13 18 93451080 1 18 242896789 1 18 242896...
output:
0
result:
ok single line: '0'
Test #58:
score: 0
Accepted
time: 20ms
memory: 38300kb
input:
18 200000 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 ...
output:
0
result:
ok single line: '0'
Test #59:
score: 0
Accepted
time: 31ms
memory: 46068kb
input:
18 200000 1 16 142470606 1 16 142470606 1 16 142470606 1 16 142470606 1 18 403405575 1 18 403405575 1 18 403405575 1 18 403405575 1 18 403405575 1 16 142470606 1 16 142470606 1 18 403405575 1 18 403405575 1 18 403405575 1 18 403405575 1 18 403405575 1 16 142470606 1 18 403405575 1 16 142470606 16 18...
output:
1
result:
ok single line: '1'
Test #60:
score: -35
Time Limit Exceeded
input:
18 200000 4 9 299686894 3 5 299686894 7 8 299686894 1 16 299686894 3 17 299686894 6 9 299686894 12 15 299686894 4 14 299686894 2 5 299686894 15 16 299686894 4 9 299686894 5 17 299686894 3 5 299686894 1 12 299686894 9 13 299686894 6 16 299686894 3 4 299686894 12 17 299686894 6 11 299686894 6 16 29968...
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #1:
0%