제출 #90481

#제출 시각아이디문제언어결과실행 시간메모리
90481tincamatei괄호 문자열 (CEOI16_match)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> using namespace std; int st[100000], top; bool check(string str, string par) { for(int i = 0; i < str.size(); ++i) if(par[i] == '(') st[top++] = i; else if(top > 0 && par[st[top - 1]] == '(' && str[st[top - 1]] == str[i]) --top; else return false; if(top == 0) return true; return false; } vector<int> poz[26]; int main() { string str, par; cin >> str; for(int i = 0; i < str.size(); ++i) poz[str[i] - 'a'].push_back(i); par.resize(str.size()); for(int i = 0; i < 26; ++i) { for(int j = 0; j < poz[i].size() / 2; ++j) par[poz[i][j]] = '('; for(int j = poz[i].size() / 2; j < poz[i].size(); ++j) par[poz[i][j]] = ')'; } if(check(str, par)) cout << par; else cout << -1; return 0; }

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

match.cpp: In function 'bool check(std::__cxx11::string, std::__cxx11::string)':
match.cpp:8:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < str.size(); ++i)
                  ~~^~~~~~~~~~~~
match.cpp: In function 'int main()':
match.cpp:28:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < str.size(); ++i)
                  ~~^~~~~~~~~~~~
match.cpp:34:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j = 0; j < poz[i].size() / 2; ++j)
                    ~~^~~~~~~~~~~~~~~~~~~
match.cpp:36:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j = poz[i].size() / 2; j < poz[i].size(); ++j)
                                    ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...