답안 #471357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471357 2021-09-08T14:29:54 Z lovrot 질문 (CEOI14_question_grader) C++11
0 / 100
2977 ms 24112 KB
#include <bits/stdc++.h>

using namespace std;

bool breakb = false;

vector<int> out;

int m;

void shuffle(int x, int pos, int par){
	//cout << x << ' ' << pos << ' ' << par << "\n"; 

	if(breakb) return;

	if(pos >= 12){ 
		out.push_back(par);
		if(out.size() > m)
			breakb = true;

		return;
	}

	if(x) 
		shuffle(x - 1, pos + 1, par ^ (1 << pos));
	
	if(12 - pos > x)
		shuffle(x, pos + 1, par);
}

int encode(int n, int x, int y){ 
	ios_base::sync_with_stdio(false);
	
	m = n;
	shuffle(6, 0, 0);

	for (int i = 0; i < 12; i++)
		if ((out[x] & (1 << i)) && (!(out[y] & (1 << i))))
			return i+1;
}
#include <bits/stdc++.h>

using namespace std;

bool breakb = false;

vector<int> out;

int m;

void shuffle(int x, int pos, int par){
	//cout << x << ' ' << pos << ' ' << par << "\n"; 

	if(breakb) return;
	
	if(pos >= 12){ 
		out.push_back(par);
		if(out.size() > m)
			breakb = true;

		return;
	}

	if(x) 
		shuffle(x - 1, pos + 1, par ^ (1 << pos));
	
	if(12 - pos > x)
		shuffle(x, pos + 1, par);
}

int decode(int n, int q, int h){ 
	ios_base::sync_with_stdio(false);

	shuffle(6, 0, 0);

	m = n;

	if(out[q] & (1 << h - 1)) return 1;
	return 0;
}

Compilation message

encoder.cpp: In function 'void shuffle(int, int, int)':
encoder.cpp:18:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |   if(out.size() > m)
      |      ~~~~~~~~~~~^~~
encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
   40 | }
      | ^

decoder.cpp: In function 'void shuffle(int, int, int)':
decoder.cpp:18:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |   if(out.size() > m)
      |      ~~~~~~~~~~~^~~
decoder.cpp: In function 'int decode(int, int, int)':
decoder.cpp:38:22: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   38 |  if(out[q] & (1 << h - 1)) return 1;
      |                    ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2779 ms 24112 KB wrong answer
2 Incorrect 2977 ms 24100 KB wrong answer