Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- // #include <ext/pb_ds/assoc_container.hpp>
- // #include <ext/pb_ds/tree_policy.hpp>
- typedef long long ll;
- typedef long double ld;
- #define rep(i, a, n) for(ll i = (a); i < (n); i++)
- #define per(i, a, n) for(ll i = (n-1); i >= (a); i--)
- #define F first
- #define S second
- #define maxx(a, b) a = max(a, b)
- #define minn(a, b) a = min(a, b)
- #define db(x) cerr << #x << " = " << x << endl
- #define N 1111111
- #define mod 1000000007
- #define rt return
- #define inf 123456789123456789ll
- using namespace std;
- // using namespace __gnu_pbds;
- // typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
- #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
- void err(istream_iterator<string> it) {}
- template<typename T, typename... Args>
- void err(istream_iterator<string> it, T a, Args... args)
- {
- cerr << *it << " = " << a << endl;
- err(++it, args...);
- }
- ll rec(ll n, ll k, ll t, ll son)
- {
- ll ok = 0;
- // if(t)ok = 1;
- rep(i,0,n-k+1)
- {
- ll now = son;
- ll okmi = 1;
- rep(j,i,i+k)
- if(now&(1ll<<j))
- {
- okmi = 0;
- break;
- }
- else
- now |= (1ll<<j);
- if(!okmi)
- continue;
- ok |= !rec(n,k,t^1,now);
- }
- // error(t,ok);
- rt ok;
- }
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- ll n,k; cin>>n>>k;
- string s; cin>>s;
- if(k == 1ll)
- {
- ll now = count(begin(s),end(s),'O');
- cout<<(now&1ll ? 1ll : 2ll);
- rt 0;
- }
- bool ok = 0;
- ll son = 0ll;
- rep(i,0,n)
- son |= (s[i] == 'X' ? (1ll<<i) : 0ll);
- //
- // db(son);
- ll ans = 0;
- rep(i,0,n-k+1)
- {
- ll now = son;
- ll okmi = 1;
- rep(j,i,i+k)
- if(now&(1ll<<j))
- {
- okmi = 0;
- break;
- }
- else
- now |= (1ll<<j);
- if(!okmi)
- continue;
- ok = 1;
- ans |= !rec(n,k,1,now);
- }
- if(!ok)
- rt cout<<0,0;
- cout<<(ans ? 1 : 2);
- rt 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement