Cancer of the topic and people! ! !
T2 title and sample surface is not the same, so I hung up (yes that's the reason I write analog write hung up)
T1 flood problem, too lazy to explain, five minutes AC
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <bits/stdc++.h> 2 #define ll long long 3 using namespace std; 4 ll n; 5 int main() 6 { 7 cin>>n; 8 if(n<4) 9 { 10 cout<<"NO"<<endl; 11 return 0; 12 } 13 if(n%2==0) 14 { 15 cout<<"NO"<<endl; 16 return 0; 17 } 18 n--; 19 cout<<"1"<<" "<<(n-2)/2<<endl; 20 }
T2 simulation
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 int n,k,m,t,la,lb; 5 int main() 6 { 7 scanf("%d%d%d%d",&n,&k,&m,&t); 8 for(register int i=1;i<=t;i++) 9 { 10 scanf("%d%d",&la,&lb); 11 if(la==1) 12 { 13 if(n<m) 14 { 15 n++; 16 if(k>=lb) 17 { 18 k++; 19 } 20 } 21 } 22 if(la==0) 23 { 24 if(k<=lb) 25 { 26 n=lb; 27 } 28 else 29 { 30 k-=lb; 31 n-=lb; 32 } 33 } 34 printf("%d %d\n",n,k); 35 } 36 }
I think is a positive solution T3, but hung up the fight, in fact, the number of lines and the intersection between violence enumerate them every two parallel lines, remember starting and ending points and the length of the judgment on it, and then directly set a formula, the results
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define ll long long 4 int n,sn,hn; 5 ll a,b,c,d,ans,num; 6 struct shu{ll x,y1,y2;}s[1050]; 7 struct heng{ll y,x1,x2;}h[1050]; 8 int xl,xr,sl,sr,yu,yd; 9 int main() 10 { 11 cin>>n; 12 for(int i=1;i<=n;i++){ 13 scanf("%lld%lld%lld%lld",&a,&b,&c,&d); 14 if(a==c){ 15 if(b>d)swap(b,d); 16 sn++; 17 s[sn].x=a; 18 s[sn].y1=b; 19 s[sn].y2=d; 20 continue; 21 } 22 if(a>c)swap(a,c); 23 hn++; 24 h[hn].y=b; 25 h[hn].x1=a; 26 h[hn].x2=c; 27 } 28 for(int i=1;i<=hn;i++){ 29 for(int j=i+1;j<=hn;j++){ 30 xl=max(h[i].x1,h[j].x1); 31 xr=min(h[i].x2,h[j].x2); 32 if(xl>=xr)continue; 33 num=0; 34 yu=min(h[i].y,h[j].y); 35 yd=max(h[i].y,h[j].y); 36 for(int k=1;k<=sn;k++){ 37 if(s[k].x>=xl&&s[k].x<=xr&&s[k].y1<=yu&&s[k].y2>=yd)num++; 38 } 39 ans+=num*(num-1)/2; 40 } 41 } 42 printf("%lld",ans); 43 44 }