atcoder161 E - Yutori

 

E - Yutori 


Time Limit: 2 sec / Memory Limit: 1024 MB

 

Problem Statement

Takahashi has decided to work on KK days of his choice from the NN days starting with tomorrow.

You are given an integer CC and a string SS . Takahashi will choose his workdays as follows:

  • After working for a day, he will refrain from working on the subsequent CC days.
  • If the ii -th character of SS is x, he will not work on Day ii , where Day 11 is tomorrow, Day 22 is the day after tomorrow, and so on.

Find all days on which Takahashi is bound to work.

Constraints

  • 1N2×1051≤N≤2×105
  • 1KN1≤K≤N
  • 0CN0≤C≤N
  • The length of SS is NN .
  • Each character of SS is o or x.
  • Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.

Input

Input is given from Standard Input in the following format:

n k c s

Output

Print all days on which Takahashi is bound to work in ascending order, one per line.


Sample Input 1 Copy

Copy
11 3 2
ooxxxoxxxoo

Sample Output 1 Copy

Copy
6

Takahashi is going to work on 33 days out of the 1111 days. After working for a day, he will refrain from working on the subsequent 22 days.

There are four possible choices for his workdays: Day 1,6,101,6,10 , Day 1,6,111,6,11 , Day 2,6,102,6,10 , and Day 2,6,112,6,11 .

Thus, he is bound to work on Day 66 .


Sample Input 2 Copy

Copy
5 2 3 
ooxoo

Sample Output 2 Copy

Copy
1
5

There is only one possible choice for his workdays: Day 1,51,5 .


Sample Input 3 Copy

Copy
5 1 0 
ooooo

Sample Output 3 Copy

Copy
 
  

There may be no days on which he is bound to work.


Sample Input 4 Copy

Copy
16 4 3 
ooxxoxoxxxoxoxxo

Sample Output 4 Copy

Copy
11 
16 
others ac record
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;
#define display(v) f(v.size())cout << v[i] << " "
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
//////////////////////*********CODE***********/////////////////////
//////////////////////////////////////////////////////////////////

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   int n,k,c;   cin>>n>>k>>c;
   string str; cin>>str;
   int pre[n],suf[n];  // ith day no earlier than this. //ith work can br done later than this
   memset(pre,0,sizeof(pre));
   memset(suf,0,sizeof(suf));
   int  work = 1;
   for(int i =0;i<n;i++)
   {
      if(str[i] == 'o')
      {
         pre[i] = work++;
         i+=c;
         if(work > k)break;
      }
   }
   work--;
   for(int i = n-1;i>=0;i--)
   {
      if(str[i] == 'o')
      {
         suf[i] = work--;
         i-=c;
         if(work <= 0)break;
      }
   }
   for(int i=0;i<n;i++)
   {
      if(pre[i]!=0 && pre[i] == suf[i])
      {
         cout << i+1 << "\n";
      }
   }

   return 0;
}    

 

Guess you like

Origin www.cnblogs.com/asunayi/p/12650631.html