/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 1ms 376.0 KiB
#3 Accepted 1ms 540.0 KiB
#4 Accepted 1ms 352.0 KiB
#5 Accepted 1ms 564.0 KiB
#6 Accepted 1ms 540.0 KiB
#7 Accepted 1ms 608.0 KiB
#8 Accepted 1ms 332.0 KiB
#9 Accepted 1ms 540.0 KiB
#10 Accepted 1ms 332.0 KiB
#11 Accepted 1ms 328.0 KiB
#12 Accepted 1ms 540.0 KiB
#13 Accepted 2ms 544.0 KiB
#14 Accepted 2ms 512.0 KiB
#15 Accepted 2ms 588.0 KiB
#16 Accepted 1ms 540.0 KiB
#17 Accepted 1ms 540.0 KiB
#18 Accepted 1ms 772.0 KiB
#19 Accepted 2ms 512.0 KiB
#20 Accepted 2ms 540.0 KiB
#21 Accepted 2ms 524.0 KiB
#22 Wrong Answer 2ms 572.0 KiB
#23 Accepted 2ms 592.0 KiB
#24 Wrong Answer 2ms 540.0 KiB

Code

//SUST_ZadeedBoss_Fanclub
//code_korlei_life_ase
//na_korle_lifeNai

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T> using o_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define double long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); 

void solve ()
{

	int n; cin >>n;
	vector <pair <int, int>> inp(n);
	for (auto &it : inp)
	{
		cin >>it.first >>it.second;
	}
	int x, y; cin >>x >>y;
	int cnt = 0;
	bool hobe = 1;
	for (auto &it : inp)
	{
		if (it.first == x && it.second == y) hobe = 0;
	}
	for (int i=0; i<n; i++)
	{
		int a1 = inp[i].first, b1 = inp[i].second;
		int a2 = inp[(i+1)%n].first, b2 = inp[(i+1)%n].second;
		if (b1 == y ^ b2 == y) {cnt++; continue;}
		if (min(b1, b2) < y && max(b1, b2) > y)
		{
			int db = b2 - b1;
			if (db == 0)
			{
				if (b1 == y)
				{
					if (min(a1, a2) < x && max(a1, a2) > x) {hobe = 0; break;}
				}
				continue;
			}
			int da = a2 - a1;
			int ndb = y - b1;
			if ((da * ndb) % db == 0 && a1 + (da * ndb) / db == x) {hobe = 0; break; }
			int nda = da * ndb / db;
			if (db * nda < da * ndb) nda++;
			if (a1 + nda > x) cnt++;
		}

	}
	if (!hobe) cnt = 0;
	if (cnt &1) cout <<"YES\n";
	else cout <<"NO\n";



}

signed main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int TCASE = 1;
	// cin >> TCASE;

	for (int tcase = 1; tcase <= TCASE; tcase++)
	{
		solve();
	}

}

Information

Submit By
Type
Submission
Problem
P1145 Nobita's Love for Shizuka
Contest
LU IUJPC : Sylhet Division 2024
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 07:17:58
Judged At
2024-12-09 07:17:58
Judged By
Score
83
Total Time
2ms
Peak Memory
772.0 KiB