제출 #1273860

#제출 시각아이디문제언어결과실행 시간메모리
1273860baotoan655Snake Escaping (JOI18_snake_escaping)C++20
100 / 100
433 ms21984 KiB
#include <bits/stdc++.h> #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } using namespace std; const int L = 20, N = 1 << L; int f[N], g[N], c[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); file("A") else file("task"); int l, q; cin >> l >> q; string s; cin >> s; int n = 1 << l; for (int i = 0; i < n; i++) f[i] += s[i] - '0', g[i] += s[i] - '0'; for (int i = 1; i < n; i++) c[i] = c[i & (i - 1)] + 1; for (int b = 0; b < l; b++) { for (int i = 0; i < n; i++) { if (i >> b & 1) { f[i] += f[i ^ (1 << b)]; g[i ^ (1 << b)] += g[i]; } } } while (q--) { string t; cin >> t; reverse(t.begin(), t.end()); int i0 = 0, i1 = 0, iq = 0; for (int b = 0; b < l; b++) if (t[b] == '0') i0 |= 1 << b; else if (t[b] == '1') i1 |= 1 << b; else iq |= 1 << b; int v = 0; if (c[iq] <= 7) { for (int t = iq; ; t = (t - 1) & iq) { v += s[t | i1] - '0'; if (t == 0) break; } } else if (c[i0] <= 7) { for (int t = i0; ; t = (t - 1) & i0) { v += (c[t] % 2 ? -1 : +1) * g[t | i1]; if (t == 0) break; } } else { for (int t = i1; ; t = (t - 1) & i1) { v += (c[t] % 2 ? -1 : +1) * f[(t ^ i1) | iq]; if (t == 0) break; } } cout << v << '\n'; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

snake_escaping.cpp: In function 'int main()':
snake_escaping.cpp:2:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
snake_escaping.cpp:10:5: note: in expansion of macro 'file'
   10 |     file("A") else file("task");
      |     ^~~~
snake_escaping.cpp:2:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
snake_escaping.cpp:10:5: note: in expansion of macro 'file'
   10 |     file("A") else file("task");
      |     ^~~~
snake_escaping.cpp:2:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
snake_escaping.cpp:10:20: note: in expansion of macro 'file'
   10 |     file("A") else file("task");
      |                    ^~~~
snake_escaping.cpp:2:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
snake_escaping.cpp:10:20: note: in expansion of macro 'file'
   10 |     file("A") else file("task");
      |                    ^~~~
#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...