F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

ZCC Loves RPG

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 130712/130712 K (Java/Others)
Total Submission(s): 174    Accepted Submission(s): 26


Problem Description
ZCC is playing a RPG game named ¡°kenji¡¯s life VI¡±.
In this game, as an advanturer, ZCC has N kinds of energy, labeled 1 to N. Before set off for an adventure, ZCC can charge some of his energy, which allow he to set the amount of every kind of energy (a_i) a non-negative integer arbitrarily. Different kind of energy is set independently.
When different energy mix, they become unstable. If there exist two integers u and v (u¡Üv), where a_u, a_u+1, ..., a_v are all positive number, and sum of those v-u+1 number exceed K, a horrific explosion occurs, and of course, Game Over.
During the adventure, the story may develop differently depending on the amount of a certain kind of energy. Sometimes there will be some CGs, but some of CGs may only appear in some certain sub-story.
ZCC has played this game many times, but failed to collect some of the CGs. Now he wonders, How many kinds of CGs is collectable?
The Scenario is given in the form of C++ like code.

As an explanation:
The Scenario is presented as a non-type function game(n, k).
game(n, k) has 2 arguments, n and k, which are actually 2 constants. n is the number of energy type available, k is the limitation of sum of consecutive positive number. There may be 3 types of statement:
1.cg(p1), means a CG numbered p1 appears here.
2.if (a[p1] >= p2) <statement> [else <statement>], is just like the branch statement in other programming languages. else is matched with the nearest if, just like the way C++ works.
3.{ <statements>* }, a block contains zero, one or several statements.
Note that though the scenario is guaranteed to satisfy the grammar above, the code-style(space, bracket, line break) may not strictly obeys the explanation above.
 

Input
A scenario with total length do not exceed 3MB.
It¡¯s guaranteed:
n¡Ü10^5;
in cg(p1), p1 is a non-negative number between 0 and 2^20-1;
in if (a[p1] >= p2), 1¡Üp1¡Ün£¬0¡Üp2¡Ü10^9.
 

Output
An integer: the number of CGs collectable.
 

Sample Input
game(3, 1){ cg(0); if (a[1] >= 1) cg(1); else if (a[1] >= 2) cg(2); if (a[2] >= 1) if (a[3] >= 1) cg(3); else cg(4); {cg(0);} }
 

Sample Output
3
 

Hint
CGs collectable are CG#0, CG#1 and CG#4.
Though CG#0 appears 2 times, the answer is 3, instead of 4.
 

Author
Õòº£ÖÐѧ
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-28 08:07:01, Gzip enabled