Submission #926988

#TimeUsernameProblemLanguageResultExecution timeMemory
926988blacktulipTable Tennis (info1cup20_tabletennis)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ort ((bas+son)/2) #define int long long #define endl "\n" int n,k,a[150005],index; inline bool check(int l,int r,int sum){ int say=0; while(l<r){ if(a[l]+a[r]==sum){ l++; r--; say++; } else if(a[l]+a[r]<sum){ index=l; l++; } else{ index=r; r--; } } if(say==n/2)return 1; return 0; } int32_t main(void){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin>>n>>k; for(int i=1;i<=n;i++)cin>>a[i]; if(check(1,n,a[1]+a[n])){ for(int i=1;i<index;i++)cout<<i<<" "; for(int i=index+1;i<=n;i++)cout<<i<<" "; return 0; } if(check(1,n-1,a[1]+a[n-1])){ for(int i=1;i<n;i++)cout<<i<<" "; return 0; } if(check(2,n,a[2]+a[n])){ for(int i=2;i<=n;i++)cout<<i<<" "; return 0; } return 0; }

Compilation message (stderr)

tabletennis.cpp:9:19: error: 'long long int index' redeclared as different kind of entity
    9 | int n,k,a[150005],index;
      |                   ^~~~~
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from tabletennis.cpp:1:
/usr/include/strings.h:61:1: note: previous declaration 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
tabletennis.cpp: In function 'bool check(long long int, long long int, long long int)':
tabletennis.cpp:20:10: error: overloaded function with no contextual type information
   20 |    index=l;
      |          ^
tabletennis.cpp:24:10: error: overloaded function with no contextual type information
   24 |    index=r;
      |          ^
tabletennis.cpp: In function 'int32_t main()':
tabletennis.cpp:37:16: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator<'
   37 |   for(int i=1;i<index;i++)cout<<i<<" ";
      |               ~^~~~~~
tabletennis.cpp:38:18: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+'
   38 |   for(int i=index+1;i<=n;i++)cout<<i<<" ";
      |             ~~~~~^~