제출 #1087948

#제출 시각아이디문제언어결과실행 시간메모리
1087948vicvic새로운 문제 (POI13_usu)C++11
11 / 100
1047 ms37176 KiB
#include <iostream> #include <fstream> #include <vector> #include <string> #include <cstring> using namespace std; int n, k, cnt=0, p=0; string input; vector <pair <int, int>> v[500005]; bool can_place (int p, char a) { int frecv[3]={0}; for (int i=0;i<v[p].size();i++) { frecv[v[p][i].first-'b']++; } return ((a=='c' && frecv[1]==0) || (a=='b' && frecv[0]<k)); } int main() { cin >> n >> k; cin >> input; input=" "+input; for (int i=1;i<=n;i++) { if (p!=0 && can_place (p, input[i])) { v[p].push_back ({input[i], i}); while (v[p].size()==k+1) { p--; } } else { cnt++; p=cnt; v[p].push_back ({input[i], i}); } } for (int i=1;i<=n/(k+1);i++) { for (auto itr : v[i]) { cout << itr.second << " "; } cout << "\n"; } return 0; }

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

usu.cpp: In function 'bool can_place(int, char)':
usu.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for (int i=0;i<v[p].size();i++)
      |                  ~^~~~~~~~~~~~
usu.cpp: In function 'int main()':
usu.cpp:29:31: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |             while (v[p].size()==k+1)
      |                    ~~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...