Codeforces Beta Round #14 (Div. 2)
A
找最大最小的行列值即可
1 #include2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define maxn 500005 7 typedef long long ll; 8 /*#ifndef ONLINE_JUDGE 9 freopen("1.txt","r",stdin);10 #endif */11 12 string str[55];13 14 int main(){15 #ifndef ONLINE_JUDGE16 freopen("1.txt","r",stdin);17 #endif18 std::ios::sync_with_stdio(false);19 int n,m;20 cin>>n>>m;21 int hangmin=105,hangmax=-1,liemin=105,liemax=-1;22 for(int i=0;i >str[i];23 for(int i=0;i
B
水题
1 #include2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define maxn 500005 7 typedef long long ll; 8 /*#ifndef ONLINE_JUDGE 9 freopen("1.txt","r",stdin);10 #endif */11 12 int n,x;13 int a[1005];14 15 int main(){16 #ifndef ONLINE_JUDGE17 // freopen("1.txt","r",stdin);18 #endif19 std::ios::sync_with_stdio(false);20 cin>>n>>x;21 int u,v;22 for(int i=1;i<=n;i++){23 cin>>u>>v;24 if(u>v) swap(u,v);25 a[u]++,a[v+1]--;26 }27 int ans=0x3f3f3f3f;28 int num=0;29 for(int i=0;i<=1001;i++){30 num+=a[i];31 if(num==n){32 ans=min(ans,abs(i-x));33 }34 }35 if(ans==0x3f3f3f3f) cout<<-1<
C
判断四条线段是否可以构成与坐标轴平行或垂直的正方形,感觉数据有点坑
1 #include2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define maxn 500005 7 typedef long long ll; 8 /*#ifndef ONLINE_JUDGE 9 freopen("1.txt","r",stdin);10 #endif */11 12 map ,int>mp;13 map ,int>::iterator it;14 map< pair< pair ,pair >,int >book;15 16 int main(){17 #ifndef ONLINE_JUDGE18 freopen("1.txt","r",stdin);19 #endif20 std::ios::sync_with_stdio(false);21 int a,b,c,d;22 int flag=0;23 for(int i=0;i<4;i++){24 cin>>a>>b>>c>>d;25 mp[make_pair(a,b)]++;26 mp[make_pair(c,d)]++;27 if(a==c&&b==d) flag=1;28 vector >v;29 v.push_back(make_pair(a,b));30 v.push_back(make_pair(c,d));31 sort(v.begin(),v.end());32 if(book[make_pair(v[0],v[1])]==0){33 book[make_pair(v[0],v[1])]=1;34 }35 else{36 flag=1;37 }38 // cout< <<" "< <<" "< <<" "< < second!=2){42 flag=1;43 }44 }45 if(flag){46 cout<<"NO"< >ve;50 for(it=mp.begin();it!=mp.end();it++){51 ve.push_back(it->first);52 }53 sort(ve.begin(),ve.end());54 if(ve[0].first==ve[1].first&&ve[2].first==ve[3].first&&55 ve[0].second==ve[2].second&&ve[1].second==ve[3].second){56 cout<<"YES"<
D
枚举删边,然后跑dfs
1 #include2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define maxn 500005 7 typedef long long ll; 8 /*#ifndef ONLINE_JUDGE 9 freopen("1.txt","r",stdin);10 #endif */11 12 int n;13 vector ve[205];14 vector >d;15 16 int r;17 18 int dfs(int pos,int pre){19 int len1=0,len2=0;20 int tmp=0;21 for(int i=0;i len1){len2=len1,len1=r;}25 else{len2=max(len2,r);}26 }27 }28 tmp=max(tmp,len1+len2);29 r=len1+1;30 return tmp;31 }32 33 int main(){34 #ifndef ONLINE_JUDGE35 freopen("1.txt","r",stdin);36 #endif37 cin>>n;38 int a,b;39 for(int i=1;i >a>>b;41 ve[a].push_back(b);42 ve[b].push_back(a);43 d.push_back(make_pair(a,b));44 }45 int ans=0;46 for(int i=0;i
E
DP,细节在代码里
1 #include2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define maxn 500005 7 typedef long long ll; 8 /*#ifndef ONLINE_JUDGE 9 freopen("1.txt","r",stdin);10 #endif */11 12 ll dp[25][15][5][2];///分别表示第i个数,第j个尖峰数,尖峰高度和上升(1)或下降(0)13 14 int main(){15 #ifndef ONLINE_JUDGE16 // freopen("1.txt","r",stdin);17 #endif18 int n,m;19 for(int i=1;i<5;i++) dp[1][1][i][1]=1;20 for(int i=2;i<=20;i++){21 for(int j=1;j<=10;j++){22 for(int k=1;k<=4;k++){23 for(int l=1;l >n>>m;39 ll ans=0;40 for(int i=1;i<=4;i++){41 ans+=dp[n][m][i][0];42 }43 cout< <