Submission #564822

# Submission time Handle Problem Language Result Execution time Memory
564822 2022-05-19T18:15:17 Z almothana05 Question (Grader is different from the original contest) (CEOI14_question_grader) C++14
60 / 100
3022 ms 24180 KB
#include <stdio.h>
#include <stdlib.h>
#include<bits/stdc++.h>
using namespace std;

string bi(int x){
	string cmp;
	while(x){
		if(x % 2 == 0){
			cmp +='0';
		}
		else{
			cmp += '1';
		}
		x /= 2;
	}
	while(cmp.size() < 10){
		cmp += '0';
	}
	return cmp;
}

int encode (int n, int x, int y) {
	int re1 = 0 , re2 = 0;
	string s , t;
	s = bi(x);
	t = bi(y);
	for(int i = 0 ; i < s.size() ; i++){
		if(s[i] == '1' && t[i] == '0'){
			return i + 1;
		}
		re1 += s[i] - '0';
		re2 += t[i] - '0';
	}
	s = bi(re1);
	t = bi(re2);
	for(int i = 0 ; i < t.size() ; i++){
		if(s[i] == '0' && t[i] == '1'){
			return 10 + i + 1;
		}
	}
	assert(5 == 6);
}
#include <stdio.h>
#include <stdlib.h>
#include<bits/stdc++.h>
using namespace std;

string bi(int x){
	string cmp;
	while(x){
		if(x % 2 == 0){
			cmp +='0';
		}
		else{
			cmp += '1';
		}
		x /= 2;
	}
	while(cmp.size() < 10){
		cmp += '0';
	}
	return cmp;
}

int decode (int n, int q, int h) {
	int re = 0;
	string s = bi(q);
	if(h <= 10){
		if(s[h - 1] == '1'){
			return 1;
		}
		else{
			return 0;
		}
	}
	h -= 11;
	for(int i = 0 ; i <s.size() ; i++){
		if(s[i] == '1'){
			re++;
		}
	}
	s = bi(re);
	if(s[h] == '0'){
		return 1;
	}
	return 0;
}

Compilation message

encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:28:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for(int i = 0 ; i < s.size() ; i++){
      |                  ~~^~~~~~~~~~
encoder.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for(int i = 0 ; i < t.size() ; i++){
      |                  ~~^~~~~~~~~~

decoder.cpp: In function 'int decode(int, int, int)':
decoder.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for(int i = 0 ; i <s.size() ; i++){
      |                  ~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 2989 ms 24132 KB Output is partially correct - maxh = 14
2 Partially correct 3022 ms 24180 KB Output is partially correct - maxh = 14