Submission #66152

# Submission time Handle Problem Language Result Execution time Memory
66152 2018-08-09T22:12:53 Z reality Xylophone (JOI18_xylophone) C++17
0 / 100
2 ms 304 KB
#include "xylophone.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}

const int N = 1e6 + 5;

int s[N];

int d1[N];
int d2[N];

void solve(int NN) {
	int n = NN;
	for (int i = 0;i + 1 < n;++i)
		d1[i] = query(i + 1,i + 2);
	for (int i = 0;i + 2 < n;++i)
		d2[i] = query(i + 1,i + 3);
	for (int sg = 0;sg < 2;++sg) {
			s[0] = 0;
			int shit = sg;
			for (int i = 1;i < n;++i) {
				if (shit)
					s[i] = s[i - 1] - d1[i - 1];
				else
					s[i] = s[i - 1] + d1[i - 1];
				if (d2[i - 1] != d1[i - 1] + d1[i]) 
					shit ^= 1;
			}
			int mn = min_element(s,s + n) - s;
			int mx = max_element(s,s + n) - s;
			const int val = s[mn];
			for (int i = 0;i < n;++i)
				s[i] -= val;
			int ok = (mn < mx);
			for (int i = 0;i < n;++i)
				ok &= 0 <= s[i] && s[i] < n;
			set < int > ss;
			for (int i = 0;i < n;++i)
				ss.insert(s[i]);
			ok &= ss.size() == n;
			if (ok) {
				break;
			} else {
				assert(sg == 0);
			}
		}
	for (int i = 0;i < n;++i)
		answer(i + 1,s[i]);
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:55:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    ok &= ss.size() == n;
          ~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 304 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 304 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 304 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -