Submission #742522

#TimeUsernameProblemLanguageResultExecution timeMemory
742522flappybirdJOIOJI (JOI14_joioji)C++17
100 / 100
33 ms6108 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 201010
#define MAXS 20
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
int tr[127];
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	tr['J'] = 0;
	tr['O'] = 1;
	tr['I'] = 2;
	int N;
	cin >> N;
	int i;
	string s;
	cin >> s;
	int a[3] = { 0, 0, 0 };
	map<pii, int> mp;
	mp[pii(0, 0)] = 1;
	int ans = 0;
	for (i = 1; i <= N; i++) {
		int t = tr[s[i - 1]];
		a[t]++;

		if (mp[pii(a[1] - a[0], a[2] - a[0])]) ans = max(a[0] - mp[pii(a[1] - a[0], a[2] - a[0])] + 1, ans);
		else mp[pii(a[1] - a[0], a[2] - a[0])] = a[0] + 1;
	}
	cout << ans * 3 << Ln;
}

Compilation message (stderr)

joioji.cpp: In function 'int main()':
joioji.cpp:32:22: warning: array subscript has type 'char' [-Wchar-subscripts]
   32 |   int t = tr[s[i - 1]];
      |                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...