Submission #874009

#TimeUsernameProblemLanguageResultExecution timeMemory
874009teacupFriend (IOI14_friend)C++14
0 / 100
1 ms604 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; int findSample(int n, int confidence[], int host[], int protocol[]){ int t1=confidence[0], t2=0; int S[]={}; S[0]=1; for (int i=1; i<n; i++){ if (protocol[i]==0){ S[i]=3-S[host[i]]; }else if (protocol[i]==1){ S[i]=S[host[i]]; }else{ //clown } if (S[i]==1){ t1+=confidence[i]; }else if (S[i]==2){ t2+=confidence[i]; } } return max(t1,t2); }

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:11:18: warning: array subscript <unknown> is outside array bounds of 'int [0]' [-Warray-bounds]
   11 |    S[i]=S[host[i]];
      |         ~~~~~~~~~^
friend.cpp:6:9: note: while referencing 'S'
    6 |     int S[]={}; S[0]=1;
      |         ^
friend.cpp:11:7: warning: array subscript i is outside array bounds of 'int [0]' [-Warray-bounds]
   11 |    S[i]=S[host[i]];
      |    ~~~^
friend.cpp:6:9: note: while referencing 'S'
    6 |     int S[]={}; S[0]=1;
      |         ^
friend.cpp:9:20: warning: array subscript <unknown> is outside array bounds of 'int [0]' [-Warray-bounds]
    9 |    S[i]=3-S[host[i]];
      |           ~~~~~~~~~^
friend.cpp:6:9: note: while referencing 'S'
    6 |     int S[]={}; S[0]=1;
      |         ^
friend.cpp:9:7: warning: array subscript i is outside array bounds of 'int [0]' [-Warray-bounds]
    9 |    S[i]=3-S[host[i]];
      |    ~~~^
friend.cpp:6:9: note: while referencing 'S'
    6 |     int S[]={}; S[0]=1;
      |         ^
friend.cpp:16:10: warning: array subscript i is outside array bounds of 'int [0]' [-Warray-bounds]
   16 |   if (S[i]==1){
      |       ~~~^
friend.cpp:6:9: note: while referencing 'S'
    6 |     int S[]={}; S[0]=1;
      |         ^
#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...