結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー kwm_tkwm_t
提出日時 2022-10-15 17:13:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,400 ms / 3,000 ms
コード長 2,125 bytes
コンパイル時間 2,443 ms
コンパイル使用メモリ 209,948 KB
実行使用メモリ 54,680 KB
最終ジャッジ日時 2023-09-09 02:51:31
合計ジャッジ時間 65,221 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
26,880 KB
testcase_01 AC 38 ms
26,880 KB
testcase_02 AC 570 ms
39,328 KB
testcase_03 AC 780 ms
43,184 KB
testcase_04 AC 557 ms
39,132 KB
testcase_05 AC 325 ms
33,380 KB
testcase_06 AC 620 ms
39,968 KB
testcase_07 AC 892 ms
34,124 KB
testcase_08 AC 98 ms
27,676 KB
testcase_09 AC 839 ms
41,188 KB
testcase_10 AC 220 ms
31,544 KB
testcase_11 AC 246 ms
33,264 KB
testcase_12 AC 491 ms
38,100 KB
testcase_13 AC 1,011 ms
45,012 KB
testcase_14 AC 438 ms
36,576 KB
testcase_15 AC 675 ms
40,848 KB
testcase_16 AC 1,099 ms
48,036 KB
testcase_17 AC 558 ms
32,720 KB
testcase_18 AC 1,013 ms
38,304 KB
testcase_19 AC 310 ms
34,548 KB
testcase_20 AC 1,114 ms
46,168 KB
testcase_21 AC 154 ms
28,332 KB
testcase_22 AC 1,301 ms
50,276 KB
testcase_23 AC 1,353 ms
50,276 KB
testcase_24 AC 1,359 ms
50,120 KB
testcase_25 AC 1,363 ms
50,320 KB
testcase_26 AC 1,379 ms
50,368 KB
testcase_27 AC 1,346 ms
50,120 KB
testcase_28 AC 1,348 ms
50,124 KB
testcase_29 AC 1,374 ms
50,156 KB
testcase_30 AC 1,372 ms
50,144 KB
testcase_31 AC 1,337 ms
50,112 KB
testcase_32 AC 1,343 ms
50,144 KB
testcase_33 AC 1,366 ms
50,336 KB
testcase_34 AC 1,394 ms
50,108 KB
testcase_35 AC 1,380 ms
50,168 KB
testcase_36 AC 1,386 ms
50,140 KB
testcase_37 AC 1,361 ms
50,356 KB
testcase_38 AC 1,385 ms
50,084 KB
testcase_39 AC 1,389 ms
50,180 KB
testcase_40 AC 1,400 ms
50,080 KB
testcase_41 AC 1,382 ms
50,264 KB
testcase_42 AC 1,286 ms
42,440 KB
testcase_43 AC 1,296 ms
42,420 KB
testcase_44 AC 1,214 ms
42,420 KB
testcase_45 AC 1,274 ms
42,408 KB
testcase_46 AC 1,291 ms
42,668 KB
testcase_47 AC 1,212 ms
36,176 KB
testcase_48 AC 1,193 ms
36,236 KB
testcase_49 AC 1,186 ms
36,384 KB
testcase_50 AC 1,196 ms
36,224 KB
testcase_51 AC 1,116 ms
36,260 KB
testcase_52 AC 206 ms
27,536 KB
testcase_53 AC 205 ms
27,584 KB
testcase_54 AC 205 ms
27,536 KB
testcase_55 AC 398 ms
26,976 KB
testcase_56 AC 397 ms
26,976 KB
testcase_57 AC 400 ms
26,968 KB
testcase_58 AC 207 ms
27,560 KB
testcase_59 AC 1,223 ms
54,680 KB
testcase_60 AC 89 ms
26,796 KB
testcase_61 AC 399 ms
27,036 KB
testcase_62 AC 55 ms
27,504 KB
testcase_63 AC 353 ms
26,908 KB
testcase_64 AC 354 ms
27,008 KB
testcase_65 AC 493 ms
27,076 KB
testcase_66 AC 399 ms
27,024 KB
testcase_67 AC 222 ms
26,876 KB
testcase_68 AC 229 ms
26,960 KB
testcase_69 AC 212 ms
26,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
long long table[3][1000006];
int sz = 3;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n;
	vector<long long>mod;
	mod.push_back(1000000007);
	mod.push_back(998244353);
	mod.push_back(1000000009);
	int base = 27;
	rep(i, sz)table[i][0] = 1;
	rep2(i, 1, 1000006) {
		rep(j, sz) {
			table[j][i] = (table[j][i - 1] * base) % mod[j];
		}
	}
	vector<set<long long>>st(sz);
	rep(i, n) {
		string s; cin >> s;
		vector<long long>val(sz);
		rep(j, s.size()) {
			rep(k, 3) {
				val[k] += table[k][j] * (s[j] - 'a' + 1);
				val[k] %= mod[k];
			}
		}
		bool chk = false;
		{
			int cnt = 0;
			rep(j, sz)if (st[j].count(val[j]))cnt++;
			if (cnt == sz)chk = true;
		}
		rep(j, s.size() - 1) {
			vector<long long>subval(sz);
			rep(k, sz) {
				subval[k] = val[k];
				subval[k] += mod[k] - table[k][j + 0] * (s[j + 0] - 'a' + 1) % mod[k];
				subval[k] += mod[k] - table[k][j + 1] * (s[j + 1] - 'a' + 1) % mod[k];
				subval[k] += table[k][j + 0] * (s[j + 1] - 'a' + 1);
				subval[k] += table[k][j + 1] * (s[j + 0] - 'a' + 1);
				subval[k] %= mod[k];
			}
			int cnt = 0;
			rep(j, sz)if (st[j].count(subval[j]))cnt++;
			if (cnt == sz)chk = true;
		}
		if (chk)cout << "Yes" << endl;
		else cout << "No" << endl;
		rep(j, sz)st[j].insert(val[j]);
	}
	return 0;
}
0