제출 #900594

#제출 시각아이디문제언어결과실행 시간메모리
900594warner1129캥거루 (CEOI16_kangaroo)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; template<ranges::range R> istream& operator>>(istream &s, R &&v) { for (auto &x : v) s >> x; return s; } template<ranges::range R> ostream& operator<<(ostream &s, R &&v) { for (auto &x : v) s << x << ' '; return s; } #ifdef LOCAL template<class... T> void dbg(T... x) { char e{}; ((cerr << e << x, e = ' '), ...); } #define debug(x...) dbg(#x, '=', x, '\n') #else #define debug(...) ((void)0) #endif #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define ff first #define ss second using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; using i128 = __int128; using u128 = unsigned __int128; template<class T> inline constexpr T inf = numeric_limits<T>::max() / 2; constexpr int mod = 1e9 + 7, inv2 = (mod + 1) / 2; template<class T> bool chmin(T &a, T b) { return (b < a and (a = b, true)); } template<class T> bool chmax(T &a, T b) { return (a < b and (a = b, true)); } void solve() { int n, s, t; cin >> n >> s >> t; bool op = s > 1; bool ed = t > 1; vector dp(n + 1, array<array<i64, 2>, 2>{}); dp[1][0][0] = 1; for (int i = 2; i <= n; i++) { decltype(dp) f(n + 1); // vector<i64> f(n + 1); for (int j = 1; j < i; j++) { if (i == s) { f[j][0][0] += dp[j][0][0]; f[j][0][1] += dp[j][0][1]; } else if (i == t) { f[j][0][0] += dp[j][0][0]; f[j][1][0] += dp[j][1][0]; } else { for (int x : {0, 1}) for (int y : {0, 1}) { f[j - 1][x][y] += dp[j][x][y] * (j - 1); f[j + 1][x][y] += dp[j][x][y] * (i - 1 - j + op + ed); if (!op) f[j + x][x ^ 1][y] += dp[j][x][y]; if (!ed) f[j + y][x][y ^ 1] += dp[j][x][y]; } } } if (s == i) op = false; if (t == i) ed = false; dp.swap(f); for (int j = 0; j <= n; j++) for (int x : {0, 1}) for (int y : {0, 1}) dp[j][x][y] %= mod; } cout << (dp[1][0][0] + dp[1][0][1] + dp[1][1][0] + dp[1][1][1]) << '\n'; } signed main() { cin.tie(0)->sync_with_stdio(false); cin.exceptions(cin.failbit); int T = 1; // cin >> T; while (T--) { solve(); } return 0; }

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

kangaroo.cpp:5:10: error: 'ranges' has not been declared
    5 | template<ranges::range R>
      |          ^~~~~~
kangaroo.cpp:5:24: error: expected '>' before 'R'
    5 | template<ranges::range R>
      |                        ^
kangaroo.cpp:6:33: error: 'R' has not been declared
    6 | istream& operator>>(istream &s, R &&v) { for (auto &x : v) s >> x; return s; }
      |                                 ^
kangaroo.cpp: In function 'std::istream& operator>>(std::istream&, int&&)':
kangaroo.cpp:6:57: error: there are no arguments to 'begin' that depend on a template parameter, so a declaration of 'begin' must be available [-fpermissive]
    6 | istream& operator>>(istream &s, R &&v) { for (auto &x : v) s >> x; return s; }
      |                                                         ^
kangaroo.cpp:6:57: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
kangaroo.cpp:6:57: error: there are no arguments to 'end' that depend on a template parameter, so a declaration of 'end' must be available [-fpermissive]
kangaroo.cpp: At global scope:
kangaroo.cpp:7:10: error: 'ranges' has not been declared
    7 | template<ranges::range R>
      |          ^~~~~~
kangaroo.cpp:7:24: error: expected '>' before 'R'
    7 | template<ranges::range R>
      |                        ^
kangaroo.cpp:8:33: error: 'R' has not been declared
    8 | ostream& operator<<(ostream &s, R &&v) { for (auto &x : v) s << x << ' '; return s; }
      |                                 ^
kangaroo.cpp: In function 'std::ostream& operator<<(std::ostream&, int&&)':
kangaroo.cpp:8:57: error: there are no arguments to 'begin' that depend on a template parameter, so a declaration of 'begin' must be available [-fpermissive]
    8 | ostream& operator<<(ostream &s, R &&v) { for (auto &x : v) s << x << ' '; return s; }
      |                                                         ^
kangaroo.cpp:8:57: error: there are no arguments to 'end' that depend on a template parameter, so a declaration of 'end' must be available [-fpermissive]