제출 #1111110

#제출 시각아이디문제언어결과실행 시간메모리
1111110huantranCijanobakterije (COCI21_cijanobakterije)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long int; const int maxn = 2e5 + 5; const int oo = 1e9 + 7; const ll inf = 1e18; int n, m; int dis[maxn], ans, vs[maxn]; int vertex; vector<int> adj[maxn]; void bfs(int u) { for (int i = 1; i <= n; i++) dis[i] = oo; dis[u] = 0; queue<int> q; q.push(u); while (!q.empty()) { int v = q.front(); q.pop(); vs[v] = 1; for (auto j : adj[v]) { if (dis[j] > dis[v] + 1) { dis[j] = dis[v] + 1; ans = max(ans, dis[j]); vertex = j; q.push(j); } } } } int solve(int u) { ans = 0; bfs(u); bfs(vertex); return ans; } int main() {} ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> n >> m; for (int i = 1; i <= m; i++) { int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } int res = 0; int cnt = 0; for (int i = 1; i <= n; i++) { if (!vs[i]) res += solve(i), cnt++; } cout << res + 1; }

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

Main.cpp:47:30: error: expected constructor, destructor, or type conversion before '(' token
   47 |     ios_base::sync_with_stdio(0);
      |                              ^
Main.cpp:48:5: error: 'cin' does not name a type; did you mean 'sin'?
   48 |     cin.tie(0), cout.tie(0);
      |     ^~~
      |     sin
Main.cpp:50:5: error: 'cin' does not name a type; did you mean 'sin'?
   50 |     cin >> n >> m;
      |     ^~~
      |     sin
Main.cpp:51:5: error: expected unqualified-id before 'for'
   51 |     for (int i = 1; i <= m; i++) {
      |     ^~~
Main.cpp:51:21: error: 'i' does not name a type
   51 |     for (int i = 1; i <= m; i++) {
      |                     ^
Main.cpp:51:29: error: 'i' does not name a type
   51 |     for (int i = 1; i <= m; i++) {
      |                             ^
Main.cpp:60:5: error: expected unqualified-id before 'for'
   60 |     for (int i = 1; i <= n; i++) {
      |     ^~~
Main.cpp:60:21: error: 'i' does not name a type
   60 |     for (int i = 1; i <= n; i++) {
      |                     ^
Main.cpp:60:29: error: 'i' does not name a type
   60 |     for (int i = 1; i <= n; i++) {
      |                             ^
Main.cpp:65:5: error: 'cout' does not name a type
   65 |     cout << res + 1;
      |     ^~~~
Main.cpp:66:1: error: expected declaration before '}' token
   66 | }
      | ^