Submission #797212

# Submission time Handle Problem Language Result Execution time Memory
797212 2023-07-29T08:03:51 Z NothingXD Triple Jump (JOI19_jumps) C++17
0 / 100
17 ms 2228 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef double ld;
typedef complex<ld> point;

void debug_out(){cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
	cerr << H << ' ';
	debug_out(T...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)

const int maxn = 1e6 + 10;

ll n, a[maxn], b[maxn];
vector<int> q;
bool mark[maxn];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);

	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> a[i] >> b[i];
		if (a[i] > b[i]+1){
			q.push_back(i);
			mark[i] = true;
		}
	}

	while(!q.empty()){
		int v = q.back();
		mark[v] = false;
		q.pop_back();
		ll tmp = (a[v]-b[v]) / 2;
		int nxt = v+1;
		if (nxt == n+1) nxt = 1;
		a[nxt] += tmp;
		a[v] -= 2 * tmp;
		if (!mark[nxt] && a[nxt] > b[nxt]+1){
			q.push_back(nxt);
			mark[nxt] = true;
		}
	}

	bool ans = true;

	for (int i = 1; i <= n; i++){
		assert(a[i] <= b[i]+1);
		if (a[i] != b[i]) ans = false;
	}
	bool majid = true;
	for (int i = 1; i <= n; i++){
		if (a[i] != b[i]+1) majid = false;
	}
	bool asghar = false;
	for (int i = 1; i <= n; i++){
		if (a[i] != 1) asghar = true;
	}
	cout << ((ans || majid)? "Yes\n": "No\n");


	return 0;
}

Compilation message

jumps.cpp: In function 'int main()':
jumps.cpp:67:7: warning: variable 'asghar' set but not used [-Wunused-but-set-variable]
   67 |  bool asghar = false;
      |       ^~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 2228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -