# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
409753 | wittydolphin | Two Transportations (JOI19_transportations) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
}
}