이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int mxF = 5e5;
int f,k,m,cnt[mxF],ord[mxF],st[1<<20],ans;
vector<int> of_type[mxF];
void upd(int x, int v) {
st[x += k] = v%m;
for (; x/=2; ) st[x] = st[x*2]*st[x*2+1]%m;
}
int qry(int l, int r) {
int res = 1;
for (l += k, r += k; l < r; l/=2, r/=2) {
if (l&1) res=res*st[l++]%m;
if (r&1) res=res*st[--r]%m;
}
return res;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
fill(st, end(st), 1);
cin >> f >> k >> m;
vector<pii> fish(f);
for (int i = 0,l,x; i < f; ++i) {
cin >> l >> x;
x--;
of_type[x].push_back(l);
fish[i] = {l, x};
}
sort(fish.begin(), fish.end());
for (int x = 0; x < k; ++x) sort(of_type[x].begin(), of_type[x].end());
vector<pii> types(k);
for (int i = 0; i < k; ++i) {
types[i] = {of_type[i].back(), i};
}
sort(types.begin(), types.end());
for (int i = 0; i < k; ++i) ord[types[i].second] = i;
int smallest = 0;
for (auto [l,x]: types) {
while (fish[smallest].first <= l/2) {
cnt[fish[smallest].second]++;
upd(ord[fish[smallest].second], cnt[fish[smallest].second]+1);
smallest++;
}
int ltm = qry(0, ord[x]);
ans = (ans+(ltm*cnt[x]%m))%m;
int sm_of_type = *upper_bound(of_type[x].begin(), of_type[x].end(), l/2);
ans = (ans+(ltm*qry(ord[x]+1, lower_bound(types.begin(), types.end(), make_pair(2*sm_of_type,0))-types.begin())))%m;
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
fish.cpp: In function 'int main()':
fish.cpp:44:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
44 | for (auto [l,x]: types) {
| ^
# | 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... |