답안 #306167

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
306167 2020-09-24T18:51:57 Z CaroLinda 길고양이 (JOI20_stray) C++14
0 / 100
51 ms 20248 KB
#include "Anthony.h"
#include <bits/stdc++.h>

#define pii pair<int,int>
#define ff first
#define ss second
#define mk make_pair
#define sz(x) (int)(x.size() )
#define ll long long
#define all(x) x.begin(),x.end()

const int MAXN = 2e5+10 ;

using namespace std ;

vector<pii> adj[MAXN] ;
vector<int> marcas ;
int seq[6] = {0,1,0,0,1,1} ;

void dfs(int x, int father , int curIdx ) //curIdx eh o que eu tenho que colocar nas minhas proximas arestas
{
	
	for(auto e : adj[x] ) 
	{
		if(e.ff == father )  continue ;

		marcas[e.ss] = seq[curIdx] ;

		if( sz(adj[e.ff] ) == 2 ) dfs( e.ff, x , (curIdx == 5 ) ? 0 : (curIdx+1) ) ;
		else dfs(e.ff, x, !seq[curIdx] ) ;
				 
	}

}

void dfs3(int x, int father, int toFill )
{

	for(auto e : adj[x] )
	{
		if(e.ff == father) continue ;

		marcas[e.ss] = toFill ;

		dfs3(e.ff, x,  (toFill == 2 ) ? 0 : (toFill+1) ) ;

	}
}

vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) 
{

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

	marcas.resize(M, 0) ;

	if(A >= 3 ) dfs3(0,-1, 0) ;
	else 	dfs(0,-1,0) ;
	

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

#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int,int>

using namespace std ;

set< string > reversedOrder ;

void Init(int A, int B) 
{
	string seq = "010011" ;

	//Creating reversedOrder
	for(int i = 0 ,ant = 5 ; i < 6 ; i++ , ant++ )
	{

		if(ant == 6 ) ant = 0 ;

		string str ;
		for(int j = i; j != ant ; j = (j == 5 ) ? 0 : (j+1) )
			str.push_back(seq[j] ) ;

		reversedOrder.insert(str) ;
	}
	                          
}

bool justGo , isFirst = true ;
int wentBefore ;
string str ;

int Move(vector<int> y) 
{
	
	int qtdNeigh = y[0] + y[1] +y[2] ;
	
	if(isFirst)
	{
		isFirst = false ;

		if(qtdNeigh == 1 )
		{
			for(int i = 0 ; i < 2 ; i++)
				if( y[i] )
				{
					wentBefore = i ;
					justGo = true ;
					return i ;
				}

		}
		if(qtdNeigh == 2 )
		{

			if( y[0] && y[1] )
			{
				str.push_back('0') ;
				str.push_back('1') ;
				wentBefore = 1 ;
				return 1 ;
			}
			int idx = (y[0] > y[1] ) ? 0 : 1 ;

			str.push_back('0' + idx ) ;
			str.push_back('0' + idx ) ;
			wentBefore = idx ;
			return idx ;

		}

	   wentBefore = (y[0] < y[1] ) ? 0 : 1 ;
	   justGo = true ;

		return wentBefore ;
	}

	if(justGo)
	{
		if( qtdNeigh == 1 )
		{

			int idx = (y[0] > y[1] ) ? 0 : 1 ;
			wentBefore = idx ;
			return idx ;
		}

		wentBefore = !wentBefore ;
		return wentBefore ;
	}

	if(qtdNeigh > 1 )
	{
		justGo = true ;
	
		if(!y[0] || !y[1] ) return -1 ;

		int idx = (y[0] == 1) ? 0 : 1 ;

		wentBefore = idx ;

		return idx ;

	}

	//Ainda estou presa na corrente
	str.push_back( '0' + ( (y[0] == 1) ? 0 : 1 ) ) ;


	if(sz(str) == 5 )
	{

		justGo = true ;

		if( reversedOrder.find(str) != reversedOrder.end() ) return -1 ;
		else 
		{
			wentBefore = (y[0] == 1 ) ? 0 : 1 ;
			return wentBefore ;
		}
	}

	wentBefore = (y[0] == 1 ) ? 0 : 1 ;

	return wentBefore ;

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 20248 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 20248 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 18080 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 18080 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9984 KB Output is correct
2 Correct 5 ms 9984 KB Output is correct
3 Correct 5 ms 9984 KB Output is correct
4 Incorrect 5 ms 10240 KB Wrong Answer [5]
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 15832 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 45 ms 15952 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -