Submission #136589

#TimeUsernameProblemLanguageResultExecution timeMemory
136589LawlietToy Train (IOI17_train)C++14
0 / 100
2043 ms1144 KiB
#include <bits/stdc++.h>

#define MAX 5010

using namespace std;

int N, M;
int curComponent;

int node[MAX];

bool isCycle[MAX];
bool isSpecial[MAX];
bool ArezouOwn[MAX];
bool BorzouOwn[MAX];

vector<int> grafo[MAX];

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v)
{
	N = a.size(); M = u.size();

	for(int g = 0 ; g < M ; g++)
	{
		if(u[g] == v[g]) isCycle[ u[g] + 1 ] = true; 
		else grafo[ u[g] + 1 ].push_back( v[g] + 1 );
	}

	for(int g = 0 ; g < r.size() ; g++)
	{
		if(r[g] == 1) isSpecial[g + 1] = true;
		else isSpecial[g + 1] = false;
	}

	for(int g = 0 ; g < N ; g++)
	{
		if(a[g] == 1) ArezouOwn[g + 1] = true;
		else BorzouOwn[g + 1] = true;
	}

	vector<int> ans;

	for(int curStation = 1 ; curStation <= N ; curStation++)
	{
		int aux = curStation;

		bool flag = false;

		while( true )
		{
			if(isCycle[aux] && isSpecial[aux] && ArezouOwn[aux])
			{
				ans.push_back(1); flag = true;
				break;
			}

			if(isCycle[aux] && !isSpecial[aux] && BorzouOwn[aux])
			{
				ans.push_back(0); flag = true;
				break;
			}

			if(grafo[aux].empty()) break;

			aux = grafo[aux].back();
		}

		if(!flag) ans.push_back( 0 );
	}

	return ans;
}

/*int main()
{
	int nn, mm, n1, n2;
	scanf("%d %d",&nn,&mm);

	vector<int> v1, v2;
	vector<int> uu, vv;

	for(int g = 0 ; g < mm ; g++)
	{
		scanf("%d %d",&n1,&n2);

		uu.push_back( n1 ); 
		vv.push_back( n2 );
	}

	for(int g = 0 ; g < nn ; g++)
	{
		scanf("%d",&n1);

		v1.push_back(n1);
	}

	for(int g = 0 ; g < nn ; g++)//ESPECIAL
	{
		scanf("%d",&n1);

		v2.push_back(n1);
	}

	vector<int> ans = who_wins(v1 , v2 , uu , vv);

	for(int g = 0 ; g < nn ; g++)
		printf("%d ",ans[g]);
}*/

Compilation message (stderr)

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int g = 0 ; g < r.size() ; g++)
                  ~~^~~~~~~~~~
#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...