結果

問題 No.1935 Water Simulation
ユーザー Kome_soudouKome_soudou
提出日時 2022-05-13 21:52:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,243 bytes
コンパイル時間 4,048 ms
コンパイル使用メモリ 241,916 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 10:00:23
合計ジャッジ時間 5,430 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

int main()
{
	int64_t a, b, c, d, N;
	cin >> a >> b >> c >> d >> N;
	
	vector<int64_t> v(4);
	v[0] = a;
	map<tuple<int64_t, int64_t, int64_t, int64_t>, int64_t> m;
	m[make_tuple(a, 0, 0, 0)] = 0;
	for(int64_t i = 1; i <= N; i++)
	{
		if(i % 4 == 1)
		{
			if(v[0] + v[1] <= b)
			{
				v[1] += v[0];
				v[0] = 0;
				
			}
			else
			{
				v[0] = v[0] + v[1] - b;
				v[1] = b;
			}
		}
		else if(i % 4 == 2)
		{
			if(v[1] + v[2] <= c)
			{
				v[2] += v[1];
				v[1] = 0;
			}
			else
			{
				v[1] = v[1] + v[2] - c;
				v[2] = c;
			}
		}
		else if(i % 4 == 3)
		{
			if(v[2] + v[3] <= d)
			{
				v[3] += v[2];
				v[2] = 0;
				
			}
			else
			{
				v[2] = v[2] + v[3] - d;
				v[3] = d;
			}
		}
		else
		{
			if(v[2] + v[3] <= a)
			{
				v[0] += v[3];
				v[3] = 0;
			}
			else
			{
				v[3] = v[3] + v[0] - a;
				v[0] = a;
			}
			
			if(!m.count(make_tuple(v[0], v[1], v[2], v[3]))) m[make_tuple(v[0], v[1], v[2], v[3])] = i;
			else i += (N - i) / (i - m.at(make_tuple(v[0], v[1], v[2], v[3]))) * (i - m.at(make_tuple(v[0], v[1], v[2], v[3])));
		}
	}
	cout << v[0] << ' ' << v[1] << ' ' << v[2] << ' ' << v[3] << endl;
	return 0;
}
0