Submission #478746

# Submission time Handle Problem Language Result Execution time Memory
478746 2021-10-08T08:25:03 Z Tenis0206 Brperm (RMI20_brperm) C++17
50 / 100
3000 ms 1900 KB
#include <bits/stdc++.h>
#include "brperm.h"

using namespace std;
char b[100005];
string s;
int query(int poz, int k)
{
    int l = (1<<k);
    if(poz+l-1>=s.size())
    {
        return 0;
    }
    for(int i=poz;i<=poz+l-1;i++)
    {
        int sim=0;
        for(int b=0;b<k;b++)
        {
            if((i-poz)&(1<<b))
            {
                sim+=(1<<(k-b-1));
            }
        }
        if(s[i]!=s[sim+poz])
        {
            return 0;
        }
    }
    return 1;
}
void init(int n, const char a[])
{
    for(int i=0;i<n;i++)
    {
        s.push_back(a[i]);
    }
}

/*int main()
{
    freopen("nr.in","r",stdin);
    freopen("nr.out","w",stdout);
    int n,q;
    char s[1000005];
    cin>>n;
    cin>>s;
    init(n,s);
    cin>>q;
    for(int i=1;i<=q;i++)
    {
        int poz,k;
        cin>>poz>>k;
        cout<<query(poz,k)<<'\n';
    }
    return 0;
}
*/

Compilation message

brperm.cpp: In function 'int query(int, int)':
brperm.cpp:10:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     if(poz+l-1>=s.size())
      |        ~~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 31 ms 1732 KB Output is correct
4 Correct 31 ms 1652 KB Output is correct
5 Correct 34 ms 1708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3081 ms 1900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 31 ms 1732 KB Output is correct
4 Correct 31 ms 1652 KB Output is correct
5 Correct 34 ms 1708 KB Output is correct
6 Execution timed out 3081 ms 1900 KB Time limit exceeded
7 Halted 0 ms 0 KB -