Submission #502227

#TimeUsernameProblemLanguageResultExecution timeMemory
502227vrohakXylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
void solve(int n) { // ako je x pozitivan //ako je x pozitivan //ako je x pozitivan //ako je x // pozitivan //ako je x pozitivan //ako je x pozitivan //ako je x pozitivan // //ako je x pozitivan int rj1[n + 65], l1, l2, l3, stg1 = 0; rj1[1] = 0; int odg1 = query(1, 2); l1 = odg1; int odg2 = query(2, 3); l2 = odg2; int odg3 = query(1, 3); l3 = odg3; rj1[2] = odg1; if (odg3 == odg2 + odg1) { rj1[3] = odg1 + odg2; } else { stg1 = 1; rj1[3] = odg1 - odg2; } int od1[n + 65], od2[n + 56], od3[n + 99]; for (int i = 4; i < n + 1; i++) { odg1 = odg2; odg2 = query(i - 1, i); odg3 = query(i - 2, i); od1[i] = odg1; od2[i] = odg2; od3[i] = odg3; if (stg1 == 0) { if (odg3 == odg2 + odg1) { rj1[i] = rj1[i - 1] + odg2; } else { stg1 = 1; rj1[i] = rj1[i - 1] - odg2; } } else { if (odg3 == odg2 + odg1) { rj1[i] = rj1[i - 1] - odg2; } else { stg1 = 0; rj1[i] = rj1[i - 1] + odg2; } } } int mini1 = 0x3f3f3f3f; for (int i = 1; i < n + 1; i++) { mini1 = min(mini1, rj1[i]); } mini1 = abs(mini1) + 1; // ovdje je krivo bilo for (int i = 1; i < n + 1; i++) { rj1[i] = rj1[i] + mini1; } // ako je x negativan //ako je x negativan //ako je x negativan //ako je x // negativan //ako je x negativan //ako je x negativan //ako je x negativan // //ako je x negativan //ako je x negativan int rj2[n + 65]; rj2[1] = 0; int stg2 = 1; int odg11 = l1; int odg22 = l2; int odg33 = l3; rj2[2] = (-1) * odg11; if (odg33 == odg22 + odg11) { rj2[3] = -(odg11 + odg22); } else { stg2 = 0; rj2[3] = rj2[2] + odg22; } for (int i = 4; i < n + 1; i++) { odg11 = od1[i]; odg22 = od2[i]; odg33 = od3[i]; if (stg2 == 0) { if (odg33 == odg22 + odg11) { rj2[i] = rj2[i - 1] + odg22; } else { stg2 = 1; rj2[i] = rj2[i - 1] - odg22; } } else { if (odg33 == odg22 + odg11) { rj2[i] = rj2[i - 1] - odg22; } else { stg2 = 0; rj2[i] = rj2[i - 1] + odg22; } } } int mini2 = 0x3f3f3f3f; for (int i = 1; i < n + 1; i++) { mini2 = min(mini2, rj2[i]); } mini2 = abs(mini2) + 1; // tu isto je krivo jer mini2 moze biti negativan for (int i = 1; i < n + 1; i++) { rj2[i] = rj2[i] + mini2; } // < ispis > < ispis > < ispis > < ispis > < ispis > < ispis > < ispis > < // ispis > < ispis > < ispis > < ispis > < ispis > < ispis > < ispis > < // ispis > < ispis > < ispis > /* int mp1 = 0, mp2 = 0, pro = 0, niz[n + 55]; // memset(niz, 0, sizeof niz); for (int i = 1; i < n + 1; i++) { if (rj1[i] == 1) { pro++; } if (rj1[i] == n and pro == 0) { mp1++; break; } }*/ int idx1=-1, idx2=-1, mp1; for(int i=1;i<=n;i++){ if(rj1[i] == 1) idx1 = i; if(rj1[i] == n) idx2 = i; } /*for (int i = 1; i < n + 1; i++){ niz[rj1[i]]++; } for (int i = 1; i < n + 1; i++){ if (niz[i] == 0){ mp2 = 1; } }*/ if (idx1 < idx2) { for (int i = 1; i < n + 1; i++) { answer(i, rj1[i]); } } else { for (int i = 1; i < n + 1; i++) { answer(i, rj2[i]); } } return; }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:8:15: error: 'query' was not declared in this scope
    8 |    int odg1 = query(1, 2);
      |               ^~~~~
xylophone.cpp:50:15: error: 'min' was not declared in this scope; did you mean 'mini1'?
   50 |       mini1 = min(mini1, rj1[i]);
      |               ^~~
      |               mini1
xylophone.cpp:52:12: error: 'abs' was not declared in this scope
   52 |    mini1 = abs(mini1) + 1;  // ovdje je krivo bilo
      |            ^~~
xylophone.cpp:98:15: error: 'min' was not declared in this scope; did you mean 'mini2'?
   98 |       mini2 = min(mini2, rj2[i]);
      |               ^~~
      |               mini2
xylophone.cpp:140:10: error: 'answer' was not declared in this scope
  140 |          answer(i, rj1[i]);
      |          ^~~~~~
xylophone.cpp:144:10: error: 'answer' was not declared in this scope
  144 |          answer(i, rj2[i]);
      |          ^~~~~~
xylophone.cpp:121:24: warning: unused variable 'mp1' [-Wunused-variable]
  121 |  int idx1=-1, idx2=-1, mp1;
      |                        ^~~