답안 #57068

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57068 2018-07-13T18:42:52 Z kjp4155 Construction of Highway (JOI18_construction) C++17
100 / 100
926 ms 103000 KB
#include<bits/stdc++.h>
using namespace std;

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 6,5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,_6,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define Debug1(a)           cout<<#a<<"="<<(a)<<"\n"
#define Debug2(a,b)         cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define Debug3(a,b,c)       cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define Debug4(a,b,c,d)     cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define Debug5(a,b,c,d,e)   cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define Debug6(a,b,c,d,e,f) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define Debug(...) macro_dispatcher(Debug, __VA_ARGS__)(__VA_ARGS__)
#define DA(a,n) cout<<#a<<"=["; printarray(a,n); cout<<"]\n"
#define DAR(a,n,s) cout<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cout<<"]\n"

#define TT1 template<class T>
#define TT1T2 template<class T1, class T2>
#define TT1T2T3 template<class T1, class T2, class T3>
template<class T, size_t N> ostream& operator << (ostream& os, const array<T, N>& v);
TT1T2 ostream& operator << (ostream& os, const pair<T1, T2>& p){ return os <<"("<<p.first<<", "<< p.second<<")"; }
TT1 ostream& operator << (ostream& os, const vector<T>& v){       bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
template<class T, size_t N> ostream& operator << (ostream& os, const array<T, N>& v) {     bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
TT1T2 ostream& operator << (ostream& os, const set<T1, T2>&v){    bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
TT1T2 ostream& operator << (ostream& os, const multiset<T1,T2>&v){bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
TT1T2T3 ostream& operator << (ostream& os, const map<T1,T2,T3>& v){ bool f = 1; os << "["; for (auto& ii : v) { if (!f)os << ", "; os << "(" << ii.first << " -> " << ii.second << ") "; f = 0; }return os << "]"; }
TT1T2 ostream& operator << (ostream& os, const multimap<T1, T2>& v){ bool f = 1; os << "["; for (auto& ii : v) { if (!f)os << ", "; os << "(" << ii.first << " -> " << ii.second << ") "; f = 0; }return os << "]"; }
TT1T2 ostream& operator << (ostream& os, priority_queue<T1, T2> v) { bool f = 1; os << "["; while (!v.empty()) { auto x = v.top(); v.pop(); if (!f) os << ", "; f = 0; os << x; } return os << "]"; }
TT1T2 void printarray(const T1& a, T2 sz, T2 beg = 0){ for (T2 i = beg; i<sz; i++) cout << a[i] << " "; cout << endl; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()
#define geti1(X) cin >> X
#define geti2(X,Y) cin >> X >> Y
#define geti3(X,Y,Z) cin >> X >> Y >> Z
#define geti4(X,Y,Z,W) cin >> X >> Y >> Z >> W
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 987654321

#define endl '\n'

const ll mod = 1e9 + 7;

struct sumTree{
	vector<ll> d; int n;
	void init(int x){
		n = 1; while( n < x ) n *= 2;
		d.resize(n*2+5);
	}
	void update(int p, ll val, int op){
		p += n-1;
		
		if( op == 0 && d[p] == val ) return;

		if( op ) d[p] += val;
		else d[p] = val;
		for(p>>=1;p;p>>=1) d[p] = d[p*2] + d[p*2+1];
	}
	ll query(int l, int r){ 
		if( l > r ) return 0;
		ll res = 0;
		for(l+=n-1,r+=n-1;l<=r;l>>=1,r>>=1){
			if( l&1 ) res += d[l++];
			if( !(r&1) ) res += d[r--];
		}
		return res;
	}
};

struct segNode{
	int l,r,val,t;
};
segNode combine(segNode a, segNode b){
	if( a.t > b.t ) return a;
	else return b;
}

struct segTree{
	int timer, n; vector<segNode> d;
	void init(int x){
		n = 1; while( n < x ) n *= 2;
		d.resize(n*2+5);
		for(auto& e : d) e = {0,0,0,0};
	}
	void update(int l, int r, int val){
		++timer;
		segNode x = {l,r,val,timer};
		for(l+=n-1,r+=n-1;l<=r;l>>=1,r>>=1){
			if( l&1 ) d[l++] = x;
			if( !(r&1) ) d[r--] = x;
		}
	}
	segNode query(int p){
		p += n-1;
		segNode ret = d[p];
		for(p>>=1;p;p>>=1) ret = combine(ret, d[p]);
		return ret;
	}
};

int sz[100500], cNo[100500], cPos[100500], cSize[100500], cHead[100500], cLeaf[100500], cN;
int vis[100500], pa[100500];
int N, timer;
int C[100500]; vector<int> E[100500];

int dfs_build(int x, int p){
	pa[x] = p;
	sz[x] = 1;
	for(auto e : E[x])if(e!=p) sz[x] += dfs_build(e,x);
	return sz[x];
}

void build_chain(int cur){
	vis[cur] = true;
	if( cHead[cN] == 0 ) cHead[cN] = cur; // new Chain
	cLeaf[cN] = cur; cNo[cur] = cN;
	cSize[cN]++; cPos[cur] = cSize[cN]; 
	int nxt = -1, mx = -1;
	
	// find chain to extend
	for(auto e : E[cur])if(!vis[e]){
		if( sz[e] > mx ){
			nxt = e; mx = sz[e];
		}
	}	
	if( mx >= 0 ) build_chain(nxt);
	for(auto e : E[cur])if(!vis[e]){
		cN++; build_chain(e);
	}
}

vector<segTree> tree;
void build_hld_segTree(){
	for(int n=1;n<=cN;n++){
		int cur = cLeaf[n];
		tree[n].init(cSize[n]+2);
	}
}

void update_to_root(int pos, int val){
	
	// handle leaf
	int cur = pos;
	int cno = cNo[cur];
	int cpos = cPos[cur];
	
	tree[cno].update(1,cpos,val);
	cur = pa[cHead[cno]];
	
	while( cur != -1 ){
		// do on current chain
		cno = cNo[cur];
		cpos = cPos[cur];
		segNode seg = tree[cno].query(cpos);
		tree[cno].update(cpos+1, seg.r, seg.val);
		tree[cno].update(1, cpos, val);
		cur = pa[cHead[cno]];
	}
	
}

sumTree stree;
ll calc_inv(int pos){
	ll ans = 0;
	vector<int> dielist;
	int cur = pos;
	while( cur != -1 ){
		// do on current chain
		int cno = cNo[cur];
		int cpos = cPos[cur];
		
		while( cpos >= 1 ){
			// 1 - look at current seg
			segNode seg = tree[cno].query(cpos);
			ll cnt = (cpos - seg.l + 1);
			ans += cnt * stree.query(1, seg.val-1);
			stree.update(seg.val, cnt, 1);
			dielist.push_back(seg.val);

			// 2 - move to prev seg
			cpos = seg.l - 1;
		}
		// move to prev chain
		cur = pa[cHead[cno]];
	}

	for(auto e : dielist) stree.update(e,0,0);

	return ans;
}

int main(){
	scanf("%d",&N);
	vector<int> v = {-100};
	repp(i,N){
		scanf("%d",C+i); v.pb(C[i]);
	}
	sort(all(v)); v.erase(unique(all(v)), v.end());
	repp(i,N) C[i] = lower_bound(all(v),C[i]) - v.begin();
	stree.init(sz(v)+5);

	vector<Pi> elist;
	rep(i,N-1){
		int a,b; geti(a,b);
		E[a].pb(b); E[b].pb(a);
		elist.push_back({a,b});
	}
	dfs_build(1,-1);
	cN = 1; build_chain(1);
	tree.resize(cN+2);
	build_hld_segTree();
	for(auto& e : elist) if( pa[e.Se] != e.Fi ) swap(e.Fi, e.Se);
	
	update_to_root(1,C[1]);
	
	for(auto e : elist){
		printf("%lld\n",calc_inv(e.Fi));
		update_to_root(e.Se, C[e.Se]);
	}

}

Compilation message

construction.cpp: In function 'void build_hld_segTree()':
construction.cpp:151:7: warning: unused variable 'cur' [-Wunused-variable]
   int cur = cLeaf[n];
       ^~~
construction.cpp: In function 'int main()':
construction.cpp:209:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N);
  ~~~~~^~~~~~~~~
construction.cpp:212:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",C+i); v.pb(C[i]);
   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2808 KB Output is correct
2 Correct 6 ms 2932 KB Output is correct
3 Correct 6 ms 3032 KB Output is correct
4 Correct 6 ms 3148 KB Output is correct
5 Correct 8 ms 3328 KB Output is correct
6 Correct 6 ms 3328 KB Output is correct
7 Correct 7 ms 3328 KB Output is correct
8 Correct 8 ms 3360 KB Output is correct
9 Correct 5 ms 3432 KB Output is correct
10 Correct 6 ms 3432 KB Output is correct
11 Correct 5 ms 3436 KB Output is correct
12 Correct 6 ms 3604 KB Output is correct
13 Correct 6 ms 3604 KB Output is correct
14 Correct 6 ms 3604 KB Output is correct
15 Correct 6 ms 3608 KB Output is correct
16 Correct 6 ms 3772 KB Output is correct
17 Correct 6 ms 3772 KB Output is correct
18 Correct 6 ms 3772 KB Output is correct
19 Correct 7 ms 3772 KB Output is correct
20 Correct 7 ms 3772 KB Output is correct
21 Correct 7 ms 3772 KB Output is correct
22 Correct 6 ms 3772 KB Output is correct
23 Correct 6 ms 3772 KB Output is correct
24 Correct 7 ms 3772 KB Output is correct
25 Correct 5 ms 3772 KB Output is correct
26 Correct 5 ms 3772 KB Output is correct
27 Correct 5 ms 3772 KB Output is correct
28 Correct 4 ms 3772 KB Output is correct
29 Correct 5 ms 3772 KB Output is correct
30 Correct 6 ms 3772 KB Output is correct
31 Correct 5 ms 3780 KB Output is correct
32 Correct 6 ms 3788 KB Output is correct
33 Correct 7 ms 3832 KB Output is correct
34 Correct 6 ms 3832 KB Output is correct
35 Correct 5 ms 3832 KB Output is correct
36 Correct 6 ms 3832 KB Output is correct
37 Correct 5 ms 3832 KB Output is correct
38 Correct 7 ms 3880 KB Output is correct
39 Correct 7 ms 3880 KB Output is correct
40 Correct 7 ms 3880 KB Output is correct
41 Correct 7 ms 3880 KB Output is correct
42 Correct 7 ms 3880 KB Output is correct
43 Correct 5 ms 3880 KB Output is correct
44 Correct 6 ms 3888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2808 KB Output is correct
2 Correct 6 ms 2932 KB Output is correct
3 Correct 6 ms 3032 KB Output is correct
4 Correct 6 ms 3148 KB Output is correct
5 Correct 8 ms 3328 KB Output is correct
6 Correct 6 ms 3328 KB Output is correct
7 Correct 7 ms 3328 KB Output is correct
8 Correct 8 ms 3360 KB Output is correct
9 Correct 5 ms 3432 KB Output is correct
10 Correct 6 ms 3432 KB Output is correct
11 Correct 5 ms 3436 KB Output is correct
12 Correct 6 ms 3604 KB Output is correct
13 Correct 6 ms 3604 KB Output is correct
14 Correct 6 ms 3604 KB Output is correct
15 Correct 6 ms 3608 KB Output is correct
16 Correct 6 ms 3772 KB Output is correct
17 Correct 6 ms 3772 KB Output is correct
18 Correct 6 ms 3772 KB Output is correct
19 Correct 7 ms 3772 KB Output is correct
20 Correct 7 ms 3772 KB Output is correct
21 Correct 7 ms 3772 KB Output is correct
22 Correct 6 ms 3772 KB Output is correct
23 Correct 6 ms 3772 KB Output is correct
24 Correct 7 ms 3772 KB Output is correct
25 Correct 5 ms 3772 KB Output is correct
26 Correct 5 ms 3772 KB Output is correct
27 Correct 5 ms 3772 KB Output is correct
28 Correct 4 ms 3772 KB Output is correct
29 Correct 5 ms 3772 KB Output is correct
30 Correct 6 ms 3772 KB Output is correct
31 Correct 5 ms 3780 KB Output is correct
32 Correct 6 ms 3788 KB Output is correct
33 Correct 7 ms 3832 KB Output is correct
34 Correct 6 ms 3832 KB Output is correct
35 Correct 5 ms 3832 KB Output is correct
36 Correct 6 ms 3832 KB Output is correct
37 Correct 5 ms 3832 KB Output is correct
38 Correct 7 ms 3880 KB Output is correct
39 Correct 7 ms 3880 KB Output is correct
40 Correct 7 ms 3880 KB Output is correct
41 Correct 7 ms 3880 KB Output is correct
42 Correct 7 ms 3880 KB Output is correct
43 Correct 5 ms 3880 KB Output is correct
44 Correct 6 ms 3888 KB Output is correct
45 Correct 6 ms 4020 KB Output is correct
46 Correct 17 ms 4808 KB Output is correct
47 Correct 16 ms 4884 KB Output is correct
48 Correct 15 ms 4960 KB Output is correct
49 Correct 14 ms 4960 KB Output is correct
50 Correct 12 ms 4960 KB Output is correct
51 Correct 15 ms 5004 KB Output is correct
52 Correct 16 ms 5396 KB Output is correct
53 Correct 17 ms 5432 KB Output is correct
54 Correct 17 ms 5528 KB Output is correct
55 Correct 14 ms 5604 KB Output is correct
56 Correct 12 ms 5680 KB Output is correct
57 Correct 20 ms 5732 KB Output is correct
58 Correct 29 ms 5732 KB Output is correct
59 Correct 22 ms 5888 KB Output is correct
60 Correct 21 ms 5888 KB Output is correct
61 Correct 20 ms 6040 KB Output is correct
62 Correct 18 ms 6116 KB Output is correct
63 Correct 16 ms 6192 KB Output is correct
64 Correct 13 ms 6192 KB Output is correct
65 Correct 13 ms 6192 KB Output is correct
66 Correct 15 ms 6192 KB Output is correct
67 Correct 16 ms 6288 KB Output is correct
68 Correct 11 ms 6288 KB Output is correct
69 Correct 12 ms 6520 KB Output is correct
70 Correct 14 ms 6520 KB Output is correct
71 Correct 15 ms 6624 KB Output is correct
72 Correct 18 ms 6624 KB Output is correct
73 Correct 21 ms 6624 KB Output is correct
74 Correct 12 ms 6648 KB Output is correct
75 Correct 14 ms 6784 KB Output is correct
76 Correct 15 ms 6784 KB Output is correct
77 Correct 15 ms 6824 KB Output is correct
78 Correct 19 ms 6888 KB Output is correct
79 Correct 14 ms 6912 KB Output is correct
80 Correct 14 ms 6912 KB Output is correct
81 Correct 16 ms 7032 KB Output is correct
82 Correct 20 ms 7224 KB Output is correct
83 Correct 16 ms 7224 KB Output is correct
84 Correct 15 ms 7240 KB Output is correct
85 Correct 20 ms 7288 KB Output is correct
86 Correct 15 ms 7288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2808 KB Output is correct
2 Correct 6 ms 2932 KB Output is correct
3 Correct 6 ms 3032 KB Output is correct
4 Correct 6 ms 3148 KB Output is correct
5 Correct 8 ms 3328 KB Output is correct
6 Correct 6 ms 3328 KB Output is correct
7 Correct 7 ms 3328 KB Output is correct
8 Correct 8 ms 3360 KB Output is correct
9 Correct 5 ms 3432 KB Output is correct
10 Correct 6 ms 3432 KB Output is correct
11 Correct 5 ms 3436 KB Output is correct
12 Correct 6 ms 3604 KB Output is correct
13 Correct 6 ms 3604 KB Output is correct
14 Correct 6 ms 3604 KB Output is correct
15 Correct 6 ms 3608 KB Output is correct
16 Correct 6 ms 3772 KB Output is correct
17 Correct 6 ms 3772 KB Output is correct
18 Correct 6 ms 3772 KB Output is correct
19 Correct 7 ms 3772 KB Output is correct
20 Correct 7 ms 3772 KB Output is correct
21 Correct 7 ms 3772 KB Output is correct
22 Correct 6 ms 3772 KB Output is correct
23 Correct 6 ms 3772 KB Output is correct
24 Correct 7 ms 3772 KB Output is correct
25 Correct 5 ms 3772 KB Output is correct
26 Correct 5 ms 3772 KB Output is correct
27 Correct 5 ms 3772 KB Output is correct
28 Correct 4 ms 3772 KB Output is correct
29 Correct 5 ms 3772 KB Output is correct
30 Correct 6 ms 3772 KB Output is correct
31 Correct 5 ms 3780 KB Output is correct
32 Correct 6 ms 3788 KB Output is correct
33 Correct 7 ms 3832 KB Output is correct
34 Correct 6 ms 3832 KB Output is correct
35 Correct 5 ms 3832 KB Output is correct
36 Correct 6 ms 3832 KB Output is correct
37 Correct 5 ms 3832 KB Output is correct
38 Correct 7 ms 3880 KB Output is correct
39 Correct 7 ms 3880 KB Output is correct
40 Correct 7 ms 3880 KB Output is correct
41 Correct 7 ms 3880 KB Output is correct
42 Correct 7 ms 3880 KB Output is correct
43 Correct 5 ms 3880 KB Output is correct
44 Correct 6 ms 3888 KB Output is correct
45 Correct 6 ms 4020 KB Output is correct
46 Correct 17 ms 4808 KB Output is correct
47 Correct 16 ms 4884 KB Output is correct
48 Correct 15 ms 4960 KB Output is correct
49 Correct 14 ms 4960 KB Output is correct
50 Correct 12 ms 4960 KB Output is correct
51 Correct 15 ms 5004 KB Output is correct
52 Correct 16 ms 5396 KB Output is correct
53 Correct 17 ms 5432 KB Output is correct
54 Correct 17 ms 5528 KB Output is correct
55 Correct 14 ms 5604 KB Output is correct
56 Correct 12 ms 5680 KB Output is correct
57 Correct 20 ms 5732 KB Output is correct
58 Correct 29 ms 5732 KB Output is correct
59 Correct 22 ms 5888 KB Output is correct
60 Correct 21 ms 5888 KB Output is correct
61 Correct 20 ms 6040 KB Output is correct
62 Correct 18 ms 6116 KB Output is correct
63 Correct 16 ms 6192 KB Output is correct
64 Correct 13 ms 6192 KB Output is correct
65 Correct 13 ms 6192 KB Output is correct
66 Correct 15 ms 6192 KB Output is correct
67 Correct 16 ms 6288 KB Output is correct
68 Correct 11 ms 6288 KB Output is correct
69 Correct 12 ms 6520 KB Output is correct
70 Correct 14 ms 6520 KB Output is correct
71 Correct 15 ms 6624 KB Output is correct
72 Correct 18 ms 6624 KB Output is correct
73 Correct 21 ms 6624 KB Output is correct
74 Correct 12 ms 6648 KB Output is correct
75 Correct 14 ms 6784 KB Output is correct
76 Correct 15 ms 6784 KB Output is correct
77 Correct 15 ms 6824 KB Output is correct
78 Correct 19 ms 6888 KB Output is correct
79 Correct 14 ms 6912 KB Output is correct
80 Correct 14 ms 6912 KB Output is correct
81 Correct 16 ms 7032 KB Output is correct
82 Correct 20 ms 7224 KB Output is correct
83 Correct 16 ms 7224 KB Output is correct
84 Correct 15 ms 7240 KB Output is correct
85 Correct 20 ms 7288 KB Output is correct
86 Correct 15 ms 7288 KB Output is correct
87 Correct 45 ms 9112 KB Output is correct
88 Correct 159 ms 14604 KB Output is correct
89 Correct 635 ms 33352 KB Output is correct
90 Correct 760 ms 35604 KB Output is correct
91 Correct 662 ms 37764 KB Output is correct
92 Correct 484 ms 37764 KB Output is correct
93 Correct 247 ms 37764 KB Output is correct
94 Correct 285 ms 37764 KB Output is correct
95 Correct 379 ms 48520 KB Output is correct
96 Correct 279 ms 50688 KB Output is correct
97 Correct 354 ms 52792 KB Output is correct
98 Correct 350 ms 55032 KB Output is correct
99 Correct 359 ms 56696 KB Output is correct
100 Correct 926 ms 56696 KB Output is correct
101 Correct 795 ms 56696 KB Output is correct
102 Correct 909 ms 56696 KB Output is correct
103 Correct 888 ms 58820 KB Output is correct
104 Correct 341 ms 67004 KB Output is correct
105 Correct 360 ms 69132 KB Output is correct
106 Correct 391 ms 71288 KB Output is correct
107 Correct 393 ms 71288 KB Output is correct
108 Correct 508 ms 71288 KB Output is correct
109 Correct 707 ms 71800 KB Output is correct
110 Correct 287 ms 71800 KB Output is correct
111 Correct 339 ms 79224 KB Output is correct
112 Correct 359 ms 79224 KB Output is correct
113 Correct 306 ms 79896 KB Output is correct
114 Correct 914 ms 79896 KB Output is correct
115 Correct 684 ms 79896 KB Output is correct
116 Correct 369 ms 84608 KB Output is correct
117 Correct 449 ms 87456 KB Output is correct
118 Correct 296 ms 89928 KB Output is correct
119 Correct 375 ms 90480 KB Output is correct
120 Correct 259 ms 90480 KB Output is correct
121 Correct 395 ms 92572 KB Output is correct
122 Correct 314 ms 92972 KB Output is correct
123 Correct 435 ms 97500 KB Output is correct
124 Correct 382 ms 100008 KB Output is correct
125 Correct 507 ms 100532 KB Output is correct
126 Correct 336 ms 100712 KB Output is correct
127 Correct 304 ms 102600 KB Output is correct
128 Correct 313 ms 103000 KB Output is correct