AtCoder Grand Contest 019

Submission #1542691

Source codeソースコード

#include <iostream>
#include <sstream>
#include <fstream>

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>

#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
// #include <unordered_map>
#include <set>
#include <utility>
#include <bitset>
#include <limits>
#include <climits>
using namespace std;

#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

#define INTSPACE 11
char _buf[INTSPACE*1000000 + 3];  // ここ要確認

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}
int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}


int lis(vector<int>& a) {
    int M = a.size();
    assert(0 < M && M <= 200000);

    vector<int> dp(M-1, 1e9);
    dp[0] = a[0];
    int maxlen = 1;
    for (int i=1; i<M; ++i) {
        int len = (int)(lower_bound(dp.begin(),dp.begin()+i, a[i]) - dp.begin())+1;
        maxlen = max(maxlen, len);
        dp[len-1] = min(dp[len-1], a[i]);
    }
    // cout << a << endl;
    // cout << dp << endl;
    return maxlen;
}

int main() {
    vector<int> tmp(4);
    loadvec(tmp,4);
    int x1=tmp[0], y1=tmp[1], x2=tmp[2], y2=tmp[3];
    int xmin=min(x1,x2), xmax=max(x1,x2);
    int ymin=min(y1,y2), ymax=max(y1,y2);
    if (x2 < x1) {
        swap(x1,x2); swap(y1,y2);
    }
    long double ans = 100.0 * ((xmax - xmin) + (ymax - ymin));
    long double pi = 3.141592653589793238462643;

    int N = loadint();
    vector<ii> ft;
    ft.reserve(N);
    rep(i,N){
        loadvec(tmp,2);
        int Xi=tmp[0], Yi=tmp[1];
        if (IN(Xi,xmin,xmax) && IN(Yi,ymin,ymax)) {
            ft.pb(ii(Xi,Yi));
        }
    }
    sort(ALL(ft));
    int M = ft.size();
    vector<int> a(M);
    rep(i,M) a[i] = ft[i].second;
    if (xmax == xmin || ymax == ymin) {
        // cout << a << endl;
        assert(M == 0 || M == 1);
        ans += (pi*10 - 20)*M; // M = 0 or 1
    } else if (M > 0) {
        assert(x1 < x2);
        if (y1 > y2) {
            rep(i,M) a[i] = ymax - a[i];
        }
        // cout << a << endl;
        int L = lis(a);
        ans += (pi*5 - 20) * L; // uso
    }
    printf("%.15Lf\n", ans);
    return 0;
}

Submission

Task問題 C - Fountain Walk
User nameユーザ名 naoya_t
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 RE
Score得点 0
Source lengthソースコード長 3805 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt
All 0 / 900 sample_01.txt,sample_02.txt,sample_03.txt,sample_01.txt,sample_02.txt,sample_03.txt,subtask_1_01.txt,subtask_1_02.txt,subtask_1_03.txt,subtask_1_04.txt,subtask_1_05.txt,subtask_1_06.txt,subtask_1_07.txt,subtask_1_08.txt,subtask_1_09.txt,subtask_1_10.txt,subtask_1_11.txt,subtask_1_12.txt,subtask_1_13.txt,subtask_1_14.txt,subtask_1_15.txt,subtask_1_16.txt,subtask_1_17.txt,subtask_1_18.txt,subtask_1_19.txt,subtask_1_20.txt,subtask_1_21.txt,subtask_1_22.txt,subtask_1_23.txt,subtask_1_24.txt,subtask_1_25.txt,subtask_1_26.txt,subtask_1_27.txt,subtask_1_28.txt,subtask_1_29.txt,subtask_1_30.txt,subtask_1_31.txt,subtask_1_32.txt,subtask_1_33.txt,subtask_1_34.txt,subtask_1_35.txt,subtask_1_36.txt,subtask_1_37.txt,subtask_1_38.txt,subtask_1_39.txt,subtask_1_40.txt,subtask_1_41.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_01.txt RE
subtask_1_02.txt RE
subtask_1_03.txt RE
subtask_1_04.txt AC 1 ms 256 KB
subtask_1_05.txt AC 1 ms 256 KB
subtask_1_06.txt AC 1 ms 256 KB
subtask_1_07.txt AC 1 ms 256 KB
subtask_1_08.txt AC 1 ms 256 KB
subtask_1_09.txt AC 8 ms 256 KB
subtask_1_10.txt WA
subtask_1_11.txt WA
subtask_1_12.txt WA
subtask_1_13.txt AC 17 ms 256 KB
subtask_1_14.txt WA
subtask_1_15.txt WA
subtask_1_16.txt WA
subtask_1_17.txt RE
subtask_1_18.txt AC 11 ms 256 KB
subtask_1_19.txt AC 11 ms 256 KB
subtask_1_20.txt AC 42 ms 3328 KB
subtask_1_21.txt AC 44 ms 3328 KB
subtask_1_22.txt AC 44 ms 3328 KB
subtask_1_23.txt AC 43 ms 3328 KB
subtask_1_24.txt AC 1 ms 256 KB
subtask_1_25.txt AC 1 ms 256 KB
subtask_1_26.txt AC 1 ms 256 KB
subtask_1_27.txt AC 1 ms 256 KB
subtask_1_28.txt AC 20 ms 384 KB
subtask_1_29.txt AC 22 ms 384 KB
subtask_1_30.txt AC 48 ms 3328 KB
subtask_1_31.txt AC 26 ms 3328 KB
subtask_1_32.txt AC 30 ms 3328 KB
subtask_1_33.txt AC 30 ms 3328 KB
subtask_1_34.txt AC 27 ms 3328 KB
subtask_1_35.txt AC 35 ms 3328 KB
subtask_1_36.txt AC 37 ms 3328 KB
subtask_1_37.txt AC 34 ms 3328 KB
subtask_1_38.txt AC 34 ms 3328 KB
subtask_1_39.txt AC 34 ms 3328 KB
subtask_1_40.txt AC 31 ms 3328 KB
subtask_1_41.txt AC 33 ms 3328 KB