Codeforces Round #207 (Div. 1) A. Knight Tournament(STL)

脑子又卡了。。。来一发set的,STL真心不熟。

 1 #include <stdio.h>

 2 #include <string.h>

 3 #include <iostream>

 4 #include <set>

 5 using namespace std;

 6 int flag[400001];

 7 set<int>se;

 8 set<int>::iterator it1,it,it2;

 9 int main()

10 {

11     int i,x,y,num,n,m;

12     scanf("%d%d",&n,&m);

13     for(i = 1; i <= n; i ++)

14         se.insert(i);

15     for(i = 1; i <= m; i ++)

16     {

17         scanf("%d%d%d",&x,&y,&num);

18         it1 = se.lower_bound(x);

19         for(it = it1; it != se.end()&&(*it) <= y;)

20         {

21             if(*it == num)

22             {

23                 it ++;

24                 continue;

25             }

26             flag[*it] = num;

27             it2 = it;

28             it2 ++;

29             se.erase(it);

30             it = it2;

31         }

32     }

33     for(i = 1; i <= n; i ++)

34     {

35         if(i == 1)

36             printf("%d",flag[i]);

37         else

38             printf(" %d",flag[i]);

39     }

40     printf("\n");

41     return 0;

42 }

 

你可能感兴趣的:(codeforces)