답안 #798810

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
798810 2023-07-31T04:35:51 Z tlnk07 Cijanobakterije (COCI21_cijanobakterije) C++17
0 / 70
42 ms 372 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;
		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 << cnt;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:25:20: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   25 |   else if(cnt1 > 1 && cnt2 == 1 || cnt2 > 1 && cnt1 == 1) cout << 5;
      |           ~~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -