結果
| 問題 |
No.2213 Neq Move
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-10 23:22:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 679 bytes |
| コンパイル時間 | 3,616 ms |
| コンパイル使用メモリ | 250,960 KB |
| 最終ジャッジ日時 | 2025-02-10 13:43:20 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
ll A,B,C,D;
void solve(){
ll ans = C+D+2;
if(A==1||B==1)ans = C+D+3;
for(int isA = 0;isA<2;isA++){
for(int isB = 0;isB<2;isB++){
if(isA==0&&isB==0){
if((A<B)==(C<D)&&A<=C&&B<=D){
ans = min(ans,C-A+D-B);
}
}else if(isA==0&&isB==1){
if(C>D&&A<=C){
ans = min(ans,C-A+D+1);
}
}else if(isA==1&&isB==0){
if(C<D&&B<=D){
ans = min(ans,D-B+C+1);
}
}
}
}
cout<<ans<<endl;
}
signed main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t;
cin >> t;
while(t--){
cin >> A >> B >> C >> D;
solve();
}
}