結果
問題 | No.1034 テスターのふっぴーさん |
ユーザー | rxoxixyxd |
提出日時 | 2020-04-24 23:15:29 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,479 bytes |
コンパイル時間 | 1,400 ms |
コンパイル使用メモリ | 164,464 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-08-05 06:04:25 |
合計ジャッジ時間 | 2,595 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 1 ms
4,384 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | AC | 2 ms
4,376 KB |
testcase_14 | AC | 2 ms
4,380 KB |
testcase_15 | AC | 2 ms
4,380 KB |
testcase_16 | AC | 1 ms
4,380 KB |
testcase_17 | AC | 1 ms
4,380 KB |
testcase_18 | AC | 1 ms
4,380 KB |
testcase_19 | AC | 2 ms
4,380 KB |
testcase_20 | AC | 2 ms
4,380 KB |
testcase_21 | AC | 2 ms
4,376 KB |
testcase_22 | AC | 2 ms
4,376 KB |
testcase_23 | AC | 2 ms
4,376 KB |
testcase_24 | AC | 2 ms
4,376 KB |
testcase_25 | AC | 2 ms
4,380 KB |
testcase_26 | AC | 2 ms
4,376 KB |
testcase_27 | AC | 2 ms
4,380 KB |
testcase_28 | AC | 2 ms
4,380 KB |
testcase_29 | AC | 1 ms
4,380 KB |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < n; ++i) #define ALL(c) (c).begin(), (c).end() #define SUM(x) std::accumulate(ALL(x), 0LL) #define MIN(v) *std::min_element(v.begin(), v.end()) #define MAX(v) *std::max_element(v.begin(), v.end()) #define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end()) using namespace std; typedef long long ll; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = 1e9; const long long INFL = 1LL<<60; ll solve() { ll n, i, j; cin >> n >> i >> j; ll x, y; if (i < n/2 && j < n/2) { x = y = min(i, j); } else if (i < j && i + j <= n-1) { x = y = min(i, j); } else if (i < j && i + j > n-1) { x = y = (n-1) - max(i, j); } else if (i > j && i+j <= n-1) { x = y = min(i, j); } else if (i > j && i+j > n-1) { x = y = (n-1) - max(i, j); } else if (i >= n/2){ x = y = (n-1) - max(i, j); } ll n_xy = 4 * (x * n) - 4 * x * x; ll ans = n_xy; ll h = y, w = x; if (i == y) { ans += j-x; } else if (j == n - x - 1) { ans += n - 2*x - 1; ans += i - y; } else if (i == n - y - 1) { ans += (n-2*x)*2 - 2; ans += (n-x-1) -j; } else { ans += (n-2*x)*3 - 3; ans += (n-y-1) -i; } return ans; } int main() { int q; cin >> q; rep(i, q) { cout << solve() << endl; } return 0; }