Submission #42733

#TimeUsernameProblemLanguageResultExecution timeMemory
42733AryanSMPlaninarenje (COCI18_planinarenje)C++14
160 / 160
11 ms6568 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define mp make_pair #define pb push_back #define pii pair<int,int> #define F first #define S second int const M=2e5+10; int match[M],match2[M]; vector<int>adj[M]; bool good[M],mark[M]; bool dfs(int v) { mark[v]=1; for(int i=0;i<adj[v].size();i++) { int u=adj[v][i]; if(!match[u] || (!mark[match[u]] && dfs(match[u]))) { match[u]=v; match2[v]=u; return 1; } } return 0; } void dfs_check(int v) { good[v]=1; for(int i=0;i<adj[v].size();i++) { int u=adj[v][i]; if(!good[match[u]])dfs_check(match[u]); } } main() { int n,m; cin>>n>>m; for(int i=1;i<=m;i++) { int a,b; cin>>a>>b; adj[a].pb(b); } while(true) { bool fin=0; for(int i=1;i<=n;i++)mark[i]=0; for(int i=1;i<=n;i++) { if(!mark[i] && !match2[i]) { if(dfs(i))fin=1; } } if(!fin)break; } for(int i=1;i<=n;i++) { if(!match2[i])dfs_check(i); } for(int i=1;i<=n;i++) { if(!good[i])cout<<"Slavko"; else cout<<"Mirko"; cout<<"\n"; } }

Compilation message (stderr)

planinarenje.cpp: In function 'bool dfs(long long int)':
planinarenje.cpp:16:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<adj[v].size();i++)
               ^
planinarenje.cpp: In function 'void dfs_check(long long int)':
planinarenje.cpp:31:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<adj[v].size();i++)
               ^
planinarenje.cpp: At global scope:
planinarenje.cpp:37:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#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...