Codeforces Beta Round #44 (Div. 2)

时间:2023-01-31 12:32:40

Codeforces Beta Round #44 (Div. 2)

http://codeforces.com/contest/47

A

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define maxn 1000005
typedef long long ll;
typedef unsigned long long ull; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
map<int,int>mp;
for(int i=;i<=;i++){
mp[i*(i+)/]=;
}
int n;
cin>>n;
if(mp[n]) cout<<"YES"<<endl;
else cout<<"NO"<<endl; }

B

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define maxn 1000005
typedef long long ll;
typedef unsigned long long ull; struct sair{
char ch;
int v;
bool operator<(const sair &b)const{
return v>b.v;
}
}s; int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int a,b,c;
string str;
map<char,int>mp;
mp['A']++;
mp['B']++;
mp['C']++;
for(int i=;i<=;i++){
cin>>str;
if(str[]=='>'){
mp[str[]]++;
}
else{
mp[str[]]++;
}
}
vector<sair>ve;
int book[];
memset(book,,sizeof(book));
for(map<char,int>::iterator it=mp.begin();it!=mp.end();it++){
s.ch=it->first;
s.v=it->second;
if(book[s.v]){
cout<<"Impossible"<<endl;
return ;
}
book[s.v]=;
ve.push_back(s);
}
sort(ve.begin(),ve.end());
for(int i=;i<ve.size();i++){
cout<<ve[i].ch;
} }

C

大模拟

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define maxn 1000005
typedef long long ll;
typedef unsigned long long ull; vector<string>ans;
string s[];
bool add(char &a,char b){if (a!='.'&&a!=b)return ;a=b;return ;} int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
for (int i=;i<=;i++)cin>>s[i];
sort(s,s+);
do{
vector<string>v(s[].size(),string(s[].size(),'.'));
if (s[].size()!=s[].size()+s[].size()-) continue;
if (s[].size()!=s[].size()+s[].size()-) continue;
bool fl=;
for (int i=;i<s[].size();i++)fl&=add(v[i][s[].size()-],s[][i]);
for (int i=;i<s[].size();i++)fl&=add(v[s[].size()-][i],s[][i]);
for (int i=;i<s[].size();i++)fl&=add(v[][i],s[][i]);
for (int i=;i<s[].size();i++)fl&=add(v[i][],s[][i]);
for (int i=;i<s[].size();i++)fl&=add(v[s[].size()-+i][s[].size()-],s[][i]);
for (int i=;i<s[].size();i++)fl&=add(v[s[].size()-][s[].size()-+i],s[][i]);
if (!fl) continue;
if (ans.empty()||v<ans) ans=v;
}while (next_permutation(s,s+));
if (ans.empty()) cout<<"Impossible"<<endl;
else for(auto i:ans) cout<<i<<endl;
}

D

暴力搜索

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define maxn 1000005
typedef long long ll;
typedef unsigned long long ull; char s[][];
int c[],n,m,ans;
void dfs(int t)
{
int i,j;
for(i=;i<m;i++)
if(c[i]<)return ;
if(t>=n)
{
for(i=;i<m;i++)
if(c[i]>) return ;
ans++;
return ;
}
for(i=;i<=;i++)
{
for(j=;j<m;j++)
if(s[j][t]==(i+''))c[j]--;
dfs(t+);
for(j=;j<m;j++)
if(s[j][t]==(i+''))c[j]++;
}
} int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n>>m;
for(int i=;i<m;i++)cin>>s[i]>>c[i];
ans=;
dfs();
cout<<ans<<endl;
}

E

几何,把子弹按角度从小到大排序,然后模拟

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define maxn 1000005
typedef long long ll;
typedef unsigned long long ull; const double g=9.8;
double v,al[],ss[],cc[];
int d[];
pair<double,double> w[];
double x[]; double run(double x,double alpha)
{
return (v*sin(alpha)+v*sin(alpha)-g*x/(v*cos(alpha)))*x/(v*cos(alpha))/;
}
bool cmp(const int &a,const int &b)
{
return al[a]<al[b];
} int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n,m;
scanf("%d%lf",&n,&v);
for(int i=;i<=n;i++)
scanf("%lf",&al[d[i]=i]),cc[i]=cos(al[i]),ss[i]=sin(al[i]);
sort(d+,d++n,cmp);
scanf("%d",&m);
for(int i=;i<=m;i++)
scanf("%lf%lf",&w[i].first,&w[i].second);
sort(w+,w++m);
int j=;
for(int i=;i<=n;i++)
{
while(j<=m&&run(w[j].first,al[d[i]])>w[j].second)j++;
if(j>m||run(w[j].first,al[d[i]])<)
{
x[d[i]]=v*ss[d[i]]/g**v*cc[d[i]];
continue;
}
x[d[i]]=w[j].first;
}
for(int i=;i<=n;i++)
printf("%.9lf %.9lf\n",x[i],run(x[i],al[i]));
}