ICode9

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

C. Ticks Codeforces Round #744 (Div. 3)

2022-07-30 20:34:37  阅读:112  来源: 互联网

标签:744 int Ticks t2y t2x && Div include t1x


VP情况 4 / 8 

AC: A,B,D,E1 60 minutes

WA: C

手速还在线

C假题了,一直没有调出来wa2

正确作法是找点 '* '从左上和右上方向遍历,记录路径长度,直到其中有一方超出边界或者点不为 '*',终止。如果路径长度大于等于d就将路径上的每个点标记值++

最后check ,如果有点为 '*'但标记值为0就说明不符合条件

细节见代码:

//  AC one more times

////////////////////////////////////////INCLUDE//////////////////////////////////////////

#include <iostream>
#include <algorithm>
#include <cstdio>
#include<string>
#include<string.h>
#include <cstring>
#include <complex>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <list>
#include <bitset>
#include <assert.h>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <random>
#include <iterator>
#include <time.h>

using namespace std;
/////////////////////////////////////////DEFINE//////////////////////////////////////////

#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define inf64 0x3f3f3f3f3f3f3f3f

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<long long,long long> PLL;

////////////////////////////////////////CONST////////////////////////////////////////////

const int  inf = 0x3f3f3f3f;
const int maxn = 2e6 + 6;
const double eps = 1e-8;
const int mod = 1000000;

///////////////////////////////////////FUNCTION//////////////////////////////////////////

template<typename T>
void init(T q[], int n, T val){   for (int i = 0; i <= n; i++) q[i] = val;  }
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
bool cmp(int c, int d) { return c > d; }

bool cmp1(PII c, PII d) { return c.fi > d.fi; }



int cnt, c[100][100],n,m,k;  
char op[100][100];
bool st;
int d;

void search(int x,int y)
{
    int t1x=x,t2x=x,t1y=y,t2y=y;
    while(1)
    {
        int jishu=0;
        t1x=t1x-1,t1y=t1y-1;
        t2x=t2x-1,t2y=t2y+1;
        if(t1x>=0&&t1x<n&&t1y>=0&&t1y<m)
            if(op[t1x][t1y]=='*')
                jishu++;
        if(t2x>=0&&t2x<n&&t2y>=0&&t2y<m)
            if(op[t2x][t2y]=='*')
        
                jishu++;
        if(jishu<2)   break;
        cnt++;
    }

    if(cnt>=k)
    {
        c[x][y]++;
        t1x=t2x=x,t1y=t2y=y;
        while(cnt--)
        {
            t1x=t1x-1,t1y=t1y-1;
            t2x=t2x-1,t2y=t2y+1;
            if(t1x>=0&&t1x<n&&t1y>=0&&t1y<m)
                if(op[t1x][t1y]=='*')
                    c[t1x][t1y]++;
            if(t2x>=0&&t2x<n&&t2y>=0&&t2y<m)
                if(op[t2x][t2y]=='*')
                    c[t2x][t2y]++;
        }
    }
}
void solve()
{
    cin>>n>>m>>k;
    st=false;    memset(c,0,sizeof c);
    for(int i=0;i<n;i++)    cin>>op[i];

    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            if( op[i][j]=='*' && 
                ( i-1>=0 && j-1>=0 && j+1<m) ) 
            {

                cnt=0;
                search(i,j);
            }
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            if(op[i][j]=='*'&&c[i][j]<=0)
                st=true;
            else if(op[i][j]=='.'&&c[i][j]>=1)
                st=true;
    if(st)
        cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return;
}

    

    
int main()
{
    std::ios::sync_with_stdio(false);   cin.tie(nullptr), cout.tie(nullptr);
    
    int T;cin>>T;for(int i=1;i<=T;i++)
        solve();    


    return 0;
}

 

标签:744,int,Ticks,t2y,t2x,&&,Div,include,t1x
来源: https://www.cnblogs.com/magicat/p/16535726.html

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

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

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

ICode9版权所有