結果
| 問題 | No.8057 A xor B = C |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-01 23:16:15 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,999 bytes |
| 記録 | |
| コンパイル時間 | 1,015 ms |
| コンパイル使用メモリ | 141,348 KB |
| 実行使用メモリ | 6,144 KB |
| 最終ジャッジ日時 | 2026-03-15 09:00:03 |
| 合計ジャッジ時間 | 1,497 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 4 RE * 1 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/vector:67,
from main.cpp:2:
In function '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = int*; _ForwardIterator = int*]',
inlined from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _Sentinel, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = int*; _Sentinel = int*; _ForwardIterator = int*; _Tp = int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_uninitialized.h:637:37,
inlined from 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/vector.tcc:257:35,
inlined from 'int main()' at main.cpp:120:16:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_uninitialized.h:273:31: warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' writing between 1 and 40000 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
273 | __builtin_memcpy(std::__niter_base(__result),
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
274 | std::__niter_base(__first),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
275 | __n * sizeof(_ValT));
| ~~~~~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/allocator.h:46,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:45,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/locale_classes.h:42,
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;
typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932; // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod
bool check(vector<int>& v){
int sz = v.size();
for(int i = 0; i < sz; ++i){
if(v[i]) return true;
}
return false;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s, t;
cin >> s >> t;
reverse(s.begin(), s.end());
reverse(t.begin(), t.end());
int ns = s.length(), nt = t.length();
vector<int> a(ns), b(nt);
for(int i = 0; i < ns; ++i) a[i] = s[i] - '0';
for(int i = 0; i < nt; ++i) b[i] = t[i] - '0';
vector<int> A;
while(check(a)){
A.push_back((a[0] % 2 == 0) ? 0 : 1);
if(a[0] % 2 != 0) --a[0];
a[0] /= 2;
for(int i = 1; i < ns; ++i){
int foo = 10 * a[i];
foo /= 2;
a[i - 1] += foo % 10;
a[i] = foo / 10;
}
}
vector<int> B;
while(check(b)){
B.push_back((b[0] % 2 == 0) ? 0 : 1);
if(b[0] % 2 != 0) --b[0];
b[0] /= 2;
for(int i = 1; i < nt; ++i){
int foo = 10 * b[i];
foo /= 2;
b[i - 1] += foo % 10;
b[i] = foo / 10;
}
}
int na = A.size(), nb = B.size();
if(na > nb) swap(A, B), swap(na, nb);
vector<int> ans(nb);
for(int i = 0; i < na; ++i) ans[i] = A[i] ^ B[i];
for(int i = na; i < nb; ++i) ans[i] = B[i];
vector<int> ans2(10000, 0);
int digit_cnt = 1, digit_cnt2 = 1;
vector<int> pow2(10000, 0);
pow2[0] = 1;
if(ans[0]) ans2[0] = 1;
for(int i = 1; i < ans.size(); ++i){
vector<int> hoge(10000, 0);
for(int j = 0; j < digit_cnt; ++j){
int foo = pow2[j] * 2;
hoge[j] += foo % 10;
int bar = hoge[j];
hoge[j] = bar % 10;
bar /= 10;
foo /= 10;
foo += bar;
int add = 1;
while(foo){
hoge[j + add] += foo % 10;
int bar2 = hoge[j + add];
hoge[j + add] = bar2 % 10;
bar2 /= 10;
foo /= 10;
foo += bar2;
chmax(digit_cnt, j + add + 1);
++add;
}
}
pow2 = hoge;
chmax(digit_cnt2, digit_cnt);
if(!ans[i]) continue;
for(int j = 0; j < digit_cnt2; ++j){
ans2[j] += pow2[j];
int foo = ans2[j];
ans2[j] = foo % 10;
foo /= 10;
int add = 1;
while(foo){
ans2[j + add] += foo % 10;
int bar = ans2[j + add];
ans2[j + add] = bar % 10;
bar /= 10;
foo /= 10;
foo += bar;
chmax(digit_cnt2, j + add + 1);
++add;
}
}
}
for(int i = digit_cnt2 - 1; i >= 0; --i) cout << ans2[i];
cout << endl;
// reverse(s.begin(), s.end());
// reverse(t.begin(), t.end());
// int X = atoi(s.c_str()), Y = atoi(t.c_str());
// cerr << X << " " << Y << endl;
// cerr << (X ^ Y) << endl;
}