Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 8 additions & 51 deletions algorithmic/problems/61/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,61 +31,18 @@ int main(int argc, char * argv[]) {
// Read reference answer
long long ref_score = ans.readLong();

// Read participant's answer
int d = ouf.readInt(1, n, format("d for test case %d", tc));
/** Changing to one line for test case */
long long participant_score = ouf.readLong();

vector<pair<int,int>> segments;
for (int i = 0; i < d; i++) {
int l = ouf.readInt(1, n, format("l for segment %d in test case %d", i+1, tc));
int r = ouf.readInt(l, n, format("r for segment %d in test case %d", i+1, tc));
segments.push_back({l, r});
if (participant_score != ref_score) {
quitf(_wa, "Test case %d: answer %lld does not match reference %lld",
tc, participant_score, ref_score);
}

// Validate segments
vector<bool> covered(n + 1, false);
for (auto [l, r] : segments) {
for (int day = l; day <= r; day++) {
if (covered[day]) {
quitf(_wa, "Day %d is covered multiple times in test case %d", day, tc);
}
covered[day] = true;
}
}

for (int day = 1; day <= n; day++) {
if (!covered[day]) {
quitf(_wa, "Day %d is not covered in test case %d", day, tc);
}
}

// Check chronological order
for (int i = 0; i + 1 < d; i++) {
if (segments[i].second >= segments[i+1].first) {
quitf(_wa, "Segments are not in chronological order in test case %d", tc);
}
}

// Calculate participant's score
long long total_ranks = 0;
for (auto [l, r] : segments) {
long long exp = a[r] - a[l-1];
int rank = 0;
for (int k = 1; k <= m; k++) {
if (exp >= b[k]) rank = k;
else break;
}
total_ranks += rank;
}

long long participant_score = total_ranks - c * d;

if (participant_score < ref_score) {
quitf(_wa, "Test case %d: score %lld is less than reference %lld",
tc, participant_score, ref_score);
}
/** particpant score and ref score are equal */

double ratio = min(1.0, (double)participant_score / ref_score * 0.8);
double unbounded_ratio = (double)participant_score / ref_score * 0.8;
double ratio = 0.8; // min(1.0, (double)participant_score / ref_score * 0.8);
double unbounded_ratio = 0.8; // (double)participant_score / ref_score * 0.8;

total_ratio += ratio;
total_unbounded_ratio += unbounded_ratio;
Expand Down