QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#937016#1292. Circuit Board DesignKimeyJWA 1ms4352kbC++202.2kb2025-03-16 05:15:392025-03-16 05:15:40

Judging History

This is the latest submission verdict.

  • [2025-03-16 05:15:40]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 4352kb
  • [2025-03-16 05:15:39]
  • 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 dforr(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#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;
const ld EPS = 1e-9;

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,0.0}(engine);
}

void dfs(int u, int signo) {
    vis[u] = 1;
    int cant = 0;
    for(auto v : g[u]) if (!vis[v]) cant++;
    double paso = 0.002;
    if (signo == -1) paso = paso*(-1.0);
    double dx = pick() * (signo*1.0);
    //cout << u+1 << " " << dx << ln;
    int pari = 0; 
    for(auto v : g[u]) {
        if (!vis[v]) {
            //cout << "u= " << u+1 << " v= " << v+1 << ln;
            //cout << "xu= " << pos[u].fst << " yu= " << pos[u].snd << " dx= " << dx << ln;
            double nX = pos[u].fst+dx;
            int dire = (nX > pos[u].fst ? -1 : 1);
            double nY = sqrt(1.0-(dx*dx))+pos[u].snd;
            //cout << "nx= " << nX << " ny= " << nY << ln; 
            pos[v] = {nX,nY};
            dfs(v,dire);
            dx = dx + paso;
            //if (pari%2 == 0) dx = dx - paso, pari++;
            //else dx = dx * (-1.0), pari++;
            if (dx < -1.0) dx = 1.0;
            else if (dx > 1.0) dx = -1.0;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt","r",stdin);
    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,1);
    forn(i,n) cout << setprecision(8) << fixed << pos[i].fst << " " << pos[i].snd << ln;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4352kb

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.00000000 0.00000000
-0.74006447 0.67253593
-1.60696084 1.17102434
-1.90466889 2.12568130
-2.36472197 3.01357271
-2.72364936 3.94693820
-3.25692792 4.79287790
-4.10071276 5.32955951
-4.47614955 6.25640751
-5.14539407 6.99944975
-5.89846860 7.65738497
-6.15749335 8.62325565
-6.44968087 9.57961670
-6...

result:

ok 

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 4224kb

input:

1000
65 761
553 278
364 774
438 818
222 364
880 271
926 557
121 179
725 62
181 676
986 285
910 186
607 389
66 15
874 248
51 113
443 68
64 312
227 216
539 518
749 678
836 886
948 84
292 829
777 448
392 570
639 953
211 327
561 938
480 441
727 83
958 773
714 804
675 488
848 981
728 808
440 444
398 752
...

output:

0.00000000 0.00000000
-10.24645528 18.11485451
-361.63149537 557.73443182
-257.46641593 394.08677133
-297.90460382 456.27754160
-84.12933864 130.10189892
-141.13543807 224.24606873
-215.03434605 332.37505654
-81.59279386 121.03360433
-81.09269874 126.71972330
-121.35239586 192.94108833
-72.45465656 ...

result:

wrong answer Edges 730-990 and 470-948 are too close: 0.000000000.