# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
776517 | jamezzz | Fish (IOI08_fish) | C++17 | 266 ms | 65536 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
#ifndef DEBUG
mn[1]%=m;
#endif
}
else if(cnt[j]!=0&&num[v[i].se][j]<=cnt[v[i].se]+1){
mn[num[v[i].se][j]+1]*=(cnt[j]+1);
#ifndef DEBUG
mn[num[v[i].se][j]+1]%=m;
#endif
}
}
int add=1;
for(int j=1;j<=cnt[v[i].se]+1;++j){
add*=mn[j];
#ifndef DEBUG
add%=m;
#endif
ans+=add;
#ifndef DEBUG
ans%=m;
#endif
}
for(int j=1;j<=k;++j){
mn[1]=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
4 1
8 3
4 1
2 3
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |