| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 964761 | 12345678 | Snake Escaping (JOI18_snake_escaping) | C++17 | 2050 ms | 22364 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int nx=(1<<20)+5;
int l, q, sub[nx], super[nx];
char c;
string s;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>l>>q;
for (int i=0; i<(1<<l); i++) cin>>c, sub[i]=super[i]=c-'0';
for (int i=0; i<l; i++) for (int j=0; j<(1<<l); j++) if (j&(1<<i)) sub[j]+=sub[j^(1<<i)];
for (int i=0; i<l; i++) for (int j=(1<<l)-1; j>=0; j--) if (!(j&(1<<i))) super[j]+=super[j^(1<<i)];
while (q--)
{
cin>>s;
reverse(s.begin(), s.end());
int tmp=0;
vector<int> zero, one, qrs;
for (int i=0; i<l; i++)
{
if (s[i]=='0') zero.push_back(i);
if (s[i]=='1') one.push_back(i);
if (s[i]=='?') qrs.push_back(i);
}
if (zero.size()<=(l/3)&&0)
{
for (int i=0; i<l; i++) if (s[i]=='1'||s[i]=='?') tmp+=(1<<i);
}
else if (one.size()<=(l/3)||1)
{
for (int i=0; i<l; i++) if (s[i]=='?') tmp+=(1<<i);
if (one.empty()) cout<<sub[tmp]<<'\n';
else
{
int sz=one.size(), res=0;
for (int i=0; i<(1<<sz); i++)
{
int vl=tmp;
for (int j=0; j<sz; j++) if (i&(1<<j)) vl+=(1<<one[j]);
if ((sz-__builtin_popcount(i))%2==0) res+=sub[vl];
else res-=sub[vl];
}
cout<<res<<'\n';
}
}
}
}
// 00011???
컴파일 시 표준 에러 (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... | ||||
