結果
問題 | No.1034 テスターのふっぴーさん |
ユーザー |
![]() |
提出日時 | 2020-04-24 23:15:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,479 bytes |
コンパイル時間 | 1,520 ms |
コンパイル使用メモリ | 166,192 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 03:47:30 |
合計ジャッジ時間 | 2,433 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#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;}