QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#937009 | #1292. Circuit Board Design | KimeyJ | WA | 1ms | 4224kb | C++20 | 1.7kb | 2025-03-16 04:58:51 | 2025-03-16 04:58:54 |
Judging History
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];
void dfs(int u, int signo) {
vis[u] = 1;
int cant = 0;
for(auto v : g[u]) if (!vis[v]) cant++;
double paso = 2.0/(cant+0.0);
if (signo == -1) paso = paso*(-1.0);
double dx = -1.0 * (signo+0.0);
int pari = 0;
for(auto v : g[u]) {
if (!vis[v]) {
double nX = pos[u].fst+dx;
int dire = (nX > pos[u].fst ? -1 : 1);
double nY = sqrt(1-(dx*dx))+pos[u].snd;
pos[v] = {nX,nY};
dfs(v,dire);
dx = dx + paso;
//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);
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4224kb
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 -1.00000000 0.00000000 -2.00000000 0.00000000 -3.00000000 0.00000000 -4.00000000 0.00000000 -5.00000000 0.00000000 -6.00000000 0.00000000 -7.00000000 0.00000000 -8.00000000 0.00000000 -9.00000000 0.00000000 -10.00000000 0.00000000 -11.00000000 0.00000000 -12.00000000 0.00000000...
result:
ok
Test #2:
score: 0
Accepted
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 -22.00000000 0.00000000 -713.00000000 1.00000000 -503.00000000 1.00000000 -583.00000000 1.00000000 -165.00000000 1.00000000 -283.00000000 0.00000000 -423.00000000 1.00000000 -156.00000000 0.00000000 -160.00000000 1.00000000 -243.00000000 1.00000000 -136.00000000 0.00000000 -171...
result:
ok
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 4096kb
input:
1000 1 2 1 3 2 4 2 5 3 6 3 7 4 8 4 9 5 10 5 11 6 12 6 13 7 14 7 15 8 16 8 17 9 18 9 19 10 20 10 21 11 22 11 23 12 24 12 25 13 26 13 27 14 28 14 29 15 30 15 31 16 32 16 33 17 34 17 35 18 36 18 37 19 38 19 39 20 40 20 41 21 42 21 43 22 44 22 45 23 46 23 47 24 48 24 49 25 50 25 51 26 52 26 53 27 54 27 ...
output:
0.00000000 0.00000000 -1.00000000 0.00000000 0.00000000 1.00000000 -2.00000000 0.00000000 -1.00000000 1.00000000 -1.00000000 1.00000000 0.00000000 2.00000000 -3.00000000 0.00000000 -2.00000000 1.00000000 -2.00000000 1.00000000 -1.00000000 2.00000000 -2.00000000 1.00000000 -1.00000000 2.00000000 -1.0...
result:
wrong answer Points 5 and 6 are too close: 0.000000000.