Submission #409799

#TimeUsernameProblemLanguageResultExecution timeMemory
409799wittydolphinTwo Transportations (JOI19_transportations)C++14
0 / 100
382 ms32040 KiB
#include <iostream> #include <vector> #include <bitset> #include "Azer.h" using namespace std; int COST=0; const int INF=1000000000; int received=0; int counter=0; int dist=0; vector <int> Ans; vector <int> Answer(){ return Ans; } void ReceiveA(bool x){ if(x){ received*=2; received+=1; }else{ received*=2; } counter++; if(counter==9){ dist=received; received=0; } } void InitA(int N, int A, vector <int> U,vector <int> V,vector <int> C){ vector <int> visited(N,0); vector <int> costs(N,INF); costs[0]=0; int grid[N][N]; for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ grid[i][j]=INF; } } for(int i=0;i<A;i++){ grid[U[i]][V[i]]=C[i]; grid[V[i]][U[i]]=C[i]; } for(int i=0;i<N;i++){ int min_index=-1; int min=INF; for(int j=0;j<N;j++){ if(visited[j]==0&&min>costs[j]){ min=costs[j]; min_index=j; } } if(min_index==-1){break;} if(min-COST>dist){//Bus is better COST+=dist; for(int k=0;k<9;k++){ SendA(1); }//this is 511 while(counter<20){;} counter=0; //received is now place costs[received]=COST; visited[received]=1; for(int j=0;j<N;j++){ if(visited[j]==0&&costs[j]>COST+grid[received][j]){ costs[j]=COST+grid[received][j];//renew costss } } received=0; }else{ int dif=min-COST;//our one is better COST+=dif; bitset <9> sender(dif); for(int k=0;k<9;k++){ SendA(sender[k]); } bitset <11> place(min_index); for(int k=0;k<11;k++){ SendA(place[k]); } costs[min_index]=COST; visited[min_index]=1; for(int j=0;j<N;j++){ if(visited[j]==0&&costs[j]>COST+grid[min_index][j]){ costs[j]=COST+grid[min_index][j];//renew costss } } } } for(int i=0;i<N;i++){ Ans.push_back(costs[i]); } }
#include <iostream> #include <vector> #include <bitset> #include "Baijan.h" using namespace std; int COST=0; const int INF=1000000000; int dist; int received=0; int counter=0; void ReceiveB(bool y){ if(y){ received*=2; received+=1; }else{ received*=2; } counter++; if(counter==9){ dist=received; received=0; } } void InitB(int N, int A, vector <int> S,vector <int> T,vector <int> D){ vector <int> visited(N,0); vector <int> distance(N,INF); distance[0]=0; int grid[N][N]; for(int i=0;i<N;i++){ for(int j=0;j<N;j++){ grid[i][j]=INF; } } for(int i=0;i<A;i++){ grid[S[i]][T[i]]=D[i]; grid[T[i]][S[i]]=D[i]; } for(int i=0;i<N;i++){ int min_index=-1; int min=INF; for(int j=0;j<N;j++){ if(visited[j]==0&&min>distance[j]){ min=distance[j]; min_index=j; } } if(min_index==-1){break;} int dif=min-COST; bitset <9> sender(dif); for(int k=0;k<9;k++){ SendB(sender[k]); } while(counter<9){;} if(dist==511){///this should happen in received counter=0; bitset <11> place(min_index); for(int k=0;k<11;k++){ SendB(place[k]); } COST+=dif; visited[min_index]=1; for(int j=0;j<N;j++){ if(visited[j]==0&&distance[j]>COST+grid[min_index][j]){ distance[j]=COST+grid[min_index][j];//renew distances } } }else{ COST+=dist; //received is while(counter<20){;} counter=0; distance[received]=COST; visited[received]=1; for(int j=0;j<N;j++){ if(visited[j]==0&&distance[j]>COST+grid[received][j]){ distance[j]=COST+grid[received][j];//renew distances } } received=0; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...