제출 #790401

#제출 시각아이디문제언어결과실행 시간메모리
790401bane어르신 집배원 (BOI14_postmen)C++17
컴파일 에러
0 ms0 KiB
#include<cstdio> #include<vector> #include<stack> #include<set> using namespace std; #ifdef LOCAL #include "algo/debug.h" #else #define debug(...) 42 #endif #define fr first #define sc second #define mp make_pair #define pb push_back #define pf push_front #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(), x.rend() using ll = long long; using ull = unsigned long long; using pii = pair<int,int>; using pll = pair<long long, long long>; const int nax = 200010; vector<int>flag(nax); multiset<int>adj[nax]; vector<int>pracka; void Euler(int v){ while(adj[v].size() > 0){ int x = *adj[v].begin(); adj[v].erase(adj[v].find(x)); adj[x].erase(adj[x].find(v)); Euler(x); } pracka.pb(v); } void solve(){ int n, m; scanf("%d%d",&n,&m); for (int i = 0; i < m; i++){ int a,b; scanf("%d%d",&a,&b); --a,--b; adj[a].insert(b); adj[b].insert(a); } Euler(0); int r = -1; vector<vector<int>>cycles; vector<int>visited(n + 1); stack<int>c; while(r < (int)pracka.size()){ ++r; if (visited[pracka[r]]){ cycles.push_back(vector<int>()); cycles.back().push_back(pracka[r]); while(c.top() != pracka[r]){ visited[c.top()] = 0; cycles.back().push_back(c.top()); c.pop(); } }else{ c.push(pracka[r]); visited[pracka[r]] = 1; } } for (int i = 0; i < (int)cycles.size() - 1; i++){ for (int j : cycles[i])printf("%d ", j + 1); printf("\n"); } } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; }

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

postmen.cpp: In function 'int main()':
postmen.cpp:78:6: error: 'ios' has not been declared
   78 |      ios::sync_with_stdio(0);
      |      ^~~
postmen.cpp:79:6: error: 'cin' was not declared in this scope
   79 |      cin.tie(0);
      |      ^~~
postmen.cpp:5:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    4 |  #include<set>
  +++ |+#include <iostream>
    5 |     using namespace std;
postmen.cpp:80:3: error: 'cout' was not declared in this scope
   80 |   cout.tie(0);
      |   ^~~~
postmen.cpp:80:3: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
postmen.cpp: In function 'void solve()':
postmen.cpp:43:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |      scanf("%d%d",&n,&m);
      |      ~~~~~^~~~~~~~~~~~~~
postmen.cpp:46:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |       scanf("%d%d",&a,&b);
      |       ~~~~~^~~~~~~~~~~~~~