其他分享
首页 > 其他分享> > ICPC2019银川网 络 赛

ICPC2019银川网 络 赛

作者:互联网

Baidu Star
真实菜鸡,被AK打蒙了,签到都最后才找到的。

A.Maximum Element In A Stack

Problem

栈操作,每次操作后求最大值。

Solution

加入时加此时堆里的最大值,要开long long。

Code

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<map>
#include<set>
#include<bitset>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x7fffffffffffffff
#define mem(a, x) memset(a,x,sizeof(a))
#define io_opt ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef std::pair<int, int> Pii;
typedef std::pair<ll, ll> Pll;
ll power(ll a, ll b,ll p) { ll res = 1; for (; b > 0; b >>= 1) { if (b & 1) res = res * a % p; a = a * a % p; } return res; }
ll gcd(ll p, ll q) { return q == 0 ? p : gcd(q, p % q); }
ll _abs(ll x){return x < 0 ? -x : x;}
using namespace std;
const int mod = 1e9 + 7;
const int N = 5e6+10;

int n,p,q,m;
unsigned int SA,SB,SC;
ll a[N];

stack<unsigned int> s;
unsigned int rng61(){
    SA ^= SA<<16;
    SA ^= SA>>5;
    SA ^= SA<<1;
    unsigned int t = SA;SA = SB;
    SB = SC;
    SC ^= t ^ SA;
    return SC;
}
inline void PUSH(unsigned int x){
    if(s.empty()) s.push(x);
    else s.push(max(x,s.top()));
}
inline void POP(){
    if(!s.empty()) s.pop();
}
void gen(){
    scanf("%d%d%d%d%u%u%u",&n,&p,&q,&m,&SA,&SB,&SC);
    for(int i=1;i<=n;i++){
        if(rng61() % (p+q) < p)
            PUSH(rng61() % m + 1);
        else
            POP();
        if(s.empty()) a[i]=0;
        else a[i]=s.top();
        a[i]*=i;
    }
}
int main(){
    int T;cin >> T;
    for(int i=1;i<=T;i++){
        while(!s.empty()) s.pop();
        gen();
        ll ans=a[1];
        for(int j=2;j<=n;j++)
            ans^=a[j];
        printf("Case #%d: %lld\n",i,ans);
    }
    return 0;
}

B.Rolling The Polygon

一开始看计算几何就没做,最后半小时发现很简单,298分钟过的...

Problem

给一个凸多边形和其内一点,求凸多边形在地下转一周,点走过的距离。

Solution

每个角都走一个圆弧,求出半径和补角,相乘即可。

Code

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x7fffffffffffffff
#define mem(a, x) memset(a,x,sizeof(a))
#define io_opt ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef std::pair<int, int> Pii;
typedef std::pair<ll, ll> Pll;
ll power(ll a, ll b,ll p) { ll res = 1; for (; b > 0; b >>= 1) { if (b & 1) res = res * a % p; a = a * a % p; } return res; }
ll gcd(ll p, ll q) { return q == 0 ? p : gcd(q, p % q); }
ll _abs(ll x){return x < 0 ? -x : x;}
using namespace std;
int T,n;
int cnt=0,sx,sy;
struct E{
    int x,y;
}e[60];

double anss;
double l(int x1,int y1,int x2,int y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+0.0);
}
int main(){
    //cout<<acos(-1/sqrt(2.0));
    //io_opt;
    scanf("%d",&T);
    while(T--){
        anss=0;
        cnt++;
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d%d",&e[i].x,&e[i].y);
        }
        scanf("%d%d",&sx,&sy);
        for(int i=1;i<=n;i++){
            int x1,x2,y1,y2;
            double tmp1=l(sx,sy,e[i].x,e[i].y);
            if(i==1){
                x1=e[n].x-e[1].x,y1=e[n].y-e[1].y;
                x2=e[2].x-e[1].x,y2=e[2].y-e[1].y;
            }
            else if(i==n){
                x1=e[n-1].x-e[n].x,y1=e[n-1].y-e[n].y;
                x2=e[1].x-e[n].x,y2=e[1].y-e[n].y;
            }
            else{
                x1=e[i-1].x-e[i].x,y1=e[i-1].y-e[i].y;
                x2=e[i+1].x-e[i].x,y2=e[i+1].y-e[i].y;
            }

            //cout<<'*'<<y1<<'*'<<endl;
            double tmp2=acos(-1)-(acos((x1*x2+y1*y2)*1.0/l(x1,y1,0,0)/l(x2,y2,0,0)));
            anss+=tmp1*tmp2;
            //cout<<i<<':'<<tmp1<<' '<<tmp2<<endl;
        }
        printf("Case #%d: %.3f\n",cnt,anss);
    }
    return 0;
}

C.Caesar Cipher

Problem

字母后移,给出示范和目标串,求原串。

Solution

模拟

Code

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x7fffffffffffffff
#define mem(a, x) memset(a,x,sizeof(a))
#define io_opt ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef std::pair<int, int> Pii;
typedef std::pair<ll, ll> Pll;
ll power(ll a, ll b,ll p) { ll res = 1; for (; b > 0; b >>= 1) { if (b & 1) res = res * a % p; a = a * a % p; } return res; }
ll gcd(ll p, ll q) { return q == 0 ? p : gcd(q, p % q); }
ll _abs(ll x){return x < 0 ? -x : x;}
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e5+10;
int n,m;
char a[N],b[N],c[N],ans[N];
int main(){
    int T;scanf("%d",&T);
    for(int i=1;i<=T;i++){
        scanf("%d%d",&n,&m);
        scanf("%s%s%s",a,b,c);
        int d=b[0]-a[0];
        int j=0;
        for(j=0;j<m;j++){
            int ss=c[j]-d;
            while(ss<'A') ss+=26;
            while(ss>'Z') ss-=26;
            ans[j]=ss;
        }
        ans[j]='\0';
        printf("Case #%d: %s\n",i,ans);
    }
    return 0;
}

Continue...

标签:return,int,res,ll,ICPC2019,include,银川,define
来源: https://www.cnblogs.com/sz-wcc/p/11440171.html