제출 #30144

#제출 시각아이디문제언어결과실행 시간메모리
30144gs14004무제 (POI11_smi)C++14
60 / 100
3000 ms119268 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lint; typedef long double llf; typedef pair<int, int> pi; const int MAXN = 100005; int n, m; set<int> gph[MAXN]; vector<vector<int>> pth; vector<int> lis; void dfs(int x){ lis.push_back(x); if(gph[x].empty()) return; int nxt = *gph[x].begin(); gph[x].erase(nxt); gph[nxt].erase(x); dfs(nxt); } bool instk[MAXN]; int main(){ scanf("%d %d",&n,&m); for(int i=0; i<m; i++){ int s, e, x, y; scanf("%d %d %d %d",&s,&e,&x,&y); if(x == y) continue; gph[s].insert(e); gph[e].insert(s); } for(int i=1; i<=n; i++){ if(gph[i].size() & 1){ puts("NIE"); return 0; } } for(int i=1; i<=n; i++){ if(gph[i].empty()) continue; lis.clear(); dfs(i); stack<int> stk; for(auto &i : lis){ if(instk[i]){ vector<int> v = {i}; while(!stk.empty() && stk.top() != i){ v.push_back(stk.top()); instk[stk.top()] = 0; stk.pop(); } v.push_back(i); pth.push_back(v); } else{ stk.push(i); instk[i] = 1; } } } printf("%d\n", pth.size()); for(auto &i : pth){ printf("%d ", i.size() - 1); for(auto &j : i) printf("%d ", j); puts(""); } }

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

smi.cpp: In function 'int main()':
smi.cpp:61:27: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<std::vector<int> >::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n", pth.size());
                           ^
smi.cpp:63:29: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
   printf("%d ", i.size() - 1);
                             ^
smi.cpp:25:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
                      ^
smi.cpp:28:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d",&s,&e,&x,&y);
                                   ^
#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...
#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...