結果
問題 | No.1425 Yet Another Cyclic Shifts Sorting |
ユーザー |
![]() |
提出日時 | 2021-03-18 05:34:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,186 bytes |
コンパイル時間 | 1,599 ms |
コンパイル使用メモリ | 122,932 KB |
最終ジャッジ日時 | 2025-01-19 18:01:54 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘bool is_cyc(std::vector<int>&)’: main.cpp:87:37: warning: ‘vl’ may be used uninitialized [-Wmaybe-uninitialized] 87 | return *min_element(all(da)) == vl; | ^~ main.cpp:77:18: note: ‘vl’ was declared here 77 | int cnt = 0, vl; | ^~
ソースコード
#include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <bitset> #include <climits> #include <cmath> #include <complex> #include <functional> #include <cassert> #include <stack> #include <numeric> #include <iomanip> #include <limits> #include <random> #include <unordered_map> typedef int64_t ll; typedef std::pair<int, int> Pii; typedef std::pair<ll, ll> Pll; typedef std::pair<double, double> Pdd; #define rip(_i, _n, _s) for (int _i = (_s); _i < (int)(_n); _i++) #define all(_l) _l.begin(), _l.end() #define rall(_l) _l.rbegin(), _l.rend() #define MM << " " << template<typename _T> using MaxHeap = std::priority_queue<_T>; template<typename _T> using MinHeap = std::priority_queue<_T, std::vector<_T>, std::greater<_T>>; template<typename _T> inline bool chmax(_T &_l, const _T _b) { if (_l < _b) { _l = _b; return true; } return false; } template<typename _T> inline bool chmin(_T &_l, const _T _b) { if (_l > _b) { _l = _b; return true; } return false; } template<typename _T> void vdeb(const std::vector<_T> &bb) { for (unsigned int i = 0;i < bb.size();i++) { if (i == bb.size() - 1) std::cout << bb[i]; else std::cout << bb[i] << ' '; } std::cout << '\n'; } template<typename _T> void vdeb(const std::vector<std::vector<_T>> &bb) { for (unsigned int i = 0;i < bb.size();i++) { std::cout << i << ' '; vdeb(bb[i]); } std::cout << '\n'; } using namespace std; bool is_sorted(vector<int> &da) { rip(i, da.size()-1, 0) { if(da[i] > da[i+1]) return false; } return true; } bool is_cyc(vector<int> &da) { int cnt = 0, vl; rip(i,da.size()-1,0) { if(da[i] > da[i+1]) { cnt++; vl = da[i+1]; if(cnt == 2) { return false; } } } return *min_element(all(da)) == vl; } int main() { int n; cin >> n; vector<int> da(n); rip(i,n,0) cin >> da[i]; if(is_sorted(da)) { cout << 0 << endl; } else if(is_cyc(da)) { cout << 1 << endl; } else { cout << 2 << endl; } }