結果

問題 No.8083 12歳
ユーザー torisasami4torisasami4
提出日時 2021-04-01 21:29:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 6,336 bytes
コンパイル時間 2,050 ms
コンパイル使用メモリ 181,240 KB
実行使用メモリ 39,864 KB
最終ジャッジ日時 2024-12-21 05:47:24
合計ジャッジ時間 15,807 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
39,736 KB
testcase_01 AC 15 ms
39,720 KB
testcase_02 AC 14 ms
39,692 KB
testcase_03 AC 14 ms
39,644 KB
testcase_04 AC 13 ms
39,776 KB
testcase_05 AC 15 ms
39,624 KB
testcase_06 AC 13 ms
39,492 KB
testcase_07 AC 14 ms
39,736 KB
testcase_08 AC 12 ms
39,716 KB
testcase_09 AC 14 ms
39,752 KB
testcase_10 AC 14 ms
39,648 KB
testcase_11 AC 14 ms
39,656 KB
testcase_12 AC 12 ms
39,632 KB
testcase_13 AC 15 ms
39,644 KB
testcase_14 AC 14 ms
39,632 KB
testcase_15 AC 15 ms
39,652 KB
testcase_16 AC 14 ms
39,644 KB
testcase_17 AC 14 ms
39,632 KB
testcase_18 AC 14 ms
39,680 KB
testcase_19 AC 13 ms
39,836 KB
testcase_20 AC 13 ms
39,784 KB
testcase_21 AC 14 ms
39,556 KB
testcase_22 AC 14 ms
39,680 KB
testcase_23 AC 15 ms
39,792 KB
testcase_24 AC 14 ms
39,736 KB
testcase_25 AC 15 ms
39,592 KB
testcase_26 AC 14 ms
39,684 KB
testcase_27 AC 13 ms
39,800 KB
testcase_28 AC 14 ms
39,632 KB
testcase_29 AC 14 ms
39,656 KB
testcase_30 AC 13 ms
39,764 KB
testcase_31 AC 14 ms
39,704 KB
testcase_32 AC 14 ms
39,780 KB
testcase_33 AC 14 ms
39,636 KB
testcase_34 AC 13 ms
39,700 KB
testcase_35 AC 15 ms
39,616 KB
testcase_36 AC 15 ms
39,772 KB
testcase_37 AC 15 ms
39,656 KB
testcase_38 AC 15 ms
39,740 KB
testcase_39 AC 15 ms
39,620 KB
testcase_40 AC 17 ms
39,616 KB
testcase_41 AC 15 ms
39,668 KB
testcase_42 AC 15 ms
39,508 KB
testcase_43 AC 15 ms
39,644 KB
testcase_44 AC 17 ms
39,636 KB
testcase_45 AC 15 ms
39,644 KB
testcase_46 AC 16 ms
39,612 KB
testcase_47 AC 15 ms
39,668 KB
testcase_48 AC 16 ms
39,652 KB
testcase_49 AC 17 ms
39,548 KB
testcase_50 AC 16 ms
39,692 KB
testcase_51 AC 16 ms
39,688 KB
testcase_52 AC 15 ms
39,640 KB
testcase_53 AC 13 ms
39,748 KB
testcase_54 AC 14 ms
39,660 KB
testcase_55 AC 14 ms
39,620 KB
testcase_56 AC 14 ms
39,632 KB
testcase_57 AC 12 ms
39,660 KB
testcase_58 AC 14 ms
39,616 KB
testcase_59 AC 15 ms
39,632 KB
testcase_60 AC 15 ms
39,652 KB
testcase_61 AC 13 ms
39,796 KB
testcase_62 AC 16 ms
39,784 KB
testcase_63 AC 14 ms
39,676 KB
testcase_64 AC 16 ms
39,756 KB
testcase_65 AC 17 ms
39,696 KB
testcase_66 AC 15 ms
39,720 KB
testcase_67 AC 16 ms
39,628 KB
testcase_68 AC 15 ms
39,724 KB
testcase_69 AC 13 ms
39,712 KB
testcase_70 AC 15 ms
39,628 KB
testcase_71 AC 13 ms
39,556 KB
testcase_72 AC 15 ms
39,636 KB
testcase_73 AC 16 ms
39,628 KB
testcase_74 AC 14 ms
39,640 KB
testcase_75 AC 16 ms
39,676 KB
testcase_76 AC 15 ms
39,720 KB
testcase_77 AC 14 ms
39,796 KB
testcase_78 AC 16 ms
39,696 KB
testcase_79 AC 15 ms
39,632 KB
testcase_80 AC 15 ms
39,600 KB
testcase_81 AC 15 ms
39,680 KB
testcase_82 AC 15 ms
39,624 KB
testcase_83 AC 16 ms
39,740 KB
testcase_84 AC 16 ms
39,820 KB
testcase_85 AC 13 ms
39,720 KB
testcase_86 AC 16 ms
39,700 KB
testcase_87 AC 16 ms
39,676 KB
testcase_88 AC 17 ms
39,640 KB
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
testcase_94 AC 15 ms
39,672 KB
testcase_95 AC 14 ms
39,712 KB
testcase_96 WA -
testcase_97 WA -
testcase_98 AC 16 ms
39,640 KB
testcase_99 AC 15 ms
39,788 KB
testcase_100 AC 14 ms
39,640 KB
testcase_101 AC 15 ms
39,644 KB
testcase_102 AC 16 ms
39,628 KB
testcase_103 AC 14 ms
39,728 KB
testcase_104 AC 13 ms
39,708 KB
testcase_105 AC 14 ms
39,644 KB
testcase_106 AC 15 ms
39,620 KB
testcase_107 AC 12 ms
39,716 KB
testcase_108 AC 14 ms
39,616 KB
testcase_109 AC 14 ms
39,668 KB
testcase_110 AC 15 ms
39,640 KB
testcase_111 AC 12 ms
39,616 KB
testcase_112 AC 14 ms
39,696 KB
testcase_113 AC 14 ms
39,672 KB
testcase_114 AC 13 ms
39,724 KB
testcase_115 AC 13 ms
39,660 KB
testcase_116 AC 13 ms
39,644 KB
testcase_117 AC 14 ms
39,780 KB
testcase_118 AC 14 ms
39,688 KB
testcase_119 AC 14 ms
39,508 KB
testcase_120 AC 14 ms
39,616 KB
testcase_121 AC 12 ms
39,712 KB
testcase_122 AC 14 ms
39,684 KB
testcase_123 AC 15 ms
39,624 KB
testcase_124 AC 14 ms
39,660 KB
testcase_125 AC 13 ms
39,676 KB
testcase_126 AC 14 ms
39,632 KB
testcase_127 AC 14 ms
39,636 KB
testcase_128 AC 13 ms
39,684 KB
testcase_129 AC 15 ms
39,644 KB
testcase_130 AC 16 ms
39,716 KB
testcase_131 AC 14 ms
39,688 KB
testcase_132 AC 13 ms
39,692 KB
testcase_133 AC 13 ms
39,644 KB
testcase_134 AC 13 ms
39,648 KB
testcase_135 AC 13 ms
39,704 KB
testcase_136 AC 13 ms
39,652 KB
testcase_137 AC 13 ms
39,732 KB
testcase_138 AC 14 ms
39,724 KB
testcase_139 AC 15 ms
39,648 KB
testcase_140 AC 14 ms
39,648 KB
testcase_141 AC 14 ms
39,672 KB
testcase_142 AC 13 ms
39,716 KB
testcase_143 AC 14 ms
39,648 KB
testcase_144 AC 14 ms
39,624 KB
testcase_145 AC 12 ms
39,684 KB
testcase_146 AC 15 ms
39,700 KB
testcase_147 AC 14 ms
39,616 KB
testcase_148 AC 13 ms
39,692 KB
testcase_149 AC 14 ms
39,712 KB
testcase_150 AC 13 ms
39,640 KB
testcase_151 AC 14 ms
39,720 KB
testcase_152 AC 12 ms
39,632 KB
testcase_153 AC 14 ms
39,680 KB
testcase_154 AC 14 ms
39,708 KB
testcase_155 AC 15 ms
39,680 KB
testcase_156 AC 14 ms
39,644 KB
testcase_157 AC 13 ms
39,720 KB
testcase_158 AC 14 ms
39,676 KB
testcase_159 AC 13 ms
39,624 KB
testcase_160 AC 14 ms
39,740 KB
testcase_161 AC 13 ms
39,724 KB
testcase_162 AC 13 ms
39,696 KB
testcase_163 AC 13 ms
39,640 KB
testcase_164 AC 14 ms
39,664 KB
testcase_165 AC 13 ms
39,652 KB
testcase_166 AC 13 ms
39,648 KB
testcase_167 AC 15 ms
39,624 KB
testcase_168 AC 15 ms
39,644 KB
testcase_169 AC 14 ms
39,564 KB
testcase_170 AC 14 ms
39,640 KB
testcase_171 AC 14 ms
39,664 KB
testcase_172 AC 14 ms
39,864 KB
testcase_173 AC 14 ms
39,632 KB
testcase_174 AC 12 ms
39,676 KB
testcase_175 AC 15 ms
39,640 KB
testcase_176 AC 14 ms
39,628 KB
testcase_177 AC 15 ms
39,640 KB
testcase_178 AC 14 ms
39,560 KB
testcase_179 AC 12 ms
39,528 KB
testcase_180 AC 15 ms
39,632 KB
testcase_181 AC 15 ms
39,620 KB
testcase_182 AC 14 ms
39,716 KB
testcase_183 AC 13 ms
39,720 KB
testcase_184 AC 15 ms
39,760 KB
testcase_185 AC 14 ms
39,636 KB
testcase_186 AC 12 ms
39,604 KB
testcase_187 AC 14 ms
39,632 KB
testcase_188 AC 14 ms
39,620 KB
testcase_189 AC 12 ms
39,688 KB
testcase_190 AC 14 ms
39,680 KB
testcase_191 AC 13 ms
39,756 KB
testcase_192 AC 14 ms
39,652 KB
testcase_193 AC 14 ms
39,612 KB
testcase_194 AC 14 ms
39,564 KB
testcase_195 AC 13 ms
39,704 KB
testcase_196 AC 14 ms
39,708 KB
testcase_197 AC 13 ms
39,660 KB
testcase_198 AC 14 ms
39,668 KB
testcase_199 AC 14 ms
39,624 KB
testcase_200 AC 15 ms
39,632 KB
testcase_201 AC 13 ms
39,624 KB
testcase_202 AC 14 ms
39,652 KB
testcase_203 AC 14 ms
39,724 KB
testcase_204 AC 14 ms
39,652 KB
testcase_205 AC 13 ms
39,668 KB
testcase_206 AC 15 ms
39,828 KB
testcase_207 AC 13 ms
39,668 KB
testcase_208 AC 13 ms
39,680 KB
testcase_209 AC 13 ms
39,672 KB
testcase_210 AC 14 ms
39,676 KB
testcase_211 AC 14 ms
39,516 KB
testcase_212 AC 14 ms
39,644 KB
testcase_213 AC 14 ms
39,652 KB
testcase_214 AC 15 ms
39,664 KB
testcase_215 AC 14 ms
39,644 KB
testcase_216 AC 13 ms
39,704 KB
testcase_217 AC 14 ms
39,664 KB
testcase_218 AC 14 ms
39,708 KB
testcase_219 AC 13 ms
39,676 KB
testcase_220 AC 14 ms
39,616 KB
testcase_221 AC 13 ms
39,652 KB
testcase_222 AC 15 ms
39,636 KB
testcase_223 AC 14 ms
39,776 KB
testcase_224 AC 15 ms
39,660 KB
testcase_225 AC 15 ms
39,540 KB
testcase_226 AC 14 ms
39,708 KB
testcase_227 AC 14 ms
39,668 KB
testcase_228 AC 15 ms
39,656 KB
testcase_229 AC 15 ms
39,804 KB
testcase_230 AC 14 ms
39,628 KB
testcase_231 AC 14 ms
39,628 KB
testcase_232 AC 14 ms
39,672 KB
testcase_233 AC 15 ms
39,640 KB
testcase_234 AC 15 ms
39,656 KB
testcase_235 AC 14 ms
39,700 KB
testcase_236 AC 12 ms
39,616 KB
testcase_237 AC 12 ms
39,744 KB
testcase_238 AC 14 ms
39,624 KB
testcase_239 AC 14 ms
39,764 KB
testcase_240 AC 13 ms
39,736 KB
testcase_241 AC 15 ms
39,636 KB
testcase_242 AC 14 ms
39,616 KB
testcase_243 AC 14 ms
39,696 KB
testcase_244 AC 14 ms
39,796 KB
testcase_245 AC 15 ms
39,732 KB
testcase_246 AC 13 ms
39,672 KB
testcase_247 AC 14 ms
39,624 KB
testcase_248 AC 13 ms
39,676 KB
testcase_249 AC 14 ms
39,708 KB
testcase_250 AC 14 ms
39,744 KB
testcase_251 AC 14 ms
39,640 KB
testcase_252 AC 14 ms
39,660 KB
testcase_253 AC 14 ms
39,708 KB
testcase_254 AC 14 ms
39,728 KB
testcase_255 AC 14 ms
39,504 KB
testcase_256 AC 15 ms
39,584 KB
testcase_257 AC 15 ms
39,648 KB
testcase_258 AC 16 ms
39,580 KB
testcase_259 AC 14 ms
39,700 KB
testcase_260 WA -
testcase_261 WA -
testcase_262 WA -
testcase_263 WA -
testcase_264 WA -
testcase_265 AC 15 ms
39,696 KB
testcase_266 AC 16 ms
39,784 KB
testcase_267 WA -
testcase_268 WA -
testcase_269 AC 14 ms
39,676 KB
testcase_270 AC 16 ms
39,736 KB
testcase_271 AC 15 ms
39,656 KB
testcase_272 AC 15 ms
39,736 KB
testcase_273 AC 16 ms
39,648 KB
testcase_274 AC 14 ms
39,668 KB
testcase_275 AC 15 ms
39,664 KB
testcase_276 AC 15 ms
39,656 KB
testcase_277 AC 16 ms
39,632 KB
testcase_278 AC 16 ms
39,652 KB
testcase_279 AC 16 ms
39,532 KB
testcase_280 AC 16 ms
39,664 KB
testcase_281 AC 18 ms
39,660 KB
testcase_282 AC 16 ms
39,696 KB
testcase_283 AC 15 ms
39,772 KB
testcase_284 AC 15 ms
39,760 KB
testcase_285 AC 17 ms
39,732 KB
testcase_286 AC 14 ms
39,724 KB
testcase_287 AC 14 ms
39,632 KB
testcase_288 AC 14 ms
39,636 KB
testcase_289 AC 14 ms
39,668 KB
testcase_290 AC 14 ms
39,732 KB
testcase_291 AC 13 ms
39,568 KB
testcase_292 AC 13 ms
39,688 KB
testcase_293 AC 13 ms
39,808 KB
testcase_294 AC 14 ms
39,692 KB
testcase_295 AC 14 ms
39,628 KB
testcase_296 AC 15 ms
39,820 KB
testcase_297 AC 15 ms
39,660 KB
testcase_298 AC 15 ms
39,632 KB
testcase_299 AC 14 ms
39,728 KB
testcase_300 AC 14 ms
39,620 KB
testcase_301 AC 13 ms
39,644 KB
testcase_302 AC 14 ms
39,684 KB
testcase_303 AC 14 ms
39,648 KB
testcase_304 AC 14 ms
39,632 KB
testcase_305 AC 13 ms
39,760 KB
testcase_306 AC 14 ms
39,656 KB
testcase_307 AC 13 ms
39,668 KB
testcase_308 AC 15 ms
39,708 KB
testcase_309 AC 15 ms
39,728 KB
testcase_310 AC 13 ms
39,700 KB
testcase_311 AC 13 ms
39,504 KB
testcase_312 AC 14 ms
39,696 KB
testcase_313 AC 14 ms
39,676 KB
testcase_314 AC 13 ms
39,620 KB
testcase_315 AC 14 ms
39,692 KB
testcase_316 AC 13 ms
39,660 KB
testcase_317 AC 14 ms
39,696 KB
testcase_318 AC 14 ms
39,784 KB
testcase_319 AC 15 ms
39,640 KB
testcase_320 AC 14 ms
39,628 KB
testcase_321 AC 14 ms
39,676 KB
testcase_322 AC 14 ms
39,736 KB
testcase_323 AC 15 ms
39,640 KB
testcase_324 AC 15 ms
39,800 KB
testcase_325 AC 13 ms
39,768 KB
testcase_326 AC 14 ms
39,708 KB
testcase_327 AC 13 ms
39,664 KB
testcase_328 AC 13 ms
39,680 KB
testcase_329 AC 14 ms
39,620 KB
testcase_330 AC 15 ms
39,696 KB
testcase_331 AC 14 ms
39,652 KB
testcase_332 AC 14 ms
39,620 KB
testcase_333 AC 15 ms
39,628 KB
testcase_334 AC 15 ms
39,668 KB
testcase_335 AC 14 ms
39,660 KB
testcase_336 AC 14 ms
39,628 KB
testcase_337 AC 13 ms
39,636 KB
testcase_338 AC 14 ms
39,672 KB
testcase_339 AC 14 ms
39,788 KB
testcase_340 AC 13 ms
39,684 KB
testcase_341 AC 14 ms
39,656 KB
testcase_342 AC 15 ms
39,688 KB
testcase_343 AC 14 ms
39,688 KB
testcase_344 AC 15 ms
39,668 KB
testcase_345 AC 13 ms
39,704 KB
testcase_346 AC 14 ms
39,632 KB
testcase_347 AC 14 ms
39,644 KB
testcase_348 AC 13 ms
39,668 KB
testcase_349 AC 15 ms
39,692 KB
testcase_350 AC 14 ms
39,588 KB
testcase_351 AC 15 ms
39,616 KB
testcase_352 AC 15 ms
39,596 KB
testcase_353 AC 14 ms
39,668 KB
testcase_354 AC 14 ms
39,804 KB
testcase_355 AC 15 ms
39,756 KB
testcase_356 AC 14 ms
39,704 KB
testcase_357 AC 13 ms
39,620 KB
testcase_358 AC 14 ms
39,724 KB
testcase_359 AC 13 ms
39,640 KB
testcase_360 AC 14 ms
39,632 KB
testcase_361 AC 14 ms
39,708 KB
testcase_362 AC 14 ms
39,692 KB
testcase_363 AC 14 ms
39,620 KB
testcase_364 AC 14 ms
39,652 KB
testcase_365 AC 14 ms
39,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define lscan(x) scanf("%I64d", &x)
#define lprint(x) printf("%I64d", x)
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, n) for (ll i = n - 1; i >= 0; i--)
template <class T>
using rque = priority_queue<T, vector<T>, greater<T>>;
const ll mod = 998244353;

template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

template <class T>
bool chmax(T &a, const T &b) {
    if (b > a) {
        a = b;
        return 1;
    }
    return 0;
}

ll gcd(ll a, ll b)
{
	ll c = a % b;
	while (c != 0)
	{
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}

long long extGCD(long long a, long long b, long long &x, long long &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

struct UnionFind
{
	vector<ll> data;

	UnionFind(int sz)
	{
		data.assign(sz, -1);
	}

	bool unite(int x, int y)
	{
		x = find(x), y = find(y);
		if (x == y)
			return (false);
		if (data[x] > data[y])
			swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return (true);
	}

	int find(int k)
	{
		if (data[k] < 0)
			return (k);
		return (data[k] = find(data[k]));
	}

	ll size(int k)
	{
		return (-data[find(k)]);
	}
};

ll M = 1000000007;

vector<ll> fac(2000011, 0);  //n!(mod M)
vector<ll> ifac(2000011); //k!^{M-2} (mod M)

ll mpow(ll x, ll n)
{
	ll ans = 1;
	while (n != 0)
	{
		if (n & 1)
			ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll mpow2(ll x, ll n, ll mod)
{
	ll ans = 1;
	while (n != 0)
	{
		if (n & 1)
			ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}
void setcomb()
{
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 2000010; i++)
	{
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
	}
	ifac[2000010] = mpow(fac[2000010], M - 2);
	for (ll i = 2000010; i > 0; i--)
	{
		ifac[i - 1] = ifac[i] * i % M;
	}
}
ll comb(ll a, ll b)
{
	if(fac[0] == 0)
		setcomb();
	if (a == 0 && b == 0)
		return 1;
	if (a < b || a < 0)
		return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
ll perm(ll a, ll b)
{
	if (a == 0 && b == 0)
		return 1;
	if (a < b || a < 0)
		return 0;
	return fac[a] * ifac[a - b] % M;
}
long long modinv(long long a)
{
	long long b = M, u = 1, v = 0;
	while (b)
	{
		long long t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= M;
	if (u < 0)
		u += M;
	return u;
}
ll modinv2(ll a, ll mod)
{
	ll b = mod, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= mod;
	if (u < 0)
		u += mod;
	return u;
}

template <int mod>
struct ModInt
{
	int x;

	ModInt() : x(0) {}

	ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

	ModInt &operator+=(const ModInt &p)
	{
		if ((x += p.x) >= mod)
			x -= mod;
		return *this;
	}

	ModInt &operator-=(const ModInt &p)
	{
		if ((x += mod - p.x) >= mod)
			x -= mod;
		return *this;
	}

	ModInt &operator*=(const ModInt &p)
	{
		x = (int)(1LL * x * p.x % mod);
		return *this;
	}

	ModInt &operator/=(const ModInt &p)
	{
		*this *= p.inverse();
		return *this;
	}

	ModInt operator-() const { return ModInt(-x); }

	ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

	ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

	ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

	ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

	bool operator==(const ModInt &p) const { return x == p.x; }

	bool operator!=(const ModInt &p) const { return x != p.x; }

	ModInt inverse() const
	{
		int a = x, b = mod, u = 1, v = 0, t;
		while (b > 0)
		{
			t = a / b;
			swap(a -= t * b, b);
			swap(u -= t * v, v);
		}
		return ModInt(u);
	}

	ModInt pow(int64_t n) const
	{
		ModInt ret(1), mul(x);
		while (n > 0)
		{
			if (n & 1)
				ret *= mul;
			mul *= mul;
			n >>= 1;
		}
		return ret;
	}

	friend ostream &operator<<(ostream &os, const ModInt &p)
	{
		return os << p.x;
	}

	friend istream &operator>>(istream &is, ModInt &a)
	{
		int64_t t;
		is >> t;
		a = ModInt<mod>(t);
		return (is);
	}

	static int get_mod() { return mod; }
};

using mint = ModInt<mod>;

typedef vector<vector<mint>> Matrix;

Matrix mul(Matrix a, Matrix b)
{
	assert(a[0].size() == b.size());
	int i, j, k;
	int n = a.size(), m = b[0].size(), l = a[0].size();
	Matrix c(n, vector<mint>(m));
	for (i = 0; i < n; i++)
		for (k = 0; k < l; k++)
			for (j = 0; j < m; j++)
				c[i][j] += a[i][k] * b[k][j];
	return c;
}

Matrix mat_pow(Matrix x, ll n)
{
	ll k = x.size();
	Matrix ans(k, vector<mint>(k, 0));
	for (int i = 0; i < k; i++)
		ans[i][i] = 1;
	while (n != 0)
	{
		if (n & 1)
			ans = mul(ans, x);
		x = mul(x, x);
		n = n >> 1;
	}
	return ans;
}

vector<ll> li[222222];
pair<ll,pair<ll,ll>> dfs(ll now, ll par, ll lim){
	ll cost = 0, dis = 0, rem = -1;
	if(now == 0){
		for(auto &e: li[now]){
			if(e != par){
				auto res = dfs(e, now, lim);
				cost += res.first;
				chmax(dis, res.second.first);
				chmax(rem, res.second.second);
			}
		}
		if(rem < dis)
			cost++;
		return mp(cost, mp(0, 0));
	}
	else{
		for(auto &e: li[now]){
			if(e != par){
				auto res = dfs(e, now, lim);
				cost += res.first;
				chmax(dis, res.second.first);
				chmax(rem, res.second.second);
			}
		}
		if(rem >= dis)
			dis = 0;
		else{
			if(dis == lim){
				cost++;
				dis = 0;
				rem = lim;
			}
			else
				dis++;
		}
		rem--;
		return mp(cost, mp(dis, rem));
	}
}

int main(){
	ll y, n, d;
	cin >> y >> n >> d;
	ll flag1, flag2;
	if((y+1)%4 != 0)
		flag1 = 0;
	else if((y+1)%100 == 0 && (y+1)%400 != 0)
		flag1 = 0;
	else
		flag1 = 1;
	if((y-12)%4 != 0)
		flag2 = 0;
	else if((y-12)%100 == 0 && (y-12)%400 != 0)
		flag2 = 0;
	else
		flag2 = 1;
	ll ma, mi;
	if(flag1 && flag2){
		ma = min(n, 366 - d);
		mi = max(0ll, n - d);
	}
	else if(flag1 && !flag2){
		ll t = d;
		if(t > 332)
			t--;
		ma = min(n, 365 - t);
		mi = max(0ll, n - t);
	}
	else if(!flag1 && flag2){
		ll t = d;
		if(t > 333)
			t++;
		ma = min(n, 366 - t);
		mi = max(0ll, n - t);
	}
	else{
		ma = min(n, 365 - d);
		mi = max(0ll, n - d);
	}
	cout << mi << " " << ma << endl;
}
0