Submission #1113536

#TimeUsernameProblemLanguageResultExecution timeMemory
1113536EfeBabagilNaval battle (CEOI24_battle)C++14
Compilation error
0 ms0 KiB
using namespace std;
#include <bits/stdc++.h>
#define int long long
int srt(array<int,3> a, array<int,3> b)
{
    return a[1] < b[1];  
}
int srt2(array<int,3> a,array<int,3> b)
{
    return a[1] + a[0]< b[0] + b[1];  
}
int32_t main()
{    cin>>t;

    int t;
    vector<array<int,3>> n,e,w,s;
    vector<int> ans;
    for(int i=0;i<t;i++)
    {
        int a,b;
        char c;
        
        cin>>a>>b>>c;
        if(c=='N')
        {
            n.push_back({a,b,1+i});
        }
        }
        if(c=='W')
        {
        if(c=='E')
        {
            e.push_back({a,b,1+i});
            w.push_back({a,b,1+i});
        }
        if(c=='S')
        {
            s.push_back({a,b,1+i});
        }
    }
    sort(e.begin(),e.end());
    sort(s.begin(),s.end(),srt);
 
    sort(e.begin(),e.end(),srt2);
    sort(s.begin(),s.end(),srt2);
    
    /*for(int i=0;i<e.size();i++)
    {
        cout<<e[i][0]<<" "<<e[i][1]<<endl;
    }
    cout<<endl<<endl;
    for(int i=0;i<s.size();i++)
    {
        cout<<s[i][0]<<" "<<s[i][1]<<endl;
    }*/
    int i=0;
    int j=0;
    while(i<e.size()&&j<s.size())
    {
        if(s[i][0]<=e[i][0])
        {
            i++;
        }
        else if(e[i][0]+e[i][1]==s[j][0]+s[j][1])
        {
            
            ans.push_back(e[i][2]);
            ans.push_back(s[j][2]);
            i++;
            j++;
        }
        else if(e[i][0]+e[i][1]<s[j][0]+s[j][1])
        {
            i++;
        }
        else if(e[i][0]+e[i][1]>s[i][0]+s[i][1])
        {
            j++;
        }
    }
    ans.push_back(0);
    sort(ans.begin(),ans.end());
    
    for(int i=0;i<t;i++)
    {
       /* int l=0,r=ans.size()-1;
        int flag=0;
        while(l+1<r)
        {
            int mid=(r+l)/2;
            if(ans[mid]==i+1)
            flag=1;
            else if(ans[mid]>i+1)
            r=mid;
            else
            l=mid;
            
        }*/
        auto it=lower_bound(ans.begin(),ans.end(),i+1);
        if(it==ans.end()||*it!=1+i)
        cout<<i+1<<" ";
    }
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:13:11: error: 't' was not declared in this scope; did you mean 'tm'?
   13 | {    cin>>t;
      |           ^
      |           tm
Main.cpp:29:12: error: 'c' was not declared in this scope
   29 |         if(c=='W')
      |            ^
Main.cpp:33:26: error: 'a' was not declared in this scope
   33 |             e.push_back({a,b,1+i});
      |                          ^
Main.cpp:33:28: error: 'b' was not declared in this scope
   33 |             e.push_back({a,b,1+i});
      |                            ^
Main.cpp:33:32: error: 'i' was not declared in this scope
   33 |             e.push_back({a,b,1+i});
      |                                ^
Main.cpp:33:34: error: no matching function for call to 'std::vector<std::array<long long int, 3> >::push_back(<brace-enclosed initializer list>)'
   33 |             e.push_back({a,b,1+i});
      |                                  ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::array<long long int, 3>; _Alloc = std::allocator<std::array<long long int, 3> >; std::vector<_Tp, _Alloc>::value_type = std::array<long long int, 3>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::array<long long int, 3>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::array<long long int, 3>; _Alloc = std::allocator<std::array<long long int, 3> >; std::vector<_Tp, _Alloc>::value_type = std::array<long long int, 3>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::array<long long int, 3> >::value_type&&' {aka 'std::array<long long int, 3>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
Main.cpp:34:34: error: no matching function for call to 'std::vector<std::array<long long int, 3> >::push_back(<brace-enclosed initializer list>)'
   34 |             w.push_back({a,b,1+i});
      |                                  ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::array<long long int, 3>; _Alloc = std::allocator<std::array<long long int, 3> >; std::vector<_Tp, _Alloc>::value_type = std::array<long long int, 3>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::array<long long int, 3>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::array<long long int, 3>; _Alloc = std::allocator<std::array<long long int, 3> >; std::vector<_Tp, _Alloc>::value_type = std::array<long long int, 3>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::array<long long int, 3> >::value_type&&' {aka 'std::array<long long int, 3>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
Main.cpp:38:26: error: 'a' was not declared in this scope
   38 |             s.push_back({a,b,1+i});
      |                          ^
Main.cpp:38:28: error: 'b' was not declared in this scope
   38 |             s.push_back({a,b,1+i});
      |                            ^
Main.cpp:38:32: error: 'i' was not declared in this scope
   38 |             s.push_back({a,b,1+i});
      |                                ^
Main.cpp:38:34: error: no matching function for call to 'std::vector<std::array<long long int, 3> >::push_back(<brace-enclosed initializer list>)'
   38 |             s.push_back({a,b,1+i});
      |                                  ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::array<long long int, 3>; _Alloc = std::allocator<std::array<long long int, 3> >; std::vector<_Tp, _Alloc>::value_type = std::array<long long int, 3>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::array<long long int, 3>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::array<long long int, 3>; _Alloc = std::allocator<std::array<long long int, 3> >; std::vector<_Tp, _Alloc>::value_type = std::array<long long int, 3>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::array<long long int, 3> >::value_type&&' {aka 'std::array<long long int, 3>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
Main.cpp:58:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     while(i<e.size()&&j<s.size())
      |           ~^~~~~~~~~
Main.cpp:58:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     while(i<e.size()&&j<s.size())
      |                       ~^~~~~~~~~