This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// M
#include<bits/stdc++.h>
#include "vision.h"
#define pb push_back
using namespace std;
struct Data {vector < int > v;};
int Zero = -1;
inline Data Add(Data a, Data b)
{
assert(Zero != -1);
Data d;
int carry = Zero;
if (a.v.size() > b.v.size())
swap(a, b);
while (a.v.size() < b.v.size())
a.v.pb(Zero);
for (int i = 0; i < (int)a.v.size(); i ++)
{
d.v.pb(add_xor(vector < int > {a.v[i], b.v[i], carry}));
int tmp1 = add_and(vector < int > {a.v[i], b.v[i]});
int tmp2 = add_and(vector < int > {a.v[i], carry});
int tmp3 = add_and(vector < int > {carry, b.v[i]});
carry = add_or(vector < int > {tmp1, tmp2, tmp3});
}
d.v.pb(carry);
return d;
}
void construct_network(int n, int m, int k)
{
vector < Data > D;
for (int i = 0, last = -1; i < n; i ++)
{
vector < int > vec;
if (i) vec.pb(last);
for (int j = 0; j < m; j ++)
vec.pb(i * m + j);
last = add_xor(vec);
D.pb(Data { vector < int > {last} });
if (i == n - 1)
Zero = last;
}
for (int j = 0, last = -1; j < m; j ++)
{
vector < int > vec;
if (j) vec.pb(last);
for (int i = 0; i < n; i ++)
vec.pb(i * m + j);
last = add_xor(vec);
D.pb(Data { vector < int > {last} });
}
while (D.size() > 1)
{
vector < Data > D2;
for (int i = 1; i < (int)D.size(); i += 2)
D2.pb(Add(D[i - 1], D[i]));
if (D.size() & 1)
D2.pb(D.back());
D.swap(D2);
}
Data d = D[0];
vector < int > vec;
for (int i = 0; i < (int)d.v.size(); i ++)
if (k >> i & 1)
vec.pb(d.v[i]);
else
vec.pb(add_not(d.v[i]));
add_and(vec);
return ;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |