Submission #472247

# Submission time Handle Problem Language Result Execution time Memory
472247 2021-09-13T10:14:28 Z Mr_OK_Man Zamjena (COCI18_zamjena) C++17
0 / 70
20 ms 1852 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
   long long c=0,n;
   cin>>n;
   long long a[n]={},b[n]={};
   string a1[n]={},b1[n]={};
   long long as=0,a1s=0,bs=0,b1s=0;
   for(int i=0;i<n;i++)
   {
       string s;
       cin>>s;
       long long r=0;
       for(auto i:s)
       {
           if(isdigit(i))
           {break;

           }else
           {
               r=1;
               break;
           }
       }
       if(r==0)
       {
           long long q=stol(s);
a[as]=q;
as++;
       }
       else
       {
           a1[a1s]=s;
           a1s++;
       }
   }
   for(int i=0;i<n;i++)
   {
       string s;
       cin>>s;
       long long r=0;
       for(auto i:s)
       {
           if(isdigit(i))
           {
r=0;
break;
           }
           else
           {
               r=1;
               break;
           }
       }
       if(r==0)
       {
           long long q=stol(s);
b[bs]=q;
bs++;
       }
       else
       {
           b1[b1s]=s;
           b1s++;
       }
   }
   sort(a,a+as);
   sort(a1,a1+a1s);
   sort(b,b+bs);
   sort(b1,b1+b1s);
   //for(int i=0;i<a1s;i++)cout<<a1[i]<<endl;
long long k=min(as,bs);
/*long long m=max(as,bs)-k,z;
if(as>=bs)
{
    z=1;
}
else z=0;*/
//cout<<"e"<<endl;
long long l=0,r=0,m1s=0,m2s=0,ces=0,ces1=0;
//cout<<a[0]<<" "<<b[0]<<endl;
while(l<as&&r<bs)
{
//cout<<l<<" "<<r<<endl;
    if(a[l]==b[r])
    {


        l++;
        r++;
        continue;
    }

    if(a[l]<b[r])
    {
        l++;
        m1s++;
        continue;
    }
    else
    {
        r++;
        m2s++;
        continue;
    }

}

if(l==as&&r==bs)
{

}
else if(l==as)
{
    m2s+=abs(bs-l);
}
else
{
    m1s+=abs(as-r);
}
//
//
//
long long l1=0,r1=0;
while(l1<a1s&&r1<b1s)
{
    if(a1[l1]==b1[r1])
    {
        l1++;
        r1++;
        continue;
    }
    if(a1[l1]<b1[r1])
    {
        l1++;
        ces++;
    }
    else if(b1[r1]<a1[l1])
    {
        r1++;
        ces1++;
    }
}
if(l1==a1s&&r1==b1s)
{

}
else if(l1==a1s)
{
    ces1+=abs(b1s-l1);
}
else
{
    ces+=abs(a1s-r1);
}
long long h=ces1-m1s;
long long f=ces-m2s;
if(h==f)
{
    cout<<"DA";
}
else cout<<"NE";

    return 0;
}

Compilation message

zamjena.cpp: In function 'int main()':
zamjena.cpp:7:14: warning: unused variable 'c' [-Wunused-variable]
    7 |    long long c=0,n;
      |              ^
zamjena.cpp:75:11: warning: unused variable 'k' [-Wunused-variable]
   75 | long long k=min(as,bs);
      |           ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Incorrect 2 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1064 KB Output is correct
2 Incorrect 20 ms 1852 KB Output isn't correct
3 Halted 0 ms 0 KB -