제출 #967433

#제출 시각아이디문제언어결과실행 시간메모리
967433LucaIlieStray Cat (JOI20_stray)C++17
20 / 100
38 ms17228 KiB
#include "Anthony.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2e4;
const int MAX_M = 2e4;
bool vis[MAX_N], visE[MAX_M];
int d[MAX_N];
vector<int> adj[MAX_N], uu, vv;
int pattern[6] = { 0, 0, 1, 0, 1, 1 };

vector<int> X;

void dfs( int u, int p, int t ) {
    if ( p != -1 && adj[u].size() == 2 )
        t = (t + 1) % 6;
    else
        t = (pattern[t] == 0 ? 2 : 0);

    for ( int e: adj[u] ) {
        if ( e == p )
            continue;
        X[e] = pattern[t];
        int v = (uu[e] == u ? vv[e] : uu[e]);
        dfs( v, e, t );
    }
}

vector<int> Mark( int N, int M, int A, int B, vector<int> U, vector<int> V ) {
    X.resize( M );
    uu = U;
    vv = V;

    for ( int i = 0; i < M; i++ ) {
        adj[U[i]].push_back( i );
        adj[V[i]].push_back( i );
    }

    if ( A >= 3 ) {
        queue<int> q;

        d[0] = 0;
        vis[0] = true;
        q.push( 0 );
        while ( !q.empty()) {
            int u = q.front();
            q.pop();

            for ( int e: adj[u] ) {
                if ( visE[e] )
                    continue;
                visE[e] = true;
                int v = (U[e] == u ? V[e] : U[e]);
                X[e] = d[u];
                if ( vis[v] )
                    continue;
                d[v] = (d[u] + 1) % 3;
                vis[v] = true;
                q.push( v );
            }
        }
    } else {
        dfs( 0, -1, 0 );
    }

    return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>

using namespace std;

set<string> down;

int A, B;
void Init( int a, int b ) {
    A = a;
    B = b;
    down.insert( "00101" );
    down.insert( "01011" );
    down.insert( "10110" );
    down.insert( "01100" );
    down.insert( "11001" );
    down.insert( "10010" );
}
//001011 001011
int t = 0, p = -1;
bool dir = false;
string s = "";

int Move( vector<int> y ) {
    if ( A >= 3 ) {
        if ( y[0] > 0 && y[2] == 0 )
            return 0;
        if ( y[1] > 0 && y[0] == 0 )
            return 1;
        if ( y[2] > 0 && y[1] == 0 )
            return 2;
    } else {
        if ( y[0] + y[1] == 0 ) {
            dir = true;
            return -1;
        }
        if ( y[0] + y[1] + (t > 0) != 2 ) {
            if ( t > 0 )
                y[p]++;
            dir = true;
            p = (y[0] == 1 ? 0 : 1);
            return p;
        }

        if ( dir ) {
            p = (y[0] == 1 ? 0 : 1);
            return p;
        }

        while ( y[0] > 0 ) {
            s += '0';
            y[0]--;
        }
        while ( y[1] > 0 ) {
            s += '1';
            y[1]--;
        }
        if ( t == 3 ) {
            dir = true;
            if ( down.find( s ) != down.end() )
                return -1;
        }
        t++;
        p = s.back() - '0';
        return p;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:67:1: warning: control reaches end of non-void function [-Wreturn-type]
   67 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...