其他分享
首页 > 其他分享> > NOIP多校联考7

NOIP多校联考7

作者:互联网

来自世间,一对平凡的夫妻身旁;来自昨天,谁以青春赴万丈理想?

我是寸土不让的家乡啊,我是永不低头的倔强啊,接过万千热血的初衷,当有对答世界的音量!

A.计算器(calc)

依然不知道为什么会错,但是先按正解改一下好了……

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int maxn = 105;
const ll mod = 1e9 + 7;
const int INF = 0x7ffffff;

int n, k, cnt[maxn], ma, mb, mc, md;
ll Max;

inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0')
    {
        if(ch == '-')
        {
            f = -1;
        }
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        x = (x << 1) + (x << 3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}

struct node 
{
    int id, a, b, c, d;
    bool operator < (const node &T) const 
    {
        return id < T.id;
    }
}p[maxn];

ll query(int a, int b, int c, int d)
{
    return (ll)(100+a)*(100+b)*(100+c)*(100+d);
}

int main()
{
    n = read(); k = read();
    for(int i=1; i<=n; i++)
    {
        p[i].id = read(); p[i].a = read(); p[i].b = read();
        p[i].c = read(); p[i].d = read();
        cnt[p[i].id]++;
    }
    sort(p+1, p+1+n);
    for(int i=1; i<=k; i++)
    {
        cnt[i] += cnt[i-1];
    }
    for(int i=1; i<=k; i++)
    {
        int ha = ma, hb = mb, hc = mc, hd = md;
        for(int j=cnt[i-1]+1; j<=cnt[i]; j++)
        {
            int a = ma+p[j].a, b = mb+p[j].b, c = mc+p[j].c, d = md+p[j].d;
            ll res = query(a, b, c, d);
            if(res > Max)
            {
                Max = res;
                ha = a; hb = b; hc = c; hd = d;
            }
        }
        ma = ha; mb = hb; mc = hc; md = hd;
    }
    printf("%lld", Max);
    
    return 0;
}
WA 60eps

感谢能指出以上代码问题的大佬***%%%

B.对称轴(symmetry)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int maxn = 2e5 + 3;
const ll mod = 1e9 + 7;
const int INF = 0x7ffffff;

int T, n, ans;
double x_1, y_1;

inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0')
    {
        if(ch == '-')
        {
            f = -1;
        }
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        x = (x << 1) + (x << 3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}

struct node 
{
    int x, y;
}p[maxn];

double get_k(double x_1, double y_1, double x_2, double y_2)
{
    if(x_1 == x_2) return 1.0*INF;
    if(y_1 == y_2) return 0.0;
    return (y_1-y_2) / (x_1-x_2);
}

bool check(int l, int r, int a, int b, int k)
{
    while(l > a && r > b)
    {
        double x_3 = (p[l].x+p[r].x)/2.0, y_3 = (p[l].y+p[r].y)/2.0;
        double k2 = get_k(x_1, y_1, x_3, y_3);
        l--; r++;                     
        if(abs(k-k2) > 1e-6) return 0;
    }
    return 1;
}

bool check2(int l, int r, int k)
{
    while(l < r)
    {
        double x_3 = (p[l].x+p[r].x)/2.0, y_3 = (p[l].y+p[r].y)/2.0;
        double k2 = get_k(x_1, y_1, x_3, y_3);
        l++; r--;
        if(abs(k-k2) > 1e-6) return 0;
    }
    return 1;
}

bool check3(int l, int r, int k)
{
    while(l < r)
    {
        double x_3 = (p[l].x+p[r].x)/2.0, y_3 = (p[l].y+p[r].y)/2.0;
        double k2 = get_k(x_1, y_1, x_3, y_3);
        l++; r--;
        if(abs(k-k2) > 1e-6) return 0;
    }
    double x_3 = p[l].x, y_3 = p[l].y;
    double k2 = get_k(x_1, y_1, x_3, y_3);
    if(abs(k-k2) > 1e-6) return 0;
    return 1;
}

double get_len(double x_1, double y_1, double x_2, double y_2)
{
    return (x_1-x_2)*(x_1-x_2)+(y_1-y_2)*(y_1-y_2);
}

int main()
{
    T = read();
    while(T--)
    {
        n = read(); ans = 0;
        for(int i=1; i<=n; i++)
        {
            p[i].x = read(); p[i].y = read();
            p[n+i].x = p[i].x; p[n+i].y = p[i].y;
        }
        if(n & 1)
        {
            for(int i=1; i<=n/2; i++)
            {
                int j = i+n-1;
                int lmax = (i+j)>>1, rmin = lmax+1;
                x_1 = p[i].x, y_1 = p[i].y;
                int l = lmax, r = rmin;
                double x_2 = (p[l].x+p[r].x)/2.0, y_2 = (p[l].y+p[r].y)/2.0;
                if(get_len(x_1, y_1, p[l].x, p[l].y) != get_len(x_1, y_1, p[r].x, p[r].y))
                {
                    continue;
                }
                double k = get_k(x_1, y_1, x_2, y_2);
                l--; r++;
                if(check(l, r, i, i+n, k)) ans++;
            }
        }
        else 
        {
            for(int i=1; i<=n/2; i++)
            {
                int j = i+n-1;
                int l = i, r = j;
                x_1 = (p[l].x+p[r].x)/2, y_1 = (p[l].y+p[r].y)/2;
                l++; r--;
                double x_2 = (p[l].x+p[r].x)/2.0, y_2 = (p[l].y+p[r].y)/2.0;
                double k = get_k(x_1, y_1, x_2, y_2);
                l++; r--;;
                if(check2(l, r, k)) ans++;
            }
            for(int i=1; i<=n/2; i++)
            {
                int j = i+n;
                int l = i, r = j;
                x_1 = p[l].x, y_1 = p[l].y;
                l++; r--;
                double x_2 = (p[l].x+p[r].x)/2.0, y_2 = (p[l].y+p[r].y)/2.0;
                if(get_len(x_1, y_1, p[l].x, p[l].y) != get_len(x_1, y_1, p[r].x, p[r].y))
                {
                    continue;
                }
                double k = get_k(x_1, y_1, x_2, y_2);
                l++; r--;
                if(check3(l, r, k)) ans++;
            }
        }
        printf("%d\n", ans);
    }
    
    return 0;
}
赛时TLE 20eps

就是直接枚举对称轴的直线斜率。。我也不知道我为什么心血来潮的想调它,就调了3个小时。。。

结果就是T3和T4没时间审题了。。。

D.签到题(qiandao)

我没到,,或者说,,我迟到了

未完待续……

标签:ch,return,NOIP,get,int,double,多校,2.0,联考
来源: https://www.cnblogs.com/Catherine2006/p/16528590.html