#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 << endl;
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 |
0 ms |
244 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
587 ms |
13360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
460 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 |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
284 KB |
Output is correct |
6 |
Correct |
628 ms |
13376 KB |
Output is correct |
7 |
Correct |
320 ms |
6756 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 |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
244 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
587 ms |
13360 KB |
Output is correct |
5 |
Correct |
7 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
284 KB |
Output is correct |
10 |
Correct |
628 ms |
13376 KB |
Output is correct |
11 |
Correct |
320 ms |
6756 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 |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
2 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
117 ms |
3052 KB |
Output is correct |
20 |
Correct |
448 ms |
10592 KB |
Output is correct |
21 |
Correct |
15 ms |
616 KB |
Output is correct |
22 |
Correct |
7 ms |
476 KB |
Output is correct |
23 |
Correct |
624 ms |
17268 KB |
Output is correct |
24 |
Execution timed out |
1076 ms |
26384 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |