#include <bits/stdc++.h>
using namespace std;
#define ll long long
string tobase(int a, int base) {
string str = "";
while(a > 0) {
// cout << a << " " << str << endl;
char ch = a%base;
str+= ch+'0';
a/=base;
}
reverse(str.begin(),str.end());
return str;
}
int encode(int n, int x, int y) {
string sx = tobase(x,2);
string sy = tobase(y,2);
while(sx.length() < 10) {
sx = '0'+sx;
}
while(sy.length() < 10) {
sy = '0'+sy;
}
for(int i = 0; i < 10; i++) {
if(sx.at(i) != sy.at(i)) {
return (2*i)+sx.at(i)-'0'+1;
}
}
return 0;
}
bool decode(int n, int q, int h) {
h--;
string sx = tobase(q,2);
while(sx.length() < 10) {
sx = '0'+sx;
}
if(sx.at(h/2)-'0' ==h%2) {
return true;
} else {
return false;
}
}
/*
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
// cout << tobase(920,3) << endl;
int ty;
cin >> ty;
int n,T;
cin >> n >> T;
cout << ty << " " << n << " " << T << "\n";
int mx = 0;
if(ty == 1) {
while(T--) {
int x,y;
cin >> x >> y;
string sx = tobase(x,2);
string sy = tobase(y,2);
cout << sx << " " << sy << "\n";
while(sx.length() < 10) {
sx = '0'+sx;
}
while(sy.length() < 10) {
sy = '0'+sy;
}
for(int i = 0; i < 10; i++) {
if(sx.at(i) != sy.at(i)) {
cout << (2*i)+sx.at(i)-'0'+1 << "\n";
mx = max(mx,(2*i)+sx.at(i)-'0'+1);
break;
}
}
}
} else {
while(T--) {
int q,h;
cin >> q >> h;
mx = max(mx,h);
h--;
string sx = tobase(q,2);
while(sx.length() < 10) {
sx = '0'+sx;
}
if(sx.at(h/2)-'0' ==h%2) {
cout << "yes\n";
} else {
cout << "no\n";
}
}
}
cout << mx;
return 0;
}
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
string tobase(int a, int base) {
string str = "";
while(a > 0) {
// cout << a << " " << str << endl;
char ch = a%base;
str+= ch+'0';
a/=base;
}
reverse(str.begin(),str.end());
return str;
}
int encode(int n, int x, int y) {
string sx = tobase(x,2);
string sy = tobase(y,2);
while(sx.length() < 10) {
sx = '0'+sx;
}
while(sy.length() < 10) {
sy = '0'+sy;
}
for(int i = 0; i < 10; i++) {
if(sx.at(i) != sy.at(i)) {
return (2*i)+sx.at(i)-'0'+1;
}
}
return 0;
}
bool decode(int n, int q, int h) {
h--;
string sx = tobase(q,2);
while(sx.length() < 10) {
sx = '0'+sx;
}
if(sx.at(h/2)-'0' ==h%2) {
return true;
} else {
return false;
}
}
/*
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
// cout << tobase(920,3) << endl;
int ty;
cin >> ty;
int n,T;
cin >> n >> T;
cout << ty << " " << n << " " << T << "\n";
int mx = 0;
if(ty == 1) {
while(T--) {
int x,y;
cin >> x >> y;
string sx = tobase(x,2);
string sy = tobase(y,2);
cout << sx << " " << sy << "\n";
while(sx.length() < 10) {
sx = '0'+sx;
}
while(sy.length() < 10) {
sy = '0'+sy;
}
for(int i = 0; i < 10; i++) {
if(sx.at(i) != sy.at(i)) {
cout << (2*i)+sx.at(i)-'0'+1 << "\n";
mx = max(mx,(2*i)+sx.at(i)-'0'+1);
break;
}
}
}
} else {
while(T--) {
int q,h;
cin >> q >> h;
mx = max(mx,h);
h--;
string sx = tobase(q,2);
while(sx.length() < 10) {
sx = '0'+sx;
}
if(sx.at(h/2)-'0' ==h%2) {
cout << "yes\n";
} else {
cout << "no\n";
}
}
}
cout << mx;
return 0;
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2049 ms |
79016 KB |
wrong answer |
2 |
Incorrect |
2521 ms |
79440 KB |
wrong answer |