AtCoder Regular Contest 047

Submission #1068023

Source codeソースコード

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

vll mpm = {(ll)-3e9, (ll)-3e9, (ll)3e9, (ll)3e9};

void print_answer() {
  ll sum = (mpm[0] + mpm[2]) / 2;
  ll diff = (mpm[1] + mpm[3]) / 2;
  printf("%lld %lld\n", (sum - diff) / 2, (sum + diff) / 2);
}

int main() {
  int n;
  scanf("%d", &n);
  vll x(n), y(n), plus(n), minus(n);
//  ll max_plus, min_plus, max_minus, min_minus;
  rep (i, n) {
    scanf("%lld %lld", &x[i], &y[i]);
    plus[i] = x[i] + y[i];
    minus[i] = y[i] - x[i];
    /*
    max_plus = max(max_plus, plus[i]);
    min_plus = min(min_plus, plus[i]);
    max_minus = max(max_minus, minus[i]);
    min_minus = min(min_minus, minus[i]);
    */
    mpm[0] = max(mpm[0], plus[i]);
    mpm[1] = max(mpm[1], minus[i]);
    mpm[2] = min(mpm[2], plus[i]);
    mpm[3] = min(mpm[3], minus[i]);
  }
  if (mpm[0] - mpm[2] == mpm[1] - mpm[3]) {
    print_answer();
    return 0;
  } else if (mpm[0] - mpm[2] > mpm[1] - mpm[3]) {
    bool extend1 = true;
    rep (i, n) {
      if (minus[i] != mpm[1]) {
        continue;
      }
      if (plus[i] == mpm[0] || plus[i] == mpm[2]) {
        continue;
      }
      extend1 = false;
    }
    if (extend1) {
      mpm[1] = mpm[3] + (mpm[0] - mpm[2]);
    } else {
      mpm[3] = mpm[1] - (mpm[0] - mpm[2]);
    }
    print_answer();
    return 0;
  } else {
    bool extend0 = true;
    rep (i, n) {
      if (plus[i] != mpm[0]) {
        continue;
      }
      if (minus[i] == mpm[1] || minus[i] == mpm[3]) {
        continue;
      }
      extend0 = false;
    }
    if (extend0) {
      mpm[0] = mpm[2] + (mpm[1] - mpm[3]);
    } else {
      mpm[2] = mpm[0] - (mpm[1] - mpm[3]);
    }
    print_answer();
    return 0;
  }

  return 0;
}

Submission

Task問題 B - 同一円周上
User nameユーザ名 gosenoku
Created time投稿日時
Language言語 C++14 (Clang++ 3.4)
Status状態 AC
Score得点 100
Source lengthソースコード長 2620 Byte
File nameファイル名
Exec time実行時間 42 ms
Memory usageメモリ使用量 3872 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt
All 100 / 100 sample_01.txt,sample_02.txt,subtask1_01.txt,subtask1_02.txt,subtask1_03.txt,subtask1_04.txt,subtask1_05.txt,subtask1_06.txt,subtask1_07.txt,subtask1_08.txt,subtask1_09.txt,subtask1_10.txt,subtask1_11.txt,subtask1_12.txt,subtask1_13.txt,subtask1_14.txt,subtask1_15.txt,subtask1_16.txt,subtask1_17.txt,subtask1_18.txt,subtask1_19.txt,subtask1_20.txt,subtask1_21.txt,subtask1_22.txt,subtask1_23.txt,subtask1_24.txt,subtask1_25.txt,subtask1_26.txt,subtask1_27.txt,subtask1_28.txt,subtask1_29.txt,subtask1_30.txt,subtask1_31.txt,subtask1_32.txt,subtask1_33.txt,subtask1_34.txt,subtask1_35.txt,subtask1_36.txt,subtask1_37.txt,subtask1_38.txt,subtask1_39.txt,subtask1_40.txt,subtask1_41.txt,subtask1_42.txt,subtask1_43.txt,subtask1_44.txt,subtask1_45.txt,subtask1_46.txt,subtask1_47.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 20 ms 792 KB
sample_02.txt AC 19 ms 800 KB
subtask1_01.txt AC 18 ms 928 KB
subtask1_02.txt AC 16 ms 908 KB
subtask1_03.txt AC 18 ms 928 KB
subtask1_04.txt AC 18 ms 800 KB
subtask1_05.txt AC 18 ms 924 KB
subtask1_06.txt AC 18 ms 800 KB
subtask1_07.txt AC 18 ms 796 KB
subtask1_08.txt AC 18 ms 928 KB
subtask1_09.txt AC 19 ms 924 KB
subtask1_10.txt AC 17 ms 796 KB
subtask1_11.txt AC 39 ms 3356 KB
subtask1_12.txt AC 42 ms 3744 KB
subtask1_13.txt AC 22 ms 1440 KB
subtask1_14.txt AC 33 ms 2464 KB
subtask1_15.txt AC 28 ms 2336 KB
subtask1_16.txt AC 40 ms 3612 KB
subtask1_17.txt AC 22 ms 1316 KB
subtask1_18.txt AC 22 ms 1440 KB
subtask1_19.txt AC 33 ms 2716 KB
subtask1_20.txt AC 42 ms 3744 KB
subtask1_21.txt AC 22 ms 1432 KB
subtask1_22.txt AC 27 ms 1944 KB
subtask1_23.txt AC 20 ms 1308 KB
subtask1_24.txt AC 27 ms 1952 KB
subtask1_25.txt AC 39 ms 3736 KB
subtask1_26.txt AC 33 ms 2848 KB
subtask1_27.txt AC 34 ms 2848 KB
subtask1_28.txt AC 19 ms 1040 KB
subtask1_29.txt AC 42 ms 3872 KB
subtask1_30.txt AC 36 ms 2972 KB
subtask1_31.txt AC 29 ms 2068 KB
subtask1_32.txt AC 19 ms 1056 KB
subtask1_33.txt AC 18 ms 928 KB
subtask1_34.txt AC 40 ms 3616 KB
subtask1_35.txt AC 33 ms 2712 KB
subtask1_36.txt AC 31 ms 2452 KB
subtask1_37.txt AC 38 ms 3360 KB
subtask1_38.txt AC 28 ms 2064 KB
subtask1_39.txt AC 33 ms 2836 KB
subtask1_40.txt AC 33 ms 2716 KB
subtask1_41.txt AC 21 ms 1184 KB
subtask1_42.txt AC 32 ms 2584 KB
subtask1_43.txt AC 32 ms 2592 KB
subtask1_44.txt AC 34 ms 2836 KB
subtask1_45.txt AC 36 ms 3104 KB
subtask1_46.txt AC 41 ms 3740 KB
subtask1_47.txt AC 17 ms 924 KB