QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#826179 | #9774. Same Sum | ucup-team3099# | WA | 0ms | 42504kb | C++23 | 4.7kb | 2024-12-22 03:31:58 | 2024-12-22 03:31:58 |
Judging History
你现在查看的是最新测评结果
- [2025-01-11 11:59:18]
- hack成功,自动添加数据
- (/hack/1443)
- [2024-12-23 17:02:06]
- hack成功,自动添加数据
- (/hack/1310)
- [2024-12-23 16:48:26]
- hack成功,自动添加数据
- (/hack/1309)
- [2024-12-23 16:33:45]
- hack成功,自动添加数据
- (/hack/1308)
- [2024-12-23 16:23:53]
- hack成功,自动添加数据
- (/hack/1307)
- [2024-12-23 16:13:08]
- hack成功,自动添加数据
- (/hack/1306)
- [2024-12-23 15:54:42]
- hack成功,自动添加数据
- (/hack/1305)
- [2024-12-23 14:58:39]
- hack成功,自动添加数据
- (/hack/1304)
- [2024-12-23 09:58:11]
- hack成功,自动添加数据
- (/hack/1302)
- [2024-12-23 09:47:22]
- hack成功,自动添加数据
- (/hack/1301)
- [2024-12-23 09:41:23]
- hack成功,自动添加数据
- (/hack/1300)
- [2024-12-23 09:26:32]
- hack成功,自动添加数据
- (/hack/1299)
- [2024-12-23 09:19:58]
- hack成功,自动添加数据
- (/hack/1298)
- [2024-12-23 09:13:29]
- hack成功,自动添加数据
- (/hack/1297)
- [2024-12-22 18:52:18]
- hack成功,自动添加数据
- (/hack/1296)
- [2024-12-22 18:13:14]
- hack成功,自动添加数据
- (/hack/1294)
- [2024-12-22 03:31:58]
- 提交
answer
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
const int INF = 1e9;
const int me = 50;
const int ms = 100100;
std::pair<int, int> to[me][ms];
bool isGood[ms];
int main() {
std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
int n, k, q;
std::cin >> n >> k >> q;
std::vector<long long> a(2*n), b(2*n+1, 0);
for(int i = 0; i < n; i++) {
std::cin >> a[i] >> b[i+1];
a[i]--;
a[n+i] = a[i] + k;
b[n+i+1] = b[i+1];
}
for(int i = 1; i <= 2*n; i++) {
b[i] += b[i-1];
}
{
std::vector<int> st;
auto getValue = [&](int id) {
// b[R] - b[L] <= a[R] - a[L]
// b[R] - a[R] <= b[L] - a[L]
return b[id] - a[id];
};
for(int i = 2*n-1; i >= 0; i--) {
while(!st.empty() && getValue(st.back()) >= getValue(i)) {
st.pop_back();
}
//std::cout << "value at " << i << " is " << getValue(i) << '\n';
if(i < n) {
if(st.empty()) {
isGood[i] = false;
to[0][i] = {INF, i};
} else {
isGood[i] = true;
to[0][i] = {st.back() >= n ? 1 : 0, st.back() % n};
}
//std::cout << "to[" << i << "] = {" << to[0][i].first << ", " << to[0][i].second << "}\n";
}
st.push_back(i);
}
}
for(int i = 1; i < me; i++) {
for(int j = 0; j < n; j++) {
to[i][j] = {std::min(INF, to[i-1][j].first + to[i-1][to[i-1][j].second].first), to[i-1][to[i-1][j].second].second};
}
}
auto getSum = [&](int day, int id) {
return day * b[n] + b[id];
};
while(q--) {
int x, y;
std::cin >> x >> y;
y--;x--;
int day = 0, id = 0;
for(int i = me-1; i >= 0; i--) {
auto [deltaDay, nextId] = to[i][id];
if(day + deltaDay < x || (day + deltaDay == x && nextId <= y)) {
day += deltaDay, id = nextId;
}
}
//std::cout << "at " << day << ", " << id << '\n';
long long hour = (long long) day * k + a[id] + getSum(x, y+1) - getSum(day, id) - 1;
std::cout << hour / k + 1 << ' ' << hour % k + 1 << '\n';
}
}
/*
NEVER FORGET TO:
Look at the problem's constraints before coding.
How to cheese cf:
Find a lower bound or upper bound for the problem. Have faith that it is the answer of the problem.
If it isn't the answer, have more faith or change to another bound god by looking for a better bound.
Trust guesses. Who has time to think? If people in div2 AC the problem it requires no proof since people don't prove things.
You must draw cases. Thinking gets you nowhere, so draw cases and reach illogical conclusions from them.
Sometimes drawing cases is bad because it takes too much time. Faster is to not think at all and just code a bruteforce solution.
This is called "law of small numbers". If something works for small numbers, surely it works for big numbers.
https://en.wikipedia.org/wiki/Faulty_generalization#Hasty_generalization don't mind the "faulty" part of it, in competitive programming mistakes are lightly punished
Don't think about them being right or not, cf is a battle of intuition only.
Be as stupid as possible in implementation. Trying to be smart is an easy way to get WA.
Think about 2x2 cases for matrix problems and hope that everything works for the general case.
Find a necessary condition and trust it to be sufficient. They're basically the same thing.
Heuristics might speed up your code. Forget about complexity, it's only about ACing and not proving that your solution is good.
For paths in a grid starting at (1, i) or something like that, assume that they never cross and do D&C
Consider doing problems in reverse order of queries/updates
For combinatorics problems, consider symmetry
For problems that are similar to past problems, think about the differences betweem it and the current problem.
Sometimes the difference makes no difference. Sometimes it does.
General strategy (MUST DO):
Try to solve the problem with more restricted constraints.
About testing:
Test n=1, a[i]=1, a[i]=n, etc. Basically, test low values. No need to test if pretests are strong, but if you get WA it's good.
This isn't a joke. Do it if you get stuck. It's shit practice in my opinion, but do it if you want AC.
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 42504kb
input:
8 4 1 2 3 4 5 6 7 8 2 1 8 1 1 4 4 2 1 6 2 1 8
output:
41 4
result:
wrong output format YES or NO expected, but 41 found [1st token]