hdu 4524(模拟)

郑厂长系列故事——逃离迷宫

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 1817    Accepted Submission(s): 840

Problem Description

  郑厂长没变
  还是那个假厂长真码农
  改变的是业余爱好
  他现在不研究象棋,改玩游戏了!
  
  最近,郑厂长爱上了逃离迷宫这个游戏,他日日夜夜的玩,就是想达到自己的目标:1000万,因为这个数字和他在腾讯的年收入一样多。
 
 不过,在他跑到9999999时,游戏屏幕上突然出现了好多箱子,郑厂长必须要消除所有这些箱子才能继续玩游戏。这些箱子排成一行,每个箱子上都有个数
字,每个数字代表这个箱子需要被点击的次数才会消失。每个箱子被点击时对应数字会减1,并且他右边箱子的数字也会同时减1,当箱子数字变成0,则其就就消
失了。需要说明的是,如果右边没有箱子或者右边的箱子已经消失了,则无法操作当前的箱子(以上所说的“右边”只是指紧挨着的右边,隔开的不算)。
  现在已知这些箱子的信息,请问郑厂长是否能成功消除所有的箱子然后继续达成他的千万梦想呢?

Input

输入首先包含一个正整数T,表示有T组测试样例;
每组样例有两行,第一行是一个整数n,代表有n个箱子;第二行有n个数字ai,代表每个箱子需要被点击的次数。

[Technical Specification]
T<=100
1 <= n <= 10 ^ 6
0 <= ai <= 10 ^ 9 (1 <= i <= n)

Output

  对于每个样例,如果郑厂长能成功消除这些箱子成功逃脱,请输出"yeah~ I escaped ^_^",否则就输出"I will never go out T_T"。

Sample Input

2
2
2 2
2
1 2

Sample Output

yeah~ I escaped ^_^
I will never go out T_T

直接扫过去模拟一遍就好了。

#include<stdio.h>
#include<string.h>
#include <iostream>
using namespace std;
const int N = 1000005;
int a[N];
int main()
{
    int tcase;
    scanf("%d",&tcase);
    while(tcase--){
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
        }
        bool flag = false;
        for(int i=2;i<=n;i++){
            if(a[i]<a[i-1]){
                flag = true;
                break;
            }
            a[i]-=a[i-1];
            a[i-1] = 0;
            /*for(int j=1;j<=n;j++){
                printf("%d ",a[j]);
            }
            printf("\n");*/
        }
        if(a[n]!=0) flag = true;
        if(flag) printf("I will never go out T_T\n");
        else printf("yeah~ I escaped ^_^\n");
    }

    return 0;
}
时间: 2024-07-31 14:04:54

hdu 4524(模拟)的相关文章

HDU 4930 模拟

Fighting the Landlords Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 266    Accepted Submission(s): 87 Problem Description Fighting the Landlords is a card game which has been a heat for yea

hdu 1022 模拟栈

其实就是模拟一下栈啦. 1 #include <iostream> 2 using namespace std; 3 4 const int N = 10; 5 char o1[N]; 6 char o2[N]; 7 char s[N]; 8 int ans[N * 2]; 9 10 int main () 11 { 12 int n; 13 while ( cin >> n ) 14 { 15 cin >> o1 >> o2; 16 int top = 0

hdu 4054 模拟 练习十六进制输出

http://acm.hdu.edu.cn/showproblem.php?pid=4054 貌似一般区域赛都会有一道水题 这道题PE了一次  因为输出每个数其实是两个位 如果用空格补齐的话  应该用两个空格 我用了一个空格,,, 学到: 1.%x  十六进制输出  可以输出整型,字符型等等 2.%02x  保证两位 而且会输出先导0的两位 //#pragma comment(linker, "/STACK:102400000,102400000") #include <cstd

hdu 5246(模拟)

题解:直接模拟 #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; const int N = 10005; long long n, m, k; long long s[N]; int main() { int t, cas = 1; scanf("%d", &t); while (t--) { scanf("%lld%l

hdu 5386 模拟

想明白以后会发现其实就是模拟... 因为每次只能给一整行或者一整列赋值,所以目标矩阵一开始一定有一行或者一列上数字都是相同的,然后找到对应的操作,把那一行或者那一列标记为访问过.然后新的矩阵也一定能找到一行或者一列数字都相同,再找到相应的操作,标记那一行或者那一列,依次类推,然后没有用到的操作随便找个顺序就好了.其实初始矩阵并没有什么用...... 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio>

HDU 5071 模拟

考察英语的题 - -# 按条件模拟,一遍就行了,每个聊天对象有其价值U,数组模拟队列过程即可,若存在Top标记,则和Top标记的人聊天,否则和队列的第一个人聊天 mark记录队尾,top记录Top操作,data[i].p记录U,data[i].x记录chat数,data[i].y记录该人是否被删除 Add U:在 队尾插入价值为U的人,需要特判U人已经存在 Close U::在整个队列中查找价值为U的人,将其删除,需要特判该人不存在 Chat x:当前聊天页面的人chat+=x,特判当前队列没有

HDU 2860 (模拟+并查集)

Regroup Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1057    Accepted Submission(s): 297 Problem Description When ALPC42 got to a panzer brigade, He was asked to build software to help them r

hdu 5373 模拟

简单模拟题,可以利用一下能被11整除的数的特点:奇数位的数字和与偶数位的数字和之差能被11整除. 1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cstdio> 5 using namespace std; 6 7 const int N = 1000000; 8 int s[N]; 9 int mid[N]; 10 11 int main () 12 {

hdu 5055(模拟)

Bob and math problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1481    Accepted Submission(s): 552 Problem Description Recently, Bob has been thinking about a math problem.There are N Digi