제출 #874078

#제출 시각아이디문제언어결과실행 시간메모리
874078WongYiKai친구 (IOI14_friend)C++17
8 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; int findSample(int n, int confidence[], int host[], int protocol[]){ int temp,temp2,test = 0,high = 0,test2 = 0; for (int i=0;i<n;i++){ temp = confidence[i]; high = max(high,temp); } for (int i=1;i<n;i++){ if (protocol[i] != 2) test = 1; if (protocol[i] != 0) test2 = 1; } if (test == 0){ return high; } if (test2 == 0){ vector<int> adjlist[n]; bool visited[n]; int col[n]; for (int i=1;i<n;i++){ visited[i] = false; adjlist[i].push_back(host[i]); adjlist[host[i]].push_back(i); } visited[0] = true; col[0] = 0; queue<int> pq; pq.push(0); int curr; int red = confidence[0],blue = 0; while (!pq.empty()){ curr = pq.front(); pq.pop(); for (int i=0;i<adjlist[curr].size();i++){ if (visited[adjlist[curr][i]] == false) { pq.push(adjlist[curr][i]); visited[adjlist[curr][i]] = true; if (col[curr] == 0) { col[adjlist[curr][i]] = 1; blue += confidence[adjlist[curr][i]]; } else if (col[curr] == 1) { col[adjlist[curr][i]] = 0; red += confidence[adjlist[curr][i]]; } } } } return max(red,blue); } }

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

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:35:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             for (int i=0;i<adjlist[curr].size();i++){
      |                          ~^~~~~~~~~~~~~~~~~~~~~
friend.cpp:5:13: warning: unused variable 'temp2' [-Wunused-variable]
    5 |    int temp,temp2,test = 0,high = 0,test2 = 0;
      |             ^~~~~
friend.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
   53 | }
      | ^
#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...