QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#39945#4357. School RoadZeinDaner0 57ms52868kbC++1.2kb2022-07-15 04:50:592022-07-15 04:51:01

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-15 04:51:01]
  • 评测
  • 测评结果:0
  • 用时:57ms
  • 内存:52868kb
  • [2022-07-15 04:50:59]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef pair<int,ll> il;
typedef vector<il> vil;
const ll MAX=1e18;
vector<vil> G;
int n,m;
ll dp[20][262145];
ll back(int u,int mask){
  if(dp[u][mask]!=-1) return dp[u][mask];
  if(u==n-1){
    return dp[u][mask]=0;
  }
  ll ans=0;
  for(auto &v:G[u]){
    if(!(mask&(1<<v.first))){
      ans=max(ans,back(v.first,mask|(1<<v.first))+v.second);
    }
  }
  return dp[u][mask]=ans;
}
ll dis[20];
void bfs(){
  for(int i=0;i<n;i++) dis[i]=MAX;
  priority_queue<ii, vector<ii>, greater<ii> > pq;
  pq.push(ii(0,0));
  dis[0]=0;
  while(!pq.empty()){
    int x=pq.top().second;
    pq.pop();
    for(auto &v:G[x]){
      if(dis[v.first]>dis[x]+v.second){
	dis[v.first]=dis[x]+v.second;
	pq.push(ii(dis[v.first],v.first));
      }
    }
  }
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  memset(dp,-1,sizeof dp);
  cin>>n>>m;
  G.resize(n+1);
  for(int i=0;i<m;i++){
    int a,b,w; cin>>a>>b>>w;
    a--; b--;
    G[a].push_back(il(b,w));
    G[b].push_back(il(a,w));
  }
  ll ma=back(0,1);
  bfs();
  cout<<(dis[n-1]<ma)<<endl;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 44664kb

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: 4ms
memory: 44516kb

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: 0
Accepted
time: 2ms
memory: 44436kb

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:

0

result:

ok single line: '0'

Test #13:

score: 0
Accepted
time: 46ms
memory: 50788kb

input:

18 200000
8 17 279042056
12 13 907447344
2 16 240997679
3 7 820773384
1 5 45712022
2 16 240997679
4 18 239293113
9 14 389857788
4 18 239293113
4 18 239293113
1 11 409366186
3 12 208134361
2 16 240997679
13 17 263089947
1 5 45712022
4 18 239293113
4 7 528521172
2 9 629050323
8 17 279042056
12 13 9074...

output:

0

result:

ok single line: '0'

Test #14:

score: -15
Wrong Answer
time: 46ms
memory: 50876kb

input:

18 200000
12 14 787958557
3 17 309856381
7 16 602540874
6 12 343810291
12 14 561222017
7 16 125534085
9 17 870511470
7 16 118408057
10 15 452922275
6 12 983055551
3 17 599421596
9 17 344601220
10 15 627856971
6 12 821612223
9 13 652746776
2 3 86605360
14 16 845498029
4 5 531236117
6 12 308924509
5 1...

output:

1

result:

wrong answer 1st lines differ - expected: '0', found: '1'

Subtask #3:

score: 0
Runtime Error

Test #18:

score: 0
Runtime Error

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: 1ms
memory: 44464kb

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: 39ms
memory: 50868kb

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: 57ms
memory: 52868kb

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%