ir5's blog

By ir5, 10 years ago, In English


Rating: 2150->2205

[A] : I inserted assertion to my code in order to assure that "It is guaranteed that there is exactly one leader in the room", but unfortunately it behaved wrong.

  1. int main() {
  2.     int N;
  3.     while (cin>>N) {
  4.         int mmpts=-1<<29; string res="{";
  5.         REP(j, N) {
  6.             string name;
  7.             int p,m,a,b,c,d,e; cin>>name>>p>>m>>a>>b>>c>>d>>e;
  8.             int pts=p*100-50*m+a+b+c+d+e;
  9.             assert(mmpts != pts); // <- !!!This is wrong!!!: "3 a 0..0 b 0..0 c 999...999" can cause RE.
  10.             if (mmpts < pts) mmpts=pts, res=name;
  11.         }
  12.         cout<<res<<endl;
  13.     }
  14. }

[B] : The statement was very long, so I skipped and went to C.

[C] : The statement was short in contrast to B, so I read it.
Considering the top row of the board is OK, so the problem is just counting the number of the connected components. (Assume two cells (1, i) and (1, j) are connected if (1, i) can beat (1, j).)
...But the mathematical part was a bit hard to me, so it took a bit long time.

It is surprising that this problem can be solved by only gcd.

[B(again)] : The statement looked very long at first, but it was actually not so long.
This problem was a kind of simulation (a bit hard!), and I made 2WAs. I felt C was easier than B, but it is perhaps because of individual difference.

[D]: Inserting points to a line is done by simulation with a few data structures (I used <set> and <map>). Answering queries in online looked to me very hard, but after thinking for a while, I found that it can be done by coordinate compression + BIT.

[E]: I did not have time to read E at all during the contest, so I solved this after the contest.
In this problem, finding the way to swap two adjacent cells is enough. Really constructive problem.
  • Vote: I like it
  • +34
  • Vote: I do not like it