#include "cmp.h"
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string toby(int x)
{
string s="";
while(x)
{
s+=x%2?"1":"0";
x/=2;
}
while(s.size()<13)
s+="0";
if(count(s.begin(),s.end(),'1')>6)
for(auto &c:s)
c=(c=='0'?'1':'0');
reverse(s.begin(),s.end());
return s;
}
void remember(int a)
{
string s=toby(a);
for(int i=0; i<13; i++)
if(s[i]=='1')
bit_set(i+1);
}
int compare(int b)
{
string s="";
for(int i=1; i<=13; i++)
s.push_back(bit_get(i)+'0');
reverse(s.begin(),s.end());
int ac=0;
if(s[12]=='1')
for(auto &c:s)
c=(c=='0'?'1':'0');
for(int i=0; i<12; i++)
if(s[i]=='1')
ac+=(1<<i);
if(ac>b)
return -1;
if(ac<b)
return 1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
3121 ms |
107036 KB |
Output is partially correct - maxAccess = 19, score = 19 |