제출 #1257469

#제출 시각아이디문제언어결과실행 시간메모리
1257469XXBabaProBerkaySob (COCI19_sob)C++20
0 / 110
1095 ms2372 KiB
#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define MP make_pair
#define PB push_back

using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pll = pair<ll, ll>;

template<typename T>
using vec = vector<T>;

template<typename T, int N>
using arr = array<T, N>;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

const int INF = 1e9 + 7;
const int MOD = 998244353;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int N, M;
	cin >> N >> M;
	vec<int> a(N);
	iota(a.begin(), a.end(), 0);
	vec<bool> b(N);

	auto comp = [&](int x, int y) -> bool {
		return __builtin_popcount(x) > __builtin_popcount(y);
	};
	sort(a.begin(), a.end(), comp);

	vec<int> ans(N);
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			if ((a[i] & (M + j)) == a[i] && !b[j])
			{
				ans[a[i]] = M + j;
				b[j] = 1;
				break;
			}

	for (int i = 0; i < N; i++)
		cout << i << ' ' << ans[i] << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...