Skip to content

Instantly share code, notes, and snippets.

@dulimarta
Created November 17, 2015 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dulimarta/e9a5a234f11c377df4dc to your computer and use it in GitHub Desktop.
Save dulimarta/e9a5a234f11c377df4dc to your computer and use it in GitHub Desktop.
CS263 HW07 Sample Files
//
// Created by Hans Dulimarta
//
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
#ifndef ONLINE_JUDGE
const string test_data = "1\n"
"9 2\n"
"1 100 2 1 2\n"
"2 80 2 2 1\n"
"1 90 1 1\n"
"2 40 1 2\n"
"2 50 1 1\n"
"1 60 1 2\n"
"2 75 1 1\n"
"1 95 1 1\n"
"2 30 1 2\n"
"1 3\n"
"2 4";
#endif
struct StudentData {
int region, score;
vector<int> selections;
};
int numStudents, numFDUs;
vector<StudentData> testParticipants;
void readData(istream &input) {
input >> numStudents >> numFDUs;
/* read the data of all the students */
for (int n = 0; n < numStudents; n++) {
StudentData sdata;
int numSelections, selection;
input >> sdata.region >> sdata.score >> numSelections;
for (int s = 0; s < numSelections; s++) {
input >> selection;
sdata.selections.push_back(selection);
}
testParticipants.push_back(sdata);
#ifndef ONLINE_JUDGE
cout << "Student #" << (n + 1) << " from regions "
<< sdata.region << " earned " << sdata.score
<< " points, applying to: ";
for (auto dep : sdata.selections)
cout << dep << " ";
cout << endl;
#endif
}
/* read the data of all the FDUs */
for (int n = 0; n < numFDUs; n++) {
int region, capacity;
input >> region >> capacity;
#ifndef ONLINE_JUDGE
cout << "FDU #" << (n + 1) << " in region " << region
<< " with capacity " << capacity << " students" << endl;
#endif
}
}
void solveIt() {
/* TODO Write your code for solving the problem here */
}
int main() {
#ifndef ONLINE_JUDGE
istringstream data (test_data);
#else
istream& data = cin;
#endif
int testCases;
data >> testCases;
for (int k = 0; k < testCases; k++) {
/* execute one test case */
readData(data);
solveIt();
}
return 0;
}
//
// Created by Hans Dulimarta
//
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
#ifndef ONLINE_JUDGE
const string test_data = "1\n"
"9 2\n"
"1 100 2 1 2\n"
"2 80 2 2 1\n"
"1 90 1 1\n"
"2 40 1 2\n"
"2 50 1 1\n"
"1 60 1 2\n"
"2 75 1 1\n"
"1 95 1 1\n"
"2 30 1 2\n"
"1 3\n"
"2 4";
#endif
struct StudentData {
int region, score;
vector<int> selections;
};
class UnivEntraceExam {
private:
int numStudents, numFDUs;
vector<StudentData> testParticipants;
public:
void readData(istream& input) {
input >> numStudents >> numFDUs;
/* read the data of all the students */
for (int n = 0; n < numStudents; n++) {
StudentData sdata;
int numSelections, selection;
input >> sdata.region >> sdata.score >> numSelections;
for (int s = 0; s < numSelections; s++) {
input >> selection;
sdata.selections.push_back(selection);
}
testParticipants.push_back(sdata);
#ifndef ONLINE_JUDGE
cout << "Student #" << (n + 1) << " from regions "
<< sdata.region << " earned " << sdata.score
<< " points, applying to: ";
for (auto dep : sdata.selections)
cout << dep << " ";
cout << endl;
#endif
}
/* read the data of all the FDUs */
for (int n = 0; n < numFDUs; n++) {
int region, capacity;
input >> region >> capacity;
#ifndef ONLINE_JUDGE
cout << "FDU #" << (n+1) << " in region " << region
<< " with capacity " << capacity << " students" << endl;
#endif
}
}
void solveIt() {
/* TODO Write your code for solving the problem here */
}
};
int main() {
UnivEntraceExam exam;
#ifndef ONLINE_JUDGE
istringstream data (test_data);
#else
istream& data = cin;
#endif
int testCases;
data >> testCases;
for (int k = 0; k < testCases; k++) {
/* execute one test case */
exam.readData(data);
exam.solveIt();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment