제출 #613043

#제출 시각아이디문제언어결과실행 시간메모리
613043penguinhackerHicCup (FXCUP4_hiccup)C++17
컴파일 에러
0 ms0 KiB
#include "hiccup.h" #include <bits/stdc++.h> using namespace std; const int mxN=1e6+2; int n=1, cnt[mxN]; stack<int> stk; vector<int> adj[mxN]; /*bool dfs(int u, int x) { for (int v : adj[u]) if (!dfs(v, x)) return 0; reverse(adj[u].begin(), adj[u].end()); int cur=0; for (int i=0; i<adj[u].size(); ++i) { cur+=cnt[adj[u][i]]-x; if (cur<0) return 0; } reverse(adj[u].begin(), adj[u].end()); return 1; }*/ int HicCup(string s) { stk.push(0); for (int i=0; i<s.size(); ++i) { if (s[i]=='H') { adj[stk.top()].push_back(n2); stk.push(n2++); } else if (s[i]=='C') { stk.pop(); if (stk.empty()) return -1; } else { if (!i||s[i-1]=='H') return -1; ++cnt[stk.top()]; } } return -1; /*if (stk.size()!=1) return -1; int lb=0, rb=1e6; while(lb<rb) { int mid=(lb+rb+1)/2; if (dfs(0, mid)) lb=mid; else rb=mid-1; } return lb;*/ }

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

hiccup.cpp: In function 'int HicCup(std::string)':
hiccup.cpp:27:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for (int i=0; i<s.size(); ++i) {
      |                ~^~~~~~~~~
hiccup.cpp:29:29: error: 'n2' was not declared in this scope; did you mean 'n'?
   29 |    adj[stk.top()].push_back(n2);
      |                             ^~
      |                             n