SGU 188.Factory guard

模拟

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 ;
}
上一篇:[转] vim 正则表达式 很强大


下一篇:删除除了 id 号不同,其他都相同的学生冗余信息