제출 #205095

#제출 시각아이디문제언어결과실행 시간메모리
205095Leonardo_PaesFish (IOI08_fish)C++17
0 / 100
3086 ms31608 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int,int> pii; #define f first #define s second const int maxn = 5e5+10, maxk = 30; int qtd[maxn][maxk], mark[maxk]; int32_t main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int n, k, m; cin >> n >> k >> m; vector<pii> v(n+1); vector<int> ans(n+1); for(int i=1; i<=n; i++){ cin >> v[i].f >> v[i].s; } sort(v.begin(), v.end()); for(int i=1; i<=n; i++){ ans[i] = 1; qtd[i][v[i].s]++; memset(mark, 0, sizeof mark); mark[v[i].s] = 1; for(int j=1; j<i; j++){ if(!mark[v[j].s] and v[i].f >= v[j].f + v[j].f){ mark[v[j].s] = 1; ans[i] = (ans[i] + ans[j] - qtd[j][v[i].s] + 1 + m)%m; for(int q=1; q<=k; q++){ qtd[i][q] += qtd[j][q]; } } } //cout << ans[i] << " " << qtd[i][v[i].s] << "\n"; } cout << ans[n] << "\n"; return 0; }
#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...