Submission #573525

# Submission time Handle Problem Language Result Execution time Memory
573525 2022-06-06T18:52:25 Z MadokaMagicaFan Airline Route Map (JOI18_airline) C++14
Compilation error
0 ms 0 KB
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
const ll inf = 1e9;
const int md1 = 1e9+7;
const int md2 = 998244353;

#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(), v.rend()
#define sz(v)                       ((int)v.size())

#define forn(i,n)                   for(int i = 0; i < n; ++i)
#define forbe(i,b,e)                for(int i = b; i < e; ++i)

#define pb                          push_back

#define pry                         puts("YES")
#define prn                         puts("NO")
#define endl                        '\n'

#define fst                         first
#define scn                         second

const int N = 1e3;

vector<int> adj[N+12];

void InitG(int v, int u);
void MakeG(int pos, int c, int d);

void
addadj(int a, int b)
{
    adj[a].pb(b);
    adj[b].pb(a);
    return;
}

void
Alice(int n, int m, vector<int> a, vector<int> b)
{
    for (int i = 0; i < m; ++i)
        addadj(a[i],b[i]);

    for (int i = 0; i < 9; ++i)
        addadj(n+i,n+i+1);

    for (int i = 0; i < 10; ++i)
        addadj(n+10,n+i);

    for (int i = 0; i < n+10; ++i)
        addadj(n+11,i);

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 10; ++j)
            if (i&(1<<j))
                addadj(i, n+j);

    int u = 0;
    for (int i = 0; i < n+13; ++i)
        u += sz(adj[i]);
    u >>= 1;

    InitG(n+12,u);
    u = 0;

    for (int i = 0; i < n+13; ++i) {
        for (int x : adj[i]) {
            if (x > i) continue;
            assert(x!=i);
            MakeG(u,i,x);
            ++u;
        }
    }
}

void InitMap(int n, int m);
void MakeMap(int a, int b);

void
Bob(int v, int u, vector<int> c, vector<int> d)
{
    int n = v-12;
    if (n==1) {
        InitMap(1,0);
        return;
    }

    for (int i = 0; i < n; ++i)
        adj[i].clear();

    for (int i = 0; i < u; ++i) {
        addadj(c[i],d[i]);
    }

    int endnode = -1;
    int beginnode = -1;

    bitset<N+12> special;

    for (int i = 0; i < v; ++i)
        special[i] = 1;

    for (int i = 0; i < v; ++i) {
        if (sz(adj[i]) == v-2)
            endnode = 0;
    }

    special[endnode] = 0;

    for (int x : adj[endnode])
        special[x] = 0;

    for (int i = 0; i < v; ++i)
        if(special[i])
            beginnode = i;

    special[beginnode] = 0;

    for (int x : adj[beginnode])
        special[x] = 1;

    vector<int> realval(v,0);

    vector<int> sval;
    for (int i = 0; i < v; ++i) {
        if (!special[i]) continue;
        int deg = 0;
        for (int x : adj[i]) {
            if (!special[x]) continue;
            ++deg;
        }
        if (deg==1)
            sval.pb(i);
    }

    int start = 0;

    assert(sz(sval)==2);
    if (sz(adj[sval[0]]) > sz(adj[sval[1]]))
        start = sval[1];
    else
        start = sval[0];


    int z = 9;
    while (1) {
        int nxt = -1;
        special[start]=0;
        for (int x : adj[start]) {
            if (special[x]) nxt=x;
            realval[x] += (1<<z);
        }
        if (nxt==-1) break;
        --z;
        start = nxt;
    }


    for (int x : adj[beginnode])
        special[x] = 1;
    special[endnode] = 1;
    special[beginnode] = 1;

    int m = 0;

    for (int i = 0; i < v; ++i) {
        if (special[i]) continue;
        for (int x : adj[i]) {
            if (!special[x])
                ++u;
        }
    }

    InitMap(n,u>>1);

    for (int i = 0; i < v; ++i) {
        if (special[i]) continue;
        for (int x : adj[i]) {
            if (special[i]) continue;
            if (x > i) continue;
            MakeMap(realval[i], realval[x]);
        }
    }


    return;
}

#ifdef ONPC
void
solve()
{

}

int32_t
main()
{
    int t = 1;
    /* cin >> t; */
    while(t--)
        solve();
}
#endif
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
const ll inf = 1e9;
const int md1 = 1e9+7;
const int md2 = 998244353;

#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(), v.rend()
#define sz(v)                       ((int)v.size())

#define forn(i,n)                   for(int i = 0; i < n; ++i)
#define forbe(i,b,e)                for(int i = b; i < e; ++i)

#define pb                          push_back

#define pry                         puts("YES")
#define prn                         puts("NO")
#define endl                        '\n'

#define fst                         first
#define scn                         second

const int N = 1e3;

vector<int> adj[N+12];

void InitG(int v, int u);
void MakeG(int pos, int c, int d);

void
addadj(int a, int b)
{
    adj[a].pb(b);
    adj[b].pb(a);
    return;
}

void
Alice(int n, int m, vector<int> a, vector<int> b)
{
    for (int i = 0; i < m; ++i)
        addadj(a[i],b[i]);

    for (int i = 0; i < 9; ++i)
        addadj(n+i,n+i+1);

    for (int i = 0; i < 10; ++i)
        addadj(n+10,n+i);

    for (int i = 0; i < n+10; ++i)
        addadj(n+11,i);

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 10; ++j)
            if (i&(1<<j))
                addadj(i, n+j);

    int u = 0;
    for (int i = 0; i < n+13; ++i)
        u += sz(adj[i]);
    u >>= 1;

    InitG(n+12,u);
    u = 0;

    for (int i = 0; i < n+13; ++i) {
        for (int x : adj[i]) {
            if (x > i) continue;
            assert(x!=i);
            MakeG(u,i,x);
            ++u;
        }
    }
}

void InitMap(int n, int m);
void MakeMap(int a, int b);

void
Bob(int v, int u, vector<int> c, vector<int> d)
{
    int n = v-12;
    if (n==1) {
        InitMap(1,0);
        return;
    }

    for (int i = 0; i < n; ++i)
        adj[i].clear();

    for (int i = 0; i < u; ++i) {
        addadj(c[i],d[i]);
    }

    int endnode = -1;
    int beginnode = -1;

    bitset<N+12> special;

    for (int i = 0; i < v; ++i)
        special[i] = 1;

    for (int i = 0; i < v; ++i) {
        if (sz(adj[i]) == v-2)
            endnode = 0;
    }

    special[endnode] = 0;

    for (int x : adj[endnode])
        special[x] = 0;

    for (int i = 0; i < v; ++i)
        if(special[i])
            beginnode = i;

    special[beginnode] = 0;

    for (int x : adj[beginnode])
        special[x] = 1;

    vector<int> realval(v,0);

    vector<int> sval;
    for (int i = 0; i < v; ++i) {
        if (!special[i]) continue;
        int deg = 0;
        for (int x : adj[i]) {
            if (!special[x]) continue;
            ++deg;
        }
        if (deg==1)
            sval.pb(i);
    }

    int start = 0;

    assert(sz(sval)==2);
    if (sz(adj[sval[0]]) > sz(adj[sval[1]]))
        start = sval[1];
    else
        start = sval[0];


    int z = 9;
    while (1) {
        int nxt = -1;
        special[start]=0;
        for (int x : adj[start]) {
            if (special[x]) nxt=x;
            realval[x] += (1<<z);
        }
        if (nxt==-1) break;
        --z;
        start = nxt;
    }


    for (int x : adj[beginnode])
        special[x] = 1;
    special[endnode] = 1;
    special[beginnode] = 1;

    int m = 0;

    for (int i = 0; i < v; ++i) {
        if (special[i]) continue;
        for (int x : adj[i]) {
            if (!special[x])
                ++u;
        }
    }

    InitMap(n,u>>1);

    for (int i = 0; i < v; ++i) {
        if (special[i]) continue;
        for (int x : adj[i]) {
            if (special[i]) continue;
            if (x > i) continue;
            MakeMap(realval[i], realval[x]);
        }
    }


    return;
}

#ifdef ONPC
void
solve()
{

}

int32_t
main()
{
    int t = 1;
    /* cin >> t; */
    while(t--)
        solve();
}
#endif

Compilation message

Alice.cpp: In function 'void Bob(int, int, std::vector<int>, std::vector<int>)':
Alice.cpp:167:9: warning: unused variable 'm' [-Wunused-variable]
  167 |     int m = 0;
      |         ^
/usr/bin/ld: /tmp/ccJpWSKt.o: in function `Bob(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)':
Alice.cpp:(.text+0x850): undefined reference to `InitMap(int, int)'
/usr/bin/ld: Alice.cpp:(.text+0x8ce): undefined reference to `MakeMap(int, int)'
/usr/bin/ld: Alice.cpp:(.text+0x9d0): undefined reference to `InitMap(int, int)'
/usr/bin/ld: /tmp/cc7tqQXu.o: in function `main':
grader_alice.cpp:(.text.startup+0xa2): undefined reference to `Alice(int, int, int*, int*)'
collect2: error: ld returned 1 exit status

Bob.cpp: In function 'void Bob(int, int, std::vector<int>, std::vector<int>)':
Bob.cpp:167:9: warning: unused variable 'm' [-Wunused-variable]
  167 |     int m = 0;
      |         ^
/usr/bin/ld: /tmp/ccyJsjAd.o: in function `main':
grader_bob.cpp:(.text.startup+0xb2): undefined reference to `Bob(int, int, int*, int*)'
/usr/bin/ld: /tmp/ccnjur7f.o: in function `Alice(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)':
Bob.cpp:(.text+0x205): undefined reference to `InitG(int, int)'
/usr/bin/ld: Bob.cpp:(.text+0x234): undefined reference to `MakeG(int, int, int)'
/usr/bin/ld: Bob.cpp:(.text+0x27a): undefined reference to `InitG(int, int)'
collect2: error: ld returned 1 exit status