Cod sursa(job #2708121)

Utilizator AACthAirinei Andrei Cristian AACth Data 18 februarie 2021 12:41:36
Problema Curcubeu Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.11 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f("curcubeu.in");
ofstream g("curcubeu.out");
const int Max = 1e6 + 1;
void nos()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
#define color first
#define time second
#define int long long
int n;
int a[Max],b[Max],c[Max];
int sol[Max];

void read()
{
    f>>n>>a[1]>>b[1]>>c[1];

}
int skip[Max];

void solve()
{
    int i;
    for(i=2; i<n; i++)
    {
        a[i] = (1LL*a[i-1] * i) % n;
        b[i] = (1LL*b[i-1] * i) % n;
        c[i] = (1LL*c[i-1] * i) % n;
    }
    for(i=n-1 ; i >= 1; i--)
    {
        int left = min(a[i],b[i]);
        int right = max(a[i],b[i]);
        int color = c[i];
        int j;
        for(j=left;j<=right;j++)
        {
            if(skip[j] == 0)
            {
                sol[j] = color;
                skip[j] = right;
            }
            else
                j = skip[j];
        }
    }
    for(i=1;i<n;i++)
        g<<sol[i]<<'\n';
}
void restart()
{

}

int32_t main()
{
    nos();

    read();
    solve();
    restart();

    return 0;
}