이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int matrix[11][11];
vector<int> confs;
int globMax = 0;
int n;
int tryItOut(vector<int> v) {
for (int i = 0; i < v.size(); i++)
{
for (int j = i+1; j < v.size(); j++)
{
if (matrix[v[i]][v[j]])
{
return 0;
}
}
}
int toRet = 0;
for (int i = 0; i < v.size(); i++)
{
toRet += confs[v[i]];
}
return toRet;
}
void doStuff(int x, vector<int> v) {
if (x == n) {
globMax = max(globMax, tryItOut(v));
return;
}
v.push_back(x);
doStuff(x+1, v);
v.pop_back();
doStuff(x+1, v);
}
int sub1(int n, int confidence[], int host[], int protocol[]) {
for (int i = 1; i < n; i++)
{
if (protocol[i] == 0)
{
matrix[i][host[i]] = 1;
matrix[host[i]][i] = 1;
}
else if (protocol[i] == 1)
{
for (int j = 0; j < 11; j++)
{
if (matrix[host[i]][j] == 1)
{
matrix[i][j] = 1;
matrix[j][i] = 1;
}
}
}
else
{
for (int j = 0; j < 11; j++)
{
if (matrix[host[i]][j] == 1)
{
matrix[i][j] = 1;
matrix[j][i] = 1;
}
}
matrix[i][host[i]] = 1;
matrix[host[i]][i] = 1;
}
}
vector<int> v;
doStuff(0, v);
return globMax;
}
int findSample(int N, int confidence[], int host[], int protocol[]) {
n = N;
int confSum = 0;
int confMax = 0;
for (int i = 0; i < n; i++)
{
confs.push_back(confidence[i]);
confSum += confs[i];
confMax = max(confMax, confs[i]);
}
if (n <= 10)
{
n = N;
return sub1(n, confidence, host, protocol);
}
if (protocol[1] == 1)
{
return confSum;
}
if (protocol[1] == 2)
{
return confMax;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
friend.cpp: In function 'int tryItOut(std::vector<int>)':
friend.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | for (int i = 0; i < v.size(); i++)
| ~~^~~~~~~~~~
friend.cpp:12:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | for (int j = i+1; j < v.size(); j++)
| ~~^~~~~~~~~~
friend.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for (int i = 0; i < v.size(); i++)
| ~~^~~~~~~~~~
# | 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... |