Submission #403066

# Submission time Handle Problem Language Result Execution time Memory
403066 2021-05-12T17:37:18 Z peuch "The Lyuboyn" code (IZhO19_lyuboyn) C++17
3 / 100
317 ms 7396 KB
#include<bits/stdc++.h>
using namespace std;
 
const int MAXN = 1 << 19;
 
int n, k, t, s;
 
int marc[MAXN];
 
vector<int> getK1(int n);
 
int scanBit(int tam);
void printBit(int tam, int val);
 
int main(){
	scanf("%d %d %d", &n, &k, &t);
	s = scanBit(n);
	if(k % 2 == 0){
		printf("-1\n");
		return 0;
	}
	vector<int> ord = getK1(n);
	vector<int> ans;
	for(int i = 0; i < ord.size(); i++){
		ans.push_back(s);
		for(int j = 0; j < n; j++){
			if((1 << j) & ord[i]){
				for(int x = 0; x < k; x++){
					int cur = (j + x) % n;
					ans[i] ^= (1 << cur);
				}
			}
		}
		ans[i] ^= ord[i];
	}
	int cnt = 0;
	printf("%d\n", 1 << n);
	for(int i = 0; i < ans.size(); i++)
		printBit(n, ans[i]);
}
 
vector<int> getK1(int n){
	vector<int> ret;
	if(n == 1){
		ret.push_back(0);
		ret.push_back(1);
		return ret;
	}
	vector<int> aux = getK1(n - 1);
	for(int i = 0; i < aux.size(); i++)
		ret.push_back(aux[i]);
	for(int i = aux.size() - 1; i >= 0; i--){
		ret.push_back(aux[i] | (1 << (n - 1)));
	}
	return ret;
}
 
int scanBit(int tam){
	int ret = 0;
	for(int i = tam - 1; i >= 0; i--){
		char aux;
		scanf(" %c", &aux);
		if(aux == '1') ret |= (1 << i);
	}
	return ret;
}
 
void printBit(int tam, int val){
	for(int i = tam - 1; i >= 0; i--){
		if((1 << i) & val) printf("1");
		else printf("0");
	}
	printf("\n");
}

Compilation message

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for(int i = 0; i < ord.size(); i++){
      |                 ~~^~~~~~~~~~~~
lyuboyn.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for(int i = 0; i < ans.size(); i++)
      |                 ~~^~~~~~~~~~~~
lyuboyn.cpp:36:6: warning: unused variable 'cnt' [-Wunused-variable]
   36 |  int cnt = 0;
      |      ^~~
lyuboyn.cpp: In function 'std::vector<int> getK1(int)':
lyuboyn.cpp:50:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |  for(int i = 0; i < aux.size(); i++)
      |                 ~~^~~~~~~~~~~~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%d %d %d", &n, &k, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
lyuboyn.cpp: In function 'int scanBit(int)':
lyuboyn.cpp:62:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |   scanf(" %c", &aux);
      |   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB The values in the output sequence are not pairwise distinct!
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB The values in the output sequence are not pairwise distinct!
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 1 ms 204 KB Ok
7 Correct 1 ms 204 KB Ok
8 Correct 1 ms 204 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 203 ms 7364 KB The values in the output sequence are not pairwise distinct!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB The values in the output sequence are not pairwise distinct!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 317 ms 7396 KB The values in the output sequence are not pairwise distinct!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 203 ms 7364 KB The values in the output sequence are not pairwise distinct!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 188 ms 3784 KB The values in the output sequence are not pairwise distinct!
2 Halted 0 ms 0 KB -