답안 #709166

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709166 2023-03-13T07:08:29 Z mansur Homework (CEOI22_homework) C++17
0 / 100
1000 ms 336652 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] != 'a') return 1;
	if (s[l + 4] == '?') return f(tp, l + 6, r - 1) + 1;
	else f(tp, l + 4, r - 3) + 1;
	
}

void slv() {
	cin >> s;
	int n = 0;
	for (char c: s) if (c == '?') n++;
	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:41:27: warning: value computed is not used [-Wunused-value]
   41 |  else f(tp, l + 4, r - 3) + 1;
      |                           ^
Main.cpp: At global scope:
Main.cpp:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main() {
      | ^~~~
Main.cpp: In function 'int first(int, int, int)':
Main.cpp:41:8: warning: control reaches end of non-void function [-Wreturn-type]
   41 |  else f(tp, l + 4, r - 3) + 1;
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 336652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 336652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 8680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 336652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 336652 KB Time limit exceeded
2 Halted 0 ms 0 KB -