답안 #66151

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66151 2018-08-09T22:12:15 Z reality Xylophone (JOI18_xylophone) C++17
0 / 100
2 ms 248 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,i + 1);
	for (int i = 0;i + 2 < n;++i)
		d2[i] = query(i,i + 2);
	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,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;
          ~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -