Submission #759544

#TimeUsernameProblemLanguageResultExecution timeMemory
759544otariusXylophone (JOI18_xylophone)C++17
0 / 100
1 ms208 KiB
#include "xylophone.h" #include <iostream> #include <algorithm> #include <vector> #include <set> #include <cstring> #include <queue> #include <map> #include <cmath> #include <iomanip> using namespace std; #define ff first #define sc second #define pb push_back #define ll long long #define pll pair<ll, ll> #define pii pair <int, int> #define ull unsigned long long // #define int long long // #define int unsigned long long const ll inf = 1e9 + 7; const ll weirdMod = 998244353; bool check(vector<int> v, int n) { set<int> st; for (int u : v) st.insert(u); if (st.size() != n) return false; int cur = 1; for (int u : st) { if (cur == u) cur++; else return false; } return true; } void solve(int n) { int b[n + 1], c[n + 1]; for (int i = 1; i <= n - 1; i++) b[i] = query(i, i + 1); for (int i = 1; i <= n - 2; i++) c[i] = query(i, i + 2); bool flg[n + 1]; /* flg[i] = 1, if a[i] > a[i + 1] flg[i] = 0, if a[i] < a[i + 1] */ flg[1] = 1; for (int i = 2; i <= n - 1; i++) { if (b[i - 1] + b[i] == c[i - 1]) flg[i] = flg[i - 1]; else flg[i] = !flg[i - 1]; } int cur = 1, mn = 1; vector<int> a; for (int i = 2; i <= n; i++) { if (flg[i - 1] == 1) { cur -= b[i - 1]; a.pb(cur); mn = min(mn, cur); } else { cur += b[i - 1]; a.pb(cur); mn = min(mn, cur); } } for (int &v : a) v += -mn + 1; if (check(a, n)) { for (int i = 0; i < a.size(); i++) answer(i + 1, a[i]); return; } cur = 1; mn = 1; a.clear(); for (int i = 2; i <= n; i++) { if (flg[i - 1] == 1) { cur += b[i - 1]; a.pb(cur); mn = min(mn, cur); } else { cur += b[i - 1]; a.pb(cur); mn = min(mn, cur); } } for (int &v : a) v += -mn + 1; for (int i = 0; i < a.size(); i++) answer(i + 1, a[i]); }

Compilation message (stderr)

xylophone.cpp: In function 'bool check(std::vector<int>, int)':
xylophone.cpp:31:19: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |     if (st.size() != n)
      |         ~~~~~~~~~~^~~~
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:67:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         for (int i = 0; i < a.size(); i++)
      |                         ~~^~~~~~~~~~
xylophone.cpp:81:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |     for (int i = 0; i < a.size(); i++)
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...