답안 #148631

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148631 2019-09-01T04:48:57 Z 还没编好(#3801, cauchysheep, fjzzq2002, apiad) HicCup (FXCUP4_hiccup) C++17
100 / 100
38 ms 8320 KB
#include "hiccup.h"
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 3333333
int st[SZ],sn,ma[SZ],aa=2e9,N;
string s;
void go(int l,int r)
{
	if(l>r) return;
	int w=0,su=0,c=0;
//	cout<<l<<"~"<<r<<":";
//	for(int j=l;j<=r;++j) cout<<s[j];
//	cout<<"\n";
	for(int g=r;g>=l;--g)
	{
		if(s[g]=='!')
		{
			++w;
			continue;
		}
		if(s[g]=='C')
		{
			su+=w,++c,
			aa=min(aa,su/c),w=0;
			go(ma[g]+1,g-1);
			g=ma[g];
		}
		else throw "GG";
	}
	if(w) aa=-1;
}
int HicCup(std::string S) {
	N = S.size(); s=S;
	for(int i=0;i<N;++i)
	{
		if(S[i]=='!') continue;
		if(S[i]=='H') st[++sn]=i;
		else
		{
			if(!sn) return -1;
			int g=st[sn--];
			ma[g]=i; ma[i]=g;
		}
	}
	if(sn) return -1;
	go(0,N-1);
	return aa;
}
#ifdef LOCAL
#define st my_sty
#include "grader.cpp"
#endif
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 7 ms 640 KB Output is correct
5 Correct 30 ms 8320 KB Output is correct
6 Correct 13 ms 4352 KB Output is correct
7 Correct 23 ms 4352 KB Output is correct
8 Correct 31 ms 8312 KB Output is correct
9 Correct 38 ms 8312 KB Output is correct
10 Correct 17 ms 4352 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 7 ms 640 KB Output is correct
5 Correct 30 ms 8320 KB Output is correct
6 Correct 13 ms 4352 KB Output is correct
7 Correct 23 ms 4352 KB Output is correct
8 Correct 31 ms 8312 KB Output is correct
9 Correct 38 ms 8312 KB Output is correct
10 Correct 17 ms 4352 KB Output is correct
11 Correct 15 ms 4992 KB Output is correct
12 Correct 16 ms 5504 KB Output is correct
13 Correct 13 ms 4480 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 17 ms 8192 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 7 ms 768 KB Output is correct
19 Correct 17 ms 7936 KB Output is correct
20 Correct 20 ms 8192 KB Output is correct
21 Correct 16 ms 6016 KB Output is correct
22 Correct 16 ms 4096 KB Output is correct
23 Correct 16 ms 4352 KB Output is correct
24 Correct 18 ms 8192 KB Output is correct
25 Correct 30 ms 8192 KB Output is correct
26 Correct 22 ms 8192 KB Output is correct
27 Correct 17 ms 6400 KB Output is correct
28 Correct 16 ms 4608 KB Output is correct
29 Correct 16 ms 4352 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 6 ms 768 KB Output is correct
33 Correct 4 ms 384 KB Output is correct