#include <bits/stdc++.h>
#define SIZE(x) int(x.size())
using namespace std;
std::vector<int> get_attachment(std::vector<int> source)
{
vector<int>cal;
vector<int>ag, ag2;
int pot=1, i, pos=0,cP=0, j, un;
for(i=0; pos<SIZE(source); i++)
{
if(i+1==pot)
{
pot*=2;
cP++;
cal.push_back(2);
}
else
{
cal.push_back(source[pos]);
pos++;
}
}
pot=1;
for(i=0; i<cP; i++)
{
un=0;
for(j=pot-1; j<SIZE(cal); j++)
{
if((j+1)&pot)
{
if(cal[j]==1)
un++;
}
}
if(un%2==0)
ag.push_back(0);
else
ag.push_back(1);
pot*=2;
}
for(i=SIZE(ag)-1; i>=0; i--)
{
ag2.push_back(ag[i]);
}
return ag2;
}
std::vector<int> retrieve(std::vector<int> data)
{
vector<int>ret(SIZE(data)), comp(SIZE(data)), ag, ag2;
int pot=1, pos=0, i, cP=0, j, un;
for(i=0; i<SIZE(ret); i++)
{
if(i+1==pot)
{
ret[i]=data[SIZE(data)-1];
comp[i]=2;
cP++;
ag2.push_back(ret[i]);
data.pop_back();
pot*=2;
}
else
{
ret[i]=data[pos];
comp[i]=ret[i];
pos++;
}
}
pot=1;
for(i=0; i<cP; i++)
{
un=0;
for(j=pot-1; j<SIZE(comp); j++)
{
if((j+1)&pot)
{
if(comp[j]==1)
un++;
}
}
if(un%2==0)
ag.push_back(0);
else
ag.push_back(1);
pot*=2;
}
vector<bool>bus(cP,1);
for(i=0; i<SIZE(ag); i++)
{
if(ag[i]!=ag2[i])
{
bus[i]=0;
}
}
pot=1;
int arr=0;
for(auto k:bus)
{
if(k==0)
{
arr=arr|pot;
}
pot*=2;
}
for(i=0; i<SIZE(ret); i++)
{
if(i+1==arr)
{
ret[i]=!ret[i];
}
}
vector<int>ans;
pot=1;
for(i=0; i<SIZE(ret); i++)
{
if(i+1==pot)
{
pot*=2;
}
else
{
ans.push_back(ret[i]);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
792 KB |
Output is correct |
2 |
Correct |
4 ms |
796 KB |
Output is correct |
3 |
Correct |
4 ms |
800 KB |
Output is correct |
4 |
Correct |
5 ms |
1084 KB |
Output is correct |
5 |
Correct |
6 ms |
792 KB |
Output is correct |
6 |
Correct |
5 ms |
800 KB |
Output is correct |
7 |
Correct |
6 ms |
796 KB |
Output is correct |
8 |
Correct |
4 ms |
800 KB |
Output is correct |
9 |
Correct |
5 ms |
796 KB |
Output is correct |
10 |
Correct |
4 ms |
800 KB |
Output is correct |
11 |
Correct |
4 ms |
792 KB |
Output is correct |
12 |
Correct |
5 ms |
1012 KB |
Output is correct |
13 |
Correct |
4 ms |
792 KB |
Output is correct |
14 |
Correct |
5 ms |
800 KB |
Output is correct |
15 |
Correct |
5 ms |
800 KB |
Output is correct |
16 |
Correct |
6 ms |
788 KB |
Output is correct |
17 |
Correct |
6 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
197 ms |
2516 KB |
Output is correct |
2 |
Correct |
197 ms |
2516 KB |
Output is correct |
3 |
Correct |
199 ms |
2512 KB |
Output is correct |
4 |
Correct |
208 ms |
2508 KB |
Output is correct |
5 |
Correct |
202 ms |
2504 KB |
Output is correct |
6 |
Correct |
221 ms |
2508 KB |
Output is correct |
7 |
Correct |
204 ms |
2516 KB |
Output is correct |
8 |
Correct |
191 ms |
2504 KB |
Output is correct |
9 |
Correct |
189 ms |
2520 KB |
Output is correct |
10 |
Correct |
195 ms |
2516 KB |
Output is correct |
11 |
Correct |
179 ms |
2508 KB |
Output is correct |
12 |
Correct |
213 ms |
2516 KB |
Output is correct |
13 |
Correct |
195 ms |
2508 KB |
Output is correct |
14 |
Correct |
194 ms |
2512 KB |
Output is correct |
15 |
Correct |
202 ms |
2512 KB |
Output is correct |
16 |
Correct |
206 ms |
2512 KB |
Output is correct |
17 |
Correct |
203 ms |
2508 KB |
Output is correct |
18 |
Correct |
210 ms |
2508 KB |
Output is correct |
19 |
Correct |
204 ms |
2516 KB |
Output is correct |