QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#851813 | #9568. Left Shifting 3 | Rafat_Kabir | AC ✓ | 5ms | 4120kb | C++20 | 3.6kb | 2025-01-11 02:06:45 | 2025-01-11 02:06:46 |
Judging History
answer
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <time.h>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// to erase in multiset-> less_equal<T> and
// s.erase(s.find_by_order(s.order_of_key(x)))
// lower_bound(x)=>(cannot use the stl lower_bound function)
// ll idx = s.order_of_key(x)
// if(idx == s.size()) -> no lower_bound
// else lb = *s.find_by_order(idx) // as 0-indexing
// idx-1 will give highest value which is strictly less than x
// for upper_bound->do the same with (x+1)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef tuple<ll, ll, ll> t64;
typedef vector<t64> vt64;
typedef vector<vt64> vvt64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef vector<vector<p32> > vvp32;
typedef vector<bool> vb;
ll mod = 1e9+7, MOD = 998244353;
double eps = 1e-12;
#define FOR(s, e, i) for(ll i = s; i <= e; i++)
#define ROF(s ,e, i) for(ll i = s; i >= e; i--)
#define F0R(i, e) for(ll i = 0; i < (e); i++)
#define trav(e, a) for(auto &e : a)
#define coutAll(A) for(auto asdafas : A) cout << asdafas << " "; cout << "\n";
#define foutAll(A) for(auto asdafas : A) fout << asdafas << " "; cout << "\n";
#define cinAll(A) for(auto &asdafas : A) cin >> asdafas;
#define finAll(A) for(auto &asdafas : A) fin >> asdafas;
#define minpq priority_queue<ll, v64, greater<ll>>
#define maxpq priority_queue<ll>
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
ll inf = LLONG_MAX;
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef pair<ll, ll> pii;
#define MAXN 100000000
void solve(int it)
{
int n, k;
cin >> n >> k;
string s;
cin >> s;
if(n < 7){
cout << "0\n";
return;
}
string temp = s + s;
int f = -1;
int cnt = 0;
FOR(0, n-7, i){
if(s.substr(i, 7) == "nanjing"){
if(f == -1) f = i;
++cnt;
}
}
bool ok = false;
ll idx = -1;
FOR(n-6, n-1, i){
if(temp.substr(i, 7) == "nanjing"){
ok = true;
if(idx == -1) {
// cout << "hi\n";
idx = (i+7)%n;
}
}
}
// cout << cnt << ' ' << idx << "\n";
if(!ok){
cout << cnt << "\n";
return;
}
// shift kora jay
cout << cnt + (idx <= k) << "\n";
}
int main()
{
fast_cin();
ll t = 1;
cin >> t;
for(int it=1; it<=t; it++)
{
//cout << "Case " << it << ": ";
solve(it);
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3856kb
input:
4 21 10 jingicpcnanjingsuanan 21 0 jingicpcnanjingsuanan 21 3 nanjingnanjingnanjing 4 100 icpc
output:
2 1 3 0
result:
ok 4 number(s): "2 1 3 0"
Test #2:
score: 0
Accepted
time: 4ms
memory: 3616kb
input:
2130 39 7 nnananjingannanjingngnanjinganjinggjina 1 479084228 g 33 2 gqnanjinggrjdtktnanjingcvsenanjin 24 196055605 ginganjingnanjingnanjing 23 3 ngnanjinganjingjinnanji 40 3 njingaaznannanjingnananjingyonwpnanjinga 40 207842908 nanjinggphconanjingkonanjinannanjinglxna 46 3 ingjingnnanjingnanjinging...
output:
3 0 3 2 2 3 3 4 3 4 0 2 4 3 2 1 1 1 4 2 0 3 3 0 0 1 0 0 0 5 4 0 1 2 1 2 2 1 1 1 3 3 1 3 2 0 1 2 4 1 2 1 2 1 2 3 0 1 0 0 1 1 3 2 2 1 0 3 1 2 1 1 4 4 1 1 1 1 0 1 1 1 1 2 0 4 4 3 1 1 2 1 1 1 1 5 1 4 0 1 2 1 3 4 3 3 3 3 1 3 2 1 3 1 2 0 0 1 0 5 0 2 0 3 1 0 2 2 3 2 1 2 0 1 1 1 2 4 1 3 2 0 1 1 2 2 2 1 0 3 ...
result:
ok 2130 numbers
Test #3:
score: 0
Accepted
time: 5ms
memory: 4120kb
input:
3 100000 998244353 gbppzfsncqyzmuwrcvtxsciucxusskcjhaanwhqmyncytwhkubrvcqxgcehdxyewdyvpqjcmrnmlgrytrucexmmfulqbtfctehphmrzkosyvhtvjrromqncbgsjcwhmlqidkycaxyhsrduoxayntuhqubvboseeziwjvrfagsbvtxjjbexnajqapgxydwtztzbbdpoydnjipfizdfpmczgqvdmpvxbqubtygkfpdeonegfzsttirbhzkobbigwneyvtcxndfkljdvbbcfnadtfhgo...
output:
4 1649 3651
result:
ok 3 number(s): "4 1649 3651"
Extra Test:
score: 0
Extra Test Passed