Submission #661016


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

typedef pair<long,long> P;

long cr(P a, P b)
{
	return a.fi*b.sc-a.sc*b.fi;
}

int main()
{
	int i,j;

	int n;
	cin >>n;

	vector<P> v(n);
	map<P,string> d;
	map<string,P> id;
	rep(i,n)
	{
		string s;

		cin >>s >>v[i].fi >>v[i].sc;
		d[v[i]]=s;
		id[s]=v[i];
	}
	sort(v.begin(),v.end());

	//rep(i,n) cout<<" "<<v[i].fi<<","<<v[i].sc<<" : "<<d[v[i]]<<endl;

	int m;
	cin >>m;
	vector<P> t;
	set<P> polygon;
	rep(i,m)
	{
		string tmp;
		cin >>tmp;

		t.pb(id[tmp]);
		polygon.insert(id[tmp]);
	}

	vector<string> ans;
	//内外判定
	rep(i,n)
	{
		//凸多角形に含まれる点は調べる必要が無い
		if(polygon.find(v[i])!=polygon.end()) continue;

		int ct=0;
		rep(j,m)
		{
			P a=t[j], b=t[(j+1)%m];
			//平行移動
			a.fi-=v[i].fi;
			b.fi-=v[i].fi;
			a.sc-=v[i].sc;
			b.sc-=v[i].sc;

			//線分abとx軸正の部分の交差判定
			if(a.sc>b.sc) swap(a,b);
			if(a.sc<=0 && 0<b.sc)
			{
				if(cr(a,b)<0) ++ct;
			}
		}

		if(ct%2==1) ans.pb(d[v[i]]);
	}

	rep(i,ans.size()) cout<<ans[i]<<endl;
}

Submission Info

Submission Time
Task G - 志なかばで死んだ勇者の名は…
User imulan
Language C++11 (GCC 4.9.2)
Score 100
Code Size 1366 Byte
Status AC
Exec Time 98 ms
Memory 1828 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 20
Set Name Test Cases
All 00_sample_00.txt, 00_sample_01.txt, 10_min_00.txt, 10_min_01.txt, 10_min_02.txt, 20_max_00.txt, 20_max_01.txt, 20_max_02.txt, 90_random_00.txt, 90_random_01.txt, 90_random_02.txt, 90_random_03.txt, 90_random_04.txt, 90_random_05.txt, 90_random_06.txt, 90_random_07.txt, 90_random_08.txt, 90_random_09.txt, 99_final_00.txt, yuha-c88-j.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 26 ms 800 KB
00_sample_01.txt AC 24 ms 924 KB
10_min_00.txt AC 26 ms 808 KB
10_min_01.txt AC 25 ms 796 KB
10_min_02.txt AC 26 ms 796 KB
20_max_00.txt AC 60 ms 1828 KB
20_max_01.txt AC 60 ms 1772 KB
20_max_02.txt AC 60 ms 1824 KB
90_random_00.txt AC 56 ms 1696 KB
90_random_01.txt AC 57 ms 1824 KB
90_random_02.txt AC 55 ms 1692 KB
90_random_03.txt AC 45 ms 1440 KB
90_random_04.txt AC 46 ms 1440 KB
90_random_05.txt AC 49 ms 1688 KB
90_random_06.txt AC 59 ms 1812 KB
90_random_07.txt AC 57 ms 1700 KB
90_random_08.txt AC 59 ms 1824 KB
90_random_09.txt AC 43 ms 1316 KB
99_final_00.txt AC 97 ms 1824 KB
yuha-c88-j.txt AC 98 ms 1828 KB