code forces problem
can't understand time complexityswarup
c_cpp
a year ago
1.6 kB
7
Indexable
#include<bits/stdc++.h> using namespace std; #define ll long long #define test cout<<"ok"<<endl; #define check(n) for(auto x:n)cout<<x<<" " // p.push_back(make_pair(a,b)); // pr.push_back({1,3}); //factor and divisor are same which is limited & multiple are unlimited #define debug(x) cout << #x <<" " << x << endl; #define Faster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define MX 1000000+7 vector < bool > is_prime(MX+ 1, true); /*is_prime[0] = false; is_prime[1] = true; for(int i = 2; i<= MX; i++){ if(is_prime[i] == true && i * i <= MX) { for(int j = i * i ; j <= MX ;j+= i) { is_prime[j] = false; } } }*/ void solve(){ ll n; cin >> n; char c; cin >> c; string s; cin >> s; bool flag = true; for(int i = 0; i < n; i++){ if(s[i] != c){ flag = false; break; } } if(!flag){ for(int i = 1; i < n; i++){ if(s[i] == c){ bool all_ok = true; for(int j = i + i+ 1; j < n; j+= i+1) { if(s[j] != c) all_ok = false; } if(all_ok == true){ cout << 1 <<endl; cout << i + 1 << endl; return; } } } cout << 2 << endl; cout << n <<" " << n -1 << endl; } else cout << 0 << endl; } int main(){ Faster; int t; cin >> t; while(t --){ solve(); } }
Editor is loading...
Leave a Comment