-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbvc.cpp
68 lines (60 loc) · 1.39 KB
/
bvc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
int n;
struct Case{
int min;
int max;
int close_to_min;
int close_to_max;
int nom;
};
vector<vector<int>> test_cases;
void value_input(int value, vector<int> output,int index){
output.insert(output.begin()+index,value);
test_cases.push_back(output);
}
int main(){
cin>>n;
struct Case boundaries[n];
for(int i=0;i<n;i++){
cin>>boundaries[i].min>>boundaries[i].max;
boundaries[i].close_to_min = boundaries[i].min+1;
boundaries[i].close_to_max = boundaries[i].max-1;
boundaries[i].nom = (boundaries[i].min+boundaries[i].max)/2;
}
for(int i=n-1;i>=0;i--){
vector<int> output;
for(int j=0;j<n;j++){
if(j==i && n>1){
continue;
}
else{
output.push_back(boundaries[j].nom);
}
}
value_input(boundaries[i].min, output, i);
value_input(boundaries[i].close_to_min, output, i);
value_input(boundaries[i].max, output, i);
value_input(boundaries[i].close_to_max, output, i);
}
int id=10000;
ofstream MyFile("bvc.csv");
for(int i=0;i<test_cases.size();i++){
MyFile<<id++<<", ";
for(int j=0;j<test_cases[i].size();j++){
if(j==test_cases[i].size()-1){
MyFile<<test_cases[i][j]<<endl;
}
else MyFile<<test_cases[i][j]<<",";
}
}
MyFile<<id++<<", ";
for(int i=0;i<n;i++){
if(i==n-1){
MyFile<<boundaries[i].nom<<endl;
}
else MyFile<<boundaries[i].nom<<",";
}
}