Submission #798813

# Submission time Handle Problem Language Result Execution time Memory
798813 2023-07-31T04:37:00 Z tlnk07 Cijanobakterije (COCI21_cijanobakterije) C++17
6 / 70
38 ms 344 KB
#include<bits/stdc++.h>
using namespace std;
 
long long n, chk = 0, m, cnt = 0, x, y, cnt1 = 0, cnt2 = 0;
bool check[100001];
 
int main()
{
	cin >> n >> m;
	if(n == 1)
	{
		cout << 1;
		return 0;
	}
	for(int i = 1; i <= n; ++i)
	{
		cin >> x >> y;
		if(x > 2)	chk = 1;
		if(!check[x])	++cnt;
		if(!check[y])	++cnt;
		if(x == 1 && !check[y] && y != 2)	++cnt1;
		else if(x == 2 && !check[y] && y != 1)	++cnt2;
		check[x] = check[y] = true;
	}
	if(!chk)
	{
		if(cnt1 > 1 && cnt2 > 1)	cout << 6;
		else if(cnt1 > 1 && cnt2 == 1 || cnt2 > 1 && cnt1 == 1)	cout << 5;
		else if(cnt1 == 0)
		{
			if(cnt2 > 1)	cout << 4;
			else if(cnt2 == 1)	cout << 3;
			else	cout << 2;
		}
		else if(cnt2 == 0)
		{
			if(cnt1 > 1)	cout << 4;
			else if(cnt2 == 1)	cout << 3;
			else	cout << 2;
		}
	}
	else	cout << n;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:28:20: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   28 |   else if(cnt1 > 1 && cnt2 == 1 || cnt2 > 1 && cnt1 == 1) cout << 5;
      |           ~~~~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 38 ms 344 KB Output is correct
2 Correct 4 ms 212 KB Output is correct
3 Correct 7 ms 340 KB Output is correct
4 Correct 12 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -