首页 > 代码库 > SGU 188.Factory guard
SGU 188.Factory guard
模拟
code
#include <iostream>#include <cstdio>#define LEN 1000using namespace std;int n, t;int pos[30], last[30], v[30];int ans[30];int main(){ cin >> n >> t; for (int i = 1; i <= n; ++i) cin >> pos[i]; for (int i = 1; i <= n; ++i) cin >> v[i]; for (int time = 1; time <= t; ++time) { for (int i = 1; i <= n; ++i) last[i] = pos[i], pos[i] += v[i]; for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) if ( v[i] > 0 && v[j] < 0 ) { 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 = 1; i <= n; ++i) { while (pos[i] < 0) pos[i] += LEN; while (pos[i] >= LEN) pos[i] -= LEN; } } for (int i = 1; i <= n; ++i) cout << ans[i] << ‘ ‘; return 0;}
SGU 188.Factory guard
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。