Το θέμα για την Α’ φάση του 37ου Πανελλήνιου Διαγωνισμού Πληροφορικής μπορείτε να το βρείτε εδώ.
Θα χρειαστείτε μερικά μεγάλα δοκιμαστικά αρχεία arin.in :
Δημιουργήστε δικά σας αρχεία ελέγχου με τον παρακάτω κώδικα :
//by Yannis Sitaridis Nov-2015
#include <iostream>
#include <fstream>
#include <vector>
#include<stdlib.h>
#include <time.h>
using namespace std;
int main (){
int timeSlots;
int teams;
int teamsUse;
int arr[1000000] = {};
int count[1000000] = {};
for(int i = 1; i <= timeSlots; i++){
count[i]=0;
}
cout << "Give number of timeslots"<<endl;
cin >> timeSlots;
cout << "Give number of teams"<<endl;
cin >> teams;
cout << "Give the max number of teams actually Using the computer"<<endl;
cin >> teamsUse;
if (teamsUse > teams){
cout << "Error - Invalid teams number"<<endl;
return(1);
}
srand (time(NULL));
int n = 0;
int d = teams - teamsUse;
if (d > 0){
while (n < d){
int test = rand() % teams + 1;
if (count[test]==0){
count[test]=-1;
n++;
}
}
}
ofstream outFile;
outFile.open("aris.i");
outFile << timeSlots<<" ";
outFile << teams<<endl;
for(int i = 1; i <= timeSlots; i++){
//do{
arr[i] = rand() % teams + 1;
//} while (count[arr[i]]==1);
}
for(int i = 1; i <= timeSlots; i++){
while (count[arr[i]]==-1) {
if (arr[i]<teams)
arr[i]++;
else
arr[i]--;
}
cout << arr[i] <<" ";
outFile << arr[i] <<" ";
}
cout << endl;
outFile.close();
cout << "teams not using Aris"<<endl;
for(int i = 1; i <= teams; i++){
count[i]=0;
}
for(int i = 1; i <= timeSlots; i++){
count[arr[i]]++;
}
int min=count[1];
int max=min;
for(int i = 1; i <= teams; i++){
if (count[i]==0){
cout << i << " ";
}
if (count[i]>0 && count[i]<min){
min=count[i];
}
if (count[i]>max){
max=count[i];
}
}
cout << endl;
cout << "min=" << min << " " << "max="<< max << endl;
return 0;
}