Submission #386997

#TimeUsernameProblemLanguageResultExecution timeMemory
386997achibasadzishviliFish (IOI08_fish)C++17
0 / 100
3102 ms43940 KiB
#include<bits/stdc++.h> #define ll long long #define f first #define s second #define pb push_back #define mp make_pair using namespace std; ll ans; ll n,k,mod,l[500005]; vector<ll>v[500005],t[500005]; int main(){ ios::sync_with_stdio(false); cin >> n >> k >> mod; for(int i=1; i<=n; i++){ ll x,y; cin >> x >> y; v[y].pb(x); } vector<pair<ll,ll> >g; for(int i=1; i<=k; i++){ sort(v[i].begin() , v[i].end()); if(v[i].size()){ g.pb(mp(v[i][v[i].size() - 1] , i)); } } sort(g.begin() , g.end()); for(int i=0; i<g.size(); i++){ ll ind = g[i].s; t[i] = v[ind]; } for(int i=0; i<=k; i++){ v[i] = t[i]; } for(int i=0; i<=k; i++){ if(v[i].size() == 0)continue; ll mx = v[i][(int)v[i].size() - 1],cur = 1; for(int j=0; j<=i; j++){ while(l[j] != v[j].size() && v[j][l[j]] * 2 <= mx){ l[j]++; } cur = (cur * (l[j] + 1)) % mod; } ans = (ans + cur) % mod; } cout << ans << '\n'; return 0; }

Compilation message (stderr)

fish.cpp: In function 'int main()':
fish.cpp:31:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=0; i<g.size(); i++){
      |                  ~^~~~~~~~~
fish.cpp:44:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             while(l[j] != v[j].size() && v[j][l[j]] * 2 <= mx){
      |                   ~~~~~^~~~~~~~~~~~~~
#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...
#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...