QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#731374#9568. Left Shifting 3ucup-team1766#WA 8ms3856kbC++203.0kb2024-11-10 02:47:362024-11-10 02:47:36

Judging History

你现在查看的是最新测评结果

  • [2024-11-10 02:47:36]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3856kb
  • [2024-11-10 02:47:36]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// if you end up using long double, you need to set the floating point notation to fixed, and set the percision to be very high
typedef long double ld;

// contrsuct umaps like this, unordered_map<long long, int, custom_hash> safe_map;
// FIXED_RANDOM is static so it doesn not get redeclared between function calls
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
		
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


const ll INF = 2001001001;
const ll INF2 = 2e18;
const ll MOD = 1000000007;

#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back 
#define pf push_front
#define f first
#define s second
#define mp make_pair
#define pll pair<ll, ll>
#define pint pair<int, int>
#define tp make_tuple

const bool testing = 0;
mt19937 rng(63);

// first four are north, west, east ,south
int dir1[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dir2[] = {0, 1, 0, -1, 1, -1, 1, -1};

int main() {
	// apparently this does fast i/o
	cin.tie(0) , ios::sync_with_stdio(0);
	
	// use this if you read in from a file
	/*
	freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
	*/
	
	stringstream ss;
	
	// Do it once. Do it right.
	// Read the problem statement carefully
	// Plan out the steps in words on a piece of paper before implementing
	// after RTE(obviously) but also WA, run valgrind!!!
	// Testing your solution on samples before coding is a great way to see if you read the problem correctly!!!
	// Also take notes about key elements in the problem statement while reading the problem!!!
	// If you're stuck, try small cases (not just a trick for math problems)
	// When debugging, especially when it's not your code, go through the code line by line, don't just scan
	// over sections, and if it's not your code, take notes on what each line does.
	
	//cout << fixed << setprecision(12);
	// if you use ld, use the above and don't use string stream
	
	// use instead of ceil(a, b) if a and b are positive
	// (a + b - 1) / b
	
	int t;
	cin >> t;
	while(t > 0){
		t--;
		int n, k;
		cin >> n >> k;
		string str;
		cin >> str;
		string str2 = str+str;
		int n2 = str2.size();
		vector<int> vec(n2, 0);
		for(int i = 0; i+7-1 < n2; i++){
			if(str2.substr(i, 7) == "nanjing"){
				vec[i]++;
			}
		}
		int maxAm = 0;
		int sum = 0;
		for(int i = 0; i+7-1 < n; i++){
			sum += vec[i];
		}
		maxAm = sum;
		for(int i = 1; i <= min(n-7, k); i++){
			sum -= vec[i-1];
			sum += vec[i+n-7];
			maxAm = max(sum, maxAm);
		}
		cout << maxAm << "\n";
	}
	
	cout << ss.str();
	return 0;
}

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: -100
Wrong Answer
time: 8ms
memory: 3720kb

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
0
4
2
0
3
3
0
0
0
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
0
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
0
0
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:

wrong answer 18th numbers differ - expected: '1', found: '0'