Submission #595310


Source Code Expand

#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...) fprintf(stderr, s)

template<class T> inline void amin(T &a, const T &b) { if (b<a) a=b; }
template<class T> inline void amax(T &a, const T &b) { if (a<b) a=b; }

int N;

struct Data {
    int tm;
    int id, op;
    Data(){}
    Data(int t, int i, int o) {
	tm = t;
	id = i;
	op = o;
    }
    bool operator<(const Data &y) const{
	return tm < y.tm;
    }
	
} D[200111];

double L[100111], H[100111];

int main() {
    scanf("%d", &N);
    REP (i, N) {
	int s, t;
	scanf("%d%d", &s, &t);
	D[2*i] = Data(s, i, 0);
	D[2*i+1] = Data(t, i, 1);
    }

    sort(D, D+2*N);
    int in = 0;
    double sum = 0, rate = 1;
    REP (i, 2*N) {
	if (D[i].op == 0) {
	    L[D[i].id] = sum;
	    H[D[i].id] = rate;
	    in++;
	} else {
	    double g = 1.0 / in;
				    
	    // eprintf("%f %f\n", L[D[i].id], H[D[i].id]);
	    L[D[i].id] = (sum - L[D[i].id]) / H[D[i].id];
	    H[D[i].id] = 1.0 - L[D[i].id] - g * rate / H[D[i].id];
	    
	    sum += rate * g;
	    rate *= 1 - g;
	    in--;
	    if (in == 0) rate = 1;
	}
    }

    REP (i, N) {
	amin(L[i], 1.0);
	amin(H[i], 1.0);
	amax(L[i], 0.0);
	amax(H[i], 0.0);
	printf("%.9f %.9f\n", L[i], H[i]);
    }

    return 0;
}

Submission Info

Submission Time
Task F - Yakiniku
User natsugiri
Language C++ (G++ 4.6.4)
Score 100
Code Size 1593 Byte
Status AC
Exec Time 232 ms
Memory 5032 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:39:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:42:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 22
Set Name Test Cases
Sample subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt
All subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask1_random01.txt, subtask1_random02.txt, subtask1_random03.txt, subtask1_random04.txt, subtask1_random05.txt, subtask1_random06.txt, subtask1_random07.txt, subtask1_random08.txt, subtask1_random09.txt, subtask1_random10.txt, subtask1_random11.txt, subtask1_random12.txt, subtask1_random13.txt, subtask1_special01.txt, subtask1_special02.txt, subtask1_special03.txt, subtask1_special04.txt, subtask1_special05.txt, subtask1_special06.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 108 ms 1032 KB
subtask0_sample_02.txt AC 98 ms 1000 KB
subtask0_sample_03.txt AC 30 ms 976 KB
subtask1_random01.txt AC 36 ms 968 KB
subtask1_random02.txt AC 31 ms 1048 KB
subtask1_random03.txt AC 32 ms 1008 KB
subtask1_random04.txt AC 42 ms 968 KB
subtask1_random05.txt AC 35 ms 1000 KB
subtask1_random06.txt AC 32 ms 1000 KB
subtask1_random07.txt AC 34 ms 948 KB
subtask1_random08.txt AC 27 ms 972 KB
subtask1_random09.txt AC 210 ms 4940 KB
subtask1_random10.txt AC 232 ms 4840 KB
subtask1_random11.txt AC 226 ms 4940 KB
subtask1_random12.txt AC 229 ms 4940 KB
subtask1_random13.txt AC 230 ms 5032 KB
subtask1_special01.txt AC 207 ms 4940 KB
subtask1_special02.txt AC 179 ms 4936 KB
subtask1_special03.txt AC 216 ms 4932 KB
subtask1_special04.txt AC 30 ms 1032 KB
subtask1_special05.txt AC 28 ms 968 KB
subtask1_special06.txt AC 29 ms 992 KB