Submission #570331

# Submission time Handle Problem Language Result Execution time Memory
570331 2022-05-29T08:45:45 Z 장태환(#8350) From Hacks to Snitches (BOI21_watchmen) C++17
0 / 100
88 ms 9444 KB
#include <bits/stdc++.h>
//If you have fancy wingsuit t you won in your national computer science competition, then you can make a living from prizes awarded at computer science competitions
using namespace std;
vector<int>link[300100];
int mint[300100];
int ce[300100];
vector<vector<int>>arr;
int main()
{
	int N, K;
	cin >> N >> K;
	int i;
	for (i = 0; i < K; i++)
	{
		int a, b;
		cin >> a >> b;
		link[a].push_back(b);
		link[b].push_back(a);
	}
	for (i = 1; i <= N; i++)
		link[i].push_back(i);
	queue<pair<int, int>>t;
	int g,M;
	cin >> g;
	for (i = 0; i < g; i++)
	{
		vector<int>Tr;
		cin >> M;
		while (M--)
		{
			int a;
			cin >> a;
			Tr.push_back(a);
		}
		arr.push_back(Tr);
	}
	t.push({ 1,0 });
	memset(mint, -1, sizeof(mint));
	mint[1] = 0;
	pair<int, int>rc = { 0,0 };
	while (t.size())
	{
		auto r = t.front();
		t.pop();
		int j;
		int ccd = 0;
		for (j = 0; j < link[r.first].size(); j++)
		{
			
			int n = link[r.first][j];
			if (n!=r.first&&mint[n] >= 0)
				continue;
			int k;
			for (k = 0; k < g; k++)
			{
				if (r.first == arr[k][r.second % arr[k].size()] || n == arr[k][(r.second + 1) % arr[k].size()] || n == arr[k][r.second % arr[k].size()] && r.first == arr[k][(r.second + 1) % arr[k].size()] )
					goto T;
			}
			if (j + 1 != link[r.first].size())
				ccd++;
			else
			{
				if (ccd)
					ce[r.first] = 0;
				else
					ce[r.first]++;
				if (ce[r.first] >= 400)
					break;
			}
			mint[n] = mint[r.first] + 1;
			t.push({ n,(r.second + 1)});
			T:
			int d;

		}
		
	}
	cout << "impossible";
}

Compilation message

watchmen.cpp: In function 'int main()':
watchmen.cpp:47:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for (j = 0; j < link[r.first].size(); j++)
      |               ~~^~~~~~~~~~~~~~~~~~~~~~
watchmen.cpp:56:141: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   56 |     if (r.first == arr[k][r.second % arr[k].size()] || n == arr[k][(r.second + 1) % arr[k].size()] || n == arr[k][r.second % arr[k].size()] && r.first == arr[k][(r.second + 1) % arr[k].size()] )
watchmen.cpp:59:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |    if (j + 1 != link[r.first].size())
      |        ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
watchmen.cpp:73:8: warning: unused variable 'd' [-Wunused-variable]
   73 |    int d;
      |        ^
watchmen.cpp:40:16: warning: variable 'rc' set but not used [-Wunused-but-set-variable]
   40 |  pair<int, int>rc = { 0,0 };
      |                ^~
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 9444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 9376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 9376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 9376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 9444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 9444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 9444 KB Output isn't correct
2 Halted 0 ms 0 KB -