結果

問題 No.607 開通777年記念
ユーザー newlife171128newlife171128
提出日時 2017-12-20 00:27:11
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,432 bytes
コンパイル時間 636 ms
コンパイル使用メモリ 67,668 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-05-09 13:13:15
合計ジャッジ時間 4,285 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>

using namespace std;

int main() {

	int n = 0;
	int m = 0;
	cin >> n >> m;

	int car[n];
	int car_t[n + 1];

	for(int i=0; i<n; i++){
		car[i] =0;
	}
	for(int i=0; i<n+1; i++){
		car_t[i] =0;
	}

	int tmp = 0;

	bool judge = false;

	for (int i = 0; i < m; i++) {

		for (int i = 0; i < n; i++) {
			cin >> tmp;
			car[i] += tmp;
		}

		for (int i = 0; i < n; i++) {
			car_t[i + 1] = car_t[i] + car[i];

			/*	cout<<car_t[i+1]<<endl;*/
		}

		stringstream ss;

		string fever;

		for (int t = 1; t <= n; t++) {

			int ans = car_t[t] - car_t[0];

			ss << ans;
			fever = ss.str();

			for (int i = 1; i < fever.length(); i++) {
				if (fever[0] != fever[i]) {
					break;
				}
				if (i == fever.length()-1) {
					judge = true;
				}
			}
			ss.str("");
			ss.clear(stringstream::goodbit);
			/*	cout<<"t:"<<t<<" "<<ans<<endl;*/
			int tmp = 0;
			for (int k = 0; k < n - t; k++) {
				tmp = car_t[k + 1 + t] - car_t[k + 1];

				ss << tmp;
				fever = ss.str();

				for (int i = 1; i < fever.length(); i++) {
					if (fever[0] != fever[i]) {
						break;
					}
					if (i == fever.length()-1) {
						judge = true;
					}
				}
				ss.str("");
				ss.clear(stringstream::goodbit);
				/*			cout<<"t:"<<t<<" "<<tmp<<endl;*/
			}
		}
	}


	if (judge) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

0