제출 #1117633

#제출 시각아이디문제언어결과실행 시간메모리
1117633vjudge1캥거루 (CEOI16_kangaroo)C++17
6 / 100
2049 ms336 KiB
#include <bits/stdc++.h> using namespace std; # define int long long void solve() { int n, cs, cf, ans = 0; cin >> n >> cs >> cf; vector < int > per; for(int i = 1; i <= n; i++) per.push_back(i); while(next_permutation(per.begin(), per.end())) { if(per[0] != cs || per[per.size() - 1] != cf) continue; int cnt = 2; for(int i = 1; i < per.size() - 1; i++) { if(per[i] > per[i - 1] && per[i] > per[i + 1] || per[i] < per[i - 1] && per[i] < per[i + 1]) cnt++; } if(cnt == n) ans++; } cout << ans << endl; } signed main() { int tt = 1; // cin >> tt; while(tt--) solve(); }

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

kangaroo.cpp: In function 'void solve()':
kangaroo.cpp:16:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i = 1; i < per.size() - 1; i++)
      |                    ~~^~~~~~~~~~~~~~~~
kangaroo.cpp:18:30: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   18 |       if(per[i] > per[i - 1] && per[i] > per[i + 1] || per[i] < per[i - 1] && per[i] < per[i + 1])
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...