Submission #398516

#TimeUsernameProblemLanguageResultExecution timeMemory
398516model_codeBrperm (RMI20_brperm)C++17
50 / 100
5038 ms1896 KiB
/** * user: andrei-a80 * fname: Alexandru * lname: Andrei * task: Brperm * score: 83.0 * date: 2020-12-03 12:50:14.346718 */ #include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10 #include "brperm.h" #define ll long long #define double long double #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #define all(a) (a).begin(), (a).end() #define f first #define s second #define pb push_back #define mp make_pair #define pi pair #define rc(s) return cout<<s,0 #define endl '\n' #define mod 1000000007 #define PI 3.14159265359 #define MAXN 100005 #define INF 1000000005 #define LINF 1000000000000000005ll #define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; int n; string a; void init(int n,const char s[]){ for(int i=0;i<n;i++) { a.pb(s[i]); } } int query(int i,int k){ int aba=(1<<k)-1; if(i+(1<<k)>a.size()){ return 0; } for(int j=i+(1<<k)-1;j>=i;j--) { int x=aba; string bit=""; //cout<<x<<' '; for(int nr=k-1;nr>=0;nr--) { if(x>=(1<<nr)){ bit+='1'; x-=(1<<nr); }else bit+='0'; } //cout<<bit<<' '; int indx=0; for(int nr=0;nr<bit.size();nr++) { if(bit[nr]=='1'){ indx+=(1<<nr); } } //cout<<indx<<' '<<j<<endl; if(a[i+indx]!=a[j]){ return 0; } aba--; } return 1; } /* int32_t main(){ CODE_START; string val="axxyxxyb"; init(8,val); cout<<query(0,3)<<endl; cout<<query(1,1)<<endl; cout<<query(3,2)<<endl; cout<<query(1,2)<<endl; } */

Compilation message (stderr)

brperm.cpp: In function 'int query(int, int)':
brperm.cpp:40:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 | if(i+(1<<k)>a.size()){
      |    ~~~~~~~~^~~~~~~~~
brperm.cpp:57:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 | for(int nr=0;nr<bit.size();nr++)
      |              ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...