# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
105236 | TuGSGeReL | 친구 (IOI14_friend) | C++14 | 36 ms | 1528 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "friend.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
int used[11], pre[3];
vector <int> edg[11];
int solve1(int n, int confidence[], int host[], int protocol[])
{
int ans = 0;
for (int i = 1; i < n; i++)
{
if ( !protocol[i] )
{
edg[i].pub(host[i]);
edg[host[i]].pub(i);
} else if ( protocol[i] == 1 )
{
for (int j = 0; j < edg[host[i]].size(); j++)
{
edg[edg[host[i]][j]].pub(i);
edg[i].pub(edg[host[i]][j]);
}
} else {
for (int j = 0; j < edg[host[i]].size(); j++)
{
edg[i].pub(edg[host[i]][j]);
edg[edg[host[i]][j]].pub(i);
}
edg[i].pub(host[i]);
edg[host[i]].pub(i);
}
}
for (int i = 0; i < (1 << n); i++)
{
memset(used, 0, sizeof used);
bool boo = 0;
int res = 0;
for (int j = 0; j < n; j++)
{
if ( i & (1 << j) )
{
for ( auto x : edg[j] )
if ( used[x] )
boo = 1;
res += confidence[j];
used[j] = 1;
}
}
if ( !boo )
ans = max(ans, res);
}
return ans;
}
int findSample(int n,int confidence[],int host[],int protocol[]){
if ( n <= 10 )
return solve1(n, confidence, host, protocol);
for (int i = 1; i < n; i++)
pre[protocol[i]]++;
if ( pre[1] == n - 1 )
{
int ans = 0;
for (int i = 0; i < n; i++)
ans += confidence[i];
return ans;
}
if ( pre[2] == n - 1 )
{
int ans = 0;
for (int i = 0; i < n; i++)
ans = max(ans, confidence[i]);
return ans;
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |