2018 ICPC Asia Jakarta Regional Contest

题目传送门

题号 A B C D E F G H I J K L
状态 Ο . . Ο . . . . Ο . . Ο

Ο:当场

Ø:已补

.  :  待补

A. Edit Distance

Thinking:kk pai爷

Code:kk

  不能直接反转,比如"010101",直接反转后就变成"101010",右移一位,然后加个0就可以了。

  所以要先统计01的数量,如果0大于1,就全变成1,1大于0,就全变成0(从数量上的改变就大于s/2了),相等的话,就看首位是0还是1,取相反,后面和首位不一样就行(位置)。

#include<bits/stdc++.h>
#include<tr1/unordered_map>
#include<bits/stdc++.h>
#define clr(a,b) memset(a,b,sizeof(a))
#define fpn() freopen("simple.in","r",stdin)
#define rd read()
using namespace std;
const int maxn=2010;
typedef long long ll;
int a,b;
char s[maxn];
int main(){
    cin>>s+1;
    int n=strlen(s+1);
    for(int i=1;i<=n;i++)
    {
        if(s[i]==‘0‘)a++;
        else b++;
    }
    if(a>b){
        for(int i=1;i<=n;i++)
        {
            printf("1");
        }
        puts("");
    }else if(a<b){
        for(int i=1;i<=n;i++)
        {
            printf("0");
        }
        puts("");
    }else{
        if(s[1]==‘1‘){
            printf("0");
            for(int i=2;i<=n;i++)
            {
                printf("1");
            }
            puts("");
        }else{
            printf("1");
            for(int i=2;i<=n;i++)
            {
                printf("0");
            }
            puts("");
        }
    }
} 

D. Icy Land

Thinking:kk

Code:pai爷

  首先我们考虑大一点的矩阵,对于$n*m$来说,中心的$(n-2)*(m-2)$的矩阵中,只要有冰地,这个冰地就必然到达不了,因为会直接划过去,所以我们要把中间这个矩阵直接变成"#",然后我们要确保外围的过道上有一个#能让我们进入中心区域。

  然后特殊考虑$2*n$的矩阵,还是中心的两行,只要上下有一个就可以了。

#include<bits/stdc++.h>
#include<tr1/unordered_map>
#include<bits/stdc++.h>
#define clr(a,b) memset(a,b,sizeof(a))
#define fpn() freopen("simple.in","r",stdin)
#define rd read()
using namespace std;
const int maxn=2010;
typedef long long ll;
int n,m,ans=0,flag;
char s[510][510];
void do1()
{
    for(int i=2;i<=m-1;i++)
      if(s[1][i]==‘.‘) ans++;
}
void do2()
{
    for(int i=2;i<=n-1;i++)
      if(s[i][1]==‘.‘) ans++;
}
void do3()
{
    for(int i=2;i<=n-1;i++)
      if(s[i][1]!=‘#‘&&s[i][2]!=‘#‘) ans++;
}
void do4()
{
    for(int i=2;i<=m-1;i++)
      if(s[1][i]!=‘#‘&&s[2][i]!=‘#‘) ans++;
}
void do5()
{
    for(int i=2;i<=n-1;i++)
      for(int j=2;j<=m-1;j++)
         if(s[i][j]==‘.‘) ans++;
    flag=1;
    for(int i=2;i<=m-1;i++)
       if(s[1][i]==‘#‘||s[n][i]==‘#‘) flag=0;
    for(int i=2;i<=n-1;i++)
       if(s[i][1]==‘#‘||s[i][m]==‘#‘) flag=0;
    ans+=flag;
}
void work()
{
    if(n==1) do1();
    else if(m==1) do2();
    else if(m==2) do3();
    else if(n==2) do4();
    else do5();
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
    work();
    printf("%d\n",ans);
}

F. Popping Balloons

待补。 z

G. Go Make It Complete

待补。k

H. Lexical Sign Sequence

  训练的时候想的似乎是正解?不过电脑在刚J题,没时间写

待补.z

I. Lie Detector

Thinking

Code:pai爷

  签到。

#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#define ll long long
#define maxn 4001000
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int n,p;
char s[100100][10];
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
    while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
    return x*f;
}
void init()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%s",s[i]);
}
void work()
{
    if(s[1][0]==‘L‘) p=0;
    else p=1;
    for(int i=2;i<=n;i++)
       if(s[i][0]==‘L‘) p=!p;
    if(p==0) printf("LIE\n");
    else printf("TRUTH\n");
}
int main()
{
    init();
    work();
}

J. Future Generation

待补 p z

K. Boomerangs

待补 k

L:

#include<bits/stdc++.h>
#include<tr1/unordered_map>
#include<bits/stdc++.h>
#define clr(a,b) memset(a,b,sizeof(a))
#define fpn() freopen("simple.in","r",stdin)
#define rd read()
using namespace std;
const int maxn=2010;
typedef long long ll;
char c[66];
long long k,len;
int v[66];
inline long long f(void)
{
    long long i,s = 0;
    for(i = 0;i < len;i++)
    {
        if(!v[i])
        {
            s *= 2;
            if(c[i] == ‘1‘)
            {
                s += 1;
            }
        }
    }
    return s;
}
int main(){
    long long i;
    int ans;
    while(~scanf("%lld",&k))
    {
        scanf("%s",c);
        len = strlen(c);
        memset(v,0,sizeof(v));
        ans = 0;
        while(1)
        {
            if(f() <= k)
            {
                break;
            }
            bool flag = true;
            for(i = 1;i < len;i++)
            {
                if(c[i] == ‘1‘ && v[i] == 0)
                {
                    v[i] = 1;
                    flag = false;
                    break;
                }
            }
            if(flag)
            {
                for(i = 1;i < len;i++)
                {
                    if(c[i] == ‘0‘ && v[i] == 0)
                    {
                        v[i] = 1;
                        break;
                    }
                }
            }
            ans++;
        }
        printf("%d\n",ans);
    }
}



总结:

  kk:今天比赛中途吃了个外卖(下课食堂人太多了吧)。所以中间稍微耽搁了一下下,A题一眼想到假算法,发现wa了那么多,所以等了等,果然hack了假算法,和pai爷讨论后ac,吃外卖的时候看了d题,回来稍微画了画想到正解,pai爷写的代码。后面的题目和zz、pai爷分别讨论了两道题,一道题感觉时间复杂度不对,没写完就让电脑了,一道题和zz讨论的似乎是正解,时间不够了没写。今天主要是被代码实现能力卡住了,还有没有提早提醒队友卡题的时候看新题,本来H题应该是能做的。

原文地址:https://www.cnblogs.com/mountaink/p/10472719.html

时间: 2024-09-30 15:29:23

2018 ICPC Asia Jakarta Regional Contest的相关文章

2019-2020 ICPC, Asia Jakarta Regional Contest H. Twin Buildings

As you might already know, space has always been a problem in ICPC Jakarta. To cope with this, ICPC Jakarta is planning to build two new buildings. These buildings should have a shape of a rectangle of the same size. Now, their problem is to find lan

2019-2020 ICPC, Asia Jakarta Regional Contest C. Even Path

Pathfinding is a task of finding a route between two points. It often appears in many problems. For example, in a GPS navigation software where a driver can query for a suggested route, or in a robot motion planning where it should find a valid seque

2018-2019, ICPC, Asia Yokohama Regional Contest 2018 (Gym - 102082)

2018-2019, ICPC, Asia Yokohama Regional Contest 2018 A - Digits Are Not Just Characters 签到. B - Arithmetic Progressions 题意:从给定的集合中选出最多的数构成等差数列. 题解:数字排序后,设\(dp[i][j]\)表示等差数列最后一个数字为\(a[i]\),倒数第二个数字为\(a[j]\)的最大个数.然后对于每一位枚举 \(i\),\(lower\_bound()\)找有无合法的

2018 ICPC Asia Singapore Regional A. Largest Triangle (计算几何)

题目链接:Kattis - largesttriangle Description Given \(N\) points on a \(2\)-dimensional space, determine the area of the largest triangle that can be formed using \(3\) of those \(N\) points. If there is no triangle that can be formed, the answer is \(0\

The 2018 ACM-ICPC Asia Qingdao Regional Contest K XOR Clique

K XOR Clique BaoBao has a sequence a?1??,a?2??,...,a?n??. He would like to find a subset S of {1,2,...,n} such that ?i,j∈S, a?i??⊕a?j??<min(a?i??,a?j??) and ∣S∣ is maximum, where ⊕ means bitwise exclusive or. Input There are multiple test cases. The

The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online - H Traveling on the Axis-【思维模拟题目】

H Traveling on the Axis 作者: 浙江大学竞赛命题组 单位: ACMICPC 时间限制: 500 ms 内存限制: 64 MB 代码长度限制: 32 KB 传送门 BaoBao is taking a walk in the interval [0,n] on the number axis, but he is not free to move, as at every point (i−0.5) for all i∈[1,n], where i is an intege

2018 ACM-ICPC, Asia Shenyang Regional Contest CEJ

C. Insertion Sort 求有多少 1 到 n 的排列 满足条件将前 k 个的数排列以后 最长上升子序列长度为 n?1 以上 队友推了式子 试了下就过了 1 #include<bits/stdc++.h> 2 typedef long long ll; 3 using namespace std; 4 5 ll ans,n,k,p; 6 7 ll PP() 8 { 9 ll sum=1; 10 for(int i=1;i<=k;i++) 11 sum=(sum*i)%p; 12

The 2018 ACM-ICPC Asia Beijing Regional Contest

训练时间:2019-03-31 本场阿渠连出A和D,成功带我们晋级. I题我坚定的写Java,完全没往打表找规律上想.背锅. A - Jin Yong’s Wukong Ranking List (HihoCoder - 1870) 给你n对拓扑关系,找出第一个不符合之前的拓扑关系的拓扑对. 建图,每加入一对拓扑对 x -> y,看看从 y 是否能跑到 x 即可. #include <bits/stdc++.h> #define FOPI freopen("in.txt&quo

The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online

XOR Clique Press the Button Kuririn MIRACLE Traveling on the Axis Couleur Chaleur Infinite Parenthesis Sequence Pixel Art Halting Problem Red Black Tree Live Love 原文地址:https://www.cnblogs.com/Accpted/p/11298226.html