답안 #709177

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709177 2023-03-13T07:16:50 Z mansur Homework (CEOI22_homework) C++17
0 / 100
41 ms 30432 KB
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")

#include<bits/stdc++.h>	

using namespace std;

#define all(a) a.begin(), a.end()                                                   
#define rall(a) a.rbegin(), a.rend()                 
#define sz(a) (int)a.size()
#define pf push_front
#define pb push_back
#define vt vector
#define s second
#define f first
#define nl '\n'
 
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
     
vt<pii> rid = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
vt<pii> dir = {{-1, -1}, {-1, 1}, {1, -1}, {1, 1}};
 
const int N = 5e5, mod = 1e9 + 7;

const ll inf = 1e18;
 
double eps = 1e-15;

bool flg = 0;

string s;

int f(int tp, int l, int r) {
	if (r < l) return 0;
	if (s[l + 1] != (tp ? 'a' : 'i')) return 1;
	if (s[l + 4] == '?' && s[l + 6] == '?') return 2;
	if (s[l + 4] == '?') return f(tp, l + 6, r - 1) + 1;
	else f(tp, l + 4, r - 3) + 1;
	
}

void slv() {
	cin >> s;
	if (sz(s) == 1) {
		cout << 1;
		return;
	}
	int n = 0;
	for (char c: s) if (c == '?') n++;
	if (s[4] == s[6] && s[4] == '?') {
		cout << 1;
		return;
	}
	int cnt;
	if (s[4] == '?') cnt = f((s[1] == 'a'), 6, sz(s) - 2);
	else cnt = f((s[1] == 'a'), 4, sz(s) - 4);
	cout << n - cnt;
}              
 
main() {
	//freopen("shops.in", "r", stdin);                                                                                     
	//freopen("shops.out", "w", stdout);                                                                                     
	ios_base::sync_with_stdio(0);	                                                                                       
	cin.tie(0);
	int tp = 1;
	if (flg) cin >> tp;
	while (tp--) {  	
		slv();
	}
}                                               

Compilation message

Main.cpp: In function 'int first(int, int, int)':
Main.cpp:42:27: warning: value computed is not used [-Wunused-value]
   42 |  else f(tp, l + 4, r - 3) + 1;
      |                           ^
Main.cpp: At global scope:
Main.cpp:64:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   64 | main() {
      | ^~~~
Main.cpp: In function 'int first(int, int, int)':
Main.cpp:42:8: warning: control reaches end of non-void function [-Wreturn-type]
   42 |  else f(tp, l + 4, r - 3) + 1;
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 41 ms 30432 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -