QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#731937 | #9568. Left Shifting 3 | TheZone | AC ✓ | 2ms | 4192kb | C++20 | 7.6kb | 2024-11-10 12:21:56 | 2024-11-10 12:21:56 |
Judging History
answer
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0),cout.tie(0)
#define endl '\n'
#define PII pair<int,int>
#define int long long
//#define int __int128
using namespace std;
inline int read();
inline void write(int x);
const int N = 1e5 + 10, mod = 998244353, inf = 0x3f3f3f3f, base = 131;
string str = "nanjing";
void solve(){
int n, m;
cin >> n >> m;
string s;
cin >> s;
s = ' ' + s + s;
int cnt = 0;
for(int i = 1; i <= n - 7 + 1; i++){
bool f = true;
for(int j = 0; j < 7; j++){
if(s[i + j] != str[j]){
f = false;
break;
}
}
if(f) cnt++;
}
for(int i = 1; i <= min(6ll, m); i++){
int j = n - (7 - i) + 1;
bool f = true;
for(int k = 0; k < 7; k++){
if(s[j + k] != str[k]){
f = false;
break;
}
}
if(f){
cout << cnt + 1 << endl;
return;
}
}
cout << cnt << endl;
return;
}
signed main(){
IOS;
int t = 1;
cin >> t;
while(t --) solve();
return 0;
}
inline int read(){
int x=0,f=1;char c=getchar();
while(c<'0'||c>'9'){
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
return x*f;
}
inline void write(int x){
if(x < 0) putchar('-'), x = - x;
if(x > 9) write(x / 10);
putchar('0' + x % 10);
}
/*#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0),cout.tie(0)
#define endl '\n'
#define PII pair<int,int>
#define int long long
//#define int __int128
using namespace std;
inline int read();
inline void write(int x);
const int N = 1e5 + 10, mod = 998244353, inf = 0x3f3f3f3f, base = 131;
string str = "nanjing";
void solve(){
int n, m;
cin >> n >> m;
string s;
cin >> s;
s = ' ' + s + s;
int cnt = 0;
for(int i = 1; i <= n - 7 + 1; i++){
bool f = true;
for(int j = 0; j < 7; j++){
if(s[i + j] != str[j]){
f = false;
break;
}
}
if(f) cnt++;
}
for(int i = 1; i <= min(6ll, m); i++){
int j = n - (7 - i) + 1;
bool f = true;
for(int k = 0; k < 7; k++){
if(s[j + k] != str[k]){
f = false;
break;
}
}
if(f){
cout << cnt + 1 << endl;
return;
}
}
cout << cnt << endl;
return;
}
signed main(){
IOS;
int t = 1;
cin >> t;
while(t --) solve();
return 0;
}
inline int read(){
int x=0,f=1;char c=getchar();
while(c<'0'||c>'9'){
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
return x*f;
}
inline void write(int x){
if(x < 0) putchar('-'), x = - x;
if(x > 9) write(x / 10);
putchar('0' + x % 10);
}#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0),cout.tie(0)
#define endl '\n'
#define PII pair<int,int>
#define int long long
//#define int __int128
using namespace std;
inline int read();
inline void write(int x);
const int N = 1e5 + 10, mod = 998244353, inf = 0x3f3f3f3f, base = 131;
string str = "nanjing";
void solve(){
int n, m;
cin >> n >> m;
string s;
cin >> s;
s = ' ' + s + s;
int cnt = 0;
for(int i = 1; i <= n - 7 + 1; i++){
bool f = true;
for(int j = 0; j < 7; j++){
if(s[i + j] != str[j]){
f = false;
break;
}
}
if(f) cnt++;
}
for(int i = 1; i <= min(6ll, m); i++){
int j = n - (7 - i) + 1;
bool f = true;
for(int k = 0; k < 7; k++){
if(s[j + k] != str[k]){
f = false;
break;
}
}
if(f){
cout << cnt + 1 << endl;
return;
}
}
cout << cnt << endl;
return;
}
signed main(){
IOS;
int t = 1;
cin >> t;
while(t --) solve();
return 0;
}
inline int read(){
int x=0,f=1;char c=getchar();
while(c<'0'||c>'9'){
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
return x*f;
}
inline void write(int x){
if(x < 0) putchar('-'), x = - x;
if(x > 9) write(x / 10);
putchar('0' + x % 10);
}#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0),cout.tie(0)
#define endl '\n'
#define PII pair<int,int>
#define int long long
//#define int __int128
using namespace std;
inline int read();
inline void write(int x);
const int N = 1e5 + 10, mod = 998244353, inf = 0x3f3f3f3f, base = 131;
string str = "nanjing";
void solve(){
int n, m;
cin >> n >> m;
string s;
cin >> s;
s = ' ' + s + s;
int cnt = 0;
for(int i = 1; i <= n - 7 + 1; i++){
bool f = true;
for(int j = 0; j < 7; j++){
if(s[i + j] != str[j]){
f = false;
break;
}
}
if(f) cnt++;
}
for(int i = 1; i <= min(6ll, m); i++){
int j = n - (7 - i) + 1;
bool f = true;
for(int k = 0; k < 7; k++){
if(s[j + k] != str[k]){
f = false;
break;
}
}
if(f){
cout << cnt + 1 << endl;
return;
}
}
cout << cnt << endl;
return;
}
signed main(){
IOS;
int t = 1;
cin >> t;
while(t --) solve();
return 0;
}
inline int read(){
int x=0,f=1;char c=getchar();
while(c<'0'||c>'9'){
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
return x*f;
}
inline void write(int x){
if(x < 0) putchar('-'), x = - x;
if(x > 9) write(x / 10);
putchar('0' + x % 10);
}#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0),cout.tie(0)
#define endl '\n'
#define PII pair<int,int>
#define int long long
//#define int __int128
using namespace std;
inline int read();
inline void write(int x);
const int N = 1e5 + 10, mod = 998244353, inf = 0x3f3f3f3f, base = 131;
string str = "nanjing";
void solve(){
int n, m;
cin >> n >> m;
string s;
cin >> s;
s = ' ' + s + s;
int cnt = 0;
for(int i = 1; i <= n - 7 + 1; i++){
bool f = true;
for(int j = 0; j < 7; j++){
if(s[i + j] != str[j]){
f = false;
break;
}
}
if(f) cnt++;
}
for(int i = 1; i <= min(6ll, m); i++){
int j = n - (7 - i) + 1;
bool f = true;
for(int k = 0; k < 7; k++){
if(s[j + k] != str[k]){
f = false;
break;
}
}
if(f){
cout << cnt + 1 << endl;
return;
}
}
cout << cnt << endl;
return;
}
signed main(){
IOS;
int t = 1;
cin >> t;
while(t --) solve();
return 0;
}
inline int read(){
int x=0,f=1;char c=getchar();
while(c<'0'||c>'9'){
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
return x*f;
}
inline void write(int x){
if(x < 0) putchar('-'), x = - x;
if(x > 9) write(x / 10);
putchar('0' + x % 10);
}*/
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
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: 2ms
memory: 3708kb
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: 2ms
memory: 4192kb
input:
3 100000 998244353 gbppzfsncqyzmuwrcvtxsciucxusskcjhaanwhqmyncytwhkubrvcqxgcehdxyewdyvpqjcmrnmlgrytrucexmmfulqbtfctehphmrzkosyvhtvjrromqncbgsjcwhmlqidkycaxyhsrduoxayntuhqubvboseeziwjvrfagsbvtxjjbexnajqapgxydwtztzbbdpoydnjipfizdfpmczgqvdmpvxbqubtygkfpdeonegfzsttirbhzkobbigwneyvtcxndfkljdvbbcfnadtfhgo...
output:
4 1649 3651
result:
ok 3 number(s): "4 1649 3651"
Extra Test:
score: 0
Extra Test Passed