Codeforces Round #235 (Div. 2)(二)

2014-11-24 10:37:47 · 作者: · 浏览: 2
Div2 round, then the corresponding line looks like: "2num" (where num is the identifier of this Div2 round). It is guaranteed that the identifiers of all given rounds are less than x.

Output

Print in a single line two integers ― the minimum and the maximum number of rounds that Sereja could have missed.

Sample test(s) input
3 2
2 1
2 2
output
0 0
input
9 3
1 2 3
2 8
1 4 5
output
2 3
input
10 0
output
5 9
Note

In the second sample we have unused identifiers of rounds 1, 6, 7. The minimum number of rounds Sereja could have missed equals to 2. In this case, the round with the identifier 1 will be a usual Div2 round and the round with identifier 6 will be synchronous with the Div1round.

The maximum number of rounds equals 3. In this case all unused identifiers belong to usual Div2 rounds.


贪心做的。
//15 ms	0 KB
#include
  
   
#include
   
     int vis[4007]; int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF) { memset(vis,0,sizeof(vis)); for(int i=1;i<=m;i++) { int num,a,b; scanf("%d",&num); if(num==1) { scanf("%d%d",&a,&b); vis[a]=1; vis[b]=1; } else if(num==2) { scanf("%d",&a); vis[a]=1; } } int count1=0,count2=0,flag=0; for(int i=1;i
    
     
C. Team time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

Now it's time of Olympiads. Vanya and Egor decided to make his own team to take part in a programming Olympiad. They've been best friends ever since primary school and hopefully, that can somehow help them in teamwork.

For each team Olympiad, Vanya takes his play cards with numbers. He takes only the cards containing numbers 1 and 0. The boys are very superstitious. They think that they can do well at the Olympiad if they begin with laying all the cards in a row so that:

  • there wouldn't be a pair of any side-adjacent cards with zeroes in a row;
  • there wouldn't be a group of three consecutive cards containing numbers one.

    Today Vanya brought n cards with zeroes and m cards with numbers one. The number of cards was so much that the friends do not know how to put all those cards in the described way. Help them find the required arrangement of the cards or else tell the guys that it is impossible to arrange cards in such a way.

    Input

    The first line contains two integers: n (1 ≤ n ≤ 106) ― the number of cards containing number 0; m (1 ≤ m ≤ 106) ― the number of cards containing number 1.

    Output

    In a single line print the required sequence of zeroes and ones without any spaces. If such sequence is impossible to obtain, print -1.

    Sample test(s) input
    1 2
    
    output
    101
    
    input
    4 8
    
    output
    110110110101
    
    input
    4 10
    
    output
    11011011011011
    
    input
    1 5
    
    output
    -1
    求前导0,110,10,和后导1的个数。
    //109 ms	0 KB
    #include
            
             
    using namespace std;
    int main()
    {
        int n,m;
        while(scanf("%d%d",&n,&m)!=EOF)
        {
            if(n>m+1||(n+1)*2
             
              =0&&y>=0)goto there;//如果满足条件直接跳出 } there: for(int i=0;i