이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <vector>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <string>
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vvii vector<vector<ii>>
#define pb push_back
#define vpi vector<ii>
#define forcin for(int i = 0; i<n; ++i) cin>>v[i];
#define pq priority_queue<ii>
#define mp make_pair
#define ld long double
#define vc vector<char>
#define vvc vector<vc>
#define vb vector<bool>
#define vvb vector<vb>
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define For(i, n, x) for (int i = x; i < n; i++)
#define rsz(a,x) assign(a,x)
#define endl "\n"
int construct(vvi p){
// Cap cami, components diferents
// tots == 1, graf lineal
// tots == 2, graf lineal amb el ultim unit al primer
int N = p.size();
vvi used(N,vi(N,0));
vpi edges;
/*For(i,N,0){
For(j,N,0) cout<<p[i][j]<<" "; cout<<endl;
}*/
For(i,N,0){
For(j,N,0){
if(used[i][j] || i == j) continue;
//cout<<p[i][j]<<" "<<j<<endl;
if(p[i][j] == 0) continue;
//cout<<i<<" "<<j<<endl;
// si tinc 1, vaig buscant 1ns sino dosos
int cur = j;
set<int> act;
edges.pb({i,j});
if(p[i][j] == 1) act.insert(i);
used[i][j] = used[j][i] = 1;
// Miro TOT EL CICLE
while(!act.count(cur)){
act.insert(j);
bool b = false;
For(k,N,0){
if(act.count(k) && cur != k){
//cout<<"HERE"<<endl;
if(p[k][cur] != p[cur][k] || p[cur][k] != p[i][j]){
//cout<<"HERE "<<cur<<" "<<k<<" "<<i<<" "<<j<<" "<<p[i][j]<<" "<<p[cur][k]<<endl;
return 0;
}
}
if(!act.count(k) && p[cur][k] == p[i][j] && !b){
act.insert(k);
b = 1;
//afegir edge
edges.pb({k,cur});
used[cur][k] = 1;
used[k][cur] = 1;
cur = k;
}
}
}
}
}
//cout<<"AAAAA"<<endl;
//cerr<<edges.size()<<endl;
vvi ans(N,vi(N,0));
for(auto x : edges) ans[x.f][x.s] = ans[x.s][x.f] = 1;
build(ans);
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |