# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
776499 | 2023-07-08T02:48:25 Z | jamezzz | Fish (IOI08_fish) | C++17 | 280 ms | 65536 KB |
#include <bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define fi first #define se second #define pb push_back #define sz(x) ((int)x.size()) #define all(x) x.begin(),x.end() #define LINF 1023456789123456789 typedef long long ll; typedef pair<int,int> ii; typedef pair<ll,int> li; #define maxn 500005 #define maxk 7005 int n,k,m,cnt[maxk],bad[maxk],num[maxk][maxk],mn[maxn]; vector<ii> v; int main(){ sf("%d%d%d",&n,&k,&m); for(int i=0;i<n;++i){ int l,c; sf("%d%d",&l,&c); v.pb({l,c}); ++cnt[c]; } sort(all(v)); int ptr=n-1; int ans=0; fill(mn,mn+n+1,1); for(int i=n-1;i>=0;--i){ if(bad[v[i].se])continue; while(ptr>=0&&v[i].fi<2*v[ptr].fi){ --cnt[v[ptr].se]; --ptr; } for(int j=1;j<=k;++j){ if(v[i].se==j)continue; if(!bad[j]){ mn[1]*=(cnt[j]+1); mn[1]%=m; } else if(cnt[j]!=0&&num[v[i].se][j]<=cnt[v[i].se]+1){ mn[num[v[i].se][j]+1]*=2; mn[num[v[i].se][j]+1]%=m; } } int add=1; for(int j=1;j<=cnt[v[i].se]+1;++j){ add*=mn[j]; add%=m; ans+=add; ans%=m; } for(int j=1;j<=k;++j){ if(v[i].se==j)continue; if(!bad[j])mn[1]=1; else if(cnt[j]!=0&&num[v[i].se][j]<=cnt[v[i].se]+1)mn[num[v[i].se][j]+1]=1; } for(int j=1;j<=k;++j){ num[j][v[i].se]=cnt[j]; } bad[v[i].se]=1; } pf("%d\n",ans); } /* 5 3 7 2 2 5 2 8 3 4 1 2 3 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 109 ms | 6264 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 724 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 596 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 44 ms | 3916 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 57 ms | 25020 KB | Output is correct |
2 | Incorrect | 16 ms | 8424 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 120 ms | 20868 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 162 ms | 29984 KB | Output is correct |
2 | Incorrect | 257 ms | 53292 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 280 ms | 65536 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 396 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 372 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 376 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 340 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 408 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 384 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |