답안 #456460

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
456460 2021-08-06T20:08:25 Z Antekb Sob (COCI19_sob) C++14
0 / 110
1 ms 844 KB
#include<bits/stdc++.h>
using namespace std;
void solve(int k, vector<int> A, vector<int> B){
	assert(A.size()==B.size());
	//cout<<k<<"a"<<A.size()<<"\n";
	//assert(A.size()<=(1<<k));
	if(A.size()==(1<<k)){
		//cout<<(1<<k)<<"\n";
		for(int i=0; i<B.size(); i++){
			cout<<A[((1<<k)-1)^(B[i]&((1<<k)-1))]<<" "<<B[i]<<"\n";
			//cout<<(A[B.size()-1-(B[i]&(B.size()-1))]&B[i])<<"\n";
		}
	}
	else if(A.size()<(1<<k))solve(k-1, A, B);
	else{
		assert((1<<k)<A.size());
		assert((1<<(k+1))>A.size());
		vector<int> A1, A2, B1, B2;
		for(int i=0; i<(1<<k);i++)A1.push_back(A[i]);
		for(int i=(1<<k); i<A.size();i++)A2.push_back(A[i]);
		for(int i=0; i<A.size(); i++){
			if(i+(1<<k)==A.size() || (B[i]&(1<<k))){
				for(int j=0; j<(1<<k);j++){
					B1.push_back(B[i+j]);
				}
				for(int j=i+(1<<k); j<A.size(); j++){
					B2.push_back(B[j]);
				}
				break;
			}
			else B2.push_back(B[i]);
		}
		solve(k, A1, B1);
		solve(k-1, A2, B2);
	}
}
int main(){
	int n, m;
	cin>>n>>m;
	vector<int> A, B;
	for(int i=0; i<n; i++)A.push_back(i), B.push_back(m+i);
	solve(30, A, B);
}

Compilation message

sob.cpp: In function 'void solve(int, std::vector<int>, std::vector<int>)':
sob.cpp:7:13: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    7 |  if(A.size()==(1<<k)){
      |     ~~~~~~~~^~~~~~~~
sob.cpp:9:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |   for(int i=0; i<B.size(); i++){
      |                ~^~~~~~~~~
sob.cpp:14:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   14 |  else if(A.size()<(1<<k))solve(k-1, A, B);
      |          ~~~~~~~~^~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from sob.cpp:1:
sob.cpp:16:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   assert((1<<k)<A.size());
      |          ~~~~~~^~~~~~~~~
sob.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   assert((1<<(k+1))>A.size());
      |          ~~~~~~~~~~^~~~~~~~~
sob.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int i=(1<<k); i<A.size();i++)A2.push_back(A[i]);
      |                     ~^~~~~~~~~
sob.cpp:21:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   for(int i=0; i<A.size(); i++){
      |                ~^~~~~~~~~
sob.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |    if(i+(1<<k)==A.size() || (B[i]&(1<<k))){
      |       ~~~~~~~~^~~~~~~~~~
sob.cpp:26:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int j=i+(1<<k); j<A.size(); j++){
      |                         ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -