Submission #502539

#TimeUsernameProblemLanguageResultExecution timeMemory
502539fabijan_cikacXylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#include "xylophone.h" void solve(int N){ map<int, map<int, int> > m; vector<pair<int, int> > v; int a[2 * 1e4]; bool b = true; int sol[2 * 1e4]; m[0][1] = query(0, 1); for (int i = 2; i < N; ++i){ m[i - 2][i] = query(i - 2, i); m[i - 1][i] = query(i - 1, i); } //a[0] < a[1] a[0] = 0; a[1] = m[0][1]; for (int i = 2; i < N; ++i){ bool c = false; for (int j = -1; j <= 1; ++j){ if (j == 0) continue; a[i] = a[i - 1] + j * m[i - 1][i]; if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){ c = true; break; } } if (!c) b = false; } for (int i = 0; i < N; ++i) v.push_back({a[i], i}); sort(v.begin(), v.end()); int x, y; for (int i = 0; i < n; ++i){ sol[v[i].second] = i + 1; if (i + 1 == 1) x = v[i].second; if (i + 1 == N) y = v[i].second; } if (!b || x > y){ a[0] = 0; a[1] = -m[0][1]; b = true; for (int i = 2; i < N; ++i){ bool c = false; for (int j = -1; j <= 1; ++j){ if (j == 0) continue; a[i] = a[i - 1] + j * m[i - 1][i]; if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){ c = true; break; } } if (!c) b = false; } v.clear(); for (int i = 0; i < N; ++i) v.push_back({a[i], i}); sort(v.begin(), v.end()); int x, y; for (int i = 0; i < n; ++i){ sol[v[i].second] = i + 1; if (i + 1 == 1) x = v[i].second; if (i + 1 == N) y = v[i].second; } } for (int i = 0; i < n; ++i) answer(i + 1, sol[i]); return; }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:4:5: error: 'map' was not declared in this scope
    4 |     map<int, map<int, int> > m; vector<pair<int, int> > v;
      |     ^~~
xylophone.cpp:4:9: error: expected primary-expression before 'int'
    4 |     map<int, map<int, int> > m; vector<pair<int, int> > v;
      |         ^~~
xylophone.cpp:4:33: error: 'vector' was not declared in this scope
    4 |     map<int, map<int, int> > m; vector<pair<int, int> > v;
      |                                 ^~~~~~
xylophone.cpp:4:40: error: 'pair' was not declared in this scope
    4 |     map<int, map<int, int> > m; vector<pair<int, int> > v;
      |                                        ^~~~
xylophone.cpp:4:45: error: expected primary-expression before 'int'
    4 |     map<int, map<int, int> > m; vector<pair<int, int> > v;
      |                                             ^~~
xylophone.cpp:5:13: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    5 |     int a[2 * 1e4]; bool b = true;
      |           ~~^~~~~
xylophone.cpp:5:13: error: could not convert '((double)2 * 1.0e+4)' from 'double' to 'long unsigned int'
xylophone.cpp:5:13: error: size of array 'a' has non-integral type 'double'
xylophone.cpp:6:15: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    6 |     int sol[2 * 1e4]; m[0][1] = query(0, 1);
      |             ~~^~~~~
xylophone.cpp:6:15: error: could not convert '((double)2 * 1.0e+4)' from 'double' to 'long unsigned int'
xylophone.cpp:6:15: error: size of array 'sol' has non-integral type 'double'
xylophone.cpp:6:23: error: 'm' was not declared in this scope
    6 |     int sol[2 * 1e4]; m[0][1] = query(0, 1);
      |                       ^
xylophone.cpp:18:31: error: 'max' was not declared in this scope
   18 |             if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                               ^~~
xylophone.cpp:18:17: error: 'max' was not declared in this scope
   18 |             if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                 ^~~
xylophone.cpp:18:68: error: 'min' was not declared in this scope
   18 |             if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                                                                    ^~~
xylophone.cpp:18:54: error: 'min' was not declared in this scope
   18 |             if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                                                      ^~~
xylophone.cpp:25:9: error: 'v' was not declared in this scope
   25 |         v.push_back({a[i], i});
      |         ^
xylophone.cpp:26:10: error: 'v' was not declared in this scope
   26 |     sort(v.begin(), v.end()); int x, y;
      |          ^
xylophone.cpp:26:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   26 |     sort(v.begin(), v.end()); int x, y;
      |     ^~~~
      |     short
xylophone.cpp:27:25: error: 'n' was not declared in this scope
   27 |     for (int i = 0; i < n; ++i){
      |                         ^
xylophone.cpp:39:35: error: 'max' was not declared in this scope
   39 |                 if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                                   ^~~
xylophone.cpp:39:21: error: 'max' was not declared in this scope
   39 |                 if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                     ^~~
xylophone.cpp:39:72: error: 'min' was not declared in this scope
   39 |                 if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                                                                        ^~~
xylophone.cpp:39:58: error: 'min' was not declared in this scope
   39 |                 if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                                                          ^~~
xylophone.cpp:49:29: error: 'n' was not declared in this scope
   49 |         for (int i = 0; i < n; ++i){
      |                             ^
xylophone.cpp:55:25: error: 'n' was not declared in this scope
   55 |     for (int i = 0; i < n; ++i)
      |                         ^