Submission #409753

#TimeUsernameProblemLanguageResultExecution timeMemory
409753wittydolphinTwo Transportations (JOI19_transportations)C++14
Compilation error
0 ms0 KiB
#include <iostream>
#include <vector>
#include "Azer.h"

using namespace std;
const int COST=0;
const int INF=1000000000;
int received=0;
int count=0;
int dist;
vector <int> Ans;
vector <int> Answer(){
	return Ans;
}
void SendA(bool x)
void RecieveA(bool x){
	if(x){
		received*=2;
		received+=1;
	}else{
		received*=2;
	}
	count++;
	if(count==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> 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[U[i]][V[i]]=C[i];
		grid[V[i]][U[i]]=C[i];
	}
	for(int i=0;i<N;i++){
		int min_index;
		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-COST>dist){//Bus is better
			COST+=dist;
			for(int k=0;k<9;k++){
				SendA(1);
			}//this is 511
			while(count<20){;}
			count=0;
			//received is now place
			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
				}
			}
		}else{
			int dif=min-COST;//our one is better
			COST+=dif;
			bitset <9> sender(dif);
			for(int k=0;k<9;k++){
				SendA(dif[k]);
			}
			bitset <11> place(min_index);
			for(int k=0;k<11;k++){
				SendA(place[k]);
			}
			distance[min_index]=COST;
			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
				}
			}
		}
	}
	for(int i=0;i<N;i++){
		Ans.push_back(dist[i]);
	}
}
#include <iostream>
#include <vector>
#include "Baijan.h"


using namespace std;
const int COST=0;
const int INF=1000000000;
int dist;
int received=0;
int count=0;
void RecieveB(bool x){
	if(x){
		received*=2;
		received+=1;
	}else{
		received*=2;
	}
	count++;
	if(count==9){
		dist=received;
		received=0;
	}
}
void SendB(bool x);
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);
	visited[0]=1;
	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;
		int min=INF;
		for(int j=0;j<N;j++){
			if(visited[j]==0&&min>distance[j]){
				min=distance[j];
				min_index=j;
			}
		}
		int dif=min-COST;
		bitset <9> sender(dif);
		for(int k=0;k<9;k++){
			SendB(sender[k]);
		}
		while(count<9){;}
		if(dist==511){///this should happen in received
			count=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(count<20){;}
			count=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;
		}
	}
}

Compilation message (stderr)

Azer.cpp:16:1: error: expected initializer before 'void'
   16 | void RecieveA(bool x){
      | ^~~~
Azer.cpp: In function 'void InitA(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Azer.cpp:53:8: error: assignment of read-only variable 'COST'
   53 |    COST+=dist;
      |    ~~~~^~~~~~
Azer.cpp:69:8: error: assignment of read-only variable 'COST'
   69 |    COST+=dif;
      |    ~~~~^~~~~
Azer.cpp:70:4: error: 'bitset' was not declared in this scope
   70 |    bitset <9> sender(dif);
      |    ^~~~~~
Azer.cpp:4:1: note: 'std::bitset' is defined in header '<bitset>'; did you forget to '#include <bitset>'?
    3 | #include "Azer.h"
  +++ |+#include <bitset>
    4 | 
Azer.cpp:70:15: error: 'sender' was not declared in this scope
   70 |    bitset <9> sender(dif);
      |               ^~~~~~
Azer.cpp:72:14: error: invalid types 'int[int]' for array subscript
   72 |     SendA(dif[k]);
      |              ^
Azer.cpp:74:16: error: 'place' was not declared in this scope
   74 |    bitset <11> place(min_index);
      |                ^~~~~
Azer.cpp:88:21: error: invalid types 'int[int]' for array subscript
   88 |   Ans.push_back(dist[i]);
      |                     ^

Baijan.cpp: In function 'void InitB(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Baijan.cpp:51:3: error: 'bitset' was not declared in this scope
   51 |   bitset <9> sender(dif);
      |   ^~~~~~
Baijan.cpp:4:1: note: 'std::bitset' is defined in header '<bitset>'; did you forget to '#include <bitset>'?
    3 | #include "Baijan.h"
  +++ |+#include <bitset>
    4 | 
Baijan.cpp:51:14: error: 'sender' was not declared in this scope
   51 |   bitset <9> sender(dif);
      |              ^~~~~~
Baijan.cpp:58:16: error: 'place' was not declared in this scope
   58 |    bitset <11> place(min_index);
      |                ^~~~~
Baijan.cpp:62:8: error: assignment of read-only variable 'COST'
   62 |    COST+=dif;
      |    ~~~~^~~~~
Baijan.cpp:70:8: error: assignment of read-only variable 'COST'
   70 |    COST+=dist;
      |    ~~~~^~~~~~