Skip to content

Instantly share code, notes, and snippets.

@E869120
Last active February 25, 2024 03:33
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 E869120/172754b158c84148bbc97f6f494f048e to your computer and use it in GitHub Desktop.
Save E869120/172754b158c84148bbc97f6f494f048e to your computer and use it in GitHub Desktop.
// [テスターの仕様]
// - 入力として「テストケースの入力 → あなたの出力」の順に受け取る.
// - 出力が valid かどうか (valid でない場合はその原因),および得点を出力する.
// - X+1 行出力されない場合の挙動は未定義なので注意すること.
// - 余分な出力があるかどうかはチェックされない.(実際の提出でも,余分な出力はチェックされない)
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
long long N, A[59], B[59];
long long X, U[59], V[59];
void WrongAnswer(string str) {
cout << "Wrong Answer (" << str << ")" << endl;
exit(0);
}
int main() {
// Step 1. テストケースの入力を受け取る
cin >> N;
for (int i = 1; i <= N; i++) cin >> A[i] >> B[i];
// Step 2. あなたの出力を受け取る
cin >> X;
if (X < 0 || X > 50) WrongAnswer("X is out of range");
for (int i = 1; i <= X; i++) {
cin >> U[i] >> V[i];
if (U[i] == V[i]) WrongAnswer("U[i] and V[i] is same");
if (U[i] < 1 || U[i] > N) WrongAnswer("U[i] is out of range");
if (V[i] < 1 || V[i] > N) WrongAnswer("V[i] is out of range");
}
// Step 3. シミュレーションを行う
for (int i = 1; i <= X; i++) {
long long avgA = (A[U[i]] + A[V[i]]) / 2LL;
long long avgB = (B[U[i]] + B[V[i]]) / 2LL;
A[U[i]] = avgA;
A[V[i]] = avgA;
B[U[i]] = avgB;
B[V[i]] = avgB;
}
// Step 4. 出力
long long ErrorA = abs(500000000000000000LL - A[1]);
long long ErrorB = abs(500000000000000000LL - B[1]);
long long Score = (max(ErrorA, ErrorB) == 0LL ? 2000050LL - X : (long long)(2000000.0L - 100000.0L * log10(1.0L * max(ErrorA, ErrorB) + 1.0L)));
cout << "Accepted!" << endl;
cout << "Error of A[1] = " << ErrorA << endl;
cout << "Error of B[1] = " << ErrorB << endl;
cout << "Score = " << Score << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment