CSES - Datatähti 2024 alku - Results
Submission details
Task:Säähavainnot
Sender:a256
Submission time:2023-10-31 20:20:13 +0200
Language:C++ (C++20)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'void ennusta(int)':
input/code.cpp:32:25: warning: variable 'mval' set but not used [-Wunused-but-set-variable]
   32 |         double mabs=100,mval=100,minval=100,maxval=-100,avg=0,dtc=0;
      |                         ^~~~
input/code.cpp: At global scope:
input/code.cpp:62:21: error: 'i' was not declared in this scope
   62 |         double ts=T[i][23];//,deltat=dt[i][0];
      |                     ^
input/code.cpp:64:9: error: expected unqualified-id before 'for'
   64 |         for(int h=0;h<e;++h){
      |         ^~~
input/code.cpp:64:21: error: 'h' does not name a type
   64 |         for(int h=0;h<e;++h){
      |                     ^
input/code.cpp:64:25: error: expected unqualified-id before '++' token
   64 |         for(int h=0;h<e;++h){
      |                         ^~
input/code.cpp:68:22: error: 'mval' was not declared in this scope
   68 |         double k=(ts-mval)/(e-1-12);
      |                      ^~~~
input/code.cpp:70:9: error:...

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];

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();
}

int sgn(double x){
	return (x>0)-(x<0);
}

void ennusta(int i){
	double mabs=100,mval=100,minval=100,maxval=-100,avg=0,dtc=0;
	int merkki=3;
	for(int h=0;h<23;++h){
		dt[i][h]=T[i][h+1]-T[i][h];
		if(merkki!=3&&sgn(dt[i][h]==-merkki)){
			dtc+=abs(dt[i][h-1]-dt[i][h]);
		}
		merkki=sgn(dt[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;
	} else 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);
	}
}

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);
		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();
}