結果
| 問題 | No.438 Cwwプログラミング入門 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-29 01:01:22 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,360 bytes |
| 記録 | |
| コンパイル時間 | 1,300 ms |
| コンパイル使用メモリ | 179,924 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-19 03:10:52 |
| 合計ジャッジ時間 | 5,145 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 95 WA * 3 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/cstdlib:87,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:41,
from main.cpp:1:
In function 'long long int std::abs(long long int)',
inlined from 'int main()' at main.cpp:67:18:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/std_abs.h:67:51: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized]
67 | abs(long long __x) { return __builtin_llabs (__x); }
| ^
main.cpp: In function 'int main()':
main.cpp:59:6: note: 'a' was declared here
59 | ll a,b;
| ^
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/istream:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/sstream:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/complex:50,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ccomplex:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:133:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]',
inlined from 'int main()' at main.cpp:83:3:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:212:25: warning: 'b' may be used uninitialized [-Wmaybe-uninitialized]
212 | { return _M_insert(__n); }
| ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:59:8: note: 'b' was declared here
59 | ll a,b;
| ^
ソースコード
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;
ll calczero(){
return 3;
}
string makezero(){
return "ccW";
}
ll calclen(ll a) {
if (a == 0) {
return 0;
}
if (a < 0) {
return calczero() + abs(a) * 2;
} else {
return a + (a-1);
}
}
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
ll x,y;
cin >> x >> y;
ll a,b;
ll z;
cin >> z;
ll AB = INF;
for (ll a_ = -10000; a_ <= 10000; a_++) {
ll nAB;
if (y == 0) {
if (z == a_ * x) {
nAB = abs(a);
if (AB >= nAB) {
AB = nAB;
a = a_;
b = 0;
}
}
} else if ((z - a_ * x) % y == 0) {
nAB = abs(a_) + abs((z - a_ * x) / y);
if (AB >= nAB) {
AB = nAB;
a = a_;
b = (z - a_ * x) / y;
}
}
}
DEBUG2(a,b);
const string I = "mourennaihasimasenn";
if (AB == INF) {
cout << I << endl;
return 0;
}
//DEBUG2(a,b);
char c = 'c', w = 'w', C = 'C', W = 'W';
if (a < b) {
swap(c,w);
swap(a,b);
}
// a >= b
ll anslen = 0;
if (a < 0) {
anslen += abs(a) * 2;
// b < 0
anslen += abs(b) * 2 + calczero();
} else if (a > 0) {
anslen += abs(b) * 2;
anslen += a + a - 1;
} else {
if (b < 0) {
anslen += calczero() + abs(b) * 2;
}else if (b > 0){
anslen += b + b - 1;
} else {
anslen = calczero();
}
}
if (anslen > 10000) {
cout << I << endl;
return 0;
}
string ans;
if (a < 0) {
rep(i,abs(a)) {
ans += c;
}
// b < 0
rep(i,abs(b)) {
ans += w;
}
if (b < 0) {
ans += makezero();
rep(i,abs(b)){
ans += W;
}
} else {
rep(i,abs(b)-1) {
ans += C;
}
}
rep(i,abs(a)){
ans += W;
}
} else if (a > 0) {
if (b != 0) {
rep(i,abs(b)) {
ans += w;
}
}
rep(i,a) {
ans += c;
}
rep(i,a-1){
ans += C;
}
rep(i,abs(b)){
if (b < 0) {
ans += W;
} else {
ans += C;
}
}
} else {
if (b < 0) {
rep(i,abs(b)) {
ans += w;
}
ans += makezero();
rep(i,abs(b)){
ans += W;
}
}else if (b > 0){
ans += w;
rep(i,b-1) {
ans += w;
ans += C;
}
} else {
ans = makezero();
}
}
cout << ans << endl;
//assert(sz(ans) == anslen);
return 0;
}