제출 #84165

#제출 시각아이디문제언어결과실행 시간메모리
84165nikolapesic2802무제 (POI11_smi)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int N=1e5+5; vector<int> degree(N); vector<vector<int> > graf(N); unordered_map<int,int> visited[N]; vector<vector<int> > sol; stack<int> stk; vector<int> vis(N); void solve(int tr) { //printf("Usao za %i\n",tr); vis[tr]++; stk.push(tr); if(vis[tr]==2) { vector<int> t; t.pb(tr); vis[tr]--; stk.pop(); while(stk.top()!=tr) { t.pb(stk.top()); vis[stk.top()]--; stk.pop(); } t.pb(stk.top()); sol.pb(t); } for(auto p:graf[tr]) { if(!visited[min(tr,p)][max(tr,p)]) { visited[min(tr,p)][max(tr,p)]=1; degree[tr]--; degree[p]--; solve(p); return; } } } void fastscan(int &number) { register int c; number = 0; c = getchar(); for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48; } int main() { int n,m; //scanf("%i %i",&n,&m); fastscan(n); fastscan(m); for(int i=0;i<m;i++) { int a,b,s,t; fastscan(a); fastscan(b); fastscan(s); fastscan(t); //scanf("%i %i %i %i",&a,&b,&s,&t); if(s!=t) { graf[a].pb(b); graf[b].pb(a); degree[a]++; degree[b]++; //printf("Dodajem iz %i u %i\n",a,b); } } for(int i=1;i<=n;i++) { if(degree[i]%2==1) { printf("NIE\n"); return 0; } }int n,m; //scanf("%i %i",&n,&m); fastscan(n); fastscan(m); for(int i=0;i<m;i++) { int a,b,s,t; fastscan(a); fastscan(b); fastscan(s); fastscan(t); //scanf("%i %i %i %i",&a,&b,&s,&t); if(s!=t) { graf[a].pb(b); graf[b].pb(a); degree[a]++; degree[b]++; //printf("Dodajem iz %i u %i\n",a,b); } } for(int i=1;i<=n;i++) { if(degree[i]%2==1) { printf("NIE\n"); return 0; } } for(int i=1;i<=n;i++) { while(degree[i]!=0) { while(stk.size()) stk.pop(); solve(i); vis[i]--; } } //printf("%i\n",sol.size()); for(auto p:sol) { //printf("%i ",p.size()-1); set<int> v; for(auto d:p) { if(v.count(d)&&d!=p[0]) { //assert(false); } v.insert(d); //printf("%i ",d); } //printf("\n"); } return 0; }

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

smi.cpp: In function 'int main()':
smi.cpp:84:10: error: redeclaration of 'int n'
     }int n,m;
          ^
smi.cpp:56:9: note: 'int n' previously declared here
     int n,m;
         ^
smi.cpp:84:12: error: redeclaration of 'int m'
     }int n,m;
            ^
smi.cpp:56:11: note: 'int m' previously declared here
     int n,m;
           ^