답안 #811279

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
811279 2023-08-07T03:42:06 Z pcc Sob (COCI19_sob) C++14
10 / 110
33 ms 3832 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second

inline int calc(int k){
	int re = 0;
	while(!(k&1))k>>=1,re++;
	return re;
}

struct node{
	int val;
	node(){}
	node(int k){
		val = k;
	}
	bool operator<(node b)const{
		return __builtin_popcount(val)==__builtin_popcount(b.val)?val<b.val:__builtin_popcount(val)<__builtin_popcount(b.val);
	}
};


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,m;
	cin>>n>>m;
	if(__builtin_popcount(n) == 1){
		int start = m;
		for(int i = m;i<n+m;i++){
			if(calc(start)<calc(i))start = i;
		}
		int now = start;
		for(int i = 0;i<n;i++){
			cout<<i<<' '<<now<<'\n';
			now++;
			if(now == n+m)now = m;
		}
	}
	else{
		set<node> s1,s2;
		for(int i = 0;i<n;i++)s1.insert(node(i));
		for(int i = m;i<n+m;i++)s2.insert(node(i));
		for(auto it = s1.rbegin();it != s1.rend();it++){
			cout<<it->val<<' ';
			int val = s2.begin()->val;
			for(auto &j:s2){
				if((it->val&j.val) == it->val)val = j.val;
			}
			cout<<val<<endl;
			s2.erase(node(val));
		}
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 30 ms 3832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 640 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Incorrect 1 ms 316 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 30 ms 3832 KB Output is correct
5 Correct 33 ms 640 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -