제출 #923221

#제출 시각아이디문제언어결과실행 시간메모리
923221math_rabbit_1028Fish (IOI08_fish)C++14
80 / 100
3054 ms25940 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; int n, k, MOD; vector<int> vec[505050]; ll dp[505050][2]; int p[505050]; bool compare(vector<int> A, vector<int> B) { return A.back() > B.back(); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k >> MOD; for (int i = 1; i <= n; i++) { int l, t; cin >> l >> t; vec[t].push_back(l); } for (int i = 1; i <= k; i++) sort(vec[i].begin(), vec[i].end()); sort(vec + 1, vec + k + 1, compare); for (int j = 1; j <= k; j++) p[j] = vec[j].size(); for (int i = 1; i <= k; i++) { int cnt = upper_bound(vec[i].begin(), vec[i].end(), vec[i].back()/2) - vec[i].begin(); int q = 0; dp[i][0] = 1; dp[i][1] = cnt; for (int j = k; j >= 1; j--) { if (i == j) continue; while (q < vec[i].size() && vec[i][q] <= vec[j].back()/2) q++; while (p[j] > 0 && vec[j][p[j]-1] > vec[i].back()/2) p[j]--; if (i < j) { dp[i][0] = dp[i][0]*(1+p[j])%MOD; dp[i][1] = dp[i][1]*(1+p[j])%MOD; } else { if (q > cnt) continue; dp[i][0] = dp[i][0]*(1+p[j])%MOD; } } // cout << dp[i][0] << " " << dp[i][1] << "\n"; } ll ans = 0; for (int i = 1; i <= k; i++) { ans += dp[i][0] + dp[i][1]; ans %= MOD; } cout << ans << "\n"; return 0; }

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

fish.cpp: In function 'int main()':
fish.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             while (q < vec[i].size() && vec[i][q] <= vec[j].back()/2) q++;
      |                    ~~^~~~~~~~~~~~~~~
#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...