# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1115781 | staszic_ojuz | Snake Escaping (JOI18_snake_escaping) | C++17 | 2062 ms | 4844 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
string bin(int n,int wielk){
string napis;
while(n>0){
napis+=n%2+48;
n/=2;
}
while(napis.size()!=wielk)
napis+='0';
reverse(napis.begin(),napis.end());
return napis;
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,k;
string napis,kolejne_snejki;
cin >> n >> k >> napis;
for(int i=0;i<k;++i){
cin >> kolejne_snejki;
int suma=0;
for(int j=0;j<(1<<n);++j){
string cos=bin(j,n);
bool jest = true;
for(int p=0;p<n;++p){
if(cos[p]!=kolejne_snejki[p] && kolejne_snejki[p]!='?'){
jest=false;
break;
}
}
if(jest==true){
suma+=napis[j]-48;
}
}
cout << suma << endl;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |