結果

問題 No.1313 N言っちゃダメゲーム (4)
ユーザー morimariomorimario
提出日時 2020-12-10 03:50:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 3,643 bytes
コンパイル時間 2,293 ms
コンパイル使用メモリ 205,732 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 14:50:28
合計ジャッジ時間 3,644 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using pll = pair<ll, ll>; using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using pdd = pair<double, double>; using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using pbb = pair<bool, bool>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using pss = pair<string, string>; using vs = vector<string>; using vvs = vector<vs>; using vvvs = vector<vvs>;
#define rep2(counter, start, goal) for (int counter = (int)(start); counter < (int)(goal); ++counter)
#define rep(counter, goal) rep2(counter, 0, goal)
#define rep3(counter, start, goal) for (int counter = (int)(start); counter > (int)(goal); --counter)
#define rep0(times) for (int counter = 0; counter < (int)(times); ++counter)
#define all(container) begin(container), end(container)
template <typename T> bool chmax(T &x, const T &y) { if (x < y) { x = y; return true; } return false; }
template <typename T> bool chmin(T &x, const T &y) { if (x > y) { x = y; return true; } return false; }
void yn(bool flag) { cout << (flag ? "yes" : "no") << "\n"; }
void Yn(bool flag) { cout << (flag ? "Yes" : "No") << "\n"; }
void YN(bool flag) { cout << (flag ? "YES" : "NO") << "\n"; }
void set_prec(const int &digits) { cout << fixed << setprecision(digits); cerr << fixed << setprecision(digits); }
template <typename T> void pr(const T &obj) { cerr << obj; }
template <typename T, typename ...Ts> void pr(const T &first, const Ts &...rest) { pr(first); pr(", "); pr(rest...); }
template <typename S, typename T> void pr(const pair<S, T> &pair) { pr("("); pr(pair.first); pr(", "); pr(pair.second); pr(")"); }
template <typename T> void pr(const vector<T> &vec) { pr("{"); for (T obj : vec) { pr(obj); pr(", "); } pr("}"); }
template <typename T> void pr(const vector<vector<T>> &vv) { pr("\n"); rep(index, vv.size()) { pr("["); pr(index); pr("]: "); pr(vv[index]); pr("\n"); } }
template <typename T> void pr(const set<T> &vec) { pr("{"); for (T obj : vec) { pr(obj); pr(", "); } pr("}"); }
template <typename S, typename T> void pr(const map<S, T> &map) { pr("{"); for (pair<S, T> pair : map) { pr("("); pr(pair.first); pr(": "); pr(pair.second); pr("), "); } pr("}"); }
#define db(obj) cerr << #obj << ": "; pr(obj); cerr << " "
#define dl(obj) db(obj); cerr << "\n";
#define dm(...) cerr << "(" << #__VA_ARGS__ << "): ("; pr(__VA_ARGS__); cerr << ") "
#define dml(...) dm(__VA_ARGS__); cerr << "\n"
// #include <atcoder/all>
// using namespace atcoder;
// const ll MOD = 1000000007; // 998244353;
// const ll INF = 1000000007;

// i:N-1~1 として、ゲームをiから始めたときに先手必勝となるか(fst[i])を順次定めていく
// i~i+Kに先手必勝の数が一つでもあればiは後手必勝、そうでなければiは先手必勝
// 今見ているiに対し、i~i+Kに先手必勝の数がいくつあるか(m)を管理する

int main() {
	// 0-ind
	int N, K; cin >> N >> K;
	string S; cin >> S; // 1~N-1
	S = "o" + S; // 0~N-1
	// dl(S);

	vb fst(N); // 0~N-1
	int m = 0; // j:1~Kでfst[i+j]となるjの個数
	
	rep3(i, N - 1, -1) { // i: N-1 ~ 0(一応0を含む)
		// db(i); db(S[i]); dl(S[i - 1]);
		if (S[i] == 'o' && m == 0) {
			fst[i] = true;
			++m;
		}
		if (i + K <= N && S[i + K] == 'o' && fst[i + K]) --m;

		// db(fst); dl(m);
	}
	bool f = false;
	rep2(i, 1, K + 1) if (fst[i]) {
		cout << i << endl;
		f = true;
	}
	if (!f) cout << 0 << endl;
}
0