Nu aveti permisiuni pentru a descarca fisierul grader_test3.ok
Cod sursa(job #518528)
| Utilizator | Data | 1 ianuarie 2011 17:13:01 | |
|---|---|---|---|
| Problema | Congr | Scor | 80 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.7 kb |
#include <stdio.h>
#include <algorithm>
#include <time.h>
#include <stdlib.h>
using namespace std;
#define NMAX 600010
int V[NMAX], ind[NMAX];
int n, S;
inline int modulo(int x){
if(x > n) return x-n;
if(x < 0) return x+n;
return x;
}
int main(){
freopen("congr.in", "r", stdin);
freopen("congr.out", "w", stdout);
scanf("%d", &n);
srand(time(NULL));
for(int i = 1; i < 2*n; ++i){
scanf("%d", &V[i]);
V[i] %= n;
ind[i] = i;
if(i <= n) S = (S+V[i])%n;
}
while(S){
int p1 = 1 + rand()%n;
int p2 = n + 1 + rand()%(n-1);
S = modulo(S - V[ind[p1]] + V[ind[p2]]);
swap(ind[p1], ind[p2]);
}
for(int i = 1; i <= n; ++i)
printf("%d ", ind[i]);
return 0;
}
