Submission #11549308


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N, K, C; string S;
int dp[201010];
vector<int> pre[201010];
bool vis[201010];
vector<int> dpt[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K >> C >> S;

	rep(i, 0, N + 1) dp[i] = -inf;
	dp[0] = 0;
	rep(i, 0, N) {
		if (chmax(dp[i + 1], dp[i])) pre[i + 1].clear();
		if (dp[i + 1] == dp[i]) pre[i + 1].push_back(i);

		if (S[i] == 'o') {
			if (chmax(dp[min(N, i + 1 + C)], dp[i] + 1)) pre[min(N, i + 1 + C)].clear();
			if (dp[min(N, i + 1 + C)] == dp[i] + 1) pre[min(N, i + 1 + C)].push_back(i);
		}
	}
	
	if (K < dp[N]) return;

	queue<int> que;

	vis[N] = true;
	que.push(N);

	while (!que.empty()) {
		int cu = que.front(); que.pop();
		fore(to, pre[cu]) {
			if (!vis[to]) {
				vis[to] = true;
				que.push(to);
			}

			if (dp[cu] == dp[to] + 1) {
				dpt[dp[to]].push_back(to + 1);
			}
		}
	}

	vector<int> ans;
	rep(i, 0, K) if (dpt[i].size() == 1) ans.push_back(dpt[i][0]);
	sort(all(ans));
	fore(a, ans) printf("%d\n", a);
}





Submission Info

Submission Time
Task E - Yutori
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 500
Code Size 2369 Byte
Status
Exec Time 49 ms
Memory 25612 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01, sample_02, sample_03, sample_04
All 500 / 500 hand_01, hand_02, max_01, max_02, max_03, max_04, max_05, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, sample_01, sample_02, sample_03, sample_04
Case Name Status Exec Time Memory
hand_01 4 ms 10496 KB
hand_02 4 ms 10496 KB
max_01 17 ms 17172 KB
max_02 17 ms 17172 KB
max_03 28 ms 20112 KB
max_04 49 ms 25612 KB
max_05 17 ms 17172 KB
random_01 9 ms 12544 KB
random_02 13 ms 14032 KB
random_03 23 ms 18068 KB
random_04 23 ms 18068 KB
random_05 23 ms 18068 KB
random_06 23 ms 18068 KB
random_07 23 ms 18068 KB
random_08 23 ms 18068 KB
random_09 23 ms 18068 KB
random_10 23 ms 18068 KB
sample_01 4 ms 10496 KB
sample_02 4 ms 10496 KB
sample_03 4 ms 10496 KB
sample_04 4 ms 10496 KB