답안 #439910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
439910 2021-07-01T07:34:01 Z hivakarami Sob (COCI19_sob) C++14
110 / 110
360 ms 26384 KB
#include<bits/stdc++.h>

 
using namespace std;
 
typedef long long int ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define pii pair<int, int>

 
const int N = 2e5 + 5;
const ll inf = 1e9 * 600;
const ll mod = 1e9 + 7;
const int lg = 30;


vector<pii> v[2], t[4];

void solve(int l, int r)
{
	if(l+1 == r)
	{
		cout << v[0][l].s << ' ' << v[1][l].s << '\n';
		return;
	}
		
	t[0].clear();
	t[1].clear();
	t[2].clear();
	t[3].clear();
	
	
	for(int i = l; i < r; i++)
	{
		if(v[0][i].f%2 == 0)
			t[0].pb({v[0][i].f/2, v[0][i].s});
		else
			t[2].pb({v[0][i].f/2, v[0][i].s});
	}
	
	if(t[0].size() > t[2].size() && v[1][l].f % 2 == 1)
		v[1][l].f--;
		
	for(int i = l; i < r; i++)
	{
		if(v[1][i].f%2 == 0)
			t[1].pb({v[1][i].f/2, v[1][i].s});
		else
			t[3].pb({v[1][i].f/2, v[1][i].s});
	}

	int sz0 = t[0].size();

	for(int i = l; i < l+sz0; i++)
	{
		v[0][i] = t[0][i-l];
		v[1][i] = t[1][i-l];
	}

	for(int i = l+sz0; i < r; i++)
	{
		v[0][i] = t[2][i-l-sz0];
		v[1][i] = t[3][i-l-sz0];
	}
		
	
	//cout << l << ' ' << r << endl;
	
	solve(l, l+sz0);
	solve(l+sz0, r);
	
}





int main()
{
    
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);	

	
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		v[0].pb({i, i});
	
	for(int i = m; i < m+n; i++)
		v[1].pb({i, i});

	solve(0, n);
		
	


	return 0;
}

 

 

 
 





# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 183 ms 13412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 175 ms 13376 KB Output is correct
7 Correct 87 ms 6720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 183 ms 13412 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 175 ms 13376 KB Output is correct
11 Correct 87 ms 6720 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 39 ms 3080 KB Output is correct
20 Correct 144 ms 10548 KB Output is correct
21 Correct 5 ms 712 KB Output is correct
22 Correct 2 ms 460 KB Output is correct
23 Correct 201 ms 17328 KB Output is correct
24 Correct 360 ms 26384 KB Output is correct
25 Correct 339 ms 26048 KB Output is correct