제출 #1305960

#제출 시각아이디문제언어결과실행 시간메모리
1305960limon4ickSnake Escaping (JOI18_snake_escaping)C++20
5 / 100
2071 ms58920 KiB
/*#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("unroll-loops") #pragma ("reroll") */ #include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define ins insert #define F first #define S second const int mod = 1e7 + 7,N = 5010,inf = 1e18; signed main(){ //freopen("snnfsn.in","r",stdin) //freopen("snnfsn.out","w",stdout) std::ios::sync_with_stdio(false); cin.tie(0); int n,q; cin >> n >> q; string s; cin >> s; while(q--){ string t; cin >> t; set<int>st; int ans = 0; for(int i = 0;i<(1 << n);i++) st.ins(i); for(int j = 0;j<t.size();j++){ if(t[j]=='?') continue; bool ok = (t[j]=='0'); vector<int>v; for(auto x:st){ if((x>>(n-j-1))&1 && ok) v.pb(x); if(!((x>>(n-j-1))&1) && !ok) v.pb(x); } for(auto x:v) st.erase(x); } for(auto x:st){ ans+=(s[x] - '0'); } cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...