답안 #464496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464496 2021-08-13T10:10:57 Z Itamar XORanges (eJOI19_xoranges) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <algorithm>
#include <vector>
using namespce std;

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:4:7: error: expected nested-name-specifier before 'namespce'
    4 | using namespce std;
      |       ^~~~~~~~
xoranges.cpp:6:1: error: 'vector' does not name a type
    6 | vector<int> odd;
      | ^~~~~~
xoranges.cpp:7:1: error: 'vector' does not name a type
    7 | vector<int> eve;
      | ^~~~~~
xoranges.cpp:8:1: error: 'vector' does not name a type
    8 | vector<int> val;
      | ^~~~~~
xoranges.cpp: In function 'void fun()':
xoranges.cpp:14:19: error: 'val' was not declared in this scope
   14 |         xo = xo ^ val[i];
      |                   ^~~
xoranges.cpp:15:9: error: 'eve' was not declared in this scope
   15 |         eve[i] = xo;
      |         ^~~
xoranges.cpp:19:19: error: 'val' was not declared in this scope
   19 |         xo = xo ^ val[i];
      |                   ^~~
xoranges.cpp:20:9: error: 'odd' was not declared in this scope
   20 |         odd[i] = xo;
      |         ^~~
xoranges.cpp: In function 'int main()':
xoranges.cpp:27:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   27 |     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:29:5: error: 'odd' was not declared in this scope
   29 |     odd.resize(n);
      |     ^~~
xoranges.cpp:30:5: error: 'eve' was not declared in this scope
   30 |     eve.resize(n);
      |     ^~~
xoranges.cpp:34:9: error: 'val' was not declared in this scope
   34 |         val.push_back(x);
      |         ^~~
xoranges.cpp:45:13: error: 'val' was not declared in this scope
   45 |             val[b - 1] = c;
      |             ^~~
xoranges.cpp:50:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   50 |                 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:50:30: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   50 |                 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:54:21: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   54 |                     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:54:46: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   54 |                     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:59:21: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   59 |                     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:59:34: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   59 |                     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:63:21: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   63 |                     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:63:45: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   63 |                     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:66:21: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   66 |                     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:66:34: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   66 |                     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)
      |     ^~~~