답안 #50974

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
50974 2018-06-15T10:20:34 Z model_code 단층 (JOI16_ho_t5) C++17
100 / 100
766 ms 15516 KB
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define SIZE 262144
class segtree
{
public:
	ll seg[SIZE*2];
	ll flag[SIZE*2];
	void update(int beg,int end,int node,int lb,int ub,ll num)
	{
		if(ub<beg||end<lb)return;
		if(beg<=lb&&ub<=end)
		{
			flag[node]+=num;
			return;
		}
		if(flag[node])
		{
			flag[node*2]+=flag[node];
			flag[node*2+1]+=flag[node];
			flag[node]=0;
		}
		update(beg,end,node*2,lb,(lb+ub)/2,num);
		update(beg,end,node*2+1,(lb+ub)/2+1,ub,num);
	}
	ll get(int pl,int node,int lb,int ub)
	{
		if(pl==lb&&ub==pl)
		{
			return flag[node];
		}
		if(flag[node])
		{
			flag[node*2]+=flag[node];
			flag[node*2+1]+=flag[node];
			flag[node]=0;
		}
		if(pl<=(lb+ub)/2)return get(pl,node*2,lb,(lb+ub)/2);
		else return get(pl,node*2+1,(lb+ub)/2+1,ub);
	}
};
segtree tree1,tree2;
typedef pair<ll,ll>pii;
typedef pair<ll,pii>pi3;
int main()
{
	int num,query;
	scanf("%d%d",&num,&query);
	for(int i=1;i<=SIZE-1;i++)
	{
		tree1.update(i,i,1,0,SIZE-1,i);
		tree2.update(i,i,1,0,SIZE-1,-i);
	}
	vector<pi3>vec;
	for(int i=0;i<query;i++)
	{
		int za,zb;
		ll zc;
		scanf("%d%d%lld",&za,&zb,&zc);
		vec.push_back(make_pair(za,make_pair(zb,zc)));
	}
	reverse(vec.begin(),vec.end());
	for(int i=0;i<query;i++)
	{
		if(vec[i].second.first==1)
		{
			int beg=0,end=SIZE-1;
			for(;;)
			{
				int med=(beg+end)/2+1;
				if(tree2.get(med,1,0,SIZE-1)<-vec[i].first)end=med-1;
				else beg=med;
				if(beg==end)
				{
					tree1.update(0,beg,1,0,SIZE-1,-vec[i].second.second*2);
					break;
				}
			}
		}
		else
		{
			int beg=0,end=SIZE-1;
			for(;;)
			{
				int med=(beg+end)/2+1;
				if(tree1.get(med,1,0,SIZE-1)>vec[i].first)end=med-1;
				else beg=med;
				if(beg==end)
				{
					tree2.update(beg+1,SIZE-1,1,0,SIZE-1,-vec[i].second.second*2);
					break;
				}
			}
		}
	}
	for(int i=1;i<=num;i++)printf("%lld\n",-(tree1.get(i,1,0,SIZE-1)+tree2.get(i,1,0,SIZE-1))/2);
}

Compilation message

2016_ho_t5.cpp: In function 'int main()':
2016_ho_t5.cpp:51:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&num,&query);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
2016_ho_t5.cpp:62:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%lld",&za,&zb,&zc);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 95 ms 4600 KB Output is correct
2 Correct 66 ms 4712 KB Output is correct
3 Correct 70 ms 4712 KB Output is correct
4 Correct 67 ms 4788 KB Output is correct
5 Correct 69 ms 4992 KB Output is correct
6 Correct 69 ms 4992 KB Output is correct
7 Correct 68 ms 4992 KB Output is correct
8 Correct 72 ms 4992 KB Output is correct
9 Correct 81 ms 4992 KB Output is correct
10 Correct 74 ms 4992 KB Output is correct
11 Correct 72 ms 4992 KB Output is correct
12 Correct 87 ms 4992 KB Output is correct
13 Correct 85 ms 4992 KB Output is correct
14 Correct 66 ms 4992 KB Output is correct
15 Correct 69 ms 4992 KB Output is correct
16 Correct 69 ms 4992 KB Output is correct
17 Correct 64 ms 4992 KB Output is correct
18 Correct 65 ms 4992 KB Output is correct
19 Correct 67 ms 4992 KB Output is correct
20 Correct 65 ms 4992 KB Output is correct
21 Correct 64 ms 4992 KB Output is correct
22 Correct 64 ms 4992 KB Output is correct
23 Correct 67 ms 4992 KB Output is correct
24 Correct 64 ms 4992 KB Output is correct
25 Correct 63 ms 4992 KB Output is correct
26 Correct 63 ms 4992 KB Output is correct
27 Correct 63 ms 4992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 95 ms 4600 KB Output is correct
2 Correct 66 ms 4712 KB Output is correct
3 Correct 70 ms 4712 KB Output is correct
4 Correct 67 ms 4788 KB Output is correct
5 Correct 69 ms 4992 KB Output is correct
6 Correct 69 ms 4992 KB Output is correct
7 Correct 68 ms 4992 KB Output is correct
8 Correct 72 ms 4992 KB Output is correct
9 Correct 81 ms 4992 KB Output is correct
10 Correct 74 ms 4992 KB Output is correct
11 Correct 72 ms 4992 KB Output is correct
12 Correct 87 ms 4992 KB Output is correct
13 Correct 85 ms 4992 KB Output is correct
14 Correct 66 ms 4992 KB Output is correct
15 Correct 69 ms 4992 KB Output is correct
16 Correct 69 ms 4992 KB Output is correct
17 Correct 64 ms 4992 KB Output is correct
18 Correct 65 ms 4992 KB Output is correct
19 Correct 67 ms 4992 KB Output is correct
20 Correct 65 ms 4992 KB Output is correct
21 Correct 64 ms 4992 KB Output is correct
22 Correct 64 ms 4992 KB Output is correct
23 Correct 67 ms 4992 KB Output is correct
24 Correct 64 ms 4992 KB Output is correct
25 Correct 63 ms 4992 KB Output is correct
26 Correct 63 ms 4992 KB Output is correct
27 Correct 63 ms 4992 KB Output is correct
28 Correct 70 ms 5116 KB Output is correct
29 Correct 71 ms 5116 KB Output is correct
30 Correct 71 ms 5140 KB Output is correct
31 Correct 70 ms 5704 KB Output is correct
32 Correct 70 ms 5704 KB Output is correct
33 Correct 73 ms 5704 KB Output is correct
34 Correct 73 ms 8860 KB Output is correct
35 Correct 79 ms 8860 KB Output is correct
36 Correct 69 ms 8860 KB Output is correct
37 Correct 84 ms 8860 KB Output is correct
38 Correct 71 ms 8860 KB Output is correct
39 Correct 78 ms 8860 KB Output is correct
40 Correct 76 ms 9020 KB Output is correct
41 Correct 86 ms 9020 KB Output is correct
42 Correct 70 ms 9020 KB Output is correct
43 Correct 70 ms 9020 KB Output is correct
44 Correct 68 ms 9020 KB Output is correct
45 Correct 70 ms 9020 KB Output is correct
46 Correct 69 ms 9020 KB Output is correct
47 Correct 70 ms 9020 KB Output is correct
48 Correct 68 ms 9020 KB Output is correct
49 Correct 68 ms 9020 KB Output is correct
50 Correct 73 ms 9020 KB Output is correct
51 Correct 69 ms 9020 KB Output is correct
52 Correct 76 ms 9020 KB Output is correct
53 Correct 74 ms 9020 KB Output is correct
54 Correct 70 ms 9020 KB Output is correct
55 Correct 69 ms 9020 KB Output is correct
56 Correct 69 ms 9020 KB Output is correct
57 Correct 70 ms 9020 KB Output is correct
58 Correct 71 ms 9020 KB Output is correct
59 Correct 78 ms 9020 KB Output is correct
60 Correct 69 ms 9020 KB Output is correct
61 Correct 70 ms 9020 KB Output is correct
62 Correct 77 ms 9020 KB Output is correct
63 Correct 69 ms 9020 KB Output is correct
64 Correct 70 ms 9020 KB Output is correct
65 Correct 68 ms 9020 KB Output is correct
66 Correct 70 ms 9020 KB Output is correct
67 Correct 69 ms 9020 KB Output is correct
68 Correct 68 ms 9020 KB Output is correct
69 Correct 68 ms 9020 KB Output is correct
70 Correct 71 ms 9020 KB Output is correct
71 Correct 65 ms 9020 KB Output is correct
72 Correct 64 ms 9020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 95 ms 4600 KB Output is correct
2 Correct 66 ms 4712 KB Output is correct
3 Correct 70 ms 4712 KB Output is correct
4 Correct 67 ms 4788 KB Output is correct
5 Correct 69 ms 4992 KB Output is correct
6 Correct 69 ms 4992 KB Output is correct
7 Correct 68 ms 4992 KB Output is correct
8 Correct 72 ms 4992 KB Output is correct
9 Correct 81 ms 4992 KB Output is correct
10 Correct 74 ms 4992 KB Output is correct
11 Correct 72 ms 4992 KB Output is correct
12 Correct 87 ms 4992 KB Output is correct
13 Correct 85 ms 4992 KB Output is correct
14 Correct 66 ms 4992 KB Output is correct
15 Correct 69 ms 4992 KB Output is correct
16 Correct 69 ms 4992 KB Output is correct
17 Correct 64 ms 4992 KB Output is correct
18 Correct 65 ms 4992 KB Output is correct
19 Correct 67 ms 4992 KB Output is correct
20 Correct 65 ms 4992 KB Output is correct
21 Correct 64 ms 4992 KB Output is correct
22 Correct 64 ms 4992 KB Output is correct
23 Correct 67 ms 4992 KB Output is correct
24 Correct 64 ms 4992 KB Output is correct
25 Correct 63 ms 4992 KB Output is correct
26 Correct 63 ms 4992 KB Output is correct
27 Correct 63 ms 4992 KB Output is correct
28 Correct 70 ms 5116 KB Output is correct
29 Correct 71 ms 5116 KB Output is correct
30 Correct 71 ms 5140 KB Output is correct
31 Correct 70 ms 5704 KB Output is correct
32 Correct 70 ms 5704 KB Output is correct
33 Correct 73 ms 5704 KB Output is correct
34 Correct 73 ms 8860 KB Output is correct
35 Correct 79 ms 8860 KB Output is correct
36 Correct 69 ms 8860 KB Output is correct
37 Correct 84 ms 8860 KB Output is correct
38 Correct 71 ms 8860 KB Output is correct
39 Correct 78 ms 8860 KB Output is correct
40 Correct 76 ms 9020 KB Output is correct
41 Correct 86 ms 9020 KB Output is correct
42 Correct 70 ms 9020 KB Output is correct
43 Correct 70 ms 9020 KB Output is correct
44 Correct 68 ms 9020 KB Output is correct
45 Correct 70 ms 9020 KB Output is correct
46 Correct 69 ms 9020 KB Output is correct
47 Correct 70 ms 9020 KB Output is correct
48 Correct 68 ms 9020 KB Output is correct
49 Correct 68 ms 9020 KB Output is correct
50 Correct 73 ms 9020 KB Output is correct
51 Correct 69 ms 9020 KB Output is correct
52 Correct 76 ms 9020 KB Output is correct
53 Correct 74 ms 9020 KB Output is correct
54 Correct 70 ms 9020 KB Output is correct
55 Correct 69 ms 9020 KB Output is correct
56 Correct 69 ms 9020 KB Output is correct
57 Correct 70 ms 9020 KB Output is correct
58 Correct 71 ms 9020 KB Output is correct
59 Correct 78 ms 9020 KB Output is correct
60 Correct 69 ms 9020 KB Output is correct
61 Correct 70 ms 9020 KB Output is correct
62 Correct 77 ms 9020 KB Output is correct
63 Correct 69 ms 9020 KB Output is correct
64 Correct 70 ms 9020 KB Output is correct
65 Correct 68 ms 9020 KB Output is correct
66 Correct 70 ms 9020 KB Output is correct
67 Correct 69 ms 9020 KB Output is correct
68 Correct 68 ms 9020 KB Output is correct
69 Correct 68 ms 9020 KB Output is correct
70 Correct 71 ms 9020 KB Output is correct
71 Correct 65 ms 9020 KB Output is correct
72 Correct 64 ms 9020 KB Output is correct
73 Correct 622 ms 14108 KB Output is correct
74 Correct 619 ms 14108 KB Output is correct
75 Correct 607 ms 14268 KB Output is correct
76 Correct 766 ms 14304 KB Output is correct
77 Correct 639 ms 14304 KB Output is correct
78 Correct 601 ms 14304 KB Output is correct
79 Correct 645 ms 14304 KB Output is correct
80 Correct 541 ms 15144 KB Output is correct
81 Correct 481 ms 15452 KB Output is correct
82 Correct 581 ms 15452 KB Output is correct
83 Correct 524 ms 15452 KB Output is correct
84 Correct 537 ms 15452 KB Output is correct
85 Correct 502 ms 15452 KB Output is correct
86 Correct 478 ms 15452 KB Output is correct
87 Correct 478 ms 15516 KB Output is correct
88 Correct 423 ms 15516 KB Output is correct
89 Correct 483 ms 15516 KB Output is correct
90 Correct 480 ms 15516 KB Output is correct
91 Correct 413 ms 15516 KB Output is correct
92 Correct 421 ms 15516 KB Output is correct
93 Correct 432 ms 15516 KB Output is correct
94 Correct 413 ms 15516 KB Output is correct
95 Correct 469 ms 15516 KB Output is correct
96 Correct 369 ms 15516 KB Output is correct
97 Correct 455 ms 15516 KB Output is correct
98 Correct 511 ms 15516 KB Output is correct
99 Correct 437 ms 15516 KB Output is correct
100 Correct 398 ms 15516 KB Output is correct
101 Correct 427 ms 15516 KB Output is correct
102 Correct 462 ms 15516 KB Output is correct
103 Correct 434 ms 15516 KB Output is correct
104 Correct 394 ms 15516 KB Output is correct
105 Correct 392 ms 15516 KB Output is correct
106 Correct 406 ms 15516 KB Output is correct
107 Correct 436 ms 15516 KB Output is correct
108 Correct 418 ms 15516 KB Output is correct
109 Correct 489 ms 15516 KB Output is correct
110 Correct 416 ms 15516 KB Output is correct
111 Correct 419 ms 15516 KB Output is correct
112 Correct 390 ms 15516 KB Output is correct
113 Correct 451 ms 15516 KB Output is correct
114 Correct 397 ms 15516 KB Output is correct
115 Correct 390 ms 15516 KB Output is correct
116 Correct 425 ms 15516 KB Output is correct
117 Correct 512 ms 15516 KB Output is correct
118 Correct 492 ms 15516 KB Output is correct
119 Correct 121 ms 15516 KB Output is correct
120 Correct 118 ms 15516 KB Output is correct