CSES - Datatähti 2024 alku - Results
Submission details
Task:Säähavainnot
Sender:vgtcross
Submission time:2023-10-30 20:33:27 +0200
Language:C++ (C++20)
Status:READY
Result:65
Feedback
groupverdictscore
#1ACCEPTED64.75
Test results
testverdicttimescore
#1ACCEPTED0.01 s8.25details
#2ACCEPTED0.01 s8.88details
#3ACCEPTED0.01 s8.38details
#4ACCEPTED0.01 s8.25details
#5ACCEPTED0.01 s7.88details
#6ACCEPTED0.01 s7.88details
#7ACCEPTED0.02 s7.5details
#8ACCEPTED0.01 s7.75details

Code

#include <bits/stdc++.h>

#define MODE 1

#if MODE
#define debug(x) cout << #x << ": " << x << endl
#define log(x) cout << x << endl
#define test(x) x
#else
#define debug(x)
#define log(x)
#define test(x)
#endif

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define X real()
#define Y imag()

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using P = complex<ll>;

const ll M = 1000000007; // 998244353

double diff[24];
int cnt[24];
double avgdiff;
int avgcnt;

const int que = 4;
const int avg = 7;

void day() {
    int n = 36;
    vector<double> v(n);
    for (auto &i : v) cin >> i;
    for (int i = 1; i < n; ++i) {
        diff[(i-1) % 24] += v[i] - v[i-1];
        ++cnt[(i-1) % 24];
    }
    avgdiff += *max_element(v.begin(), v.begin()+12) - *min_element(v.begin(), v.begin()+12);
    avgdiff += *max_element(v.begin()+24, v.begin()+36) - *min_element(v.begin()+24, v.begin()+36);
    avgcnt += 2;
}

void precalc() {
    for (int i = 0; i < 24; ++i) diff[i] /= cnt[i];
    avgdiff /= avgcnt;
    
    for (int i = 0; i < 24; ++i) cout << "diff[" << i << "] = " << diff[i] << ";\n";
    cout << "avgdiff = " << avgdiff << ";\n";
}

void init() {
    diff[0] = -0.022644;
    diff[1] = -0.163462;
    diff[2] = -0.278169;
    diff[3] = -0.376600;
    diff[4] = -0.456300;
    diff[5] = -0.506288;
    diff[6] = -0.513712;
    diff[7] = -0.448325;
    diff[8] = -0.335575;
    diff[9] = -0.261112;
    diff[10] = -0.213094;
    diff[11] = -0.181088;
    diff[12] = -0.130363;
    diff[13] = -0.051612;
    diff[14] = 0.118125;
    diff[15] = 0.338363;
    diff[16] = 0.472075;
    diff[17] = 0.569262;
    diff[18] = 0.593550;
    diff[19] = 0.547150;
    diff[20] = 0.479512;
    diff[21] = 0.400562;
    diff[22] = 0.280188;
    diff[23] = 0.144525;
    double cur = 0, minv = 0, maxv = 0;
    for (int i = 24-avg; i < 24; ++i) {
        cur += diff[i];
        minv = min(minv, cur);
        maxv = max(maxv, cur);
    }
    avgdiff = maxv - minv;
}

void solve() {
    vector<double> v(24);
    for (auto &i : v) cin >> i;
    double mul = (*max_element(v.end()-avg, v.end()) - *min_element(v.end()-avg, v.end())) / avgdiff;
    for (int i = 24; i < 36-que; ++i) {
        double nx = v[i-1] + mul * diff[(i-1) % 24];
        cout << nx << ' ';
        v.push_back(nx);
    }
    for (int i = 36-que; i < 36; ++i) cout << "? ";
    cout << '\n';
}

int main() {
    cin.tie(0) -> sync_with_stdio(0);
    
    cout << fixed << setprecision(6);
    
#if 0
    int t = 0;
    if (t == 0) cin >> t;
    while (t--) day();
    precalc();
#else
    init();
    int t = 0;
    if (t == 0) cin >> t;
    while (t--) solve();
#endif
    return 0;
}

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.243145 0.236385 0.187587 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.633558 2.628300 2.590345 2.5...
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.416399 10.366826 10.008969 ...
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.439697 17.402141 17.131037 ...
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.380152 -4.398929 -4.534481 ...
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.791757 12.761713 12.544830 ...
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.761649 -1.767657 -1.811034 ...
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.182169 15.153627 14.947588 ...
Truncated