結果
問題 | No.2213 Neq Move |
ユーザー |
|
提出日時 | 2023-02-10 21:50:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 867 bytes |
コンパイル時間 | 1,667 ms |
コンパイル使用メモリ | 190,896 KB |
最終ジャッジ日時 | 2025-02-10 12:35:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 5 |
ソースコード
#include <bits/stdc++.h>using i64 = long long;void solve() {int a, b, c, d;std::cin >> a >> b >> c >> d;if (a > b) {std::swap(a, b);std::swap(c, d);}int ans = 0;if (c > d) {if (c < a) {std::cout << 1 + c + 1 + d << "\n";return;}b = 0;ans++;std::swap(a, b);std::swap(c, d);}if (a <= c && b <= d) {ans += c - a;} else {ans += c + 1;if (a == 1) {ans++;}}if (b <= d) {ans += d - b;} else {ans += d + 1;}std::cout << ans << "\n";}int main() {std::ios::sync_with_stdio(false);std::cin.tie(nullptr);int t;std::cin >> t;while (t--) {solve();}return 0;}