QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#937021#1292. Circuit Board DesignKimeyJWA 2ms4480kbC++201.7kb2025-03-16 05:42:072025-03-16 05:42:07

Judging History

This is the latest submission verdict.

  • [2025-03-16 05:42:07]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 4480kb
  • [2025-03-16 05:42:07]
  • 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];
const double PI = acos(-1);
int cont = 1;
int n;

void dfs(int u, int signo) {
    vis[u] = 1;
    int cant = 0;
    for(auto v : g[u]) if (!vis[v]) cant++;
    if (cant == 0) return;
    double dx = 0.0;
    double dy = 0.0;
    for(auto v : g[u]) {
        if (!vis[v]) {
            double nX = pos[u].fst+cos((cont*PI)/(n+0.0));
            int dire = (nX >= pos[u].fst ? -1 : 1);
            double nY = pos[u].fst+sin((cont*PI)/(n+0.0));
            pos[v] = {nX,nY};
            dfs(v,dire);
            cont++;
            //if (pari%2 == 0) dx = dx - paso, pari++;
            //else dx = dx * (-1.0), pari++;

        }
    }
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 4480kb

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.000000000000 0.000000000000
0.999995065202 0.003141587486
1.999990130404 1.003136652688
2.999985195606 2.003131717890
3.999980260807 3.003126783091
4.999975326009 4.003121848293
5.999970391211 5.003116913495
6.999965456413 6.003111978697
7.999960521615 7.003107043899
8.999955586817 8.003102109101
...

result:

wrong answer Length of edge 2 incorrect: nan.