Submission #232688

# Submission time Handle Problem Language Result Execution time Memory
232688 2020-05-17T20:32:08 Z duality Stray Cat (JOI20_stray) C++14
0 / 100
17 ms 4224 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 "Anthony.h"

vpii adjList[20000];
int dist[20000];
queue<int> Q;
vi m;
string s = "010011";
int doDFS(int u,int p,int pp,int c) {
    int i;
    int x = 0;
    if (p != -1) m[pp] = s[c]-'0';
    for (i = 0; i < adjList[u].size(); i++) {
        int v = adjList[u][i].first;
        if (v != p) x++;
    }
    if (x == 1) {
        for (i = 0; i < adjList[u].size(); i++) {
            int v = adjList[u][i].first;
            if (v != p) doDFS(v,u,adjList[u][i].second,(c+1) % 6);
        }
    }
    else {
        for (i = 0; i < adjList[u].size(); i++) {
            int v = adjList[u][i].first;
            if (v != p) doDFS(v,u,adjList[u][i].second,(s[c]-'0')^1);
        }
    }
    return 0;
}
vector<int> Mark(int N,int M,int A,int B,vector<int> U,vector<int> V) {
    int i;
    for (i = 0; i < M; i++) {
        adjList[U[i]].pb(mp(V[i],i));
        adjList[V[i]].pb(mp(U[i],i));
    }
    if (A >= 3) {
        for (i = 0; i < N; i++) dist[i] = -1;
        Q.push(0),dist[0] = 0;
        while (!Q.empty()) {
            int u = Q.front();
            Q.pop();

            for (i = 0; i < adjList[u].size(); i++) {
                int v = adjList[u][i].first;
                if (dist[v] == -1) {
                    dist[v] = dist[u]+1;
                    Q.push(v);
                }
            }
        }
        for (i = 0; i < M; i++) {
            if (dist[U[i]] == dist[V[i]]) m.pb(dist[U[i]] % 3);
            else m.pb(min(dist[U[i]],dist[V[i]]) % 3);
        }
    }
    else {
        m.resize(M);
        doDFS(0,-1,-1,0);
    }

    for (i = 0; i < N; i++) {
        vi a;
        int x = 0;
        for (int j = 0; j < adjList[i].size(); j++) {
            if (adjList[i][j].first < i) x = m[adjList[i][j].second];
            else a.pb(m[adjList[i][j].second]);
        }
        for (int j = 0; j < a.size(); j++) {
            if (a[j] == x) {
                assert(a.size() == 1);
            }
        }
    }

    return m;
}
#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 "Catherine.h"

int a,b;
void Init(int A,int B) {
    a = A,b = B;
}
vi v;
int f = 1;
int Move(vector<int> y) {
    if (a >= 3) {
        if ((y[1] == 0) && (y[2] == 0)) return 0;
        else if ((y[0] == 0) && (y[2] == 0)) return 1;
        else if ((y[0] == 0) && (y[1] == 0)) return 2;
        else if (y[0] == 0) return 1;
        else if (y[1] == 0) return 2;
        else return 0;
    }
    else {
        if (v.empty()) {
            if (y[0]+y[1] == 2) {
                if (y[0] > 0) y[0]--,v.pb(0);
                else y[1]--,v.pb(1);
                if (y[0] > 0) v.pb(0);
                else v.pb(1);
                return v[1];
            }
            else {
                f = 0;
                if (y[0] == 1) v.pb(0);
                else v.pb(1);
                return v[0];
            }
        }
        else {
            if (f) {
                if (y[0]+y[1] == 1) {
                    if (y[0] == 1) v.pb(0);
                    else v.pb(1);
                    if (v.size() == 5) {
                        string s;
                        int i;
                        for (i = 0; i < v.size(); i++) s += '0'+v[i];
                        if ((s == "11010") || (s == "10100") || (s == "01001") \
                            || (s == "10011") || (s == "00110") || (s == "01101")) {

                            f = 0;
                            v = vi(1,v[3]);
                            return -1;
                        }
                        else {
                            f = 0;
                            return v.back();
                        }
                    }
                    else return v.back();
                }
                else {
                    if ((y[0] == 0) || (y[1] == 0)) {
                        f = 0;
                        v = vi(1,v.back());
                        return -1;
                    }
                    else {
                        f = 1;
                        v.pb(v.back()^1);
                        return v.back();
                    }
                }
            }
            else {
                if (y[0]+y[1] == 1) {
                    if (y[0] == 1) v.pb(0);
                    else v.pb(1);
                    return v.back();
                }
                else {
                    v.pb(v.back()^1);
                    return v.back();
                }
            }
        }
    }
}

Compilation message

Anthony.cpp: In function 'int doDFS(int, int, int, int)':
Anthony.cpp:68:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0; i < adjList[u].size(); i++) {
                 ~~^~~~~~~~~~~~~~~~~~~
Anthony.cpp:73:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (i = 0; i < adjList[u].size(); i++) {
                     ~~^~~~~~~~~~~~~~~~~~~
Anthony.cpp:79:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (i = 0; i < adjList[u].size(); i++) {
                     ~~^~~~~~~~~~~~~~~~~~~
Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:99:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (i = 0; i < adjList[u].size(); i++) {
                         ~~^~~~~~~~~~~~~~~~~~~
Anthony.cpp:120:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < adjList[i].size(); j++) {
                         ~~^~~~~~~~~~~~~~~~~~~
Anthony.cpp:124:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < a.size(); j++) {
                         ~~^~~~~~~~~~

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:98:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                         for (i = 0; i < v.size(); i++) s += '0'+v[i];
                                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 4224 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 4224 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 4096 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 4096 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 3840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 3840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -