Codeforces Round #367 Div. 2 [11110]

#include <iostream>
#include <map>
#include <math.h>
using namespace std;
int main()
{
    double a, b;
    cin >> a >> b;
    int n;
    cin >> n;
    double MIN = 1e10;
    while (n--)
    {
        double x, y, v;
        cin >> x >> y >> v;
        double tmp = sqrt((a - x) * (a - x) + (b - y) * (b - y)) / v;
        if (tmp < MIN) MIN = tmp;
    }
    printf("%.10lf\n",MIN);
    return 0;
}

#include <iostream>
#include <map>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int x[100000];

int main()
{
    int n, q;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> x[i];
    sort(x, x + n);
    cin >> q;
    while (q--)
    {
        int m;
        cin >> m;
        if (m < x[0])
        {
            cout << 0 << endl;
            continue;
        }
        if (m >= x[n - 1])
        {
            cout << n << endl;
            continue;
        }
        int l = 0, r = n - 1, mid;
        while (1)
        {
            mid = (l + r) >> 1;
            if (m < x[mid]) r = mid;
            else l = mid;
            if (l == r || l + 1 == r) break;
        }
        cout << l + 1 << endl;
    }
    //system("pause");
    return 0;
}

f[i][0]表示把前i个排好序且第i个不翻转的最小代价,f[i][1]表示把前i个排好序且第i个翻转的最小代价。

#include <iostream>
#include <map>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

long long dp[110000][2];
bool cmp[110000][2][2];
long long c[110000];
string s[110000], r[110000];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> c[i];
    for (int i = 1; i <= n; i++)
    {
        cin >> s[i];
        r[i] = s[i];
        reverse(r[i].begin(), r[i].end());
    }
    for (int i = 2; i <= n; i++)
    {
        if (s[i - 1] <= s[i]) cmp[i][0][0] = true;
        else cmp[i][0][0] = false;
        if (r[i - 1] <= s[i]) cmp[i][0][1] = true;
        else cmp[i][0][1] = false;
        if (s[i - 1] <= r[i]) cmp[i][1][0] = true;
        else cmp[i][1][0] = false;
        if (r[i - 1] <= r[i]) cmp[i][1][1] = true;
        else cmp[i][1][1] = false;
    }
    dp[1][0] = 0;
    dp[1][1] = c[1];
    for (int i = 2; i <= n; i++)
    {
        dp[i][0] = 1e15;
        if (cmp[i][0][0] && dp[i - 1][0] < dp[i][0])
            dp[i][0] = dp[i - 1][0];
        if (cmp[i][0][1] && dp[i - 1][1] < dp[i][0])
            dp[i][0] = dp[i - 1][1];
        dp[i][1] = 1e15;
        if (cmp[i][1][0] && dp[i - 1][0] + c[i] < dp[i][1])
            dp[i][1] = dp[i - 1][0] + c[i];
        if (cmp[i][1][1] && dp[i - 1][1] + c[i] < dp[i][1])
            dp[i][1] = dp[i - 1][1] + c[i];
    }
    long long ans;
    if (dp[n][0] < dp[n][1]) ans = dp[n][0];
    else ans = dp[n][1];
    if (ans == 1e15) cout << -1 << endl;
    else cout << ans << endl;
    //system("pause");
    return 0;
}

#include<bits/stdc++.h>
#include<set>
using namespace std;

multiset<int> ms;

int main()
{
    int n;
    cin >> n;
    ms.clear();
    ms.insert(0);
    while (n--)
    {
        char ch;
        int x;
        cin >> ch >> x;
        if (ch == ‘+‘) ms.insert(x);
        if (ch == ‘-‘) ms.erase(ms.find(x));
        if (ch == ‘?‘)
        {
            int ans = 0;
            for (int i = 30; i >= 0; i--)
            {
                int tmp;
                if ((x & (1 << i)) == 0)
                {
                    tmp = ans | (1 << i);
                    auto it = ms.lower_bound(tmp);
                    if (it == ms.end()) continue;
                    if ((*it) - tmp >= (1 << i)) continue;
                    if ((*it) & (1 << i)) ans |= (1 << i);
                }
                else
                {
                    auto it = ms.lower_bound(ans);
                    int debug = *it;
                    if ((*it) & (1 << i)) ans |= (1 << i);
                }
            }
            cout << (ans ^ x) << endl;
        }
    }
    return 0;
}

时间: 2024-10-12 14:32:25

Codeforces Round #367 Div. 2 [11110]的相关文章

Codeforces Round #367 (Div. 2) D. Vasiliy&#39;s Multiset

题目链接:Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset 题意: 给你一些操作,往一个集合插入和删除一些数,然后?x让你找出与x异或后的最大值 题解: trie树xjb搞就行,每次要贪心,尽量满足高位为1. 1 #include<bits/stdc++.h> 2 #define F(i,a,b) for(int i=a;i<=b;i++) 3 using namespace std; 4 5 namespace trie 6 {

Codeforces Round #367 (Div. 2)

A. Beru-taxi (Codeforces 706A) 水题,求一下到每个点的距离,取最小值即可 #include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> #define N using namespace std; int n,x,y,p,q,s; double t,ans=1000000000; int main() { scanf("%d%d%d&

Codeforces Round #367 (Div. 2) 题解

A code: #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #define maxn 1005 using namespace std; int main() { double ans,tans; double x0,y0,x,y,v; cin >> x0 >> y0; ans

Codeforces Round #363 Div.2[11110]

好久没做手生了,不然前四道都是能A的,当然,正常发挥也是菜. A:Launch of Collider 题意:20万个点排在一条直线上,其坐标均为偶数.从某一时刻开始向左或向右运动,速度为每秒1个单位长度.输入给出每个点的坐标及其移动的方向,求发生第一次碰撞的时间,若不会碰撞,则输出-1 最先发生碰撞的是一定是初始时相邻的两个点,因此只需对每个点循环一边,判断其是否会与下一个点碰撞,并求出其时间即可. #include<stdio.h> #include<stdlib.h> int

Codeforces Round #367 (Div. 2) ABCD

A. Beru-taxi 题解: 水,求下距离就行了 代码: #include<bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define se second #define fs first #define ll long long #define CLR(x) memset(x,0,sizeof x) #define MC(x,y) memcpy(x,y,sizeof(x)) #

Codeforces Round #367 (Div. 2) 套题

吐槽:只能说是上分好场,可惜没打,唉 A:Beru-taxi (水题,取最小值) #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string>

Codeforces Round #365 Div.2[11110]

血崩,做了俩小时只过了一道题,低级错误疯狂的犯.幸好不知道为什么貌似没算分,不然rating要爆炸. A:呵呵 #include<stdio.h> #include<stdlib.h> int main() { //freopen("input.txt","r",stdin) ; int N; scanf("%d",&N); int x=0,y=0; for (int i=1;i<=N;i++) { int

Codeforces Round #279 (Div. 2) ABCD

Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard input/

Codeforces Round #428 (Div. 2)

Codeforces Round #428 (Div. 2) A    看懂题目意思就知道做了 #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define rep(i,a,b) for (int i=a; i<=b; ++i) #define per(i,b,a) for (int i=b; i>=a; --i