Submission #119794

# Submission time Handle Problem Language Result Execution time Memory
119794 2019-06-22T11:15:37 Z tinjyu Simurgh (IOI17_simurgh) C++14
13 / 100
1682 ms 4216 KB
#include "simurgh.h"
#include <iostream>
using namespace std;
long long int Na,can,tag[5005],map[505][505],r,road[5005],tmpans[505][505],s1,s2,anstag[2500000],p;
long long int bfs(int x)
{
	for(int i=0;i<Na;i++)
	{
		if(map[i][x]!=-1 && tag[i]==0 && map[i][x]!=s1 && map[i][x]!=s2)
		{
			//cout<<x<<" "<<i<<"  ";
			tag[i]=1;
			road[p]=map[i][x];
			p++;
			bfs(i);
		}
	}
	return 0;
}
std::vector<int> find_roads(int N, std::vector<int> u, std::vector<int> v) {
	Na=N;
	long long int M=u.size();
	for(int i=0;i<Na;i++)
	{
		for(int j=0;j<Na;j++)map[i][j]=-1;
	}
	for(int i=0;i<M;i++)
	{
		map[u[i]][v[i]]=i;
		map[v[i]][u[i]]=i;
	}	
	for(int i=0;i<Na;i++)
	{
		int c=-1;
		for(int j=0;j<Na;j++)
		{
			if(map[i][j]!=-1)
			{
				//cout<<j<<endl;
				if(c==-1)
				{
					c=j;
					tmpans[i][0]=1;
					tmpans[i][1]=map[i][j];
				}
				else
				{
					for(int k=0;k<Na;k++)tag[k]=0;
					tag[c]=1;
					tag[i]=1;
					s1=map[i][c];
					s2=map[i][j];
					p=0;
					bfs(c);
					//cout<<endl;
					
					//cout<<endl;
					//for(int k=0;k<Na;k++)tmp+=tag[k];
					//cout<<tmp<<endl;
					if(tag[j]==1)
					{
						bfs(i);
						std::vector<int> r(Na - 1);
						for(int k=0;k<Na-1;k++)r[k]=road[k];
						for(int k=0;k<Na;k++)tag[k]=0;
						
						
						r[Na-2]=map[i][c];
						/*for(int k=0;k<Na;k++)
						{
							long long int t=r[k];
							//cout<<t<<" "<<u[t]<<" "<<v[t]<<"  ";
							tag[u[t]]++;
							tag[v[t]]++;
						}
						for(int k=0;k<Na;k++)
						{
							cout<<tag[k]<<" ";
							tag[k]=0;
						}
						cout<<endl;*/
						long long int a= count_common_roads(r);
						r[Na-2]=map[i][j];
						/*for(int k=0;k<Na;k++)
						{
							long long int t=r[k];
							//cout<<t<<" "<<u[t]<<" "<<v[t]<<"  ";
							tag[u[t]]++;
							tag[v[t]]++;
						}
						for(int k=0;k<Na;k++)
						{
							cout<<tag[k]<<" ";
							tag[k]=0;
						}
						cout<<endl;*/
						long long int b= count_common_roads(r);
						if(a==b)
						{
							tmpans[i][0]++;
							tmpans[i][tmpans[i][0]]=map[i][j];
						}
						else if(a<b)
						{
							tmpans[i][0]=1;
							tmpans[i][1]=map[i][j];
							c=j;
						}
					}
					else
					{
						tmpans[i][0]++;
						tmpans[i][tmpans[i][0]]=map[i][j];
					}
				}
			}
			//cout<<endl;
			//for(int k=1;k<=tmpans[i][0];k++)cout<<tmpans[i][k]<<" ";
			//cout<<endl;
		}
		//cout<<endl;
	}
	std::vector<int> r(Na - 1);
	//cout<<"can"<<endl;
 
	long long int p=0;
	for(int i=0;i<Na;i++)
	{
		//cout<<i<<endl;
		//cout<<tmpans[i][0]<<endl;
		for(int j=1;j<=tmpans[i][0];j++)
		{
			if(anstag[tmpans[i][j]]==0)
			{
				anstag[tmpans[i][j]]=1;
				r[p]=tmpans[i][j];	
				//cout<<r[p]<<" ";
				p++;
			}
		}
		//cout<<endl;
	}
	return r;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB correct
2 Correct 2 ms 384 KB correct
3 Correct 2 ms 384 KB correct
4 Correct 2 ms 384 KB correct
5 Correct 2 ms 384 KB correct
6 Correct 2 ms 384 KB correct
7 Correct 2 ms 384 KB correct
8 Correct 2 ms 256 KB correct
9 Correct 2 ms 384 KB correct
10 Correct 2 ms 384 KB correct
11 Correct 2 ms 384 KB correct
12 Correct 2 ms 384 KB correct
13 Correct 3 ms 384 KB correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB correct
2 Correct 2 ms 384 KB correct
3 Correct 2 ms 384 KB correct
4 Correct 2 ms 384 KB correct
5 Correct 2 ms 384 KB correct
6 Correct 2 ms 384 KB correct
7 Correct 2 ms 384 KB correct
8 Correct 2 ms 256 KB correct
9 Correct 2 ms 384 KB correct
10 Correct 2 ms 384 KB correct
11 Correct 2 ms 384 KB correct
12 Correct 2 ms 384 KB correct
13 Correct 3 ms 384 KB correct
14 Correct 15 ms 824 KB correct
15 Correct 15 ms 768 KB correct
16 Correct 15 ms 768 KB correct
17 Correct 16 ms 768 KB correct
18 Correct 8 ms 768 KB correct
19 Correct 16 ms 768 KB correct
20 Correct 15 ms 768 KB correct
21 Correct 16 ms 768 KB correct
22 Correct 11 ms 768 KB correct
23 Correct 9 ms 768 KB correct
24 Correct 9 ms 768 KB correct
25 Runtime error 5 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB correct
2 Correct 2 ms 384 KB correct
3 Correct 2 ms 384 KB correct
4 Correct 2 ms 384 KB correct
5 Correct 2 ms 384 KB correct
6 Correct 2 ms 384 KB correct
7 Correct 2 ms 384 KB correct
8 Correct 2 ms 256 KB correct
9 Correct 2 ms 384 KB correct
10 Correct 2 ms 384 KB correct
11 Correct 2 ms 384 KB correct
12 Correct 2 ms 384 KB correct
13 Correct 3 ms 384 KB correct
14 Correct 15 ms 824 KB correct
15 Correct 15 ms 768 KB correct
16 Correct 15 ms 768 KB correct
17 Correct 16 ms 768 KB correct
18 Correct 8 ms 768 KB correct
19 Correct 16 ms 768 KB correct
20 Correct 15 ms 768 KB correct
21 Correct 16 ms 768 KB correct
22 Correct 11 ms 768 KB correct
23 Correct 9 ms 768 KB correct
24 Correct 9 ms 768 KB correct
25 Runtime error 5 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB correct
2 Correct 2 ms 384 KB correct
3 Incorrect 1682 ms 4216 KB WA in grader: NO
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB correct
2 Correct 2 ms 384 KB correct
3 Correct 2 ms 384 KB correct
4 Correct 2 ms 384 KB correct
5 Correct 2 ms 384 KB correct
6 Correct 2 ms 384 KB correct
7 Correct 2 ms 384 KB correct
8 Correct 2 ms 256 KB correct
9 Correct 2 ms 384 KB correct
10 Correct 2 ms 384 KB correct
11 Correct 2 ms 384 KB correct
12 Correct 2 ms 384 KB correct
13 Correct 3 ms 384 KB correct
14 Correct 15 ms 824 KB correct
15 Correct 15 ms 768 KB correct
16 Correct 15 ms 768 KB correct
17 Correct 16 ms 768 KB correct
18 Correct 8 ms 768 KB correct
19 Correct 16 ms 768 KB correct
20 Correct 15 ms 768 KB correct
21 Correct 16 ms 768 KB correct
22 Correct 11 ms 768 KB correct
23 Correct 9 ms 768 KB correct
24 Correct 9 ms 768 KB correct
25 Runtime error 5 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Halted 0 ms 0 KB -