Submission #138318

#TimeUsernameProblemLanguageResultExecution timeMemory
138318NucleistFriend (IOI14_friend)C++14
0 / 100
3 ms504 KiB
#include <bits/stdc++.h> #include "friend.h" using namespace std; #define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define debug(x) cerr << " - " << #x << ": " << x << endl; #define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl; #define all(x) (x).begin(),(x).end() #define sz(x) (int)x.size() #define ll long long #define INF 1000000000 #define pb push_back struct greateri { template<class T> bool operator()(T const &a, T const &b) const { return a > b; } }; int weight[12]; bool visited[12]; vector<int>adj[12]; int dal; int solve(int node) { if(node>=dal){/*debug(-1);*/return 0;} int ans = 0; ans = max(ans,solve(node+1)); if(!visited[node]) { visited[node]=1; for (int i = 0; i < adj[node].size(); ++i) { int next = adj[node][i]; visited[next]=1; } //debug(node); ans=max(ans,solve(node+1)+weight[node]); for (int i = 0; i < adj[node].size(); ++i) { int next = adj[node][i]; visited[next]=0; } visited[node]=0; } return ans; } int findSample(int n,int confidence[],int host[],int protocol[]) { dal = n; for (int i = 0; i < n; ++i) { weight[i]=confidence[i]; } for (int i = 1; i < dal; ++i) { int now = host[i]; int prot = protocol[i]; int newi = i; if(prot==0 || prot==2) { adj[now].pb(newi); adj[newi].pb(now); } if(prot==1 || prot==2) { //debugs(newi,now); int vol = adj[now].size(); for (int j = 0; j < adj[now].size(); ++j) { int neigh = adj[now][j]; //debug(neigh); adj[neigh].pb(newi); adj[newi].pb(neigh); } } } return solve(0); } //code the AC sol ! // BS/queue/map

Compilation message (stderr)

friend.cpp: In function 'int solve(int)':
friend.cpp:29:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < adj[node].size(); ++i)
                   ~~^~~~~~~~~~~~~~~~~~
friend.cpp:36:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < adj[node].size(); ++i)
                   ~~^~~~~~~~~~~~~~~~~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:66:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int j = 0; j < adj[now].size(); ++j)
                     ~~^~~~~~~~~~~~~~~~~
friend.cpp:65:9: warning: unused variable 'vol' [-Wunused-variable]
     int vol = adj[now].size();
         ^~~
#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...