QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#103389 | #523. 部落战争 | zaneyu# | 40 | 4ms | 3760kb | C++20 | 4.0kb | 2023-05-05 17:01:22 | 2024-05-26 02:50:50 |
Judging History
answer
/*input
4 4 3
0 0
1 0
0 1
1 1
-1 0
0 3
0 2
0 -1
0 0
2 3
0 -1
*/
#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;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//#pragma GCC target("avx2")
//order_of_key #of elements less than x
// find_by_order kth element
using ll=long long;
using ld=long double;
using pii=pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll maxn=1e3+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const int MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-4;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
out<<P.f<<' '<<P.s;
return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
REP(i,sz(V)) out<<V[i]<<((i!=sz(V)-1)?" ":"");
return out;
}
ll mult(ll a,ll b){
return a*b%MOD;
}
ll mypow(ll a,ll b){
a%=MOD;
if(a==0) return 0;
if(b<=0) return 1;
ll res=1LL;
while(b){
if(b&1) res=(res*a)%MOD;
a=(a*a)%MOD;
b>>=1;
}
return res;
}
struct P{
ll x,y;
P(ll x=0,ll y=0):x(x),y(y){}
void read(){
cin>>x>>y;
}
ll operator *(const P &b) const{
return (ll)x*b.y-(ll)y*b.x;
}
P operator -(const P &b) const{
return P{x-b.x,y-b.y};
}
void operator -=(const P&b){
x-=b.x,y-=b.y;
}
ll triangle(const P&b,const P&c) const{
return (b-*this)*(c-*this);
}
int ori(const P&a,const P&b) const{
P z=*this;
ll x=(a-z)*(b-z);
if(x<0) return -1;
if(x>0) return 1;
return 0;
}
bool operator < (const P&b) const{
return make_pair(x,y)<make_pair(b.x,b.y);
}
};
ll dot(P a,P b){
return a.x*b.x+a.y*b.y;
}
vector<P> hull(vector<P> &arr){
sort(ALL(arr));
int n=sz(arr);
vector<P> v;
REP(j,2){
const int S=sz(v)+2;
for(int i=0;i<n;i++){
//if remove collinear points change to >=0
while(sz(v)>=S and v[sz(v)-2].triangle(v[sz(v)-1],arr[i])>=0){
v.pop_back();
}
v.push_back(arr[i]);
}
v.pop_back();
reverse(ALL(arr));
}
return v;
}
bool inter(P p1,P p2,P p3,P p4){
if((p2-p1)*(p4-p3)==0){
//parallel
if((p2-p1)*(p3-p1)!=0){
return false;
}
REP(i,2){
if(max(p1.x,p2.x)<min(p3.x,p4.x) or max(p1.y,p2.y)<min(p3.y,p4.y)){
return false;
}
swap(p1,p3),swap(p2,p4);
}
return true;
}
REP(i,2){
int a=p1.ori(p2,p3),b=p1.ori(p2,p4);
if(a==b){
return false;
}
swap(p1,p3);
swap(p2,p4);
}
return true;
}
int main(){
ios::sync_with_stdio(false),cin.tie(0);
int n,m,q;
cin>>n>>m>>q;
vector<P> a(n),b(m);
REP(i,n) a[i].read();
REP(i,m) b[i].read();
a=hull(a),b=hull(b);
n=sz(a),m=sz(b);
while(q--){
int dx,dy;
cin>>dx>>dy;
bool hv=0;
for(auto &x:b) x.x+=dx,x.y+=dy;
REP(i,n){
REP(j,m){
if(inter(a[i],a[(i+1)%n],b[j],b[(j+1)%m])){
hv=1;
break;
}
}
if(hv) break;
}
for(auto &x:b) x.x-=dx,x.y-=dy;
cout<<hv<<'\n';
}
}
详细
Test #1:
score: 10
Accepted
time: 0ms
memory: 3600kb
input:
5 5 500 6407435 3293303 7667584 -28726709 12981947 3232993 -4728920 -20310419 11417244 -21375059 -9897535 1003568 11250465 -455741 -212338 27421583 -8617310 23838234 1170809 22010017 9475604 -55467994 -4050339 3741774 -837777 3712301 21965125 2292518 15461481 -52915993 6607803 -55284619 4978498 3464...
output:
1 0 1 1 1 1 0 1 0 1 1 0 1 0 0 0 1 1 1 1 1 0 1 0 1 0 0 0 1 1 1 0 0 0 0 1 0 1 1 1 1 0 1 1 1 1 1 0 0 1 1 1 0 0 1 0 1 0 0 0 1 0 1 0 0 1 0 0 1 1 1 0 0 0 0 1 0 0 0 1 1 0 1 1 1 1 0 0 1 0 1 1 0 1 1 0 1 0 0 0 0 0 0 1 1 1 1 0 1 1 1 0 1 1 0 1 0 0 1 0 0 1 1 0 1 1 1 1 1 1 0 1 0 0 1 0 1 0 0 1 0 0 1 1 1 1 0 1 0 1 ...
result:
ok 500 lines
Test #2:
score: 10
Accepted
time: 1ms
memory: 3600kb
input:
5 5 500 -27523822 3903432 -8164905 12245974 -12788492 -18439238 -9257256 12571383 -7088899 -13518632 8395941 908038 3503624 10427724 -14313118 13946163 -8810192 15122696 -23606580 1742581 -2846782 -33320015 10422149 -23265478 -28254784 -10728385 -25177201 8093012 -7071570 -16767903 -24720747 8309611...
output:
0 0 0 1 1 1 1 0 1 1 1 1 1 1 0 0 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 0 1 0 0 1 0 1 0 0 0 0 1 1 0 0 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 0 1 0 1 0 0 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 0 1 0 1 1 0 1 0 1 0 0 1 1 1 1 0 0 0 0 1 0 0 0 1 1 1 1 1 0 1 0 1 0 1 1 0 0 1 0 1 0 1 0 1 1 0 0 0 1 ...
result:
ok 500 lines
Test #3:
score: 10
Accepted
time: 4ms
memory: 3532kb
input:
50 50 500 4254966 4514473 -10243311 29338943 -11714256 28967870 -3638225 -329846 -11636788 -126679 -5182905 -625577 6032976 21796923 -13140961 28452003 1041973 27162958 -2756343 -84802 -7820141 29623403 -1439665 28473013 -2457947 28853419 -7990305 29616231 -7601697 29629812 -14884269 1278440 -998615...
output:
1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 0 1 0 0 1 1 0 0 1 0 0 1 1 1 0 1 0 1 1 0 0 1 0 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 1 1 0 1 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 1 1 0 0 1 0 1 1 1 0 1 0 1 1 0 0 1 1 0 1 1 0 1 0 1 1 0 1 1 0 0 1 1 0 1 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 1 ...
result:
ok 500 lines
Test #4:
score: 10
Accepted
time: 2ms
memory: 3760kb
input:
50 50 500 9401701 -3609043 2012208 -1102882 -1811540 -26010495 -5041437 -3110073 10286335 -4329717 12578870 -20602424 10667571 -4684127 12022858 -6227670 6703376 -2076756 -3916528 -2467881 -8883942 -6948248 4710266 -26206538 8123463 -24867007 5052685 -26121576 -4028108 -2524942 -1941055 -1669813 319...
output:
1 0 1 0 0 1 1 0 1 0 1 0 1 0 0 1 0 1 1 0 1 1 0 0 0 1 1 1 1 1 1 0 1 0 0 1 1 0 1 1 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 1 1 1 1 0 1 0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 1 0 1 0 1 0 0 0 0 1 0 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 1 0 0 0 1 0 0 1 0 0 1 0 0 1 1 0 0 1 ...
result:
ok 500 lines
Test #5:
score: 0
Time Limit Exceeded
input:
10000 10000 500 1666056 -27430003 -4367330 9570472 18716225 -12240967 -1787485 -27373792 -15436704 1726451 5020083 -26867542 -2574044 -27271537 -11443050 6074066 -4820607 -26789265 15100955 2873536 -9623440 7349040 976214 10130141 -9144842 7634171 6079703 9216512 15077673 -20242861 16905511 69303 13...
output:
result:
Test #6:
score: 0
Time Limit Exceeded
input:
10000 10000 500 9282217 -4781364 1501964 25031109 -3834648 -5391055 8360673 -5218666 -7317209 -3446949 -10874263 199999 -3638519 23977553 -10806642 104184 9180387 23342430 8585209 23627902 -742433 24790641 2593801 -6522640 -13108369 4871264 -3278720 24111737 -1204794 24700179 2670075 25028975 145219...
output:
result:
Test #7:
score: 0
Time Limit Exceeded
input:
10000 10000 500 18739956 22581499 226899 20847190 4459986 -8474225 19625260 22085584 17107612 -8505721 1592846 21819795 4911498 -8647734 754040 -6425195 11298530 -9694797 8002434 -9467273 15632721 -9011669 19047199 -7595729 26034505 15249508 1304680 21631076 16199900 -8834823 20427260 -6752268 -5838...
output:
result:
Test #8:
score: 0
Time Limit Exceeded
input:
100000 100000 100000 24235601 -13951926 -10355885 -24094242 -5635989 -27027698 12252374 12885344 6137155 -28841530 15967851 10799403 9725989 13814468 -7061607 12038424 -9834599 -24505790 11646839 -27414386 -2187954 -28266157 -18126630 -3597220 3069276 14729493 -199316 14425458 11896146 -27311875 -12...
output:
result:
Test #9:
score: 0
Time Limit Exceeded
input:
100000 100000 100000 8354421 -26671439 8956353 6194768 18000019 5113843 -731040 989961 20842988 3589967 1941343 -23926046 17724523 5225919 26327648 -18097349 26513711 -2848520 19914037 -24750782 19992615 -24705163 -3889910 -4001319 26006870 -1907798 11797680 6399489 3081377 -24663720 14262223 -26766...
output:
result:
Test #10:
score: 0
Time Limit Exceeded
input:
100000 100000 100000 -17714771 -18844934 13960381 -21362034 -13107507 -24716099 -5216508 -28653304 -6830004 7079906 -7371497 6895381 15737377 -2830941 -16200790 -21359312 -17628244 -19016144 8224158 -26586063 -732489 7976996 13458776 -22030283 -5650557 -28549478 16498589 -4770663 4862335 -28120485 8...