답안 #148625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148625 2019-09-01T04:47:43 Z 还没编好(#3801, cauchysheep, fjzzq2002, apiad) HicCup (FXCUP4_hiccup) C++17
0 / 100
29 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 666666
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 Runtime error 29 ms 8320 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Runtime error 29 ms 8320 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -