ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

HZNU Training 2 for Zhejiang Provincial Collegiate Programming Contest 2019

2019-04-10 19:38:03  阅读:330  来源: 互联网

标签:Provincial Training orz Contest int scanf ++ ans include


赛后总结:

    T:今天下午参加了答辩比赛,没有给予队友很大的帮助。远程做题的时候发现队友在H上遇到了挫折,然后我就和她们说我看H吧,她们就开始做了另外两道题。今天一人一道题。最后我们在研究一道dp的时候,被疯狂卡时间和内存,也是最后三十分钟开始写的,感觉受到了挫折。┭┮﹏┭┮

 

 

题解:

    

E - Coins POJ - 1742 
F - Break Standard Weight ZOJ - 3706 
G - Frets On Fire CodeForces - 1119D 
H - Pavel and Triangles CodeForces - 1119E 

    题意:给你n种木柜,An-1种木棍表示为2^(n-1)的长度有多少根,问你最多可以组成几种不同的等腰或等边三角形。

 贪心。因为第一根木棍长度最小,无法成为后面三角形的腰,所以减去等边三角形,只能作为底边。然后对于1~n-1的边长,先看能分成几个2,与底边总数进行比较,然后取小的。接下来就是一系列删减的操作。当然也要算等边三角形的啦。

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
using namespace std;
const int maxn = 3e5+50;
#define MAX_DISTANCE 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define ll long long
#define SIGN(A) ((A > 0) ? 1 : -1) 
#define NO_DISTANCE 1000000
const double INF = 10000000000.00;
#define LL long long int 
#define mod 1000000007
int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); }
int n;
ll a[maxn],num;
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%lld", &a[i]);
    ll ans = a[0] / 3;
    a[0] %= 3;
    ll sum = a[0];
    for (int i = 1; i < n; i++)
    {
        num = min(sum, a[i] / 2);
        ans += num;
        sum -= num;
        a[i] -= num*2;
        ans += a[i] / 3;
        a[i] %= 3;
        sum += a[i];
    }
    cout << ans<<endl;
    return 0;
}
View Code
I - Tesla CodeForces - 996C 

    题意:一个4*n大小的停车场,第一行和第四行为有编号停车位,中间两行为带有编号的车辆。车辆需要停到对应的编号车位里。车辆可以进行左右移动,以及在边缘进行上下移动,移动一下算一步。如果可以在20000步内,所有车辆都可以停到自己的车位上,就输出解法,不可以输出-1.

 一道模拟和思维的题目。我们可以通过适当变换,将车辆和车位各变成一维数组,对车辆进行移动,即对数组进行移动,尝试是否可以对准车位,然后需要记录一下路径。

/*
 I have a dream!A AC deram!!
 orz orz orz orz orz orz orz orz orz orz orz
 orz orz orz orz orz orz orz orz orz orz orz
 orz orz orz orz orz orz orz orz orz orz orz

 */

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 4e5 + 10;
const int MAXN = 1e5 + 5;
const int INF = 0x3f3f3f3f;
int a[110][110];
int n, k, s;
struct node
{
    int id, x, y;
    node(int _id, int _x, int _y) {
        id = _id;
        x = _x;
        y = _y;
    };
};
vector<node>ans;

void stop()
{
    for (int i = 0; i < 2 * n; i++)
    {
        if (a[1][i] && (a[1][i] == a[0][i]))
        {
            ans.push_back(node( a[1][i], i / n == 1 ? 4 : 1, i % n + 1 ));
            a[1][i] = 0;
            k--;
        }
            
    }
}
bool judge()
{
    stop();
    for (int i = 0; i < 2 * n; i++)
    {
        if (!a[1][i])
            return true;
    }
    return false;
}

void turn()
{
    vector<node>v1, v2;
    int t = a[1][2 * n - 1];
    for (int i = 2 * n - 1; i >= 1; i--)
    {
        a[1][i] = a[1][i - 1];
        if (a[1][i])
        {
            if (i > s)
                v1.push_back(node(a[1][i], i / n == 1 ? 3 : 2, i % n + 1 ));
            else
                v2.push_back(node(a[1][i], i / n == 1 ? 3 : 2, i%n + 1 ));
        }
    }
    a[1][0] = t;
    if (t)
        v2.push_back(node (t, 2, 1 ));
    vector<node>::iterator it;
    for (it = v2.begin(); it != v2.end(); it++)
        ans.push_back(*it);
    for (it = v1.begin(); it != v1.end(); it++)
        ans.push_back(*it);
}
int main()
{
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[0][i]);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[1][i]);
    for (int i = 2 * n - 1; i >= n; i--)
        scanf("%d", &a[1][i]);
    for (int i = 2 * n - 1; i >= n; i--)
        scanf("%d", &a[0][i]);
    if (!judge())
    {
        printf("-1\n");
        return 0;
    }
    for (int i = 0; i < 2 * n; i++)
    {
        if (!a[1][i])
        {
            s = i;
            break;
        }
    }
    while (k)
    {
        stop();
        turn();
        s = (s + 1) % (2 * n);
    }
    printf("%d\n", ans.size());
    vector<node>::iterator it;
    for (it = ans.begin(); it != ans.end(); it++)
    {
        int x = (*it).x;
        int y = (*it).y;
        int id = (*it).id;
        if (x == 3 || x == 4)
            y = n - y + 1;
        printf("%d %d %d\n", id, x, y);
    }
    
    return 0;
}
View Code

 

标签:Provincial,Training,orz,Contest,int,scanf,++,ans,include
来源: https://www.cnblogs.com/Tangent-1231/p/10685545.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有