제출 #148497

#제출 시각아이디문제언어결과실행 시간메모리
148497ProofByTLE (#200)HicCup (FXCUP4_hiccup)C++17
24 / 100
157 ms3388 KiB
#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 // // // //////////////////////////////////////////////////////////////////////////////////////////////////////

컴파일 시 표준 에러 (stderr) 메시지

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;
           ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...