提交记录 8986
用户 | 题目 | 状态 | 得分 | 用时 | 内存 | 语言 | 代码长度 |
---|---|---|---|---|---|---|---|
Dustii | noi17a. 【NOI2017】整数 | Accepted | 100 | 373.156 ms | 19076 KB | C++11 | 2.21 KB |
提交时间 | 评测时间 |
---|---|
2019-03-30 19:03:38 | 2020-08-01 01:28:31 |
#include <set>
#include <cstdio>
#include <cctype>
#include <bitset>
const int ioSize = 1 << 21 | 1;
char iBuf[ioSize], *iS, *iE;
inline char getc() { return iS == iE ? iE = iBuf + fread(iS = iBuf, 1, ioSize, stdin), iS == iE ? EOF : *iS++ : *iS++; }
void readi(int &x)
{
char c;
bool isneg = false;
for (c = getc(); !isdigit(c) && c != '-'; c = getc())
;
if (c == '-')
isneg = true, c = getc();
x = c ^ '0';
for (c = getc(); isdigit(c); c = getc())
(x *= 10) += c ^ '0';
if (isneg)
x = -x;
}
typedef unsigned long long ull;
const int base = 60, maxN = 1000005;
const ull MAX = (1ULL << 60) - 1;
ull A[maxN], B[maxN];
std::set<int> diffPos;
void add(int x)
{
int block = x / base;
x %= base;
ull temp = 1ULL << x;
while (temp)
{
ull old = A[block];
A[block] += temp;
temp = A[block] >> base;
A[block] &= MAX;
if (old == B[block] && A[block] != B[block])
diffPos.insert(block);
if (old != B[block] && A[block] == B[block])
diffPos.erase(block);
++block;
}
}
void minus(int x)
{
int block = x / base;
x %= base;
ull temp = 1ULL << x;
while (temp)
{
ull old = B[block];
B[block] += temp;
temp = B[block] >> base;
B[block] &= MAX;
if (A[block] == old && A[block] != B[block])
diffPos.insert(block);
if (A[block] != old && A[block] == B[block])
diffPos.erase(block);
++block;
}
}
int query(int x)
{
int block = x / base;
x %= base;
int ans = (A[block] >> x & 1) ^ (B[block] >> x & 1);
ull temp = A[block] ^ B[block];
temp &= (1ULL << x) - 1;
if (!temp)
{
auto it = diffPos.lower_bound(block);
if (it != diffPos.begin())
{
--it;
block = *it;
temp = A[block] ^ B[block];
}
}
if (temp)
{
int pos = 63 - __builtin_clzll(temp);
if ((A[block] >> pos & 1) < (B[block] >> pos & 1))
ans ^= 1;
}
return ans;
}
int main()
{
int n, t1, t2, t3;
readi(n), readi(t1), readi(t2), readi(t3);
for (int o, a, b, k; n--;)
{
readi(o);
if (o == 1)
{
readi(a), readi(b);
if (a > 0)
{
for (int i = 0; i != 30; ++i)
if (a >> i & 1)
add(b + i);
}
else if (a < 0)
{
a = -a;
for (int i = 0; i != 30; ++i)
if (a >> i & 1)
minus(b + i);
}
}
else
{
readi(k);
printf("%d\n", query(k));
}
}
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 17.36 us | 36 KB | Accepted | Score: 4 | 显示更多 |
Testcase #2 | 50.26 us | 36 KB | Accepted | Score: 4 | 显示更多 |
Testcase #3 | 492.41 us | 56 KB | Accepted | Score: 4 | 显示更多 |
Testcase #4 | 560.8 us | 72 KB | Accepted | Score: 4 | 显示更多 |
Testcase #5 | 1.669 ms | 120 KB | Accepted | Score: 4 | 显示更多 |
Testcase #6 | 837.28 us | 116 KB | Accepted | Score: 4 | 显示更多 |
Testcase #7 | 2.676 ms | 328 KB | Accepted | Score: 4 | 显示更多 |
Testcase #8 | 2.584 ms | 184 KB | Accepted | Score: 4 | 显示更多 |
Testcase #9 | 9.11 ms | 1020 KB | Accepted | Score: 4 | 显示更多 |
Testcase #10 | 14.052 ms | 1 MB + 88 KB | Accepted | Score: 4 | 显示更多 |
Testcase #11 | 15.985 ms | 992 KB | Accepted | Score: 4 | 显示更多 |
Testcase #12 | 9.419 ms | 1 MB + 656 KB | Accepted | Score: 4 | 显示更多 |
Testcase #13 | 21.945 ms | 2 MB + 292 KB | Accepted | Score: 4 | 显示更多 |
Testcase #14 | 65 ms | 5 MB + 368 KB | Accepted | Score: 4 | 显示更多 |
Testcase #15 | 48.01 ms | 6 MB + 400 KB | Accepted | Score: 4 | 显示更多 |
Testcase #16 | 134.885 ms | 8 MB + 696 KB | Accepted | Score: 4 | 显示更多 |
Testcase #17 | 136.72 ms | 2 MB + 848 KB | Accepted | Score: 4 | 显示更多 |
Testcase #18 | 212.721 ms | 12 MB + 16 KB | Accepted | Score: 4 | 显示更多 |
Testcase #19 | 251.404 ms | 13 MB + 672 KB | Accepted | Score: 4 | 显示更多 |
Testcase #20 | 344.072 ms | 17 MB + 440 KB | Accepted | Score: 4 | 显示更多 |
Testcase #21 | 170.416 ms | 15 MB + 120 KB | Accepted | Score: 4 | 显示更多 |
Testcase #22 | 255.298 ms | 3 MB + 528 KB | Accepted | Score: 4 | 显示更多 |
Testcase #23 | 283.253 ms | 6 MB + 512 KB | Accepted | Score: 4 | 显示更多 |
Testcase #24 | 271.679 ms | 3 MB + 628 KB | Accepted | Score: 4 | 显示更多 |
Testcase #25 | 373.156 ms | 18 MB + 644 KB | Accepted | Score: 4 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-09-08 08:59:58 | Loaded in 2 ms | Server Status
个人娱乐项目,仅供学习交流使用