首页 > 其他 > 详细

SGU 188.Factory guard

时间:2014-09-09 21:18:59      阅读:425      评论:0      收藏:0      [点我收藏+]

模拟

code

#include <iostream>
#include <cstdio>
#define LEN 1000
using 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

原文:http://www.cnblogs.com/keam37/p/3963306.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!