Submission #117603

# Submission time Handle Problem Language Result Execution time Memory
117603 2019-06-16T18:19:15 Z duality Two Transportations (JOI19_transportations) C++14
0 / 100
976 ms 11728 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];
    int num,c = 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;
    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;
    for (i = 0; i < 11; i++) SendA(0);
    for (i = 0; i < 20; i++) SendA(0);
}
void ReceiveA(bool x) {
    int i,j;
    num <<= 1,num |= (x == 1),c++;
    if (c == 31) {
        int u = num >> 20;
        if ((num & ((1 << 20)-1)) < dist[u]) {
            dist[u] = num & ((1 << 20)-1);
            for (j = 10; j >= 0; j--) SendA((u & (1 << j)) > 0);
            for (j = 19; j >= 0; j--) SendA((dist[u] & (1 << j)) > 0);
        }
        for (i = 0; i < adjList[u].size(); i++) {
            int v = adjList[u][i].first;
            if ((dist[u]+adjList[u][i].second) < dist[v]) {
                dist[v] = dist[u]+adjList[u][i].second;
                for (j = 10; j >= 0; j--) SendA((v & (1 << j)) > 0);
                for (j = 19; j >= 0; j--) SendA((dist[v] & (1 << j)) > 0);
            }
        }
        c = num = 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];
    int num,c = 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;
    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;
    for (i = 0; i < 11; i++) SendB(0);
    for (i = 0; i < 20; i++) SendB(0);
}
void ReceiveB(bool y) {
    int i,j;
    num <<= 1,num |= (y == 1),c++;
    if (c == 31) {
        int u = num >> 20;
        if ((num & ((1 << 20)-1)) < dist[u]) {
            dist[u] = num & ((1 << 20)-1);
            for (j = 10; j >= 0; j--) SendB((u & (1 << j)) > 0);
            for (j = 19; j >= 0; j--) SendB((dist[u] & (1 << j)) > 0);
        }
        for (i = 0; i < adjList[u].size(); i++) {
            int v = adjList[u][i].first;
            if ((dist[u]+adjList[u][i].second) < dist[v]) {
                dist[v] = dist[u]+adjList[u][i].second;
                for (j = 10; j >= 0; j--) SendB((v & (1 << j)) > 0);
                for (j = 19; j >= 0; j--) SendB((dist[v] & (1 << j)) > 0);
            }
        }
        c = num = 0;
    }
}

Compilation message

Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:88:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (i = 0; i < adjList[u].size(); i++) {
                     ~~^~~~~~~~~~~~~~~~~~~

Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:88:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (i = 0; i < adjList[u].size(); i++) {
                     ~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 350 ms 692 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1248 KB Output is correct
2 Incorrect 484 ms 752 KB Wrong Answer [2]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 325 ms 636 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 874 ms 1336 KB Output is correct
2 Correct 976 ms 1224 KB Output is correct
3 Incorrect 135 ms 11728 KB Wrong Answer [2]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 874 ms 1336 KB Output is correct
2 Correct 976 ms 1224 KB Output is correct
3 Incorrect 135 ms 11728 KB Wrong Answer [2]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 874 ms 1336 KB Output is correct
2 Correct 976 ms 1224 KB Output is correct
3 Incorrect 135 ms 11728 KB Wrong Answer [2]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 350 ms 692 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -