CSES - Datatähti 2024 alku - Results
Submission details
Task:Säähavainnot
Sender:a256
Submission time:2023-10-31 11:08:49 +0200
Language:C++ (C++20)
Status:READY
Result:0
Feedback
groupverdictscore
#1ACCEPTED0
Test results
testverdicttimescore
#1ACCEPTED0.01 s0details
#2ACCEPTED0.01 s0details
#3ACCEPTED0.01 s0details
#4ACCEPTED0.01 s0details
#5ACCEPTED0.01 s0details
#6ACCEPTED0.01 s0details
#7ACCEPTED0.01 s0details
#8ACCEPTED0.01 s0details

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 10123
#define NN 2000
#define EI (-1e5)

int n;
double T[N][24],dt[N][24],E[N][12],S[12],avg[12],END[N];

double mittaus[8000][24],oikea[8000][24];

double kertoimet[12][25]={
{0.11760797342252015, 0.10764119601284991, 0.07774086378704387, 0.05780730896983737, 0.02790697674404283, -0.001993355481761602, -0.021926910298964493, -0.031893687707567994, -0.04186046511616532, -0.021926910298964493, -0.01196013289036347, -0.001993355481761602, -0.01196013289036347, -0.001993355481761602, -0.001993355481761602, -0.01196013289036347, -0.031893687707567994, -0.01196013289036347, -0.01196013289036347, -0.021926910298964493, -0.021926910298964493, -0.01196013289036347, -0.001993355481761602, 0.017940199335438257, -0.13156146179359451},
{0.1568106312300269, 0.14352159468379988, 0.10365448504939184, 0.07707641195978317, 0.03720930232539044, -0.0026578073090154698, -0.029235880398619324, -0.042524916943423995, -0.05581395348822043, -0.029235880398619324, -0.01594684385381796, -0.0026578073090154698, -0.01594684385381796, -0.0026578073090154698, -0.0026578073090154698, -0.01594684385381796, -0.042524916943423995, -0.01594684385381796, -0.01594684385381796, -0.029235880398619324, -0.029235880398619324, -0.01594684385381796, -0.0026578073090154698, 0.023920265780584347, -0.17541528239145937},
{0.1960132890375336, 0.17940199335474985, 0.1295681063117398, 0.09634551494972896, 0.04651162790673805, -0.003322259136269337, -0.036544850498274155, -0.05315614617927999, -0.06976744186027553, -0.036544850498274155, -0.01993355481727245, -0.003322259136269337, -0.01993355481727245, -0.003322259136269337, -0.003322259136269337, -0.01993355481727245, -0.05315614617927999, -0.01993355481727245, -0.01993355481727245, -0.036544850498274155, -0.036544850498274155, -0.01993355481727245, -0.003322259136269337, 0.029900332225730433, -0.2192691029893242},
{0.2352159468450403, 0.21528239202569982, 0.15548172757408774, 0.11561461793967474, 0.05581395348808566, -0.003986710963523204, -0.043853820597928986, -0.06378737541513599, -0.08372093023233064, -0.043853820597928986, -0.02392026578072694, -0.003986710963523204, -0.02392026578072694, -0.003986710963523204, -0.003986710963523204, -0.02392026578072694, -0.06378737541513599, -0.02392026578072694, -0.02392026578072694, -0.043853820597928986, -0.043853820597928986, -0.02392026578072694, -0.003986710963523204, 0.035880398670876515, -0.26312292358718903},
{0.2548172757487937, 0.23322259136117482, 0.16843853820526172, 0.12524916943464764, 0.06046511627875947, -0.004318936877150139, -0.047508305647756405, -0.06910299003306399, -0.09069767441835819, -0.047508305647756405, -0.025913621262454185, -0.004318936877150139, -0.025913621262454185, -0.004318936877150139, -0.004318936877150139, -0.025913621262454185, -0.06910299003306399, -0.025913621262454185, -0.025913621262454185, -0.047508305647756405, -0.047508305647756405, -0.025913621262454185, -0.004318936877150139, 0.03887043189344956, -0.2850498338861215},
{0.274418604652547, 0.25116279069664976, 0.18139534883643568, 0.13488372092962053, 0.06511627906943326, -0.004651162790777072, -0.05116279069758382, -0.07441860465099198, -0.09767441860438573, -0.05116279069758382, -0.02790697674418143, -0.004651162790777072, -0.02790697674418143, -0.004651162790777072, -0.004651162790777072, -0.02790697674418143, -0.07441860465099198, -0.02790697674418143, -0.02790697674418143, -0.05116279069758382, -0.05116279069758382, -0.02790697674418143, -0.004651162790777072, 0.0418604651160226, -0.3069767441850539},
{0.274418604652547, 0.25116279069664976, 0.18139534883643568, 0.13488372092962053, 0.06511627906943326, -0.004651162790777072, -0.05116279069758382, -0.07441860465099198, -0.09767441860438573, -0.05116279069758382, -0.02790697674418143, -0.004651162790777072, -0.02790697674418143, -0.004651162790777072, -0.004651162790777072, -0.02790697674418143, -0.07441860465099198, -0.02790697674418143, -0.02790697674418143, -0.05116279069758382, -0.05116279069758382, -0.02790697674418143, -0.004651162790777072, 0.0418604651160226, -0.3069767441850539},
{0.2548172757487937, 0.23322259136117482, 0.16843853820526172, 0.12524916943464764, 0.06046511627875947, -0.004318936877150139, -0.047508305647756405, -0.06910299003306399, -0.09069767441835819, -0.047508305647756405, -0.025913621262454185, -0.004318936877150139, -0.025913621262454185, -0.004318936877150139, -0.004318936877150139, -0.025913621262454185, -0.06910299003306399, -0.025913621262454185, -0.025913621262454185, -0.047508305647756405, -0.047508305647756405, -0.025913621262454185, -0.004318936877150139, 0.03887043189344956, -0.2850498338861215},
{0.2548172757487937, 0.23322259136117482, 0.16843853820526172, 0.12524916943464764, 0.06046511627875947, -0.004318936877150139, -0.047508305647756405, -0.06910299003306399, -0.09069767441835819, -0.047508305647756405, -0.025913621262454185, -0.004318936877150139, -0.025913621262454185, -0.004318936877150139, -0.004318936877150139, -0.025913621262454185, -0.06910299003306399, -0.025913621262454185, -0.025913621262454185, -0.047508305647756405, -0.047508305647756405, -0.025913621262454185, -0.004318936877150139, 0.03887043189344956, -0.2850498338861215},
{0.2352159468450403, 0.21528239202569982, 0.15548172757408774, 0.11561461793967474, 0.05581395348808566, -0.003986710963523204, -0.043853820597928986, -0.06378737541513599, -0.08372093023233064, -0.043853820597928986, -0.02392026578072694, -0.003986710963523204, -0.02392026578072694, -0.003986710963523204, -0.003986710963523204, -0.02392026578072694, -0.06378737541513599, -0.02392026578072694, -0.02392026578072694, -0.043853820597928986, -0.043853820597928986, -0.02392026578072694, -0.003986710963523204, 0.035880398670876515, -0.26312292358718903},
{0.2352159468450403, 0.21528239202569982, 0.15548172757408774, 0.11561461793967474, 0.05581395348808566, -0.003986710963523204, -0.043853820597928986, -0.06378737541513599, -0.08372093023233064, -0.043853820597928986, -0.02392026578072694, -0.003986710963523204, -0.02392026578072694, -0.003986710963523204, -0.003986710963523204, -0.02392026578072694, -0.06378737541513599, -0.02392026578072694, -0.02392026578072694, -0.043853820597928986, -0.043853820597928986, -0.02392026578072694, -0.003986710963523204, 0.035880398670876515, -0.26312292358718903},
{0.21561461794128697, 0.19734219269022485, 0.14252491694291378, 0.10598006644470186, 0.051162790697411864, -0.003654485049896271, -0.040199335548101574, -0.05847176079720799, -0.07674418604630309, -0.040199335548101574, -0.021926910298999697, -0.003654485049896271, -0.021926910298999697, -0.003654485049896271, -0.003654485049896271, -0.021926910298999697, -0.05847176079720799, -0.021926910298999697, -0.021926910298999697, -0.040199335548101574, -0.040199335548101574, -0.021926910298999697, -0.003654485049896271, 0.032890365448303475, -0.24119601328825663},
};

void luedata(){
	ifstream in;
	in.open("sample_data.txt");

	int Nn;
	in>>Nn;
	for(int i=0;i<8000;++i){
		for(int h=0;h<24;++h) in>>mittaus[i][h];
		for(int h=0;h<12;++h) in>>oikea[i][h];
	}

	in.close();
}

void lineaarinen_ennuste(int i){
	for(int h=0;h<12;++h){
		E[i][h]=kertoimet[h][24];
		END[i]=4;
		for(int k=0;k<24;++k) E[i][h]+=T[i][k]*kertoimet[h][k];
	}
}

void ennusta(int i){
	double mabs=100,mval=100,minval=100,maxval=-100,avg=0;
	for(int h=0;h<23;++h){
		dt[i][h]=T[i][h+1]-T[i][h];
	}
	END[i]=7;

	for(int h=0;h<24;++h){
		if(abs(T[i][h])<mabs){
			mabs=abs(T[i][h]);
			mval=T[i][h];
		}
		minval=min(minval,T[i][h]);
		maxval=max(maxval,T[i][h]);
		avg+=T[i][h];
	}
	avg/=24;

	if(maxval-minval<3.2){
		END[i]=12;
	} else if(maxval-minval<6){
		END[i]=9;
	}

	if(maxval-minval>9){
		END[i]=5;
	}

	double ts=T[i][23];//,deltat=dt[i][0];
	int e=4;
	for(int h=0;h<e;++h){
		E[i][h]=ts;
	}

	double k=(ts-mval)/(e-1-12);

	for(int h=e;h<12;++h){
		ts+=k;

		//ts+=deltat;
		//deltat=kk(ts,deltat,h);

		E[i][h]=ts;
		//E[i][h]=(1.5*ts+0.5*T[i][h]+0.5*avg)/2.5;
		//E[i][h]=avg;
		S[h]+=E[i][h];
	}
}

void solve(){
	for(int i=0;i<n;++i){
		//ennusta(i);
		lineaarinen_ennuste(i);
	}
}

void simulaatio(){
	luedata();
	n=8000;
	for(int i=0;i<n;++i){
		for(int h=0;h<24;++h){
			T[i][h]=mittaus[i][h];
		}
	}
	solve();
	double s=0;
	for(int i=0;i<n;++i){
		int a=0,b=0;
		for(int h=0;h<END[i];++h){
			double d=abs(E[i][h]-oikea[i][h]);
			if(d<0.75){
				++a;
			} else if(d>=2.05){
				++b;
			}
		}
		s+=min(25*max(a-b,0),100);
	}
	s/=n;
	cout<<s<<'\n';
}

void prosentti(){
	luedata();
	n=1000;
	double p=0;
	ofstream out;
	out.open("weather_output");
	for(int i=0;i<n;++i){
		for(int h=0;h<24;++h){
			T[i][h]=mittaus[i][h];
		}
	}
	for(int i=0;i<n;++i){
		//ennusta(i);
		lineaarinen_ennuste(i);
		int a=0,b=0;
		for(int h=0;h<END[i];++h){
			double d=abs(E[i][h]-oikea[i][h]);
			if(d<0.75){
				++a;
			} else if(d>=2.05){
				++b;
			}
		}
		p+=max(0,a-b);

		if(a-b<3){
			for(int h=0;h<24;++h) out<<mittaus[i][h]<<' ';
			for(int h=0;h<12;++h) out<<oikea[i][h]<<' ';
			out<<'\n';

			for(int h=0;h<12;++h) out<<E[i][h]<<' ';
			out<<'\n';
		}
	}

	out.close();
	cerr<<p/(12*n)<<'\n';
}

void ratkaisu(){
	cin>>n;
	for(int i=0;i<n;++i){
		for(int h=0;h<24;++h) cin>>T[i][h];
	}

	solve();

	for(int i=0;i<n;++i){
		int e=END[i];
		for(int h=0;h<e;++h){
			printf("%.1f ",E[i][h]);
		}
		for(int h=e;h<12;++h){
			printf("? ");
		}
	}
	puts("");

}

int main(){
	//srand(time(NULL));
	cin.tie(0)->sync_with_stdio(0);
	ratkaisu();
	//prosentti();
	//simulaatio();
}

Test details

Test 1

Verdict: ACCEPTED

input
1000
-0.4 -0.1 -0.2 -0.3 -0.4 -0.5 ...

correct output
0.4 0.4 0.5 0.8 0.9 1.1 1.3 1....

user output
-0.1 -0.1 -0.1 -0.2 ? ? ? ? ? ...
Truncated

Test 2

Verdict: ACCEPTED

input
1000
2.9 2.9 2.9 2.1 2.6 2 2 2.2 2....

correct output
2.3 1.6 1.5 1.1 1 0.7 0.6 0.8 ...

user output
0.4 0.5 0.7 0.8 ? ? ? ? ? ? ? ...
Truncated

Test 3

Verdict: ACCEPTED

input
1000
6.6 6 6.4 6 4.6 4.6 4.2 4.3 4....

correct output
10 10.9 10.3 10.1 9.1 7.3 5.7 ...

user output
1.3 1.7 2.1 2.5 ? ? ? ? ? ? ? ...
Truncated

Test 4

Verdict: ACCEPTED

input
1000
19.4 20.2 19.1 18.9 18.3 17.3 ...

correct output
18 18.2 17 17.5 17.2 16.2 12 8...

user output
3.9 5.2 6.5 7.9 ? ? ? ? ? ? ? ...
Truncated

Test 5

Verdict: ACCEPTED

input
1000
-5.7 -5.8 -5.8 -5.9 -7.1 -6.9 ...

correct output
-4.2 -4.1 -4 -3.8 -3.5 -3.2 -3...

user output
-0.6 -0.8 -1.1 -1.3 ? ? ? ? ? ...
Truncated

Test 6

Verdict: ACCEPTED

input
1000
14.8 14.8 15.4 12.9 11.8 9.7 9...

correct output
11.8 11 11.6 10.8 10.4 10.4 10...

user output
3.2 4.3 5.4 6.5 ? ? ? ? ? ? ? ...
Truncated

Test 7

Verdict: ACCEPTED

input
1000
0.7 1 2 1.4 0.6 -0.4 -0.9 -0.7...

correct output
-1.3 -0.5 -0.6 -1 -3.2 -7.2 -6...

user output
0.7 0.9 1.1 1.3 ? ? ? ? ? ? ? ...
Truncated

Test 8

Verdict: ACCEPTED

input
1000
15.1 15.3 14.9 14.4 14.4 13.7 ...

correct output
15.6 15.9 16 15.2 14.6 14.4 13...

user output
2.6 3.5 4.3 5.2 ? ? ? ? ? ? ? ...
Truncated