Submission #501832

#TimeUsernameProblemLanguageResultExecution timeMemory
501832BornaCizmarevicXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; void solve (int n){ //ako je x pozitivan int rj1[n+65]; rj1[1]=0; int stg1 = 0; int odg1 = query (1, 2); int odg2 = query (2, 3); int odg3 = query (1, 3); rj1[2] = x; if (odg3 == odg2 + odg1){ rj1[3] = x + y; } else { stg1 = 1; rj1[3] = x - y; } for (int i = 4; i < n+1; i++){ odg1 = odg2; odg2 = query(i-1, i); odg3=query(i-2,i); if (odg3 == odg2 + odg1){ if (stg1 == 0){ rj1[i] = rj1[i - 1] + y; } else { rj1[i] = rj1[i - 1] - y; } } else { if (stg1 == 0){ rj1[i] = rj1[i - 1] - y; } else { rj1[i] = rj1[i - 1] + y; } } } int odp1 = query (1, n); int mini1 = 0x3f3f3f3f; for (int i = 1;i < n; i++){ mini1 = min(mini1 , rj1[i]); } mini1 = mini1*(-1) + 1; for (int i = 1;i < n; i++){ rj1[i] = rj1[i] + mini1; } //ako je x negativan int rj2[n+65]; rj2[1]=0; int stg2 = 1; int odg11 = query (1, 2); int odg22 = query (2, 3); int odg33 = query (1, 3); rj2[2] = x; if (odg33 == odg22 + odg11){ rj2[3] = x + y; } else { stg2 = 0; rj2[3] = x - y; } for (int i = 4; i < n+1; i++){ odg11 = odg22; odg22 = query(i - 1, i); odg33=query(i - 2,i); if (odg33 == odg22 + odg11){ if (stg2 == 0){ rj2[i] = rj2[i - 1] + y; } else { rj2[i] = rj2[i - 1] - y; } } else { if (stg1 == 0){ rj2[i] = rj2[i - 1] - y; } else { rj2[i] = rj2[i - 1] + y; } } } int odp2 = query (1, n); int mini2 = 0x3f3f3f3f; for (int i = 1;i < n; i++){ mini2 = min(mini2 , rj2[i]); } mini2 = mini2*(-1) + 1; for (int i = 1;i < n; i++){ rj2[i] = rj2[i] + mini2; } //ispis if (odp1 == n - 1){ for (int i = 1; i < n+1; i++){ cout << "answer(" << i << ", " << rj1[i] <<")\n"; } } else { for (int i = 1; i < n+1; i++){ cout << "answer(" << i << ", " << rj2[i] <<")\n"; } } return; }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:14:12: error: 'x' was not declared in this scope
   14 |   rj1[2] = x;
      |            ^
xylophone.cpp:16:17: error: 'y' was not declared in this scope
   16 |    rj1[3] = x + y;
      |                 ^
xylophone.cpp:20:17: error: 'y' was not declared in this scope
   20 |    rj1[3] = x - y;
      |                 ^
xylophone.cpp:28:28: error: 'y' was not declared in this scope
   28 |      rj1[i] = rj1[i - 1] + y;
      |                            ^
xylophone.cpp:31:28: error: 'y' was not declared in this scope
   31 |      rj1[i] = rj1[i - 1] - y;
      |                            ^
xylophone.cpp:36:28: error: 'y' was not declared in this scope
   36 |      rj1[i] = rj1[i - 1] - y;
      |                            ^
xylophone.cpp:39:28: error: 'y' was not declared in this scope
   39 |      rj1[i] = rj1[i - 1] + y;
      |                            ^
xylophone.cpp:61:17: error: 'y' was not declared in this scope
   61 |    rj2[3] = x + y;
      |                 ^
xylophone.cpp:65:17: error: 'y' was not declared in this scope
   65 |    rj2[3] = x - y;
      |                 ^
xylophone.cpp:73:28: error: 'y' was not declared in this scope
   73 |      rj2[i] = rj2[i - 1] + y;
      |                            ^
xylophone.cpp:76:28: error: 'y' was not declared in this scope
   76 |      rj2[i] = rj2[i - 1] - y;
      |                            ^
xylophone.cpp:81:28: error: 'y' was not declared in this scope
   81 |      rj2[i] = rj2[i - 1] - y;
      |                            ^
xylophone.cpp:84:28: error: 'y' was not declared in this scope
   84 |      rj2[i] = rj2[i - 1] + y;
      |                            ^
xylophone.cpp:88:7: warning: unused variable 'odp2' [-Wunused-variable]
   88 |   int odp2 = query (1, n);
      |       ^~~~