제출 #502317

#제출 시각아이디문제언어결과실행 시간메모리
502317vrohakXylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; 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], rj2[n]; int d[n], t[n], odg1, odg2, odg3, sss=0; for(int i=1;i<=n;i++){ d[i] = query(i, i+1); if(i!=1) t[i] = query(i-1, i+1); } odg2=d[0]; rj1[1] = 0; rj1[2] = odg2; for (int i = 3; i < n + 1; i++) { odg1 = d[i-2]; odg2 = d[i-1]; odg3 = t[i-1]; if(odg1+odg2 != odg3){ if(sss==0) sss=1; else sss=0; } rj1[i] = rj1[i-1] + odg2 * (sss * 2 - 1); } } int mn = 0, mx=0; for (int i = 1; i < n + 1; i++) { mn = min(mn, rj1[i]); mx = max(mx, rj1[i]); } mn = abs(mn) + 1; for (int i = 1; i < n + 1; i++) { rj2[i] = mx-rj1[i]+1; rj1[i] = rj1[i] + mn; } int idx1, idxn; for (int i = 1; i < n + 1; i++) { if(rj1[i] == 1) idx1 = i; if(rj1[i] == n) idxn = i; } if (idx1 < idxn) { 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; }

컴파일 시 표준 에러 (stderr) 메시지

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:12:16: warning: unused variable 'rj2' [-Wunused-variable]
   12 |    int rj1[n], rj2[n];
      |                ^~~
xylophone.cpp: At global scope:
xylophone.cpp:37:4: error: expected unqualified-id before 'for'
   37 |    for (int i = 1; i < n + 1; i++) {
      |    ^~~
xylophone.cpp:37:20: error: 'i' does not name a type
   37 |    for (int i = 1; i < n + 1; i++) {
      |                    ^
xylophone.cpp:37:31: error: 'i' does not name a type
   37 |    for (int i = 1; i < n + 1; i++) {
      |                               ^
xylophone.cpp:41:4: error: 'mn' does not name a type
   41 |    mn = abs(mn) + 1;
      |    ^~
xylophone.cpp:42:4: error: expected unqualified-id before 'for'
   42 |    for (int i = 1; i < n + 1; i++) {
      |    ^~~
xylophone.cpp:42:20: error: 'i' does not name a type
   42 |    for (int i = 1; i < n + 1; i++) {
      |                    ^
xylophone.cpp:42:31: error: 'i' does not name a type
   42 |    for (int i = 1; i < n + 1; i++) {
      |                               ^
xylophone.cpp:48:4: error: expected unqualified-id before 'for'
   48 |    for (int i = 1; i < n + 1; i++) {
      |    ^~~
xylophone.cpp:48:20: error: 'i' does not name a type
   48 |    for (int i = 1; i < n + 1; i++) {
      |                    ^
xylophone.cpp:48:31: error: 'i' does not name a type
   48 |    for (int i = 1; i < n + 1; i++) {
      |                               ^
xylophone.cpp:53:4: error: expected unqualified-id before 'if'
   53 |    if (idx1 < idxn) {
      |    ^~
xylophone.cpp:57:6: error: expected unqualified-id before 'else'
   57 |    } else {
      |      ^~~~
xylophone.cpp:63:4: error: expected unqualified-id before 'return'
   63 |    return;
      |    ^~~~~~
xylophone.cpp:64:1: error: expected declaration before '}' token
   64 | }
      | ^