| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1368416 | maya_s | Love Polygon (BOI18_polygon) | C++20 | 2094 ms | 16176 KiB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll SIZE = 100100;
bool info[SIZE];
ll solve(ll n, vector<ll> &edge, vector<vector<ll>> &rg){
vector<ll> e(n);
for(ll i = 1; i <= n; i++) e[i-1] = edge[i]-1;
if(n % 2) return -1;
vector<bool> bv(n);
for(ll i = n-1; i >= 0; i--){
bv[i] = 1;
sort(bv.begin(), bv.end());
do{
vector<ll> ind(n), outd(n);
ll cnt = 0;
for(ll j = 0; j < n; j++) {
if(bv[j]) cnt++;
else ind[e[j]]++, outd[j]++;
}
bool lol = 1;
for(ll j = 0; j < n; j++){
if(ind[j] + outd[j] > 1){
if(!(ind[j] + outd[j] == 2 && e[e[j]] == j && e[j] != j)) lol = 0;
}
}
if(lol) return cnt;
}
while(next_permutation(bv.begin(), bv.end()));
}
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL);
ll n, cnt = 0; cin >> n;
vector<ll> edge(n+1);
vector<vector<ll>> rg(n+1);
map<string, ll> names;
for(ll i = 0; i < n; i++){
string s, t; cin >> s >> t;
if(!names[s]) names[s] = ++cnt;
if(!names[t]) names[t] = ++cnt;
edge[names[s]] = names[t]; rg[names[t]].push_back(names[s]);
}
cout << solve(n, edge, rg);
}컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
