2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Prefer

2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)
http://codeforces.com/contest/730

G. Car Repair Shop
水题,题意是安排日程,因为最迟不得超过客户要求开始的日子,所以是很简单的贪心,检查该段日子是否有安排,没有就安排在该日子,有就提前做,复杂度是O(n²log n)

#include <iostream>
#include <cstdio>
#include <algorithm> 
using namespace std;
typedef long long int ll;
struct node{
    ll a,b;
}day[205];
int cnt;
int check(ll s,ll e){
    int flag = 0;
    for(int j=0;j<cnt;++j){
    if((s<=day[j].a && day[j].a <= e )||(day[j].a<=s && s<=day[j].b)){flag=1;break;}
    }
    return flag;
}
bool cmp(struct node a,struct node b){
    return a.a<=b.a?1:0;
}
int main()
{
    int n;
    cnt=0;
    scanf("%d",&n);
    ll now=1;
    for(int i=1;i<=n;++i){
        ll s,d,e;
        scanf("%lld %lld",&s,&d);
        e=s+d-1;        
        if(check(s,e)){
            now=1;
            for(int k=0;k<cnt;++k){
                if(now+d-1<day[k].a)break;
                else now=day[k].b+1;
            }
            day[cnt].a=now;
            now=now+d-1;
            day[cnt].b=now;     
            printf("%lld %lld\n",day[cnt].a,day[cnt].b);
            cnt++;now++;
            sort(day,day+cnt,cmp);
        }else {
            day[cnt].a=s;
            day[cnt].b=e;       
            printf("%lld %lld\n",s,e);
            cnt++;
            sort(day,day+cnt,cmp);
        }
    }
    return 0;
}

H. Delete Them
水题,问是否存在一个可以匹配所有要删掉的字符串的字符串,并且要求字符串长度相同,也不能误删,其中?可以匹配任意字符

#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
using namespace std;
typedef long long int  ll;
string s[105];
int a[105];
bool re[105];
int main(int argc, const char * argv[]) {
    int m,n;
    while (cin>>n>>m) {
        for (int i=1; i<= n; i++)
            cin>>s[i];
        int flag = 1;
        memset(re, 0, sizeof(re));
        for(int i=1;i<=m;++i)
        {
            cin>>a[i];
            re[a[i]]=true;
        }
        int len = s[a[1]].length();

        string ss = s[a[1]];

        for(int i=2;i<=m;++i)
        {
            if (len != s[a[i]].length()) {
                flag = 0;
                break;
            }
            else {
                for (int j=0; j<len; ++j) {
                    if (ss[j]=='?') continue;
                    if(s[a[i]][j] != ss[j])ss[j] = '?';
                }
            }
        }
        //cout<<ss<<endl;
        for(int i=1;i<=n;++i)
        {
            if(!re[i]){
                if(s[i].length()==len){
                    int ok=0;
                    for (int j=0; j<len; ++j) {
                        if(ss[j]=='?')continue;
                        else if(ss[j]!=s[i][j]){
                            ok=1;break;
                        }
                    }
                    if(!ok){flag=0;break;}
                }
            }
        }
        if(flag)cout<<"Yes"<<endl<<ss<<endl;
        else cout<<"No"<<endl;

    }
    return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值