답안 #668702

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
668702 2022-12-04T14:31:08 Z sysia Sob (COCI19_sob) C++17
0 / 110
2 ms 580 KB
//Sylwia Sapkowska
#include <bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define int long long
const int oo = 1e18, oo2 = 1e9+7, K = 20;
const int mod = 998244353;

void rec(vector<int>a, vector<int>b, int bit){
	assert(a.size() == b.size());
	int n = (int)a.size();
	if (bit < 0){
		for (int i = 0; i<n; i++){
			cout << a[i] << " " << b[i] << "\n";
		}
		return;
	}
	vector<vector<int>>A(2), B(2);
	for (auto v: a)	A[(bool)(v&(1<<bit))].emplace_back(v);
	for (auto v: b)	B[(bool)(v&(1<<bit))].emplace_back(v);
	// debug(A, B);
	int diff = A[0].size()-B[0].size();
	assert(diff >= 0);
	rotate(A[0].begin(), A[0].begin()+diff, A[0].end());
	vector<int>mv;
	for (int i = 0; i<diff; i++){
		mv.emplace_back(A[0].back());
		A[0].pop_back();
	}
	reverse(mv.begin(), mv.end());
	for (auto x: A[1]) mv.emplace_back(x);
	A[1] = mv;
	// debug(A, B);
	rec(A[0], B[0], bit-1);
	rec(A[1], B[1], bit-1);
}

void solve(){
	int n, m; cin >> n >> m;
	vector<int>a, b;
	for (int i = 0; i<n; i++){
		a.emplace_back(i);
		b.emplace_back(m+i);
	}
	rec(a, b, 3);
}

int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	solve();
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -