Cod sursa(job #3246508)

Utilizator teodora_lauraTeodora teodora_laura Data 3 octombrie 2024 15:10:32
Problema Curcubeu Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.32 kb
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cassert>
using namespace std;
typedef long long ll;

vector<int>parent, nr, sol;
int n, m, mx = 0;
vector<pair<int, int>>v, q;

int get_root(int nod) {
	if (parent[nod] == nod)
		return nod;
	return parent[nod]=get_root(parent[nod]);
}
void merge(int x, int y) {
	x = get_root(x);
	y = get_root(y);
	if(x!=y)
	{
		parent[y] = x;
		nr[x] += nr[y];
	}
	mx = max(mx, nr[x]);
	mx = max(mx, nr[y]);
}
void make_root(int nod) {
	assert(0 <= nod && nod <n);
	parent[nod] = nod;
	nr[nod] = 1;
	mx = max(mx, 1);
	if (nod-1>=0&&parent[nod - 1] != -1)
		merge(nod, nod - 1);
	if (nod+1<n&&parent[nod + 1] != -1)
		merge(nod, nod + 1);
}


int get_nr(int nod) {
	return nr[get_root(nod)];
}

struct interval {
	int a, b, c;
};
signed main()
{
#ifdef INFOARENA
	freopen("curcubeu.in", "r", stdin);
	freopen("curcubeu.out", "w", stdout);
#endif
	
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	sol.resize(n + 1, -1);

	for (int i = 1; i <= n - 1; i++) {
		a = (a * i) % n;
		b = (b * i) % n;
		c = (c * i) % n;
		for (int j = min(a, b); j <= max(a, b); j++)
			sol[j] = c;
	}
	for (int i = 1; i <= n - 1; i++) {
		cout << sol[i] << " ";
	}
}