CSES - Datatähti 2024 qualification mirror - Results
Submission details
Task:Säähavainnot
Sender:Pelmenner
Submission time:2023-10-31 20:36:46 +0200
Language:C++ (C++20)
Status:READY
Result:69
Feedback
groupverdictscore
#1ACCEPTED69
Test results
testverdicttimescore
#1ACCEPTED0.02 s8.75details
#2ACCEPTED0.02 s9details
#3ACCEPTED0.02 s8.88details
#4ACCEPTED0.02 s8.75details
#5ACCEPTED0.02 s8.88details
#6ACCEPTED0.02 s8.38details
#7ACCEPTED0.02 s8details
#8ACCEPTED0.02 s8.38details

Code

#include <bits/stdc++.h>

using namespace std;

using Day = array<double, 24>;

istream& operator>>(istream& in, Day& day)
{
	for (int i = 0; i < 24; ++i)
		cin >> day[i];
	return in;
}

void solve(Day& day, vector<optional<double>>& answer)
{
	const double threshold = 0.8;
	answer[0] = day[23] + (day[23] - day[22]) / 2;
	for (int i = 1; i < 7 && abs(day[i] - day[i - 1]) <= threshold; ++i)
		answer[i] = answer[i - 1].value() + day[i] - day[i - 1];

	if (abs(day[23] - day[0]) > threshold)
		return;
	for (int i = 8; i < 12; ++i)
		answer[i] = day[i] + 0.9 * (day[23] - day[0]);
}

void solveLinearRegression(Day& day, vector<optional<double>>& answer);

int main()
{
	cin.tie(nullptr)->sync_with_stdio(false);

	int n = 0;
	cin >> n;

	vector<Day> days(n);
	for (int i = 0; i < n; ++i)
		cin >> days[i];

	for (int i = 0; i < n; ++i)
	{
		vector<optional<double>> answer(12);
		solveLinearRegression(days[i], answer);
		for (auto x : answer)
		{
			if (x.has_value())
				cout << x.value() << " ";
			else
				cout << "? ";
		}
		cout << "\n";
	}

	return 0;
}

void solveLinearRegression(Day& day, vector<optional<double>>& answer)
{
	vector<vector<double>> weights =
		{{ -7.19536718e-03, -1.74542621e-03, 1.75918228e-03, 5.91255356e-02,
		   -5.65039283e-02, 5.03743245e-02, -4.85330522e-02, 4.87630363e-02,
		   -1.79481937e-02, -2.46322335e-02, 1.42751818e-02, 2.43636281e-02,
		   -5.48504778e-02, 3.48849813e-02, -2.37597975e-02, 1.50269700e-02,
		   3.82078229e-03, 3.83665214e-04, -1.36746407e-02, -1.21417495e-02,
		   -1.42938828e-02, -5.91281748e-02, 5.61587414e-02, 1.02069584e+00 },
		 { -1.31346305e-02, -4.55195094e-02, 6.20262347e-02, 6.42610760e-02,
		   -6.02390383e-02, 3.76535436e-02, -3.48680132e-02, 3.48980326e-02,
		   2.15989579e-02, -9.32201352e-02, 7.11579156e-02, 4.51970113e-02,
		   -1.09573356e-01, 3.00499067e-02, -2.74708327e-02, 3.59231262e-02,
		   1.47086109e-02, -3.48723470e-02, 3.11218912e-02, -2.56826376e-02,
		   -2.05949044e-02, -6.88193712e-02, 1.84059303e-02, 1.06173528e+00 },
		 { -3.94746470e-02, -5.64461332e-02, 5.38285506e-02, 1.09575758e-01,
		   -7.93196314e-02, 8.41612824e-02, -5.82091369e-02, 3.16139308e-02,
		   2.09230352e-02, -8.62177639e-02, 8.45917696e-02, 3.66372477e-02,
		   -1.00595472e-01, -2.58428735e-03, -3.01614637e-02, 6.31998774e-02,
		   -1.34344237e-02, -2.19913575e-02, 3.74958399e-02, 1.37671860e-02,
		   -2.64367535e-04, -1.45504816e-01, 2.00233759e-02, 1.06721500e+00 },
		 { -3.38566605e-02, -8.16911834e-02, 1.68445540e-02, 1.22426641e-01,
		   -4.50552168e-02, 8.74561041e-02, -2.92471087e-02, 1.94901843e-02,
		   -1.07642738e-02, -4.63976275e-02, 4.92126480e-02, 9.12753262e-02,
		   -1.46969742e-01, -5.11619059e-03, -4.31563882e-02, 8.99971563e-02,
		   -3.31775615e-02, -1.59691426e-02, 1.02831179e-01, 1.16834405e-02,
		   -1.77917086e-02, -1.31800475e-01, -2.48910204e-02, 1.05790761e+00 },
		 { -3.50888734e-02, -8.74504680e-02, 1.32195990e-03, 4.03801937e-02,
		   -3.05155586e-02, 1.68953141e-01, 8.17518516e-03, -2.69947754e-03,
		   -5.00344933e-02, -1.05909837e-02, 5.99740502e-02, 5.52279207e-02,
		   -1.15179125e-01, -2.07360551e-02, -3.63097766e-02, 8.32472198e-02,
		   -4.95004168e-02, 2.05276620e-03, 1.91005193e-01, 3.82183139e-02,
		   -7.82224520e-02, -1.08807253e-01, -7.41351841e-02, 1.02892072e+00 },
		 { -1.59945413e-02, -8.92568810e-02, -1.43943086e-02, -2.27871564e-02,
		   -8.19588961e-02, 2.08097962e-01, 9.50886397e-02, -3.22557754e-02,
		   -3.42420574e-02, -3.57069036e-02, 9.72419194e-02, 1.21513842e-02,
		   -4.85987833e-02, -6.76227647e-02, -8.23281510e-02, 1.23258521e-01,
		   1.01169335e-02, 6.96164767e-02, 1.51595128e-01, 2.90502746e-02,
		   -7.49668665e-02, -1.15552461e-01, -4.51847339e-02, 9.32217635e-01 },
		 { -3.00937395e-02, -9.49364027e-02, 2.93094202e-02, -9.49992256e-02,
		   -1.08664487e-01, 1.57438340e-01, 1.93293555e-01, -3.99653559e-02,
		   -4.34097809e-02, 2.03819838e-02, 1.00469843e-01, -6.00074546e-02,
		   -4.68123406e-03, -9.30047465e-02, -9.56131922e-02, 1.95483085e-01,
		   7.82421398e-02, 5.98821539e-02, 1.29226586e-01, -1.84202623e-02,
		   -3.33954316e-02, -1.11990484e-01, -1.16193841e-02, 8.29938878e-01 },
		 { -1.15612301e-02, -9.11302803e-02, 1.95322345e-02, -8.62911533e-02,
		   -1.33663656e-01, 9.14657798e-02, 1.48137044e-01, 1.78735460e-02,
		   -5.24132776e-02, 8.53682057e-02, 7.98202243e-02, -7.90274639e-02,
		   2.67631115e-02, -8.70049729e-02, -7.93815361e-02, 2.60789085e-01,
		   1.27250463e-01, -4.42230576e-02, 1.11736541e-01, 9.89166458e-03,
		   -2.86746122e-02, -8.48927184e-02, -4.15267963e-02, 7.78007731e-01 },
		 { -2.93580075e-02, -7.82903898e-02, 2.10896699e-02, -7.50663174e-02,
		   -1.45858808e-01, 7.32559994e-02, 1.00743333e-01, -4.74834127e-02,
		   1.42256472e-02, 1.26048274e-01, 1.20409885e-01, -1.46965890e-01,
		   6.93464803e-02, -7.72114731e-02, -1.64124589e-02, 2.72242998e-01,
		   1.26472237e-01, -1.27414391e-01, 1.41442836e-01, 3.74609627e-03,
		   -2.11648030e-02, -6.49469287e-02, -4.05072298e-02, 7.19818557e-01 },
		 { -7.84354473e-03, -1.06462864e-01, 3.72252728e-02, -9.45750744e-02,
		   -1.47803216e-01, 8.71558094e-02, 5.44248016e-02, -8.36305511e-02,
		   7.56563014e-02, 1.15812246e-01, 1.32212157e-01, -1.35716689e-01,
		   5.90995646e-02, -6.51925676e-02, 2.50244119e-02, 3.02770288e-01,
		   8.83296127e-02, -1.47022411e-01, 1.70653598e-01, -3.53929249e-02,
		   -1.52405733e-02, -2.61683605e-02, -5.82881076e-02, 6.77844635e-01 },
		 { -1.22222212e-02, -8.88871810e-02, 2.51299179e-02, -8.42553572e-02,
		   -1.43466984e-01, 5.25883932e-02, 2.30400278e-02, -5.66153534e-02,
		   9.35961787e-02, 8.24710484e-02, 1.43329129e-01, -1.24705638e-01,
		   9.35961787e-02, 8.24710484e-02, 1.43329129e-01, -1.24705638e-01,
		   8.76916590e-02, -6.91894958e-02, 6.01044245e-02, 2.81080024e-01,
		   8.90050634e-02, -1.73215540e-01, 2.06644197e-01, -3.82332815e-02,
		   -4.36380179e-02, -1.53676952e-02, -3.32551729e-02, 6.31911226e-01 },
		 { -2.94630447e-04, -7.75754950e-02, -1.38582895e-02, -5.33296720e-02,
		   -1.44799080e-01, 2.65457484e-02, 1.35598511e-02, -3.28906879e-02,
		   8.32839532e-02, 5.98898740e-02, 1.65966376e-01, -1.26181751e-01,
		   1.26617345e-01, -9.73263812e-02, 9.96948019e-02, 2.85415247e-01,
		   5.07406431e-02, -1.43236841e-01, 1.74414390e-01, -2.56543568e-02,
		   -1.84660464e-02, -3.70232095e-02, -3.88716278e-02, 6.11207981e-01 }};

	int length = 4;
	double range = *max_element(day.begin(), day.end()) - *min_element(day.begin(), day.end());
	if (range < 2.0)
		length = 12;
	else if (range < 5.0)
		length = 8;
	else if (range < 12)
		length = 6;

	fill(answer.begin(), answer.begin() + length, 0.0);
	for (int i = 0; i < 24; ++i)
		for (int j = 0; j < length; ++j)
			answer[j] = answer[j].value() + day[i] * weights[j][i];
}

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.225857 0.232605 0.197821 0.1...
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
2.56707 2.56908 2.48013 2.3950...
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
10.2559 10.3157 10.1486 9.7812...
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
17.2945 17.2714 17.132 16.8747...
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
-4.35842 -4.31168 -4.36422 -4....
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
12.805 12.9424 12.7497 12.3498...
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
-1.685 -1.58348 -1.5668 -1.659...
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
15.0397 15.0173 14.7719 14.523...
Truncated