Submission #491601

#TimeUsernameProblemLanguageResultExecution timeMemory
491601n3rm1nTable Tennis (info1cup20_tabletennis)C++17
11 / 100
17 ms2136 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN=150505; void speed() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } int n,k; long long a[MAXN]; void read() { cin>>n>>k; for(int i=1;i<=n+k;i++) cin>>a[i]; } bool check(int idx) { int i=1,j=n+k; if(i==idx)i++; if(j==idx)j--; long long sum=a[i]+a[j]; i++; j--; while(i<j) { if(i==idx)i++; if(j==idx)j--; if(a[i]+a[j]!=sum)return false; i++; j--; } return true; } void solve_st1() { for(int i=1;i<=n+k;i++) { if(check(i)==true) { for(int j=1;j<i;j++) cout<<a[j]<<" "; for(int j=i+1;j<=n+k;j++) cout<<a[j]<<" "; cout<<endl; } } } bool used[MAXN]; bool found=false; void check() { vector<long long>v; for(int i=1;i<=n+k;i++) { if(used[i]==1)v.push_back(a[i]); } int i=0; int j=v.size()-1; long long sum=a[i]+a[j]; i++; j--; while(i<=j) { if(sum!=a[i]+a[j])return; i++; j--; } for(int i=0;i<v.size();i++) { cout<<v[i]<<" "; } cout<<endl; found=true; } void gen(int pos,int cntused) { if(pos>n+k) { if(cntused==n&&found==false)check(); return; } used[pos]=1; gen(pos+1,cntused+1); used[pos]=0; gen(pos+1,cntused); } int main() { speed(); read(); if(k==1&&n<=2000) { solve_st1(); return 0; } if(n+k<=18) { gen(1,0); return 0; } return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'void check()':
tabletennis.cpp:71:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |     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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...