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

洛谷P1159 排行榜 模拟

时间:2017-06-29 14:03:16      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:using   class   ace   else   固定   type   end   stream   cin   

洛谷P1159 排行榜

模拟

DOWN的人 正序 排到前面
UP的人 正序 排在后面
然而要注意 SAME 是不变的
所以说SAME 的位置是固定的,这个要特殊做

 

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <string>
 4 #include <iostream>
 5 using namespace std ; 
 6 
 7 int n,topu,topd ; 
 8 string up[101],down[101],all[101] ; 
 9 string s,type ; 
10 bool f[101] ; 
11 
12 int main() 
13 {
14     cin>>n ; 
15     topu = 0 ; topd = 0 ; 
16     for(int i=1;i<=n;i++)
17     {
18         cin>>all[ i ]>>type ;
19         if(type[ 0 ]==D) down[++topd] = all[ i ] ; 
20         if(type[ 0 ]==S) f[ i ] = 1 ; 
21         if(type[ 0 ]==U) up[++topu] = all[ i ] ;   
22     }
23     int zd = 1 , zu = 1 ; 
24     for(int i=1;i<=n;i++) 
25     {
26         if( f[ i ] ) 
27         {
28             cout<<all[ i ]<<endl ; 
29             continue ; 
30         }
31         if( zd<=topd ) 
32             cout<<down[zd]<<endl ,zd++ ; 
33         else
34             cout<<up[zu]<<endl ,zu++ ;  
35     }
36     return 0 ; 
37 }

 

洛谷P1159 排行榜 模拟

标签:using   class   ace   else   固定   type   end   stream   cin   

原文地址:http://www.cnblogs.com/third2333/p/7094061.html

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