Submission #163157

#TimeUsernameProblemLanguageResultExecution timeMemory
163157mat_vXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
/* #include "xylophone.h" #include <bits/stdc++.h> using namespace std; */ int n; int niz[5005]; int simuliraj(int a, int b, int c){ return max(max(a,b), c) - min(min(a,b), c); } void solve(int N){ n = N; int poz1 = 0; int l = 1; int r = n; while(l < r){ int mid = (l + r + 1) / 2; int pom = query(mid, n); if(pom == n - 1){ l = mid; } else r = mid - 1; } poz1 = l; //cout << poz1 << endl; /*for(int i=n; i>=1; i--){ if(query(i,n) == n-1){ poz1 = i; break; } }*/ niz[poz1] = 1; if(poz1>1){ niz[poz1 - 1] = 1 + query(poz1 - 1, poz1); } niz[poz1 + 1] = 1 + query(poz1, poz1 + 1); for(int i=poz1 - 2; i >= 1; i--){ int val1 = query(i,i+1); int prvi = niz[i + 1] - val1; int drugi = niz[i + 1] + val1; if(prvi <= 0 || drugi > n){ if(prvi <= 0)niz[i] = drugi; else niz[i] = prvi; continue; } int val2 = query(i,i+2); int tmp1 = simuliraj(niz[i + 1], niz[i + 2], prvi); int tmp2 = simuliraj(niz[i + 1], niz[i + 2], drugi); if(tmp1 == val2)niz[i] = prvi; else niz[i] = drugi; } for(int i=poz1+2; i<=n; i++){ int val1 = query(i-1,i); int prvi = niz[i - 1] - val1; int drugi = niz[i - 1] + val1; if(prvi <= 0 || drugi > n){ if(prvi <= 0)niz[i] = drugi; else niz[i] = prvi; continue; } int val2 = query(i-2,i); int tmp1 = simuliraj(niz[i - 1], niz[i - 2], prvi); int tmp2 = simuliraj(niz[i - 1], niz[i - 2], drugi); if(tmp1 == val2)niz[i] = prvi; else niz[i] = drugi; } for(int i=1; i<=n; i++)answer(i, niz[i]); }

Compilation message (stderr)

xylophone.cpp: In function 'int simuliraj(int, int, int)':
xylophone.cpp:11:16: error: 'max' was not declared in this scope
     return max(max(a,b), c) - min(min(a,b), c);
                ^~~
xylophone.cpp:11:12: error: 'max' was not declared in this scope
     return max(max(a,b), c) - min(min(a,b), c);
            ^~~
xylophone.cpp:11:35: error: 'min' was not declared in this scope
     return max(max(a,b), c) - min(min(a,b), c);
                                   ^~~
xylophone.cpp:11:31: error: 'min' was not declared in this scope
     return max(max(a,b), c) - min(min(a,b), c);
                               ^~~
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:20:19: error: 'query' was not declared in this scope
         int pom = query(mid, n);
                   ^~~~~
xylophone.cpp:37:29: error: 'query' was not declared in this scope
         niz[poz1 - 1] = 1 + query(poz1 - 1, poz1);
                             ^~~~~
xylophone.cpp:39:25: error: 'query' was not declared in this scope
     niz[poz1 + 1] = 1 + query(poz1, poz1 + 1);
                         ^~~~~
xylophone.cpp:51:13: warning: unused variable 'tmp2' [-Wunused-variable]
         int tmp2 = simuliraj(niz[i + 1], niz[i + 2], drugi);
             ^~~~
xylophone.cpp:66:13: warning: unused variable 'tmp2' [-Wunused-variable]
         int tmp2 = simuliraj(niz[i - 1], niz[i - 2], drugi);
             ^~~~
xylophone.cpp:70:28: error: 'answer' was not declared in this scope
     for(int i=1; i<=n; i++)answer(i, niz[i]);
                            ^~~~~~