結果
| 問題 |
No.2213 Neq Move
|
| コンテスト | |
| ユーザー |
planes
|
| 提出日時 | 2023-02-10 22:24:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 926 bytes |
| コンパイル時間 | 1,250 ms |
| コンパイル使用メモリ | 166,836 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-07 16:35:30 |
| 合計ジャッジ時間 | 1,713 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
ll INF=2e18;
void solve() {
ll A,B,C,D;cin>>A>>B>>C>>D;
ll ans=0;
if(A==C&&B==D){
cout<<0<<endl;
return ;
}
if(C<=A&&D<=B) {
if(C!=A) ans+=C+1;
if(B!=D) ans+=D+1;
if(A==C) {
if(C<D) {
ans+=1+C;
if(A==1) ans++;
}
}
if(B==D) {
if(D<C) {
ans+=1+D;
if(B==1) ans++;
}
}
}
else if(A<=C&&B<=D) {
ans+=(D-B)+(C-A);
if(A<=B&&D<=C) {
ans+=B+1;
}
if(B<=A&&C<=D) {
ans+=A+1;
}
}
else if(C<A) {
ans+=C+1+(D-B);
if(D<=C) {
ans+=B+1;
if(B==1) ans++;
}
}
else {
ans+=(C-A)+D+1;
if(C<=D) {
ans+=A+1;
if(A==1) ans++;
}
}
cout<<ans<<endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll t;cin>>t;
for(ll i=0;i<t;i++) {
solve();
}
}
planes