Submission #134150

#TimeUsernameProblemLanguageResultExecution timeMemory
134150ckodserTeams (IOI15_teams)C++14
0 / 100
4091 ms10008 KiB
#include "teams.h" #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> #endif int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);} #define ll int #define pb push_back #define ld long double #define mp make_pair #define F first #define S second #define pii pair<ll,ll> using namespace :: std; const ll maxn=1e5+500; const ll inf=1e9+800; const ll mod=1e9+7; const ll maxm=1e5+500; const ll sq=700; ll n; ll a[maxn]; ll b[maxn]; void init(int N, int A[], int B[]) { n=N; for(ll i=0;i<N;i++){ a[i]=A[i]; b[i]=B[i]; } } ll ger[sq][sq]; void makeGer(ll m,ll k[]){ memset(ger,0,sizeof ger); for(ll i=0;i<n;i++){ ll l=lower_bound(k,k+m,a[i])-k; ll r=upper_bound(k,k+m,b[i])-k-1; for(ll x=l;x<=r;x++){ for(ll y=x;y<=r;y++){ ger[x][y]++; } } } for(ll t=m;t>=1;t--){ for(ll l=0;l+t-1<m;l++){ ll r=l+t-1; if(l!=0){ ger[l][r]-=ger[l-1][r]; } if(r!=m-1){ ger[l][r]-=ger[l][r+1]; } if(l!=0 && r!=m-1){ ger[l][r]+=ger[l-1][r+1]; } } } } ll comp[maxm]; ll tmp[sq]; ll gri[sq]; int can(int m, int k[]) { sort(k,k+m); memset(gri,0,sizeof gri); memset(tmp,0,sizeof tmp); for(ll i=0;i<m;i++){ comp[i]=(k[i]); } ll sz=unique(comp,comp+m)-comp; makeGer(sz,comp); for(ll i=0;i<m;i++){ tmp[lower_bound(comp,comp+sz,k[i])-comp]++; } for(ll i=0;i<sz;i++){ comp[i]*=tmp[i]; } for(ll i=0;i<sz;i++){ for(ll j=i;j<sz;j++){ gri[j]+=ger[i][j]; } for(ll j=i;j<sz && 0<comp[i];j++){ ll res=min(comp[i],gri[j]); comp[i]-=res; gri[j]-=res; } if(comp[i])return 0; } return 1; }

Compilation message (stderr)

teams.cpp: In function 'void makeGer(int, int*)':
teams.cpp:90:31: warning: conversion to 'int' from 'long int' may alter its value [-Wconversion]
   ll l=lower_bound(k,k+m,a[i])-k;
        ~~~~~~~~~~~~~~~~~~~~~~~^~
teams.cpp:91:33: warning: conversion to 'int' from 'long int' may alter its value [-Wconversion]
   ll r=upper_bound(k,k+m,b[i])-k-1;
        ~~~~~~~~~~~~~~~~~~~~~~~~~^~
teams.cpp: In function 'int can(int, int*)':
teams.cpp:123:27: warning: conversion to 'int' from 'long int' may alter its value [-Wconversion]
  ll sz=unique(comp,comp+m)-comp;
        ~~~~~~~~~~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...