답안 #119952

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
119952 2019-06-22T17:36:47 Z duality Two Transportations (JOI19_transportations) C++14
70 / 100
1750 ms 85536 KB
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#include "Azer.h"

namespace {
    int N;
    vpii adjList[2000];
    int dist[2000],done[2000];
    int num,c = 0,s = 0,l = 0;
}

void InitA(int N,int A,vector<int> U,vector<int> V,vector<int> C) {
    int i;
    ::N = N;
    for (i = 0; i < N; i++) dist[i] = (1 << 20)-1,done[i] = 0;
    for (i = 0; i < A; i++) {
        adjList[U[i]].pb(mp(V[i],C[i]));
        adjList[V[i]].pb(mp(U[i],C[i]));
    }
    dist[0] = 0,done[0] = 1;
    for (i = 0; i < adjList[0].size(); i++) dist[adjList[0][i].first] = adjList[0][i].second;
}
void ReceiveA(bool x) {
    int i,m = -1;
    for (i = 0; i < N; i++) {
        if (!done[i] && ((m == -1) || (dist[i] < dist[m]))) m = i;
    }
    if (m == -1) return;
    if (s == 0) {
        if (dist[m] == ((1 << 20)-1)) {
            for (i = 0; i < 9; i++) SendA(1);
        }
        else {
            for (i = 0; i < 9; i++) SendA(((dist[m]-l) >> i) & 1);
        }
        s = 1;
    }
    else if (s == 1) {
        if (x == 0) s = 2;
        else {
            for (i = 0; i < 11; i++) SendA((m >> i) & 1);
            l = dist[m];
            s = 3;
        }
    }
    else if (s == 2) {
        num |= (x << c),c++;
        if (c == 20) {
            dist[num >> 9] = (num & ((1 << 9)-1))+l;
            l += (num & ((1 << 9)-1)),s = 3;
            m = num >> 9;
            c = num = 0;
        }
    }
    if (s == 3) {
        done[m] = 1;
        for (i = 0; i < adjList[m].size(); i++) {
            int v = adjList[m][i].first;
            dist[v] = min(dist[v],dist[m]+adjList[m][i].second);
        }
        s = 0;
    }
}
vector<int> Answer() {
    int i;
    vi ans;
    for (i = 0; i < N; i++) ans.pb(dist[i]);
    return ans;
}
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#include "Baijan.h"

namespace {
    int N;
    vpii adjList[2000];
    int dist[2000],done[2000];
    int num,c = 0,s = 0,l = 0;
}

void InitB(int N,int B,vector<int> S,vector<int> T,vector<int> D) {
    int i;
    ::N = N;
    for (i = 0; i < N; i++) dist[i] = (1 << 20)-1,done[i] = 0;
    for (i = 0; i < B; i++) {
        adjList[S[i]].pb(mp(T[i],D[i]));
        adjList[T[i]].pb(mp(S[i],D[i]));
    }
    dist[0] = 0,done[0] = 1;
    for (i = 0; i < adjList[0].size(); i++) dist[adjList[0][i].first] = adjList[0][i].second;
    SendB(0);
}
void ReceiveB(bool y) {
    int i,m = -1;
    for (i = 0; i < N; i++) {
        if (!done[i] && ((m == -1) || (dist[i] < dist[m]))) m = i;
    }
    if (s == 0) {
        num |= (y << c),c++;
        if (c == 9) {
            if ((l+(num & ((1 << 9)-1))) < dist[m]) SendB(1),s = 1;
            else {
                SendB(0);
                for (i = 0; i < 9; i++) SendB(((dist[m]-l) >> i) & 1);
                for (i = 0; i < 11; i++) SendB((m >> i) & 1);
                l = dist[m];
                s = 3;
                c = num = 0;
            }
        }
    }
    else if (s == 1) {
        num |= (y << c),c++;
        if (c == 20) {
            dist[num >> 9] = (num & ((1 << 9)-1))+l;
            l += (num & ((1 << 9)-1)),s = 3;
            m = num >> 9;
            c = num = 0;
        }
    }
    if (s == 3) {
        done[m] = 1;
        for (i = 0; i < adjList[m].size(); i++) {
            int v = adjList[m][i].first;
            dist[v] = min(dist[v],dist[m]+adjList[m][i].second);
        }
        s = 0;
        SendB(0);
    }
}

Compilation message

Azer.cpp: In function 'void InitA(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Azer.cpp:75:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0; i < adjList[0].size(); i++) dist[adjList[0][i].first] = adjList[0][i].second;
                 ~~^~~~~~~~~~~~~~~~~~~
Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:111:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (i = 0; i < adjList[m].size(); i++) {
                     ~~^~~~~~~~~~~~~~~~~~~

Baijan.cpp: In function 'void InitB(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Baijan.cpp:75:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0; i < adjList[0].size(); i++) dist[adjList[0][i].first] = adjList[0][i].second;
                 ~~^~~~~~~~~~~~~~~~~~~
Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:108:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (i = 0; i < adjList[m].size(); i++) {
                     ~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 830 ms 648 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1248 KB Output is correct
2 Correct 1250 ms 1584 KB Output is correct
3 Correct 1286 ms 1968 KB Output is correct
4 Correct 1730 ms 55200 KB Output is correct
5 Correct 1578 ms 48048 KB Output is correct
6 Correct 286 ms 1568 KB Output is correct
7 Correct 1464 ms 48224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1580 ms 1824 KB Output is correct
2 Correct 8 ms 1504 KB Output is correct
3 Incorrect 872 ms 748 KB Wrong Answer [2]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 408 ms 1504 KB Output is correct
2 Correct 616 ms 1504 KB Output is correct
3 Correct 838 ms 23760 KB Output is correct
4 Correct 500 ms 1824 KB Output is correct
5 Correct 860 ms 17248 KB Output is correct
6 Correct 468 ms 1392 KB Output is correct
7 Correct 352 ms 1560 KB Output is correct
8 Correct 450 ms 1576 KB Output is correct
9 Correct 750 ms 36000 KB Output is correct
10 Correct 958 ms 35872 KB Output is correct
11 Correct 1142 ms 61296 KB Output is correct
12 Correct 956 ms 53464 KB Output is correct
13 Correct 542 ms 1624 KB Output is correct
14 Correct 6 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 408 ms 1504 KB Output is correct
2 Correct 616 ms 1504 KB Output is correct
3 Correct 838 ms 23760 KB Output is correct
4 Correct 500 ms 1824 KB Output is correct
5 Correct 860 ms 17248 KB Output is correct
6 Correct 468 ms 1392 KB Output is correct
7 Correct 352 ms 1560 KB Output is correct
8 Correct 450 ms 1576 KB Output is correct
9 Correct 750 ms 36000 KB Output is correct
10 Correct 958 ms 35872 KB Output is correct
11 Correct 1142 ms 61296 KB Output is correct
12 Correct 956 ms 53464 KB Output is correct
13 Correct 542 ms 1624 KB Output is correct
14 Correct 6 ms 1408 KB Output is correct
15 Correct 602 ms 1504 KB Output is correct
16 Correct 398 ms 1360 KB Output is correct
17 Correct 559 ms 1416 KB Output is correct
18 Correct 986 ms 17536 KB Output is correct
19 Correct 732 ms 1520 KB Output is correct
20 Correct 802 ms 18136 KB Output is correct
21 Correct 760 ms 1592 KB Output is correct
22 Correct 714 ms 1648 KB Output is correct
23 Correct 980 ms 43920 KB Output is correct
24 Correct 1358 ms 43728 KB Output is correct
25 Correct 1486 ms 75136 KB Output is correct
26 Correct 1170 ms 64248 KB Output is correct
27 Correct 562 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 408 ms 1504 KB Output is correct
2 Correct 616 ms 1504 KB Output is correct
3 Correct 838 ms 23760 KB Output is correct
4 Correct 500 ms 1824 KB Output is correct
5 Correct 860 ms 17248 KB Output is correct
6 Correct 468 ms 1392 KB Output is correct
7 Correct 352 ms 1560 KB Output is correct
8 Correct 450 ms 1576 KB Output is correct
9 Correct 750 ms 36000 KB Output is correct
10 Correct 958 ms 35872 KB Output is correct
11 Correct 1142 ms 61296 KB Output is correct
12 Correct 956 ms 53464 KB Output is correct
13 Correct 542 ms 1624 KB Output is correct
14 Correct 6 ms 1408 KB Output is correct
15 Correct 602 ms 1504 KB Output is correct
16 Correct 398 ms 1360 KB Output is correct
17 Correct 559 ms 1416 KB Output is correct
18 Correct 986 ms 17536 KB Output is correct
19 Correct 732 ms 1520 KB Output is correct
20 Correct 802 ms 18136 KB Output is correct
21 Correct 760 ms 1592 KB Output is correct
22 Correct 714 ms 1648 KB Output is correct
23 Correct 980 ms 43920 KB Output is correct
24 Correct 1358 ms 43728 KB Output is correct
25 Correct 1486 ms 75136 KB Output is correct
26 Correct 1170 ms 64248 KB Output is correct
27 Correct 562 ms 1880 KB Output is correct
28 Correct 806 ms 1504 KB Output is correct
29 Correct 916 ms 1736 KB Output is correct
30 Correct 1474 ms 42432 KB Output is correct
31 Correct 798 ms 1376 KB Output is correct
32 Correct 1217 ms 37224 KB Output is correct
33 Correct 868 ms 1584 KB Output is correct
34 Correct 922 ms 1760 KB Output is correct
35 Correct 904 ms 1680 KB Output is correct
36 Correct 1174 ms 49288 KB Output is correct
37 Correct 1506 ms 49112 KB Output is correct
38 Correct 1750 ms 85536 KB Output is correct
39 Correct 1482 ms 78376 KB Output is correct
40 Correct 1026 ms 1784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 830 ms 648 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -