超极快读快写
#include <bits/stdc++.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdint.h>
#include <ctype.h>
#include <cstring>
using namespace std;
constexpr size_t MSIZE = 1 << 25;
constexpr size_t PRE_DATA_SIZE = 0x10000;
const int PROT = PROT_READ;
const int FLAGS = MAP_PRIVATE;
char* c = nullptr;
uint64_t pre_data[PRE_DATA_SIZE];
using u32 = uint64_t;
inline void init_pre_data() {
fill_n(pre_data, PRE_DATA_SIZE, UINT32_MAX);
for (size_t i = 0; i < 10; ++i) {
for (size_t j = 0; j < 10; ++j) {
uint16_t key = (('0' + j) << 8) | ('0' + i);
pre_data[key] = i + j * 10;
}
}
}
inline u32 readu() {
while (*c <= ' ') ++c;
u32 x = 0;
while (true) {
uint16_t key;
memcpy(&key, c, sizeof(key));
if (pre_data[key] != UINT32_MAX) {
x = x * 100 + pre_data[key];
c += 2;
} else {
break;
}
}
if (isdigit(static_cast<unsigned char>(*c))) {
x = x * 10 + (*c - '0');
++c;
}
return x;
}
inline void write_str(const char* s) {
while (*s != '\0') {
putchar_unlocked(*s);
++s;
}
}
inline void write_u32(u32 x) {
static char buf[12];
char* ptr = buf + 11;
*ptr = '\0';
if (x == 0) {
*(--ptr) = '0';
} else {
while (x > 0) {
*(--ptr) = (x % 10) + '0';
x /= 10;
}
}
write_str(ptr);
putchar_unlocked('\n');
}
inline void cleanup() {
if (c != MAP_FAILED && c != nullptr) {
munmap(c, MSIZE);
}
}
int main() {
int fd = open("/dev/stdin", O_RDONLY);
if (fd == -1) {
perror("open stdin failed");
exit(EXIT_FAILURE);
}
c = static_cast<char*>(mmap( nullptr, MSIZE, PROT,FLAGS, fd, 0));
close(fd);
if (c == MAP_FAILED) {
perror("mmap failed");
exit(EXIT_FAILURE);
}
atexit(cleanup);
init_pre_data();
u32 k = readu();
while (k >= 4) {
write_u32(readu() ^ readu());
write_u32(readu() ^ readu());
write_u32(readu() ^ readu());
write_u32(readu() ^ readu());
k -= 4;
}
while (k-- > 0) {
write_u32(readu() ^ readu());
}
return 0;
}