답안 #788168

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
788168 2023-07-19T21:04:53 Z jamkel Two Transportations (JOI19_transportations) C++14
62 / 100
1012 ms 57772 KB
#include <bits/stdc++.h>
#include "Azer.h"
using namespace std;
#define st first
#define nd second
int odl=0,numer=0;
int k1=0,k2=0;
int n;
int p=0;
vector<int>w(2000,-1);
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>q;
vector<vector<pair<int,int>>>graf;
int ile=1;
vector<int>Answer()
{
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        v[i]=w[i];
    }
    return v;
}
void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C)
{
    n=N;
    w[0]=0;
    for(int i=0;i<n;i++)
    {
        graf.push_back({{}});
    }
    for(int i=0;i<A;i++)
    {
        graf[U[i]].push_back({C[i],V[i]});
        graf[V[i]].push_back({C[i],U[i]});
    }
    for(long unsigned int i=1;i<graf[0].size();i++)
    {
        q.push({graf[0][i].st,graf[0][i].nd});
    }
    q.push({1048575,0});
    if(ile<n)
    {
        for(int i=0;i<9;i++)
        {
            SendA(q.top().st&(1<<i));
        }
        for(int i=0;i<11;i++)
        {
           SendA(q.top().nd&(1<<i));
        }
    }
}
void ReceiveA(bool x)
{
    if(k1<9)
    {
        if(x)
        {
            odl+=pow(2,k1);
        }
        k1++;
    }
    else
    {
        if(x)
        {
            numer+=pow(2,k2);
        }
        k2++;
    }
    if(k2==11)
    {       
            p+=odl;
            w[numer]=p;
            ile++;
            for(long unsigned int i=0;i<graf[numer].size();i++)
            {
                q.push({graf[numer][i].st+p,graf[numer][i].nd});
            }
            while(w[q.top().nd]>-1 && q.size()>1)
            {
                q.pop();
            }
            if(ile<n)
            {
                if(q.top().st==1048575)
                {
                    for(int i=0;i<9;i++)
                    {
                        SendA(1);
                    }
                }
                else
                {
                    for(int i=0;i<9;i++)
                    {
                        SendA((q.top().st-p)&(1<<i));
                    }
                }
                for(int i=0;i<11;i++)
                {
                    SendA(q.top().nd&(1<<i));
                }
            }
            k1=0;k2=0;odl=0;numer=0;
    }
}
#include <bits/stdc++.h>
#include "Baijan.h"
using namespace std;
#define st first
#define nd second
int odl_b=0,numer_b=0;
int k1_b=0,k2_b=0;
int n_b;
int p_b=0;
vector<int>w_b(2000,-1);
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>q_b;
vector<vector<pair<int,int>>>graf_b;
void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D)
{
    w_b[0]=0;
    n_b=N;
    for(int i=0;i<n_b;i++)
    {
        graf_b.push_back({{}});
    }
    for(int i=0;i<B;i++)
    {
        graf_b[S[i]].push_back({D[i],T[i]});
        graf_b[T[i]].push_back({D[i],S[i]});
    }
    for(long unsigned int i=0;i<graf_b[0].size();i++)
    {
        q_b.push({graf_b[0][i].st,graf_b[0][i].nd});
    }
    q_b.push({1048575,0});         
}
void ReceiveB(bool x)
{
    if(k1_b<9)
    {
        if(x)
        {
            odl_b+=pow(2,k1_b);
        }
        k1_b++;
    }
    else
    {
        if(x)
        {
            numer_b+=pow(2,k2_b);
        }
        k2_b++;
    }
    if(k2_b==11)
    {
            while(w_b[q_b.top().nd]>-1 && q_b.size()>1)
            {
                q_b.pop();
            }
            if(odl_b>=q_b.top().st-p_b)
            {
                odl_b=q_b.top().st-p_b;
                numer_b=q_b.top().nd;
            }        
            w_b[numer_b]=p_b+odl_b;
            for(long unsigned int i=0;i<graf_b[numer_b].size();i++)
            {
                q_b.push({graf_b[numer_b][i].st+p_b+odl_b,graf_b[numer_b][i].nd});
            }
            while(w_b[q_b.top().nd]>-1 && q_b.size()>1)
            {
                q_b.pop();
            }
            for(int i=0;i<9;i++)
            {
                SendB(odl_b&(1<<i));
            }
            for(int i=0;i<11;i++)
            {
                SendB(numer_b&(1<<i));
            }
            p_b+=odl_b;
            k1_b=0;k2_b=0;odl_b=0;numer_b=0;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 146 ms 384 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 400 KB Output is correct
2 Runtime error 176 ms 424 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 121 ms 328 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 287 ms 688 KB Output is correct
2 Correct 305 ms 672 KB Output is correct
3 Correct 325 ms 13344 KB Output is correct
4 Correct 273 ms 656 KB Output is correct
5 Correct 310 ms 9960 KB Output is correct
6 Correct 257 ms 656 KB Output is correct
7 Correct 241 ms 656 KB Output is correct
8 Correct 251 ms 656 KB Output is correct
9 Correct 488 ms 23668 KB Output is correct
10 Correct 461 ms 23652 KB Output is correct
11 Correct 659 ms 46576 KB Output is correct
12 Correct 549 ms 44348 KB Output is correct
13 Correct 245 ms 760 KB Output is correct
14 Correct 1 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 287 ms 688 KB Output is correct
2 Correct 305 ms 672 KB Output is correct
3 Correct 325 ms 13344 KB Output is correct
4 Correct 273 ms 656 KB Output is correct
5 Correct 310 ms 9960 KB Output is correct
6 Correct 257 ms 656 KB Output is correct
7 Correct 241 ms 656 KB Output is correct
8 Correct 251 ms 656 KB Output is correct
9 Correct 488 ms 23668 KB Output is correct
10 Correct 461 ms 23652 KB Output is correct
11 Correct 659 ms 46576 KB Output is correct
12 Correct 549 ms 44348 KB Output is correct
13 Correct 245 ms 760 KB Output is correct
14 Correct 1 ms 400 KB Output is correct
15 Correct 253 ms 776 KB Output is correct
16 Correct 311 ms 656 KB Output is correct
17 Correct 280 ms 696 KB Output is correct
18 Correct 403 ms 10032 KB Output is correct
19 Correct 253 ms 656 KB Output is correct
20 Correct 379 ms 10328 KB Output is correct
21 Correct 318 ms 756 KB Output is correct
22 Correct 311 ms 656 KB Output is correct
23 Correct 609 ms 26584 KB Output is correct
24 Correct 536 ms 26692 KB Output is correct
25 Correct 882 ms 52416 KB Output is correct
26 Correct 778 ms 49012 KB Output is correct
27 Correct 287 ms 908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 287 ms 688 KB Output is correct
2 Correct 305 ms 672 KB Output is correct
3 Correct 325 ms 13344 KB Output is correct
4 Correct 273 ms 656 KB Output is correct
5 Correct 310 ms 9960 KB Output is correct
6 Correct 257 ms 656 KB Output is correct
7 Correct 241 ms 656 KB Output is correct
8 Correct 251 ms 656 KB Output is correct
9 Correct 488 ms 23668 KB Output is correct
10 Correct 461 ms 23652 KB Output is correct
11 Correct 659 ms 46576 KB Output is correct
12 Correct 549 ms 44348 KB Output is correct
13 Correct 245 ms 760 KB Output is correct
14 Correct 1 ms 400 KB Output is correct
15 Correct 253 ms 776 KB Output is correct
16 Correct 311 ms 656 KB Output is correct
17 Correct 280 ms 696 KB Output is correct
18 Correct 403 ms 10032 KB Output is correct
19 Correct 253 ms 656 KB Output is correct
20 Correct 379 ms 10328 KB Output is correct
21 Correct 318 ms 756 KB Output is correct
22 Correct 311 ms 656 KB Output is correct
23 Correct 609 ms 26584 KB Output is correct
24 Correct 536 ms 26692 KB Output is correct
25 Correct 882 ms 52416 KB Output is correct
26 Correct 778 ms 49012 KB Output is correct
27 Correct 287 ms 908 KB Output is correct
28 Correct 420 ms 724 KB Output is correct
29 Correct 331 ms 832 KB Output is correct
30 Correct 637 ms 23980 KB Output is correct
31 Correct 344 ms 836 KB Output is correct
32 Correct 563 ms 21136 KB Output is correct
33 Correct 351 ms 912 KB Output is correct
34 Correct 435 ms 868 KB Output is correct
35 Correct 417 ms 912 KB Output is correct
36 Correct 669 ms 29280 KB Output is correct
37 Correct 634 ms 29236 KB Output is correct
38 Correct 1012 ms 57772 KB Output is correct
39 Correct 818 ms 55468 KB Output is correct
40 Correct 315 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 146 ms 384 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -