結果
問題 | No.396 クラス替え |
ユーザー |
![]() |
提出日時 | 2016-07-15 23:48:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 842 bytes |
コンパイル時間 | 724 ms |
コンパイル使用メモリ | 60,280 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 11:08:01 |
合計ジャッジ時間 | 1,424 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <string> using namespace std; int getClass( int rank, int classCount ) { int tmp = (int)(rank/classCount); int ret = rank - tmp * classCount; if( tmp % 2 == 0 ) { // even } else { // odd // reverse ret = classCount - 1 - ret; } return ret; } void solve() { int N,M,X,Y; cin >> N >> M; cin >> X >> Y; string ans = "NO"; if( M == 1 ) { ans = "YES"; } else { int classOfX = getClass(X-1,M); int classOfY = getClass(Y-1,M); if( classOfX == classOfY ) { ans = "YES"; } } cout << ans <<endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; }