ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1880. Psych Up's Eigenvalues

Wrong on test 1 ????????
Posted by DanGeros 22 May 2020 16:09
#include <iostream>
using namespace std;
int v[4001],w[4001],q[4001];
    int se_gaseste (int val , int inceput , int sfarsit,int v[4001]) {
        int mijloc=(inceput+sfarsit)/2;
        if (v[mijloc]==val) return 1;
        if (inceput >= sfarsit) return 0;
        if (val>v[mijloc]) se_gaseste(val,mijloc+1,sfarsit,v);
            else se_gaseste(val,inceput,mijloc-1,v);

    }
int main()
{
    int n,m,t,nr=0;
    cin>>n;
    for (int i=1;i<=n;i++)
        cin>>v[i];
    cin>>m;
    for (int i=1;i<=m;i++)
        cin>>w[i];
    cin>>t;
    for (int i=1;i<=t;i++)
        cin>>q[i];
    for (int i=1;i<=n;i++) {
        if ( se_gaseste(v[i],1,m,w) && se_gaseste(v[i],1,t,q)) nr++;
    }
    cout<<nr;
    return 0;
}



i tested this algorithm on many exemples and all works how i can't pass the first test, please help , thx.
A little explication : i take every number from first vector and i check if exist in last both vectors . i use binary search

Edited by author 22.05.2020 16:12