Pagini recente » Istoria paginii runda/321/clasament | Cod sursa (job #643983) | Cod sursa (job #2861208) | Cod sursa (job #1098553) | Cod sursa (job #3140119)
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int n, a, b, c;
struct update
{
int left, right, no;
};
vector <int> nextPos, v;
vector <update> updates;
int findNextPos(int x)
{
if(x == nextPos[x])
return x;
return nextPos[x] = findNextPos(nextPos[x]);
}
int main()
{
ios_base :: sync_with_stdio(0);
cin.tie(0);
freopen("curcubeu.in", "r", stdin);
freopen("curcubeu.out", "w", stdout);
cin >> n >> a >> b >> c;
nextPos.resize(n + 1);
v.resize(n);
for(int i = 1; i <= n; i ++)
nextPos[i] = i;
if(a < b)
updates.pb({a, b, c});
else
updates.pb({b, a, c});
for(int i = 2; i < n; i ++)
{
a = (a * i) % n;
b = (b * i) % n;
c = (c * i) % n;
if(a < b)
updates.pb({a, b, c});
else
updates.pb({b, a, c});
}
// sort(updates.begin(), updates.end(), [](const update &a, const update &b)
// {
// if(a.right == b.right)
// return a.left < b.left;
// return a.right < b.right;
// });
//
for(int i = n - 2; i >= 0; i --)
{
int pos = findNextPos(updates[i].left);
while(pos <= updates[i].right)
{
v[pos] = updates[i].no;
pos = findNextPos(pos);
nextPos[pos] = findNextPos(updates[i].right + 1);
}
}
for(int i = 1; i < n; i++)
cout << v[i] << "\n";
return 0;
}