QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#225177 | #6549. Two Missing Numbers | ucup-team1069 | 0 | 1ms | 3940kb | C++20 | 4.4kb | 2023-10-24 03:07:23 | 2023-10-24 03:07:23 |
answer
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
#define make_unique(x) sort(all(x)), x.erase(unique(all(x)), x.end())
mt19937 bruh(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rofl(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef set<int> si;
typedef set<ll> sll;
typedef set<pii> spii;
typedef set<pll> spll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, ll> mll;
const int N = 1e6 + 2;
const int M = 1e5;
const int inf = 2e9 + 3;
const ll INF = 1e18;
const ld pi2 = 2.0 * 3.141592653589793;
const ld pi = 3.141592653589793;
const ld eps = 1e-12;
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
#ifndef PC
#define gcd __gcd
#endif
void files(string s = "main") {
#ifndef PC
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
#endif
}
using Ull = __int128;
Ull mod = ((Ull)(1) << 64) + ((Ull)(1) << 46) + ((Ull)(1) << 4) + ((Ull)(1) << 1) + ((Ull)(1) << 0);
Ull sz = ((Ull)(1) << 64);
ull mul(ull a, ull b) {
Ull r = a, res = 0;
for (ull i = 0; i < 64; ++i) {
if ((b >> i) & 1)
res ^= r;
r <<= 1;
}
for (ull i = 127; i >= 64; --i) {
if ((res >> i) & 1) {
res ^= (mod << (i - 64));
}
}
return res;
}
ull add(ull a, ull b) {
return a ^ b;
}
ull inv(ull a) {
Ull pw = sz - 2;
ull res = 1;
for (Ull i = 0; i <= 64; ++i) {
if ((pw >> i) & 1) {
res = mul(res, a);
}
a = mul(a, a);
}
return res;
}
int f[64][64], p[128][64], k[64][64];
ull qs(ull a) {
ull res = 0;
for (int i = 0; i < 64; ++i) {
for (int j = 0; j < 64; ++j) {
if ((a >> j) & 1) {
res ^= (f[i][j] << i);
}
}
}
return res;
}
int main() {
speed;
ull now = 1;
for (int i = 0; i < 128; ++i) {
for (int j = 0; j < 64; ++j)
p[i][j] ^= ((now >> j) & 1);
now = mul(now, 2);
}
for (int i = 0; i < 64; ++i)
for (int j = 0; j < 64; ++j)
if (p[2 * i][j])
f[j][i] ^= 1;
int q, n;
cin >> q >> n;
if (q == 1) {
ull x = 0, y = 0;
while (n--) {
ull p = 0;
cin >> p;
x = add(x, p);
y = add(y, mul(p, mul(p, p)));
}
cout << x << " " << y << '\n';
}
else {
ull x, y;
cin >> x >> y;
while (n--) {
ull p = 0;
cin >> p;
x = add(x, p);
y = add(y, mul(p, mul(p, p)));
}
ull d = x;
ull c = add(mul(x, x), mul(y, inv(x)));
for (int i = 0; i < 64; ++i) {
for (int j = 0; j < 64; ++j) {
for (int l = 0; l < 64; ++l) {
f[l][j] ^= ((d >> i) & 1) & (p[i + j][l]);
}
}
}
bitset<64> C = c;
for (int i = 0; i < 64; i++) {
if (f[i][i] == 1) {
for (int j = i + 1; j < 64; ++j) {
if (f[j][i] == 1) {
for (int k = 0; k < 64; ++k) {
f[j][k] ^= f[i][k];
}
C[j] = C[j] ^ C[i];
}
}
}
}
bitset<64> X;
for (int i = 63; i >= 0; --i) {
for (int j = i + 1; j < 64; ++j)
X[i] = X[i] ^ X[j];
X[i] = X[i] ^ C[i];
}
y = X.to_ullong();
x = add(x, y);
cout << x << " " << y << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3888kb
First Run Input
1 5 5 1 4 4 5
First Run Output
1 1
Second Run Input
2 3 1 1 9 9 3
Second Run Output
3 1
result:
ok correct
Test #2:
score: 100
Accepted
time: 0ms
memory: 3940kb
First Run Input
1 1 0
First Run Output
0 0
Second Run Input
2 1 0 0 1
Second Run Output
1 0
result:
ok correct
Test #3:
score: 0
Wrong Answer
time: 1ms
memory: 3872kb
First Run Input
1 1 10625130587464985929
First Run Output
10625130587464985929 13391699470145443296
Second Run Input
2 1 10625130587464985929 13391699470145443296 1167154569617655189
Second Run Output
10862828303802019745 1550962124683577213
result:
wrong answer incorrect, read 1550962124683577213 10862828303802019745 but expected 1167154569617655189 10625130587464985929