제출 #798811

#제출 시각아이디문제언어결과실행 시간메모리
798811tlnk07Cijanobakterije (COCI21_cijanobakterije)C++17
0 / 70
41 ms336 KiB
#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 << cnt; }

컴파일 시 표준 에러 (stderr) 메시지

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 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...