Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:第一个ac,庆祝一下

Posted by 43453719 at 2014-11-14 23:16:32 on Problem 1068
In Reply To:第一个ac,庆祝一下 Posted by:hongbin_neu at 2012-08-17 13:19:46
> /**
>  *@author: Bin Hong <hongbin0908@gmail.com>
>  */
> 
> 
> #include <iostream>
> #include <deque>
> #include <stack>
> 
> //#define __DEBUG__
> 
> int case_num;
> int num;
> std::deque<bool> pas;
> 
> std::stack<int> op;
> 
> #ifdef __DEBUG__
> void output() {
>     std::cout << "[";
>     for (int i = 0; i < (int)pas.size();i++) {
>         if (pas[i]) {
>             std::cout << "(" << " ";
>         } else {
>             std::cout << ")" << " ";
>         }
>                 
>     }
>     std::cout << "]" << std::endl;
> }
> #endif
> 
> void encode() {
>     for (int i = 0; i < (int)pas.size();i++) {
>         if (pas[i]) {
>             op.push(i);
>         } else {
>             int left = op.top(); op.pop();
>             std::cout << (i - left + 1)/2 << " ";
>         }
>     }
> 
>     std::cout << std::endl;
> }
> 
> 
> 
> void cal_per_line(int num) {
>     pas.clear();
>     int last = 0;
>     int cur = 0;
>     for (int i = 0; i < num; i++) {
>         std::cin >> cur;
> #ifdef __DEBUG__
>         std::cout << cur << " ";
> #endif
>         for (int j = 0; j < cur - last; j++) {
>             pas.push_back(true);
>         }
>         pas.push_back(false);
>         last = cur;
>     }
> #ifdef __DEBUG__
>     std::cout << std::endl;
>     output();
> #endif
>     encode();
>     
> }
> 
> 
> int main(int argc, char** argv) {
>     std::cin >> case_num;
> #ifdef __DEBUG__
>     std::cout << "case_num: " << case_num << std::endl;
> #endif
>     for (int i = 0 ; i < case_num; i++) {
>         std::cin >> num;
> #ifdef __DEBUG__
>         std::cout << "num: " << num << std::endl;
> #endif
>         cal_per_line(num);
>     }
>     return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator