제출 #39035

#제출 시각아이디문제언어결과실행 시간메모리
39035Scayre결혼 문제 (IZhO14_marriage)C++14
12 / 100
1500 ms26676 KiB
// // omae wa mou shindeiru. // #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx") #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <string> #include <bitset> #include <cstdio> #include <limits> #include <vector> #include <climits> #include <cstring> #include <cstdlib> #include <fstream> #include <numeric> #include <sstream> #include <cassert> #include <iomanip> #include <iostream> #include <algorithm> #define ll long long #define ull unsigned ll #define ioi exit(0); #define f first #define s second #define inf (int)1e9 + 7 #define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0); #define mp make_pair #define lb(x) lower_bound(x) #define ub(x) upper_bound(x) #define pb push_back #define ppb pop_back #define endl "\n" #define in(x) insert(x) #define sz(x) (int)x.size() #define all(x) x.begin(),x.end() #define pw2(x) (1<<x) //2^x #define sqr(x) ((x) * 1ll * (x)) using namespace std; const int N = (int)1e6 + 7, MOD = (int)1e9 + 7; int n,k,m; vector <int> a[N]; bool ok=0; map <int,int> mpp; ll ans,res; set <int> s; void calc(int pos,int cnt){ if(s.size()==m){ ans=max(ans,(ll)n-pos+1); return; } for(int i=0;i<a[pos].size();i++){ s.insert(a[pos][i]); mpp[a[pos][i]]=cnt; calc(pos+1,cnt+1); for(auto it=s.begin();it!=s.end();it++){ int z=*it; if(mpp[z]>cnt){ s.erase(it); } } } } int main(){ #ifdef IOI2019 freopen ("in.txt", "r", stdin); #endif NFS cin >> n >> m >> k; for(int i=1;i<=k;i++){ int x,y; cin >> x >> y; a[x].pb(y); } for(int i=1;i<=n;i++){ ok=0; calc(i,1); res+=ans; if(ans==0){ break; } s.clear(); } cout << ans << endl; #ifdef IOI2019 cout << "\nTime Elapsed : " << clock () * 1.0 / CLOCKS_PER_SEC << endl; #endif ioi }

컴파일 시 표준 에러 (stderr) 메시지

marriage.cpp: In function 'void calc(int, int)':
marriage.cpp:80:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(s.size()==m){
             ^
marriage.cpp:84:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<a[pos].size();i++){
               ^
#Verdict Execution timeMemoryGrader output
Fetching results...