码迷,mamicode.com
首页 > 其他好文 > 详细

SGU 188.Factory guard

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

标签:style   blog   color   os   io   ar   for   div   sp   

模拟

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

标签:style   blog   color   os   io   ar   for   div   sp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!