Submission #464495

# Submission time Handle Problem Language Result Execution time Memory
464495 2021-08-13T10:09:43 Z Itamar XORanges (eJOI19_xoranges) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <algorithm>
#include <vector>

vector<int> odd;
vector<int> eve;
vector<int> val;
int n, q;

void fun() {
    int xo = 0;
    for (int i = 0; i < n; i += 2) {
        xo = xo ^ val[i];
        eve[i] = xo;
    }
    xo = 0;
    for (int i = 1; i < n; i += 2) {
        xo = xo ^ val[i];
        odd[i] = xo;
    }
}

int main()
{

    cin >> n;
    cin >> q;
    odd.resize(n);
    eve.resize(n);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        val.push_back(x);

    }

    fun();
    for (int i = 0; i < q; i++) {
        int a, b, c;
        cin >> a;
        cin >> b;
        cin >> c;
        if (a == 1) {
            val[b - 1] = c;
            fun();
        }
        else {
            if ((b - c-1) % 2 == 0) {
                cout << 0 << endl;
            }
            else {
                if (b == 1) {
                    cout << eve[(c - 1) ] << endl;
                }
                else if
                    ((b - 1) % 2 == 0) {
                    int x = (eve[(b - 3)]) ^ (eve[(c - 1)]);
                    cout << x << endl;
                }
                else if (b == 2) {
                    
                    cout << odd[(c - 1)] << endl;
                } else{
                    int x = odd[(b - 3)] ^ odd[(c-1)];
                    cout << x << endl;
                }
            }
        }

    }
}

Compilation message

xoranges.cpp:5:1: error: 'vector' does not name a type
    5 | vector<int> odd;
      | ^~~~~~
xoranges.cpp:6:1: error: 'vector' does not name a type
    6 | vector<int> eve;
      | ^~~~~~
xoranges.cpp:7:1: error: 'vector' does not name a type
    7 | vector<int> val;
      | ^~~~~~
xoranges.cpp: In function 'void fun()':
xoranges.cpp:13:19: error: 'val' was not declared in this scope
   13 |         xo = xo ^ val[i];
      |                   ^~~
xoranges.cpp:14:9: error: 'eve' was not declared in this scope
   14 |         eve[i] = xo;
      |         ^~~
xoranges.cpp:18:19: error: 'val' was not declared in this scope
   18 |         xo = xo ^ val[i];
      |                   ^~~
xoranges.cpp:19:9: error: 'odd' was not declared in this scope
   19 |         odd[i] = xo;
      |         ^~~
xoranges.cpp: In function 'int main()':
xoranges.cpp:26:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   26 |     cin >> n;
      |     ^~~
      |     std::cin
In file included from xoranges.cpp:1:
/usr/include/c++/10/iostream:60:18: note: 'std::cin' declared here
   60 |   extern istream cin;  /// Linked to standard input
      |                  ^~~
xoranges.cpp:28:5: error: 'odd' was not declared in this scope
   28 |     odd.resize(n);
      |     ^~~
xoranges.cpp:29:5: error: 'eve' was not declared in this scope
   29 |     eve.resize(n);
      |     ^~~
xoranges.cpp:33:9: error: 'val' was not declared in this scope
   33 |         val.push_back(x);
      |         ^~~
xoranges.cpp:44:13: error: 'val' was not declared in this scope
   44 |             val[b - 1] = c;
      |             ^~~
xoranges.cpp:49:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   49 |                 cout << 0 << endl;
      |                 ^~~~
      |                 std::cout
In file included from xoranges.cpp:1:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
xoranges.cpp:49:30: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   49 |                 cout << 0 << endl;
      |                              ^~~~
      |                              std::endl
In file included from /usr/include/c++/10/iostream:39,
                 from xoranges.cpp:1:
/usr/include/c++/10/ostream:681:5: note: 'std::endl' declared here
  681 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
xoranges.cpp:53:21: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   53 |                     cout << eve[(c - 1) ] << endl;
      |                     ^~~~
      |                     std::cout
In file included from xoranges.cpp:1:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
xoranges.cpp:53:46: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   53 |                     cout << eve[(c - 1) ] << endl;
      |                                              ^~~~
      |                                              std::endl
In file included from /usr/include/c++/10/iostream:39,
                 from xoranges.cpp:1:
/usr/include/c++/10/ostream:681:5: note: 'std::endl' declared here
  681 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
xoranges.cpp:58:21: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   58 |                     cout << x << endl;
      |                     ^~~~
      |                     std::cout
In file included from xoranges.cpp:1:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
xoranges.cpp:58:34: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   58 |                     cout << x << endl;
      |                                  ^~~~
      |                                  std::endl
In file included from /usr/include/c++/10/iostream:39,
                 from xoranges.cpp:1:
/usr/include/c++/10/ostream:681:5: note: 'std::endl' declared here
  681 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
xoranges.cpp:62:21: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   62 |                     cout << odd[(c - 1)] << endl;
      |                     ^~~~
      |                     std::cout
In file included from xoranges.cpp:1:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
xoranges.cpp:62:45: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   62 |                     cout << odd[(c - 1)] << endl;
      |                                             ^~~~
      |                                             std::endl
In file included from /usr/include/c++/10/iostream:39,
                 from xoranges.cpp:1:
/usr/include/c++/10/ostream:681:5: note: 'std::endl' declared here
  681 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
xoranges.cpp:65:21: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   65 |                     cout << x << endl;
      |                     ^~~~
      |                     std::cout
In file included from xoranges.cpp:1:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
xoranges.cpp:65:34: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   65 |                     cout << x << endl;
      |                                  ^~~~
      |                                  std::endl
In file included from /usr/include/c++/10/iostream:39,
                 from xoranges.cpp:1:
/usr/include/c++/10/ostream:681:5: note: 'std::endl' declared here
  681 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~