結果
問題 |
No.1034 テスターのふっぴーさん
|
ユーザー |
|
提出日時 | 2020-04-24 21:37:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 722 bytes |
コンパイル時間 | 1,676 ms |
コンパイル使用メモリ | 165,652 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 02:30:56 |
合計ジャッジ時間 | 2,565 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; void ans(long long a) { cout << a << "\n"; } void solve() { long long n, i, j; cin >> n >> i >> j; i++, j++; long long m = min(min(i, n-i+1), min(j, n-j+1)); long long x = (m-1) * 4 * (n-1) - 4 * (m-1) * (m-2); long long xc = m, yc = m; if (i == xc) return ans(x + j - yc); x += n - 1 - 2 * (m - 1), yc = n - m + 1; if (j == yc) return ans(x + i - xc); x += n - 1 - 2 * (m - 1), xc = n - m + 1; if (i == xc) return ans(x + yc - j); x += n - 1 - 2 * (m - 1), yc = m; return ans(x + xc - i); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int q; cin >> q; while (q--) solve(); return 0; }