Submission #84152

#TimeUsernameProblemLanguageResultExecution timeMemory
84152nikolapesic2802Untitled (POI11_smi)C++14
20 / 100
3060 ms214336 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); map<int,int> visited[N]; vector<vector<int> > sol; stack<int> stk; void solve(int tr) { //printf("Usao za %i\n",tr); stk.push(tr); if(degree[tr]%2==0&&stk.size()>1) { vector<int> t; t.pb(tr); stk.pop(); while(stk.top()!=tr) { t.pb(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; } } } int main() { int n,m; scanf("%i %i",&n,&m); for(int i=0;i<m;i++) { int a,b,s,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); } } printf("%i\n",sol.size()); for(auto p:sol) { printf("%i ",p.size()-1); for(auto d:p) { printf("%i ",d); } printf("\n"); } return 0; }

Compilation message (stderr)

smi.cpp: In function 'int main()':
smi.cpp:77: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:80: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:46:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i %i",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~
smi.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i %i %i %i",&a,&b,&s,&t);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...