Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link ×

onlyone's blog

By onlyone, 9 years ago, In English,
A: it's very easy. a bool vis[] is ok.

B: it can think as a directional Graph. xi->yi. there are two (a ,b), they appeer time less than N-1. we can do dfs from a to b, to check whether a can reach b, if it can, cout  a b , else cout b a.
ps:What a bad thing is I got WA during the contest, because I wrote  a 'j' as i. = =....

C: let change the sequence to a sequence only have -1,0, 1.
   s[1] = 0, if in[i]-in[i-1] > 0, s[i] = 1, else if less than 0, s[i] = -1, no change to oh.

First, we can know, if the shortest unordered subsequence exist, the length is 3, and the first number can be one of the three. scan S[i] from 2->N, if S[i]!=0, break,b=i, then continue scan, if exist S[i]+S[b]==0,break, c = i, then the ouordered subS exist.
sub is 0 1 -1 or 0 -1 1,

From -100 0 100 98 =>0 1 1 -1, but as the method above, a = 1, b = 2, c = 4, but they are ordered. the ans should be a, c-1, c. a is always 1.

why?   b is the first 1(-1), c is the first -1(1), so the number between b and c, is less than numb[b] && larger than numb[c] / larger than b && less than c, also may equal to numb[b] so compare "numb[c-1] to numb[a]" is the same "numb[b] to numb[a]" ,larger or less. numb[c] only compared to numb[c-1] from the S[]. so a c-1 c can be the ans.

/* my code:
val[1] = 0;
          for (i = 2; i <= N; i++)
              val[i] = (b-a);
              a = b;
              if (val[i]<0) val[i] = -1;
              else if (val[i]>0) val[i] = 1;
      //    if (N <= 2) {printf("0\n");continue ;}
          k = 1;
          a = 1;
          for (i = 2; i <= N; i++)
              if (val[i]) break;
          if (i <= N)
             b = i;
             for (i++; i <= N; i++)
             if (val[i]+val[b]==0)
             if (i<=N)
              b = i-1;
              c = i;


I was Hacked by others. After thinking problem E, I find the bug -100 0 100 98, but the contest is over.

This Round....How tragical I am !!!
I will do better the next Round.

I want to know how to solve the Problem D and Problem E, can you help me? thanks..

  • Vote: I like it
  • 0
  • Vote: I do not like it

9 years ago, # |
  Vote: I like it 0 Vote: I do not like it
You can watch all solutions here:
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it
Your solution for problem C was really nice.
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it
Here are my solutions for example:
Problem A
Problem B
Problem C
Problem E (example)
  • 9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    SKYDOS,  thank you first, but I only know C++.
    My ask you a question in Geometry ?
    A point  P(x,y,z), it rotated widdershins (counterclockwise) around a vector L(x,y,z) by angle ang (radian),
    I want to know the new point after rotation. How to creat the matrix ?