Submission #1141708

#TimeUsernameProblemLanguageResultExecution timeMemory
1141708ereringcmp (balkan11_cmp)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "cmp.h" using namespace std; #define pb push_back void remember(int n) { int x=1; for(int i=1;i<=3;i++){ int a=n%4; n/=4; int b=n%4; string s="100"; if(i==2)s[0]='2'; if(i==3)s[0]='3'; s+=to_string(a); s+=to_string(b); a=stoi(s); bit_set(a); n/=4; } } int compare(int b) { vector<int> v; for(int i=1;i<=3;i++){ int a=b%4; b/=4; int c=b%4; string s="100"; if(i==2)s[0]='2'; if(i==3)s[0]='3'; s+=to_string(a); s+=to_string(c); a=stoi(s); v.pb(a); b/=4; } for(int i=v.size()-1;i>=0;i--){ int x=v[i],r=bit_get(x); if(r==1)continue; string s=to_string(x); int j=s[3]-'0',k=s[4]-'0'; if(k-1+(j-1)*4<3-k+(3-j)*4){ for(int l=j;l>=0;l--){ for(int o=(l==j?k-1:3);o>=0;o--){ string s1="000"; s1[0]=s[0]; s1+=to_string(l); s1+=to_string(o); r=bit_get(s1); if(r)return 1; } } } else{ for(int l=j;l<=3;l++){ for(int o=(l==j?k+1:0);o<=3;o++){ string s1="000"; s1=s[0]; s1+=to_string(l); s1+=to_string(o); r=bit_get(s1); if(r)return -1; } } } } return 0; }

Compilation message (stderr)

cmp.cpp: In function 'int compare(int)':
cmp.cpp:49:21: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int'
   49 |           r=bit_get(s1);
      |                     ^~
      |                     |
      |                     std::string {aka std::__cxx11::basic_string<char>}
In file included from cmp.cpp:2:
cmp.h:4:17: note:   initializing argument 1 of 'int bit_get(int)'
    4 | int bit_get(int addr);
      |             ~~~~^~~~
cmp.cpp:61:21: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int'
   61 |           r=bit_get(s1);
      |                     ^~
      |                     |
      |                     std::string {aka std::__cxx11::basic_string<char>}
In file included from cmp.cpp:2:
cmp.h:4:17: note:   initializing argument 1 of 'int bit_get(int)'
    4 | int bit_get(int addr);
      |             ~~~~^~~~