제출 #53862

#제출 시각아이디문제언어결과실행 시간메모리
53862baactreeFish (IOI08_fish)C++17
0 / 100
1039 ms31736 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll tree[1 << 20]; int sz = 1 << 19; int n, m, mod; pair<int, int> arr[500005]; vector<int> vec[500005]; bool chk[500005]; int t[500005]; void update(int idx, int val) { idx += sz; tree[idx] = val; idx /= 2; while (idx) { tree[idx] = tree[idx * 2] * tree[idx * 2 + 1] % mod; idx /= 2; } } ll query(int le, int ri) { le += sz; ri += sz; ll ret = 1; while (le <= ri) { if (le & 1)ret = ret * tree[le++] % mod; if (!(ri & 1))ret = ret * tree[ri--] % mod; le /= 2; ri /= 2; } return ret; } int main() { scanf("%d%d%d", &n, &m, &mod); for (int i = 0; i < n; i++) scanf("%d%d", &arr[i].first, &arr[i].second); sort(arr, arr + n); int cnt = 0; for (int i = n - 1; i >= 0; i--) { if (!chk[arr[i].second]) { t[arr[i].second] = ++cnt; chk[arr[i].second] = true; } } for (int i = 0; i < n; i++) { arr[i].second = t[arr[i].second]; vec[arr[i].second].push_back(i); } ll ans = 0; for (int i = 0; i < 500005; i++) tree[i + sz] = 1; for (int i = sz - 1; i; i--) tree[i] = tree[i * 2] * tree[i * 2 + 1] % mod; int idx = 0; int ri = 500004; for (int i = 0; i < n; i++) { while (arr[idx].first * 2 <= arr[i].first) { update(arr[idx].second, tree[arr[idx].second + sz] + 1); idx++; } if (vec[arr[i].second].back()==i) { ans = (ans + query(arr[i].second, 500004)) % mod; ll temp = tree[arr[idx].second + sz]; update(arr[idx].second, 1); int it = -1; for (auto x : vec[arr[i].second]) { if (arr[x].first > arr[i].first / 2) { it = x; break; } } int le = arr[it].first * 2; while (ri>=0&&(vec[ri].empty()||arr[vec[ri].back()].first < le))ri--; ans = (ans + query(ri + 1, 500004)) % mod; update(arr[idx].second, temp); } } printf("%lld\n", ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

fish.cpp: In function 'int main()':
fish.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &m, &mod);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
fish.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &arr[i].first, &arr[i].second);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...