2017 United Kingdom and Ireland Programming Contest - A ~ L - (Undone) - (Online)(Solved 10 problems)

链接:https://codeforces.com/gym/101606


A - Alien Sunset

暴力枚举小时即可。

#include<bits/stdc++.h>
using namespace std;
const int maxn=23;
int n;
int h[maxn],r[maxn],s[maxn];
inline bool dark(int id,int time)
{
    if(r[id]<s[id])
    {
        if(r[id]<time && time<s[id]) return 0;
        else return 1;
    }
    if(r[id]>s[id])
    {
        if(s[id]<=time && time<=r[id]) return 1;
        else return 0;
    }
}
int main()
{
    cin>>n;
    int mx=0;
    for(int i=1;i<=n;i++) cin>>h[i]>>r[i]>>s[i], mx=max(h[i],mx);

    for(int time=0;time<mx*1825;time++)
    {
        bool ok=1;
        for(int i=1;i<=n;i++) if(!dark(i,time%h[i])) ok=0;
        if(ok)
        {
            cout<<time<<endl;
            return 0;
        }
    }
    cout<<"impossible"<<endl;
}

B - Breaking Biscuits - (Undone)


C - Cued In - [水]

#include<bits/stdc++.h>
using namespace std;
int n;
string s;
map<string,int> mp;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    mp["red"]=1,
    mp["yellow"]=2,
    mp["green"]=3,
    mp["brown"]=4,
    mp["blue"]=5,
    mp["pink"]=6,
    mp["black"]=7;

    cin>>n;
    int red=0, sum=0, mx=0;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        mx=max(mx,mp[s]);
        if(s=="red") red++;
        else sum+=mp[s];
    }

    if(red==n) cout<<"1\n";
    else if(red==0) cout<<sum<<‘\n‘;
    else cout<<red*(mx+1)+sum<<‘\n‘;
}

D - Deranging Hat - (Undone)


E - Education - [贪心]

$O(n^2)$ 时间复杂度的贪心。

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define fi first
#define se second
const int maxn=5e3+10;

int n,m;
P s[maxn];
int ans[maxn];

struct F{
    int id;
    int capa,rent;
    bool operator<(const F& o)
    {
        return capa>o.capa;
    }
}f[maxn];
bool vis[maxn];

int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++) scanf("%d",&s[i].fi), s[i].se=i;
    sort(s+1,s+n+1,greater<P>{});

    //for(int i=1;i<=n;i++) printf("%d %d\n",s[i].fi,s[i].se);

    for(int i=1;i<=m;i++) f[i].id=i;
    for(int i=1;i<=m;i++) scanf("%d",&f[i].capa);
    for(int i=1;i<=m;i++) scanf("%d",&f[i].rent);
    sort(f+1,f+m+1);

    //for(int i=1;i<=m;i++) printf("%d: %d %d\n",f[i].id,f[i].capa,f[i].rent);

    memset(vis,0,sizeof(vis));
    memset(ans,0,sizeof(ans));
    for(int i=1;i<=n;i++)
    {
        int mn=1e3+50, mnid=0;
        for(int j=1;j<=m && f[j].capa>=s[i].fi;j++)
        {
            if(vis[j]) continue;
            if(f[j].rent<mn)
            {
                mn=f[j].rent;
                mnid=j;
            }
        }
        vis[mnid]=1;
        ans[s[i].se]=f[mnid].id;
    }
    bool ok=1;
    for(int i=1;i<=n;i++) if(ans[i]==0) ok=0;
    if(ok) for(int i=1;i<=n;i++) printf("%d ",ans[i]);
    else printf("impossible");
    cout<<endl;
}

F - Flipping Coins - [概率DP]


H - Hiking - (Undone)


I - I Work All Day - (Undone)


J - Just A Minim - [水]

#include<bits/stdc++.h>
using namespace std;
int n;
double t[20];
int main()
{
    t[0]=2.0;
    t[1]=1.0;
    t[2]=1.0/2.0;
    t[4]=1.0/4.0;
    t[8]=1.0/8.0;
    t[16]=1.0/16.0;

    cin>>n;
    double res=0.0;
    for(int i=1,x;i<=n;i++)
    {
        scanf("%d",&x);
        res+=t[x];
    }
    printf("%.7f\n",res);
}

L - Lizard Lounge - [计算几何+LIS]

原文地址:https://www.cnblogs.com/dilthey/p/10703153.html

时间: 2024-11-01 23:52:58

2017 United Kingdom and Ireland Programming Contest - A ~ L - (Undone) - (Online)(Solved 10 problems)的相关文章

The North American Invitational Programming Contest 2017 题目

NAIPC 2017 Yin and Yang Stones 75.39% 1000ms 262144K A mysterious circular arrangement of black stones and white stones has appeared. Ming has been tasked with balancing the stones so that only one black and one white stone remain. Ming has two opera

(寒假开黑gym)2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)

layout: post title: (寒假开黑gym)2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017) author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces 传送门 付队! 许老师! B.Buildings (polya定理) 题意 B:给你m面墙,每面墙是n*n的格子,你有c种颜色,问你有多少种涂色方案.用po

2017 UESTC Training for Dynamic Programming

2017 UESTC Training for Dynamic Programming A    思维, 或 dp, 很有意思 方法1: 构造法:蛇形安排赛程表算法复杂度:O(N^2)将1-N排成两竖列,每一轮同一行的为对手保持1的位置不变,其他位置按顺(逆)时方向依次旋转1    6          1    2          1    3          1    4          1    5      2    5          3    6          4   

ZOJ 3703 Happy Programming Contest(0-1背包)

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3703 Happy Programming Contest Time Limit: 2 Seconds      Memory Limit: 65536 KB In Zhejiang University Programming Contest, a team is called "couple team" if it consists of only two s

Happy Programming Contest zoj3703 dp

Description In Zhejiang University Programming Contest, a team is called "couple team" if it consists of only two students loving each other. In the contest, the team will get a lovely balloon with unique color for each problem they solved. Sinc

Bentley MX V8i United Kingdom 08.11.09.845 1DVD

Bentley MX V8i United Kingdom 08.11.09.845 1DVDBentley.PULS.XM.V8.9.0.28 数字管道脉动分析Bentley.AutoPIPE.8i.v09.01.01.02Bentley Rail Track V8i 08.11.09.845 Win64 1CD Bentley Power GEOPAK V8i v08.11.09.845 1DVD Bentley Power InRoads V8i v08.11.09.845 1DVD Be

ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2018) Syria, Lattakia, Tishreen University, April, 30, 2018

ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2018) Syria, Lattakia, Tishreen University, April, 30, 2018 Problem A. Can Shahhoud Solve it? Problem B. Defeat the Monsters Problem C. UCL Game Night Problem

The 2018 ACM-ICPC China JiangSu Provincial Programming Contest快速幂取模及求逆元

题目来源 The 2018 ACM-ICPC China JiangSu Provincial Programming Contest 35.4% 1000ms 65536K Persona5 Persona5 is a famous video game. In the game, you are going to build relationship with your friends. You have N friends and each friends have his upper b

ACM International Collegiate Programming Contest, JUST Collegiate Programming Contest (2018)

ACM International Collegiate Programming Contest, JUST Collegiate Programming Contest (2018) B. New Assignment 有n个人(1?≤?n?≤?104),有男有女,每个人都有一个id,现在这n个人分成学习互助小组,有三种组队模式,一个男人一组,一个女人一组,一男一女一组,如果要一男一女一组,那么这两人id的gcd要>1.保证任意三个人的gcd=1.求小组的组数最少是多少? 看起来是一个很裸的二