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;
    }
  • 相关阅读:
    最小生成树
    负环详解
    P2053 [SCOI2007]修车
    P3254 圆桌问题
    P3114 [USACO15JAN]踩踏Stampede
    SP1043 GSS1
    SP2713 GSS4
    导出mysql内数据 python建倒排索引
    社团管理系统——总结报告
    北京地铁出行线路规划——代码实现
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626236.html
Copyright © 2011-2022 走看看