水题 Gym 100553K Knockout Racing

时间:2023-03-09 21:57:00
水题 Gym 100553K Knockout Racing

题目传送门

 /*
题意:有若干个点在一个区间内来回移动,1m/s。
水题:n^2的复杂度能解决,注意时间可能大于一个周期,要取模
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std; typedef long long ll;
const int MAXN = 1e3 + ;
const int INF = 0x3f3f3f3f;
ll x[MAXN], y[MAXN];
struct Question
{
ll x, y, t;
}q[MAXN];
int ans[MAXN]; int main(void) //Gym 100553K Knockout Racing
{
// freopen ("K.in", "r", stdin);
freopen ("knockout.in", "r", stdin);
freopen ("knockout.out", "w", stdout); int n, m;
while (scanf ("%d%d", &n, &m) == )
{
for (int i=; i<=n; ++i) scanf ("%I64d%I64d", &x[i], &y[i]);
for (int i=; i<=m; ++i) scanf ("%I64d%I64d%I64d", &q[i].x, &q[i].y, &q[i].t);
for (int i=; i<=m; ++i)
{
int cnt = ;
for (int j=; j<=n; ++j)
{
ll d = q[i].t % ((y[j] - x[j]) * );
ll pos = x[j];
if (pos + d <= y[j]) pos += d;
else pos = y[j] - (d - (y[j] - x[j]));
if (q[i].x <= pos && pos <= q[i].y) cnt++;
}
ans[i] = cnt;
} for (int i=; i<=m; ++i) printf ("%d\n", ans[i]);
} return ;
}