您的位置:首页 > 其它

2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest

2016-07-28 22:57 393 查看
2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)

CodeForces 589A

思路:暴力模拟,注意读题,dots和‘+’到‘@’可忽略均有条件。

/*************************************************************************
File Name: A.cpp
ID: obsolescence
BLOG: http://blog.csdn.net/obsolescence LANG: C++
Mail: 384099319@qq.com
Created Time: 2016年07月28日 星期四 13时14分02秒
************************************************************************/
#include<bits/stdc++.h>
#define Max(x,y) ((x)>(y)?(x):(y))
#define Min(x,y) ((x)<(y)?(x):(y))
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();++it)
#define Abs(x,y) ((x)>(y)?((x)-(y)):((y)-(x)))
#define ll long long
#define Mem0(x) memset(x,0,sizeof(x))
#define Mem1(x) memset(x,-1,sizeof(x))
#define MemX(x) memset(x,0x3f,sizeof(x))
#define pb push_back
using namespace std;
const int N=20010;
struct node{
string s;
int ord;
bool operator < (const node &rhs) const {
return ord < rhs.ord;
}
}str
;
map<string,int> my_map;
int cnt
;

int main() {
int n,i,j;
ios::sync_with_stdio(0);
while (cin>>n) {
int top=0;
Mem0(cnt);
for (i=0; i<n; ++i) {
cin>>str[i].s;
for (j=0; str[i].s[j]; ++j)
if (str[i].s[j]=='@') break;
string tmp="",tmp1="bmail.com",tmp2="";
for (++j; str[i].s[j]; ++j) {
if (str[i].s[j]>='A' && str[i].s[j]<='Z') tmp+=str[i].s[j]-'A'+'a';
else tmp+=str[i].s[j];
}
//cout<<"tmp="<<tmp<<endl;
bool flag=0;
if (tmp==tmp1) flag=1;
for (j=0; str[i].s[j]; ++j) {
if (str[i].s[j]=='@') {
tmp2+=str[i].s[j];
break;
}
if (str[i].s[j]=='.' && flag) continue;
if (str[i].s[j]=='+' && flag) {
while (str[i].s[j+1]!='@') ++j;
} else if (str[i].s[j]>='A' && str[i].s[j]<='Z') {
tmp2+=str[i].s[j]-'A'+'a';
} else tmp2+=str[i].s[j];
}
tmp2+=tmp;
if (!my_map[tmp2]) {
my_map[tmp2]=++top;
}
//cout<<"tmp2="<<tmp2<<endl;
cnt[my_map[tmp2]]++;
str[i].ord=my_map[tmp2];
}
cout<<top<<'\n';
sort(str,str+n);
for (i=0; i<n;) {
int tmp=cnt[str[i].ord];
cout<<tmp;
while (tmp--) {
cout<<' '<<str[i].s;
++i;
}
cout<<'\n';
}
}
}


CodeForces 589B

思路:令x有序后,暴力枚举y

/*************************************************************************
File Name: B.cpp
ID: obsolescence
BLOG: http://blog.csdn.net/obsolescence LANG: C++
Mail: 384099319@qq.com
Created Time: 2016年07月28日 星期四 14时01分33秒
************************************************************************/
#include<bits/stdc++.h>
#define Max(x,y) ((x)>(y)?(x):(y))
#define Min(x,y) ((x)<(y)?(x):(y))
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();++it)
#define Abs(x,y) ((x)>(y)?((x)-(y)):((y)-(x)))
#define ll long long
#define Mem0(x) memset(x,0,sizeof(x))
#define Mem1(x) memset(x,-1,sizeof(x))
#define MemX(x) memset(x,0x3f,sizeof(x))
#define pb push_back
using namespace std;
const int N=4010;
struct node{
ll a,b;
bool operator < (const node &rhs) const {
return a < rhs.a;
}
}cake
;
ll b
;

int main() {
int n,i,j,k;
while (cin>>n) {
for (i=0; i<n; ++i) {
cin>>cake[i].a>>cake[i].b;
if (cake[i].a<cake[i].b)
swap(cake[i].a,cake[i].b);
}
sort(cake,cake+n);
ll ans=0,tmp,ansA,ansB;
for (i=0; i<n; ++i) {
for (j=i,k=0; j<n; ++j)
b[k++]=cake[j].b;
sort(b,b+k);
for (j=0; j<k; ++j) {
tmp=cake[i].a*b[j]*(k-j);
if (ans<tmp) {
ans=tmp;
ansA=cake[i].a;
ansB=b[j];
}
}
}
cout<<ans<<'\n'<<ansA<<' '<<ansB<<'\n';
}
}


CodeForces 589C

CodeForces 589D

CodeForces 589E

CodeForces 589F

思路:二分+贪心。二分时间,贪心的去安排最大不相交区间(即令b升序排序,具体证明参考此处

/*************************************************************************
File Name: F.cpp
ID: obsolescence
BLOG: http://blog.csdn.net/obsolescence LANG: C++
Mail: 384099319@qq.com
Created Time: 2016年07月28日 星期四 22时05分04秒
************************************************************************/
#include<bits/stdc++.h>
#define Max(x,y) ((x)>(y)?(x):(y))
#define Min(x,y) ((x)<(y)?(x):(y))
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();++it)
#define Abs(x,y) ((x)>(y)?((x)-(y)):((y)-(x)))
#define ll long long
#define Mem0(x) memset(x,0,sizeof(x))
#define Mem1(x) memset(x,-1,sizeof(x))
#define MemX(x) memset(x,0x3f,sizeof(x))
#define pb push_back
using namespace std;
const int N=110,M=1e5+10,INF=0x3f3f3f3f;
struct node{
int a,b;
bool operator < (const node &rhs) const {
return b<rhs.b;
}
}t
;
bool f[M];

int main() {
int n,i,j;
while (~scanf("%d",&n)) {
int maxn=0,minn=INF,min_dis=INF;
for (i=0; i<n; ++i) {
scanf("%d%d",&t[i].a,&t[i].b);
minn=Min(minn,t[i].a);
maxn=Max(maxn,t[i].b);
min_dis=Min(min_dis,t[i].b-t[i].a);
}
sort(t,t+n);
int low=0,high=Min(min_dis,(maxn-minn)/n),mid,ans=0;
while (low<=high) {
Mem0(f);
mid=(low+high)>>1;
//cout<<"low="<<low<<" high="<<high<<" mid="<<mid<<endl;
int cnt,flag=0;
for (i=0; i<n; ++i) {
cnt=0;
for (j=t[i].a; j<t[i].a+mid+cnt; ++j)
if (f[j]) cnt++;
else f[j]=1;
if (j>t[i].b) flag=1;
}
if (!flag) low=mid+1,ans=mid;
else high=mid-1;
}
printf("%d\n",ans*n);
}
}


CodeForces 589G

CodeForces 589H

CodeForces 589I 水题,签到题

CodeForces 589J

思路:bfs

/*************************************************************************
File Name: J.cpp
ID: obsolescence
BLOG: http://blog.csdn.net/obsolescence LANG: C++
Mail: 384099319@qq.com
Created Time: 2016年07月28日 星期四 15时39分32秒
************************************************************************/
#include<bits/stdc++.h>
#define Max(x,y) ((x)>(y)?(x):(y))
#define Min(x,y) ((x)<(y)?(x):(y))
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();++it)
#define Abs(x,y) ((x)>(y)?((x)-(y)):((y)-(x)))
#define ll long long
#define Mem0(x) memset(x,0,sizeof(x))
#define Mem1(x) memset(x,-1,sizeof(x))
#define MemX(x) memset(x,0x3f,sizeof(x))
#define pb push_back
using namespace std;
const int N=15;
char mp

,dir[]={'U','R','D','L'};
bool vis

[5],check

;
int mx[]={-1,0,1,0},my[]={0,1,0,-1};
struct node{
int x,y,step,d;
}s,t;

int main() {
int h,w,i,j,k;
while (~scanf("%d%d",&h,&w)) {
Mem0(vis),Mem0(check);
for (i=0; i<h; ++i) {
scanf("%s",mp[i]);
for (j=0; j<w; ++j)
if (mp[i][j]!='.' && mp[i][j]!='*') {
s.x=i,s.y=j,s.step=1;
for (k=0; k<4; ++k)
if (mp[i][j]==dir[k]) s.d=k;
}
}
queue<node> q;
q.push(s);
check[s.x][s.y]=1;
int ans=1;
while (!q.empty()) {
s=q.front();
q.pop();
ans=Max(ans,s.step);
t=s,t.x+=mx[t.d],t.y+=my[t.d];
int cnt=0;
while (t.x<0 || t.x>=h || t.y<0 || t.y>=w) {
cnt++;
s.d=(s.d+1)%4;
t=s,t.x+=mx[t.d],t.y+=my[t.d];
if(cnt>=4)break;
}
if (t.x>=0 && t.x<h && t.y>=0 && t.y<w) {
if (vis[t.x][t.y][t.d]) break;
vis[t.x][t.y][t.d]=1;
if (mp[t.x][t.y]!='*') {
if (!check[t.x][t.y]) {
t.step++;
check[t.x][t.y]=1;
}
q.push(t);
} else {
s.d=(s.d+1)%4;
q.push(s);
}
}
}
printf("%d\n",ans);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: