이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "hiccup.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
using namespace std;
const int N = 1000005;
int n;
int x, y, z;
int num;
string s;
stack < int > St;
int HicCup(string S) {
int n = S.size();
int x = 0, y = 0, z = 0;
S = "#" + S;
for (int i = 1; i <= N; i++){
if (S[i] == 'H')
x++;
else if (S[i] == 'C')
y++;
else
z++;
}
if (x != y)
return -1;
if (z % x != 0)
return -1;
num = z / x;
s = "#HC";
for (int i = 0; i < num; i++)
s += "!";
int m = num + 2;
for (int i = 1; i <= N; i++){
while (St.size() > 0 && St.top() == m)
St.pop();
if (S[i] == 'H'){
St.push (1);
continue;
}
if (St.size() == 0)
return -1;
x = St.top() + 1;
if (S[i] != s[x])
return -1;
St.pop();
St.push (x);
}
if (St.size() == 0)
return num;
return -1;
}
컴파일 시 표준 에러 (stderr) 메시지
hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:28:6: warning: unused variable 'n' [-Wunused-variable]
int n = S.size();
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |