제출 #410242

#제출 시각아이디문제언어결과실행 시간메모리
410242Blagojce캥거루 (CEOI16_kangaroo)C++11
0 / 100
3 ms376 KiB
#include <bits/stdc++.h> #define fr(i, n, m) for(int i = (n); i < (m); i ++) #define st first #define nd second #define all(v) begin(v), end(v) #define pq priority_queue #define pb push_back using namespace std; typedef long long ll; typedef pair<int,int> pii; const ll inf = 1e18; const ll mod = 1e9+7; const int mxn = 2e5; int n, f, s; int p = 0; vector<int> POS; int g(int a, int b, int pos, int side){ int dir = ((a+b)&1)^p; int ret = 0; if(side == 0){ if(dir == 0){ if(b == 0 && a == 1){ return 0; } fr(ipos, 0, pos){ POS.pb(ipos+1); ret += g(a-1, b, ipos, 0); POS.pop_back(); } } else{ if(b == 0 && a == 1){ return 1; } fr(ipos, pos, a-1){ POS.pb(ipos+1); ret += g(a-1, b, ipos, 0); POS.pop_back(); } fr(ipos, 0, b){ POS.pb(-ipos-1); ret += g(a-1, b, ipos, 1); POS.pop_back(); } } } else{ if(dir == 1){ if(a == 0 && b == 1){ return 0; } fr(ipos, pos, b-1){ POS.pb(-ipos-1); ret += g(a, b-1, ipos, 1); POS.pop_back(); } } else{ if(a == 0 && b == 1){ return 1; } fr(ipos, 0, pos){ POS.pb(-ipos-1); ret += g(a, b-1, ipos, 1); POS.pop_back(); } fr(ipos, 0, a){ POS.pb(ipos+1); ret += g(a, b-1, ipos, 0); POS.pop_back(); } } } return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); freopen("kangaroo.in", "r", stdin); freopen("kangaroo.out", "w", stdout); cin >> n >> s >> f; if(s > f) swap(s, f); --s, --f; int A = f; int B = n-A-1; int tot = g(A, B, s, 0); p = 1; tot += g(A, B, s, 0); cout<<tot<<endl; }

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

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:97:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   97 |  freopen("kangaroo.in", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:98:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   98 |  freopen("kangaroo.out", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...