# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1087947 | vicvic | Take-out (POI13_usu) | C++11 | 1040 ms | 37040 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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});
if (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;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |