Submission #1114444

#TimeUsernameProblemLanguageResultExecution timeMemory
1114444sunboiXylophone (JOI18_xylophone)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; void solve(int n){ int pos = 0; int i = 1; while(query(i, n) == n - 1){ i++; } i--; int reference = i; vector<int> a(n); int x = query(i, i + 1); a[i] = 1; a[i + 1] = x + 1; i += 2; int last = x; for (i; i <= n; i++){ int mn = min(a[i - 1], a[i - 2]); int mx = max(a[i - 1], a[i - 2]); int uno = query(i - 1, i); int dos = query(i - 2, i); if (dos > last){ if (a[i - 1] + uno == a[i - 2] + dos){ a[i] = a[i - 1] + uno; }else{ a[i] = a[i - 1] - uno; } }else{ if (a[i - 1] == mn) a[i] = a[i - 1] + uno; else a[i] = a[i - 1] - uno; } last = uno; } i = reference; x = query(i - 1, i); a[i - 1] = 1 + x; last = x; i -= 2; for (i; i >= 1; i--){ int mn = min(a[i + 1], a[i + 2]); int mx = max(a[i + 1], a[i + 2]); int uno = query(i, i + 1); int dos = query(i, i + 2); if (dos > last){ if (a[i + 1] + uno == a[i + 2] + dos){ a[i] = a[i + 1] + uno; }else{ a[i] = a[i + 1] - uno; } }else{ if (a[i + 1] == mn) a[i] = a[i + 1] + uno; else a[i] = a[i + 1] - uno; } last = uno; } for (int i = 1; i <= n; i++) answer(i, a[i]); }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:23:10: warning: statement has no effect [-Wunused-value]
   23 |     for (i; i <= n; i++){
      |          ^
xylophone.cpp:25:13: warning: unused variable 'mx' [-Wunused-variable]
   25 |         int mx = max(a[i - 1], a[i - 2]);
      |             ^~
xylophone.cpp:48:10: warning: statement has no effect [-Wunused-value]
   48 |     for (i; i >= 1; i--){
      |          ^
xylophone.cpp:50:13: warning: unused variable 'mx' [-Wunused-variable]
   50 |         int mx = max(a[i + 1], a[i + 2]);
      |             ^~
xylophone.cpp:8:9: warning: unused variable 'pos' [-Wunused-variable]
    8 |     int pos = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...