Submission #341258

#TimeUsernameProblemLanguageResultExecution timeMemory
341258juggernautMarriage questions (IZhO14_marriage)C++14
0 / 100
1 ms492 KiB
#include<bits/stdc++.h> using namespace std; int n,m,qq,mt[30005],GL,GR,vis[2005],timer; vector<int>g[2005]; queue<int>q; bool kuhn(int v){ if(vis[v]==timer)return false; vis[v]=timer; for(int to:g[v]){ if(to<GL||to>GR)continue; if(!mt[to]||kuhn(mt[to])){ mt[to]=v; return true; } } return false; } bool check(){ while(!q.empty()){ int v=q.front(); q.pop(); timer++; if(!kuhn(v)){ q.push(v); return false; } } return true; } int main(){vector<int>v={1,2,3,4,5,6,7,8,9}; srand(time(NULL)); vector<int>v1=v; random_shuffle(v.begin(),v.end()); for(int i=0;i<9;i++)if(v[i]!=v1[i]){ puts("SHUFFLE WORKS"); return 0; } scanf("%d%d%d",&n,&m,&qq); while(qq--){ int x,y; scanf("%d%d",&x,&y); g[y].push_back(x); } for(int i=1;i<=m;i++)q.push(i); int ans=0; GR=1; for(GL=1;GL<=n;GL++){ while(GR<=n&&!check())GR++; ans+=n-GR+1; if(mt[GL]){ q.push(mt[GL]); mt[GL]=0; } } cout<<ans; }

Compilation message (stderr)

marriage.cpp: In function 'int main()':
marriage.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   38 |     scanf("%d%d%d",&n,&m,&qq);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
marriage.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   41 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...