QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#872286#8614. 3Ducup-team008#WA 0ms4096kbC++173.9kb2025-01-26 00:33:332025-01-26 00:33:34

Judging History

你现在查看的是最新测评结果

  • [2025-01-26 00:33:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4096kb
  • [2025-01-26 00:33:33]
  • 提交

answer

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
typedef vector<int> vi;
#define f first
#define s second
#define derr if(1) cerr

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << flush;
// END NO SAD

template<class T>
bool updmin(T& a, T b) {
  if(b < a) {
    a = b;
    return true;
  }
  return false;
}
template<class T>
bool updmax(T& a, T b) {
  if(b > a) {
    a = b;
    return true;
  }
  return false;
}
typedef int64_t ll;
mt19937 g1(0x14004);
const double MAX_SHIFT = 0.1;
const double PI = acos(-1);

int get_random_int(int a, int b) {
  return uniform_int_distribution<int>(a, b)(g1);
}
double gen_random(double p) {
  return uniform_real_distribution<double>(0, p)(g1);
}

void solve() {
  int n;
  cin >> n;
  vector<vector<double>> dist(n);
  vector<array<double, 3>> ret(n);
  auto getscore = [&]() -> double {
    double ans = 0;
    for(int i = 0; i < n; i++) for(int j = i+1; j < n; j++) {
      double x = ret[i][0] - ret[j][0];
      double y = ret[i][1] - ret[j][1];
      double z = ret[i][2] - ret[j][2];
      updmax(ans, x*x+y*y+z*z);
    }
    return ans;
  };
  for(auto& x: dist) {
    x.resize(n);
    for(auto& y: x) cin >> y;
  }
  for(auto& x: ret) for(auto& y: x) y = gen_random(1);
  int itercount = 0;
  while(true) {
    itercount++;
    double curr = getscore();
    if(curr < 0.01) break;
    int candidx = get_random_int(0, n-1);
    array<double, 3> orig = ret[candidx];
    double dist = gen_random(MAX_SHIFT);
    double theta = gen_random(2*PI);
    double phi = gen_random(PI) - (PI/2);
    ret[candidx][0] += dist * sin(phi) * cos(theta);
    ret[candidx][1] += dist * sin(phi) * sin(theta);
    ret[candidx][2] += dist * cos(phi);
    if(getscore() >= curr) ret[candidx] = orig;
  }
  cout << fixed << setprecision(39);
  for(int i = 0; i < n; i++) for(int j = 0; j < 3; j++) cout << ret[i][j] << " \n"[j == 2];
}

// what would chika do
// are there edge cases (N=1?)
// are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// integer overflow?
// DS reset properly between test cases
// are you doing geometry in floating points

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 4096kb

input:

4
0.000000 0.758400 0.557479 0.379026
0.758400 0.000000 0.516608 0.446312
0.557479 0.516608 0.000000 0.554364
0.379026 0.446312 0.554364 0.000000

output:

0.476638217213335713129396253862068988383 0.387886334417118450179629007834591902792 1.123152154160121263259952684165909886360
0.512321992361750799815922619018238037825 0.369796422642115873991031094192294403911 1.056202387813913290415257506538182497025
0.503775343333263236900165793485939502716 0.3670...

result:

wrong answer Expected distance between 0 and 1 is 0.758400, but found 0.077993