SGU 188.Factory guard

时间:2023-03-08 17:47:30

模拟

code

#include <iostream>
#include <cstdio>
#define LEN 1000
using namespace std;
int n, t;
int pos[], last[], v[];
int ans[];
int main()
{
cin >> n >> t;
for (int i = ; i <= n; ++i) cin >> pos[i];
for (int i = ; i <= n; ++i) cin >> v[i];
for (int time = ; time <= t; ++time)
{
for (int i = ; i <= n; ++i)
last[i] = pos[i], pos[i] += v[i];
for (int i = ; i <= n; ++i)
for (int j = ; j <= n; ++j)
if ( v[i] > && v[j] < )
{
if (last[j] > last[i] && pos[i] >= pos[j])
++ans[i], ++ans[j];
else if (last[j] < last[i] && pos[i] - LEN >= pos[j])
++ans[i], ++ans[j];
}
for (int i = ; i <= n; ++i)
{
while (pos[i] < ) pos[i] += LEN;
while (pos[i] >= LEN) pos[i] -= LEN;
}
}
for (int i = ; i <= n; ++i)
cout << ans[i] << ' ';
return ;
}