제출 #292954

#제출 시각아이디문제언어결과실행 시간메모리
292954AaronNaidu친구 (IOI14_friend)C++14
11 / 100
41 ms2164 KiB
#include <bits/stdc++.h> #include "friend.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[0] == 1) { return confSum; } if (protocol[0] == 2) { return confMax; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

friend.cpp: In function 'int tryItOut(std::vector<int>)':
friend.cpp:11:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int i = 0; i < v.size(); i++)
      |                     ~~^~~~~~~~~~
friend.cpp:13:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         for (int j = i+1; j < v.size(); j++)
      |                           ~~^~~~~~~~~~
friend.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 0; i < v.size(); i++)
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...