답안 #148497

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148497 2019-09-01T04:33:11 Z ProofByTLE(#3614, Mahotsukai, McDic, Redux) HicCup (FXCUP4_hiccup) C++17
24 / 100
157 ms 3388 KB
#include<bits/stdc++.h>
#include<chrono>
using namespace std;
using namespace chrono;
#define all(a) a.begin(), a.end()
#define sz(x) (int(x.size()))
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef vector<string> vs;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
#include"hiccup.h"
bool test(const string &s, int k){
	int n = s.size(), hcnt = 0, ecnt = 0;
	bool found = false;
	for(int i = 0; i < n; i ++){
		if(s[i] == 'H'){
			hcnt ++;
		}
		else if(s[i] == 'C'){
			if(!hcnt){
				return false;
			}
			hcnt --;
			found = true;
			ecnt += k;
			found = true;
		}
		else{
			if(!i || s[i - 1] == 'H'){
				return false;
			}
			ecnt --;
			if(ecnt < 0) ecnt = 0;
		}
	}
	if(hcnt || ecnt) return false;
	return true;
}
int HicCup(string s){
	if(any_of(all(s), [](char c){return c != 'H' && c != 'C' && c != '!';})){
		return -1;
	}
	if(!test(s, 0)){
		return -1;
	}
	int n = s.size();
	int l = 0, r = n;
	while(r - l > 1){
		int m = l + r >> 1;
		test(s, m) ? l = m : r = m;
	}
	return l;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                  //
//                                                                                                  //
//                                              _____________                                       //
//             ++++++++++                ___------------------\\\\                                  //
//           +++`+``+`+`++++        ///`````````````````````````````\\\                             //
//           ++`+`+``+++`++++  /////```````````````````````````````````\\                           //
//           +++`++`+`+``+++/////`````````````````````````````````````````\\                        //
//             +++`++`+``+///```````````|```````````````````````````````````\\                      //
//          ____++++/++++/`````````````/````````|````````|```````````````````\\                     //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\\                    //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\\                  //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\\                 //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\\                //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                                  //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                  //
//                                        Created by Aeren                                          //
//                                                                                                  //
//////////////////////////////////////////////////////////////////////////////////////////////////////

Compilation message

hiccup.cpp: In function 'std::ostream& operator<<(std::ostream&, const std::vector<_Tp>&)':
hiccup.cpp:32:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(auto &x: arr) out << x << ' '; cout << "\n";
  ^~~
hiccup.cpp:32:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(auto &x: arr) out << x << ' '; cout << "\n";
                                     ^~~~
hiccup.cpp: In function 'std::ostream& operator<<(std::ostream&, const std::deque<_Tp>&)':
hiccup.cpp:42:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(auto &x: arr) out << x << ' '; cout << "\n";
  ^~~
hiccup.cpp:42:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(auto &x: arr) out << x << ' '; cout << "\n";
                                     ^~~~
hiccup.cpp: In function 'bool test(const string&, int)':
hiccup.cpp:48:7: warning: variable 'found' set but not used [-Wunused-but-set-variable]
  bool found = false;
       ^~~~~
hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:83:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m = l + r >> 1;
           ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 9 ms 512 KB Output is correct
5 Correct 151 ms 3328 KB Output is correct
6 Correct 15 ms 3328 KB Output is correct
7 Correct 15 ms 3328 KB Output is correct
8 Correct 142 ms 3388 KB Output is correct
9 Correct 157 ms 3360 KB Output is correct
10 Correct 13 ms 3328 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 9 ms 512 KB Output is correct
5 Correct 151 ms 3328 KB Output is correct
6 Correct 15 ms 3328 KB Output is correct
7 Correct 15 ms 3328 KB Output is correct
8 Correct 142 ms 3388 KB Output is correct
9 Correct 157 ms 3360 KB Output is correct
10 Correct 13 ms 3328 KB Output is correct
11 Correct 14 ms 3328 KB Output is correct
12 Correct 15 ms 3328 KB Output is correct
13 Correct 15 ms 3328 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 14 ms 3328 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 640 KB Output is correct
19 Correct 76 ms 3328 KB Output is correct
20 Incorrect 68 ms 3200 KB Output isn't correct
21 Halted 0 ms 0 KB -