Submission #572600

# Submission time Handle Problem Language Result Execution time Memory
572600 2022-06-04T18:54:32 Z groshi Monochrome Points (JOI20_monochrome) C++17
0 / 100
1 ms 332 KB
#include<iostream>
#include<vector>
#include<string>
using namespace std;
vector<int> b,w;
int n;
int wyn(int ile)
{
    int wynik=0;
    for(int i=0;i<b.size();i++)
    {
        int l=b[i];
        int r=w[(i+ile)%n];
        if(l>r)
            swap(l,r);
        int ile1=(r-l+1);
        int ile2=2*n-ile1-2;
        wynik+=min(ile1,ile2);
    }
    return wynik/2;
}
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
        if(s[i]=='B')
            b.push_back(i);
        else w.push_back(i);
    int pocz=0,kon=n,sre,ostd;
    while(pocz<kon)
    {
        sre=(pocz+kon)/2;
        if(wyn(sre)<wyn(sre+1))
        {
            ostd=sre+1;
            pocz=sre+1;
        }
        else kon=sre;
    }
    cout<<wyn(ostd);
    return 0;
}

Compilation message

monochrome.cpp: In function 'int wyn(int)':
monochrome.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<b.size();i++)
      |                 ~^~~~~~~~~
monochrome.cpp: In function 'int main()':
monochrome.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i=0;i<s.length();i++)
      |                 ~^~~~~~~~~~~
monochrome.cpp:45:19: warning: 'ostd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |     cout<<wyn(ostd);
      |                   ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -