제출 #1065344

#제출 시각아이디문제언어결과실행 시간메모리
1065344Mr_Husanboy친구 (IOI14_friend)C++17
컴파일 에러
0 ms0 KiB
#include "friend.h" #include<vector> #include <algorithm> #include <iostream> using namespace std; // Find out best sample vector<vector<int>> g; vector<int> vis, col, mt; void paint(int i, int c){ col[i] = c; for(auto u : g[i]){ if(col[u]) {assert(col[u] == -c); continue;} paint(u, -c); } } bool kuhn(int i){ if(vis[i]) return false; vis[i] = 1; for(auto u : g[i]){ if(mt[u] == -1 || kuhn(mt[u])){ mt[u] = i; return true; } } return false; } int findSample(int n,int confidence[],int host[],int protocol[]){ g.resize(n); col.resize(n); mt.assign(n, -1); for(int i = 1; i < n; i ++){ if(protocol[i] == 0){ g[host[i]].push_back(i); g[i].push_back(host[i]); } if(protocol[i] == 1){ for(auto u : g[host[i]]){ g[u].push_back(i); g[i].push_back(u); } } } for(int i = 0; i < n; i ++){ if(!col[i]) paint(i, 1); } for(int i = 0; i < n; i ++){ if(col[i] != 1) continue; for(auto u : g[i]){ if(mt[u] == -1){ mt[u] = i; break; } } } for(int i = 0; i < n; i ++){ if(col[i] != 1) continue; vis.assign(n, 0); kuhn(i); } int ans = n; for(int i = 0; i < n; i ++){ if(mt[i] != -1) ans --; } return ans; }

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

friend.cpp: In function 'void paint(int, int)':
friend.cpp:17:15: error: 'assert' was not declared in this scope
   17 |   if(col[u]) {assert(col[u] == -c); continue;}
      |               ^~~~~~
friend.cpp:5:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    4 | #include <iostream>
  +++ |+#include <cassert>
    5 | using namespace std;