Submission #83503

# Submission time Handle Problem Language Result Execution time Memory
83503 2018-11-08T14:08:05 Z nikolapesic2802 Take-out (POI13_usu) C++14
0 / 100
67 ms 9448 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back

/*
     - Find some c with k b's around add it to the answer and "delete" the c and b's.
*/
int main()
{
    int n,k;
    scanf("%i %i",&n,&k);
    char s[n];
    scanf("%s",s);
    vector<vector<int> > sol;
    vector<int> space;
    space.pb(0);
    int c=0;
    vector<int> index;
    for(int i=0;i<n;i++)
    {
        index.pb(i);
        if(s[i]=='c')
        {
            c++;
            space.pb(0);
        }
        else
        {
            space[c]++;
        }
        if(c&&space[c]+space[c-1]==k)
        {
            vector<int> tr;
            for(int i=0;i<k+1;i++)
            {
                tr.pb(index.back());
                index.pop_back();
            }
            reverse(tr.begin(),tr.end());
            sol.pb(tr);
            int dif=space[c--];
            space.pop_back();
            space[c]-=k-dif;
        }
    }
    reverse(sol.begin(),sol.end());
    for(auto p:sol)
    {
        for(auto d:p)
        {
            printf("%i ",d+1);
        }
        printf("\n");
    }
    return 0;
}

Compilation message

usu.cpp: In function 'int main()':
usu.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i %i",&n,&k);
     ~~~~~^~~~~~~~~~~~~~~
usu.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",s);
     ~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 392 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 468 KB Output is correct
2 Incorrect 3 ms 472 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Correct 3 ms 744 KB Output is correct
2 Incorrect 3 ms 744 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 2052 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 3836 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 4980 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 7280 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 9448 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -