답안 #708383

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708383 2023-03-11T16:13:00 Z alvingogo Two Transportations (JOI19_transportations) C++14
62 / 100
616 ms 48656 KB
#include <bits/stdc++.h>
#include "Azer.h"
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;

namespace{
    vector<vector<pair<int,int> > > gg;
    int n,m;
    vector<int> dis,vis;
    void send(int a,int i){
        i--;
        for(;i>=0;i--){
            SendA((a>>i)&1);
        }
    }
    int nw=0,cnt=0,tp=0,x=0,pre=0;
}

void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C){
    send(0,9);
    n=N;
    m=A;
    gg.resize(n);
    dis.resize(n,1e9);
    vis.resize(n);
    dis[0]=0;
    for(int i=0;i<m;i++){
        gg[U[i]].push_back({V[i],C[i]});
        gg[V[i]].push_back({U[i],C[i]});
    }
}

void ReceiveA(bool y){
    nw=2*nw+y;
    cnt++;
    if(tp==0){
        if(cnt==9){
            if(nw<=x){
                tp=1;
                pre+=nw;
            }
            else{
                nw=x;
                pre+=nw;
                for(int i=0;i<n;i++){
                    if(!vis[i] && dis[i]==pre){
                        send(i,11);        
                        dis[i]=pre;
                        vis[i]=1;
                        for(auto h:gg[i]){
                            dis[h.fs]=min(dis[h.fs],dis[i]+h.sc);
                        }
                        int mm=1e9;
                        for(int j=0;j<n;j++){
                            if(!vis[j] && dis[j]<mm){
                                mm=dis[j];
                            }
                        }
                        x=min(511,mm-pre);
                        send(x,9);
                        break;
                    }
                }
            }
            nw=0;
            cnt=0;
        }
    }   
    else if(tp==1){
        if(cnt==11){
            dis[nw]=pre;
            vis[nw]=1;
            for(auto h:gg[nw]){
                dis[h.fs]=min(dis[h.fs],dis[nw]+h.sc);
            }
            int mm=1e9;
            for(int i=0;i<n;i++){
                if(!vis[i] && dis[i]<mm){
                    mm=dis[i];
                }
            }
            x=min(511,mm-pre);
            send(x,9);
            cnt=0;
            nw=0;
            tp=0;
        }
    }
}

std::vector<int> Answer(){
    
    return dis;
}
#include <bits/stdc++.h>
#include "Baijan.h"
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;

namespace{
    vector<vector<pair<int,int> > > gg;
    int n,m;
    vector<int> dis,vis;
    void send(int a,int i){
        i--;
        for(;i>=0;i--){
            SendB((a>>i)&1);
        }
    }
    int nw=0,cnt=0,tp=0,x=0,pre=0;
}

void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D){
    send(0,9);
    n=N;
    m=B;
    gg.resize(n);
    dis.resize(n,1e9);
    vis.resize(n);
    dis[0]=0;
    for(int i=0;i<m;i++){
        gg[S[i]].push_back({T[i],D[i]});
        gg[T[i]].push_back({S[i],D[i]});
    }
}

void ReceiveB(bool y){
    nw=2*nw+y;
    cnt++;
    if(tp==0){
        if(cnt==9){
            if(nw<x){
                tp=1;
                pre+=nw;
            }
            else{
                nw=x;
                pre+=nw;
                for(int i=0;i<n;i++){
                    if(!vis[i] && dis[i]==pre){
                        send(i,11);        
                        dis[i]=pre;
                        vis[i]=1;
                        for(auto h:gg[i]){
                            dis[h.fs]=min(dis[h.fs],dis[i]+h.sc);
                        }
                        int mm=1e9;
                        for(int j=0;j<n;j++){
                            if(!vis[j] && dis[j]<mm){
                                mm=dis[j];
                            }
                        }
                        x=min(511,mm-pre);
                        send(x,9);
                        break;
                    }
                }
            }
            nw=0;
            cnt=0;
        }
    }   
    else if(tp==1){
        if(cnt==11){
            dis[nw]=pre;
            vis[nw]=1;
            for(auto h:gg[nw]){
                dis[h.fs]=min(dis[h.fs],dis[nw]+h.sc);
            }
            int mm=1e9;
            for(int i=0;i<n;i++){
                if(!vis[i] && dis[i]<mm){
                    mm=dis[i];
                }
            }
            x=min(511,mm-pre);
            send(x,9);
            cnt=0;
            nw=0;
            tp=0;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 260 ms 336 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 400 KB Output is correct
2 Incorrect 187 ms 328 KB Wrong Answer [2]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 241 ms 408 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 173 ms 660 KB Output is correct
2 Correct 264 ms 632 KB Output is correct
3 Correct 257 ms 13260 KB Output is correct
4 Correct 161 ms 776 KB Output is correct
5 Correct 259 ms 9964 KB Output is correct
6 Correct 237 ms 656 KB Output is correct
7 Correct 185 ms 656 KB Output is correct
8 Correct 165 ms 656 KB Output is correct
9 Correct 372 ms 18084 KB Output is correct
10 Correct 264 ms 18140 KB Output is correct
11 Correct 397 ms 35544 KB Output is correct
12 Correct 351 ms 30504 KB Output is correct
13 Correct 194 ms 656 KB Output is correct
14 Correct 2 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 173 ms 660 KB Output is correct
2 Correct 264 ms 632 KB Output is correct
3 Correct 257 ms 13260 KB Output is correct
4 Correct 161 ms 776 KB Output is correct
5 Correct 259 ms 9964 KB Output is correct
6 Correct 237 ms 656 KB Output is correct
7 Correct 185 ms 656 KB Output is correct
8 Correct 165 ms 656 KB Output is correct
9 Correct 372 ms 18084 KB Output is correct
10 Correct 264 ms 18140 KB Output is correct
11 Correct 397 ms 35544 KB Output is correct
12 Correct 351 ms 30504 KB Output is correct
13 Correct 194 ms 656 KB Output is correct
14 Correct 2 ms 400 KB Output is correct
15 Correct 267 ms 676 KB Output is correct
16 Correct 233 ms 576 KB Output is correct
17 Correct 311 ms 576 KB Output is correct
18 Correct 306 ms 10064 KB Output is correct
19 Correct 265 ms 656 KB Output is correct
20 Correct 298 ms 10260 KB Output is correct
21 Correct 270 ms 720 KB Output is correct
22 Correct 265 ms 656 KB Output is correct
23 Correct 353 ms 22048 KB Output is correct
24 Correct 383 ms 22176 KB Output is correct
25 Correct 576 ms 43620 KB Output is correct
26 Correct 432 ms 36512 KB Output is correct
27 Correct 282 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 173 ms 660 KB Output is correct
2 Correct 264 ms 632 KB Output is correct
3 Correct 257 ms 13260 KB Output is correct
4 Correct 161 ms 776 KB Output is correct
5 Correct 259 ms 9964 KB Output is correct
6 Correct 237 ms 656 KB Output is correct
7 Correct 185 ms 656 KB Output is correct
8 Correct 165 ms 656 KB Output is correct
9 Correct 372 ms 18084 KB Output is correct
10 Correct 264 ms 18140 KB Output is correct
11 Correct 397 ms 35544 KB Output is correct
12 Correct 351 ms 30504 KB Output is correct
13 Correct 194 ms 656 KB Output is correct
14 Correct 2 ms 400 KB Output is correct
15 Correct 267 ms 676 KB Output is correct
16 Correct 233 ms 576 KB Output is correct
17 Correct 311 ms 576 KB Output is correct
18 Correct 306 ms 10064 KB Output is correct
19 Correct 265 ms 656 KB Output is correct
20 Correct 298 ms 10260 KB Output is correct
21 Correct 270 ms 720 KB Output is correct
22 Correct 265 ms 656 KB Output is correct
23 Correct 353 ms 22048 KB Output is correct
24 Correct 383 ms 22176 KB Output is correct
25 Correct 576 ms 43620 KB Output is correct
26 Correct 432 ms 36512 KB Output is correct
27 Correct 282 ms 748 KB Output is correct
28 Correct 355 ms 700 KB Output is correct
29 Correct 244 ms 656 KB Output is correct
30 Correct 461 ms 24108 KB Output is correct
31 Correct 323 ms 656 KB Output is correct
32 Correct 421 ms 21064 KB Output is correct
33 Correct 355 ms 728 KB Output is correct
34 Correct 303 ms 748 KB Output is correct
35 Correct 337 ms 756 KB Output is correct
36 Correct 469 ms 24724 KB Output is correct
37 Correct 479 ms 24856 KB Output is correct
38 Correct 563 ms 48656 KB Output is correct
39 Correct 616 ms 44188 KB Output is correct
40 Correct 329 ms 912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 260 ms 336 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -