zoukankan      html  css  js  c++  java
  • 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory

    【题目链接】:http://codeforces.com/contest/821/problem/A

    【题意】

    给你一个n*n的数组;
    然后问你,是不是每个位置(x,y);
    都能找到一个同一行的元素q和同一列的元素w;
    使得q+w=a[x][y]

    【题解】

    O(N4)模拟

    【Number Of WA

    0

    【反思】

    不用考虑会选到a[x][y]本身.

    【完整代码】

    #include <bits/stdc++.h>
    using namespace std;
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    #define rep1(i,a,b) for (int i = a;i <= b;i++)
    #define rep2(i,a,b) for (int i = a;i >= b;i--)
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define ms(x,y) memset(x,y,sizeof x)
    #define Open() freopen("F:\rush.txt","r",stdin)
    #define Close() ios::sync_with_stdio(0)
    
    typedef pair<int,int> pii;
    typedef pair<LL,LL> pll;
    
    const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
    const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
    const double pi = acos(-1.0);
    const int N = 50;
    
    int a[N+10][N+10],n;
    
    void out(){
        cout <<"No"<<endl;
        exit(0);
    }
    
    int main(){
        //Open();
        Close();
        cin >> n;
        rep1(i,1,n){
            rep1(j,1,n){
                cin >> a[i][j];
            }
        }
        rep1(i,1,n){
            rep1(j,1,n){
                if (a[i][j]!=1){
                    int fi = 0;
                    rep1(ii,1,n)
                        rep1(jj,1,n)
                            if (a[ii][j]+a[i][jj]==a[i][j])
                                fi = 1;
                    if (!fi) out();
                }
            }
        }
        cout <<"Yes"<<endl;
        return 0;
    }
  • 相关阅读:
    ajax _02【XML响应,post请求】
    ajax_01【httpRequest.responseText】
    方法的定义【js函数】
    Promise基本用法
    promise
    筛选(1)
    ng-cli 中HTTP请求思路(1) (接口请求处理)
    PHP占用CPU过高几种思路
    关于tcpdump的那点事~
    虚拟机固定IP那点事
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626236.html
Copyright © 2011-2022 走看看