Блог пользователя evandrix

Автор evandrix, 12 лет назад, По-английски

250C. Movie Critics @ 2677682

  • minimise sequence & eliminate consecutive duplicates in O(n), eg. 1 1 2 3 2 3 3 1 1 3 -> 1 2 3 2 3 1 3
	vector<int> as;
	vector<int>::const_iterator it;
	it = unique(as.begin(), as.end());
	as.resize(it - as.begin());
  • For each number, if the two numbers beside it are the same, then excluding this number will get 2 fewer stress; otherwise, there will be only 1 fewer stress. For the first one and the last one, excluding these two numbers will always get 1 fewer stress.
	printf("%d",(int) (max_element(ks,ks+k)-ks+1));

_**Remember to consider 1-based and 0-based indexing schemes_

250D. Building Bridge @ 2680964

...
	int aid = lower_bound(A,A+n,ay) - A; // offset
...

250E. Mad Joe @ 2681020

...
            switch (getchar()) {
                case '.':break;
                case '+':a[i][j]=1;break;
                case '#':a[i][j]=2;break;
            }
...
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится