제출 #84162

#제출 시각아이디문제언어결과실행 시간메모리
84162nikolapesic2802무제 (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[tr][p]) { visited[tr][p]=1; visited[p][tr]=1; degree[tr]--; degree[p]--; solve(p); return; } } } void fastscan(int &number) { //variable to indicate sign of input number bool negative = false; register int c; number = 0; // extract current character from buffer c = getchar(); if (c=='-') { // number is negative negative = true; // extract the next character from the buffer c = getchar(); } // Keep on extracting characters if they are integers // i.e ASCII Value lies from '0'(48) to '9' (57) for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48; // if scanned input has a negative sign, negate the // value of the input number if (negative) number *= -1; } 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; } } 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; } #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[tr][p]) { visited[tr][p]=1; visited[p][tr]=1; degree[tr]--; degree[p]--; solve(p); return; } } } void fastscan(int &number) { //variable to indicate sign of input number bool negative = false; register int c; number = 0; // extract current character from buffer c = getchar(); if (c=='-') { // number is negative negative = true; // extract the next character from the buffer c = getchar(); } // Keep on extracting characters if they are integers // i.e ASCII Value lies from '0'(48) to '9' (57) for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48; // if scanned input has a negative sign, negate the // value of the input number if (negative) number *= -1; } 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; } } 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:117:29: warning: format '%i' expects argument of type 'int', but argument 2 has type 'std::vector<std::vector<int> >::size_type {aka long unsigned int}' [-Wformat=]
     printf("%i\n",sol.size());
                   ~~~~~~~~~~^
smi.cpp:120:32: warning: format '%i' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
         printf("%i ",p.size()-1);
                      ~~~~~~~~~~^
smi.cpp: At global scope:
smi.cpp:141:11: error: redefinition of 'const int N'
 const int N=1e5+5;
           ^
smi.cpp:7:11: note: 'const int N' previously defined here
 const int N=1e5+5;
           ^
smi.cpp:142:21: error: redefinition of 'std::vector<int> degree'
 vector<int> degree(N);
                     ^
smi.cpp:8:13: note: 'std::vector<int> degree' previously declared here
 vector<int> degree(N);
             ^~~~~~
smi.cpp:143:28: error: redefinition of 'std::vector<std::vector<int> > graf'
 vector<vector<int> > graf(N);
                            ^
smi.cpp:9:22: note: 'std::vector<std::vector<int> > graf' previously declared here
 vector<vector<int> > graf(N);
                      ^~~~
smi.cpp:144:33: error: redefinition of 'std::unordered_map<int, int> visited [100005]'
 unordered_map<int,int> visited[N];
                                 ^
smi.cpp:10:24: note: 'std::unordered_map<int, int> visited [100005]' previously declared here
 unordered_map<int,int> visited[N];
                        ^~~~~~~
smi.cpp:145:22: error: redefinition of 'std::vector<std::vector<int> > sol'
 vector<vector<int> > sol;
                      ^~~
smi.cpp:11:22: note: 'std::vector<std::vector<int> > sol' previously declared here
 vector<vector<int> > sol;
                      ^~~
smi.cpp:146:12: error: redefinition of 'std::stack<int> stk'
 stack<int> stk;
            ^~~
smi.cpp:12:12: note: 'std::stack<int> stk' previously declared here
 stack<int> stk;
            ^~~
smi.cpp:147:18: error: redefinition of 'std::vector<int> vis'
 vector<int> vis(N);
                  ^
smi.cpp:13:13: note: 'std::vector<int> vis' previously declared here
 vector<int> vis(N);
             ^~~
smi.cpp: In function 'void solve(int)':
smi.cpp:148:6: error: redefinition of 'void solve(int)'
 void solve(int tr)
      ^~~~~
smi.cpp:14:6: note: 'void solve(int)' previously defined here
 void solve(int tr)
      ^~~~~
smi.cpp: In function 'void fastscan(int&)':
smi.cpp:181:6: error: redefinition of 'void fastscan(int&)'
 void fastscan(int &number)
      ^~~~~~~~
smi.cpp:47:6: note: 'void fastscan(int&)' previously defined here
 void fastscan(int &number)
      ^~~~~~~~
smi.cpp: In function 'int main()':
smi.cpp:210:5: error: redefinition of 'int main()'
 int main()
     ^~~~
smi.cpp:76:5: note: 'int main()' previously defined here
 int main()
     ^~~~
smi.cpp:251:29: warning: format '%i' expects argument of type 'int', but argument 2 has type 'std::vector<std::vector<int> >::size_type {aka long unsigned int}' [-Wformat=]
     printf("%i\n",sol.size());
                   ~~~~~~~~~~^
smi.cpp:254:32: warning: format '%i' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
         printf("%i ",p.size()-1);
                      ~~~~~~~~~~^