Submission #341167

#TimeUsernameProblemLanguageResultExecution timeMemory
341167beksultan04Marriage questions (IZhO14_marriage)C++14
22 / 100
1598 ms6252 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define OK puts("OK"); #define NO puts("NO"); #define YES puts("YES"); #define fr first #define sc second #define ret return #define scanl(a) scanf("%lld",&a); #define scanll(a,b) scanf("%lld %lld",&a, &b); #define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define scan1(a) scanf("%d",&a); #define scan2(a,b) scanf("%d %d",&a, &b); #define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c); #define all(s) s.begin(),s.end() #define allr(s) s.rbegin(),s.rend() #define pb push_back #define sz(v) (int)v.size() #define endi puts(""); #define eps 1e-12 const int N = 1e5+12; const ll INF=1e15+7; vector <int> g[N]; int vis[N],m,n,ans,l; bool is(){ int i; for (i=1;i<=m;++i){ if (vis[i]==0)ret 0; } ret 1; } set<pii> s; void dfs(int x){ if (is()){ s.insert({l,x}); } if (x > n)ret ; int i; for (i=0;i<g[x].size();++i){ vis[g[x][i]]++; dfs(x+1); vis[g[x][i]]--; } } main(){ int i,k,j; scan3(n,m,k) while (k-- ){ int x,y; scan2(x,y) g[x].pb(y); } for (i=1;i<=n;++i){ l=i; dfs(i); } cout <<s.size(); }

Compilation message (stderr)

marriage.cpp: In function 'void dfs(int)':
marriage.cpp:42:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for (i=0;i<g[x].size();++i){
      |              ~^~~~~~~~~~~~
marriage.cpp: At global scope:
marriage.cpp:50:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main(){
      |      ^
marriage.cpp: In function 'int main()':
marriage.cpp:51:13: warning: unused variable 'j' [-Wunused-variable]
   51 |     int i,k,j;
      |             ^
marriage.cpp:16:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 | #define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~
marriage.cpp:52:5: note: in expansion of macro 'scan3'
   52 |     scan3(n,m,k)
      |     ^~~~~
marriage.cpp:15:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 | #define scan2(a,b) scanf("%d %d",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~
marriage.cpp:55:9: note: in expansion of macro 'scan2'
   55 |         scan2(x,y)
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...