QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#936762#1292. Circuit Board DesignKimeyJWA 0ms4096kbC++201.5kb2025-03-15 23:39:032025-03-15 23:39:14

Judging History

This is the latest submission verdict.

  • [2025-03-15 23:39:14]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 4096kb
  • [2025-03-15 23:39:03]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

#define forr(i, a, b) for(ll i = (ll) a; i < (ll) b; i++)
#define forn(i, n) forr(i, 0, n)
#define dforn(i,n) for(int i = n-1; i>=0; i--)
#define pb push_back
#define fst first
#define snd second
#define ln '\n'
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll MOD = 1e9 + 7;
const ll MAXN = 1009;
const ll INF = 9e18;

vi g[MAXN];
pair<double,double> pos[MAXN];
int vis[MAXN];

using my_clock=chrono::steady_clock;
mt19937_64 engine(my_clock::now().time_since_epoch().count());
 
double pick(){
    return uniform_real_distribution{-1.0,1.0}(engine);
}

void dfs(int u) {
    vis[u] = 1;
    double x = -1.0;
    for(auto v : g[u]) {
        if (!vis[v]) {
            double x = pick();
            pos[v].fst = x;
            double y = sqrt(1.0-(x*x));
            pos[v].snd = pos[u].snd+y;
            x = x + 0.00001;
            vis[v] = 1;
            dfs(v);
        }
    }
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    forn(_,n-1) {
        int u,v;
        cin >> u >> v;
        u--; v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    pos[0] = {0.0,0.0};
    dfs(0);
    forn(i,n) {
        cout << setprecision(7) << fixed << pos[i].fst << " " << pos[i].snd << ln;
    }
}

詳細信息

Test #1:

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

input:

1000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 53
...

output:

0.0000000 0.0000000
-0.5504987 0.8348360
0.6230000 1.6170578
-0.5229539 2.4694188
-0.7883593 3.0846339
-0.9811071 3.2780991
0.5504733 4.1129519
0.8132883 4.6948129
0.7340694 5.3738873
-0.8151999 5.9530670
-0.2458803 6.9223672
0.6612927 7.6724951
-0.8003268 8.2720591
-0.2063734 9.2505324
-0.3345042 1...

result:

wrong answer Length of edge 2 incorrect: nan.