#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
const ll I = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
const int II = 2 * 1000 * 1000 * 1000;
const ll M = 1000LL * 1000LL * 1000LL + 7LL;
const int N = 1000 + 7;
int tab[N][N], sp[N];
vector<vector<int>> answer;
int vis[N];
void L(int a, int b)
{
answer[a - 1][b - 1] = 1;
answer[b - 1][a - 1] = 1;
}
int construct(vector<vector<int>> xd)
{
int n = xd.size();
answer = xd;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
{
answer[i - 1][j - 1] = 0;
tab[i][j] = xd[i - 1][j - 1];
if(tab[i][j] == 3) return 0;
}
for(int i = 1; i <= n; ++i)
{
if(sp[i] == 0) sp[i] = i;
for(int j = i + 1; j <= n; ++j)
{
if(sp[i] == sp[j] && tab[i][j] != 1) return 0;
if(tab[i][j] != 1) continue;
if(tab[i][j] == 1 && sp[j] == 0)
{
L(i, j);
sp[j] = sp[i];
}
if(sp[i] != sp[j]) return 0;
}
}
cerr << "xd2\n";
for(int i = 1; i <= n; ++i)
{
for(int j = i + 1; j <= n; ++j)
{
if(sp[i] == sp[j] && tab[i][j] != 1) return 0;
if(sp[i] == sp[j]) continue;
if(tab[i][j] != tab[sp[i]][sp[j]]) return 0;
}
}
for(int i = 1; i <= n; ++i)
{
if(sp[i] != i) continue;
if(vis[i])
{
//cerr << "vis: " << i << " " << vis[i] << "\n";
for(int j = i + 1; j <= n; ++j)
if(tab[i][j] == 2 && vis[i] != vis[j] && sp[j] == j)
return 0;
continue;
}
//cerr << "cyc " << i << "\n";
vector<int> cur;
cur.pb(i);
for(int j = 1; j <= n; ++j)
{
if(tab[i][j] == 2 && vis[j]) return 0;
if(sp[j] == j && tab[i][j] == 2)
cur.pb(j);
}
/*cerr << "cur " << cur.size() << "\n";
for(int j = 0; j < (int)cur.size(); ++j)
cerr << cur[j] << " ";
cerr << "\n";*/
if(cur.size() == 1) continue;
for(int l = 0; l < (int)cur.size(); ++l)
for(int j = l + 1; j < (int)cur.size(); ++j)
if(tab[cur[l]][cur[j]] != 2) return 0;
for(int j = 1; j < (int)cur.size(); ++j)
{
L(cur[j - 1], cur[j]);
vis[cur[j]] = i;
}
L(cur.back(), cur[0]);
cerr << "end\n";
}
build(answer);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
6 ms |
3672 KB |
Output is correct |
7 |
Correct |
117 ms |
27084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
6 ms |
3672 KB |
Output is correct |
7 |
Correct |
117 ms |
27084 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
6 ms |
3420 KB |
Output is correct |
13 |
Correct |
128 ms |
27104 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
3164 KB |
Output is correct |
17 |
Correct |
62 ms |
17232 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
32 ms |
8392 KB |
Output is correct |
21 |
Correct |
125 ms |
27320 KB |
Output is correct |
22 |
Correct |
115 ms |
27472 KB |
Output is correct |
23 |
Correct |
122 ms |
27128 KB |
Output is correct |
24 |
Correct |
117 ms |
27124 KB |
Output is correct |
25 |
Correct |
62 ms |
17236 KB |
Output is correct |
26 |
Correct |
58 ms |
17232 KB |
Output is correct |
27 |
Correct |
123 ms |
27220 KB |
Output is correct |
28 |
Correct |
117 ms |
27288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 1 while actual possible 0 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
29 ms |
8620 KB |
Output is correct |
5 |
Correct |
118 ms |
27192 KB |
Output is correct |
6 |
Correct |
116 ms |
27220 KB |
Output is correct |
7 |
Correct |
126 ms |
27408 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
31 ms |
8464 KB |
Output is correct |
10 |
Correct |
119 ms |
27284 KB |
Output is correct |
11 |
Correct |
125 ms |
27076 KB |
Output is correct |
12 |
Correct |
132 ms |
27216 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
29 ms |
8580 KB |
Output is correct |
17 |
Correct |
118 ms |
27216 KB |
Output is correct |
18 |
Correct |
120 ms |
27144 KB |
Output is correct |
19 |
Correct |
124 ms |
27220 KB |
Output is correct |
20 |
Correct |
118 ms |
27124 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
6 ms |
3672 KB |
Output is correct |
7 |
Correct |
117 ms |
27084 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
6 ms |
3420 KB |
Output is correct |
13 |
Correct |
128 ms |
27104 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
3164 KB |
Output is correct |
17 |
Correct |
62 ms |
17232 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
32 ms |
8392 KB |
Output is correct |
21 |
Correct |
125 ms |
27320 KB |
Output is correct |
22 |
Correct |
115 ms |
27472 KB |
Output is correct |
23 |
Correct |
122 ms |
27128 KB |
Output is correct |
24 |
Correct |
117 ms |
27124 KB |
Output is correct |
25 |
Correct |
62 ms |
17236 KB |
Output is correct |
26 |
Correct |
58 ms |
17232 KB |
Output is correct |
27 |
Correct |
123 ms |
27220 KB |
Output is correct |
28 |
Correct |
117 ms |
27288 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
6 ms |
3672 KB |
Output is correct |
7 |
Correct |
117 ms |
27084 KB |
Output is correct |
8 |
Correct |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
6 ms |
3420 KB |
Output is correct |
13 |
Correct |
128 ms |
27104 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
3164 KB |
Output is correct |
17 |
Correct |
62 ms |
17232 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
32 ms |
8392 KB |
Output is correct |
21 |
Correct |
125 ms |
27320 KB |
Output is correct |
22 |
Correct |
115 ms |
27472 KB |
Output is correct |
23 |
Correct |
122 ms |
27128 KB |
Output is correct |
24 |
Correct |
117 ms |
27124 KB |
Output is correct |
25 |
Correct |
62 ms |
17236 KB |
Output is correct |
26 |
Correct |
58 ms |
17232 KB |
Output is correct |
27 |
Correct |
123 ms |
27220 KB |
Output is correct |
28 |
Correct |
117 ms |
27288 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |