Submission #21144344


Source Code Expand

Copy
            /**************************************
    Author : Susanka Majumder ( bingobong )
    ***************************************/
   #include<bits/stdc++.h>   
  #ifndef ONLINE_JUDGE
   #include<sys/resource.h>
    #include <sys/time.h>
    #endif

    using namespace std;
     
    /* Template file for Online Algorithmic Competitions */
    /* Typedefs */
        /* System Controllers */
        const long long CPU_TIME = 3 ; // CPU time program has acess to ( in seconds )
        const long long MAX_FILE_SIZE = 1024*1024 ; // Maximum File size that the program can create 
        /* Basic types */
        typedef long long           ll;
        typedef long double         ld;
        typedef unsigned long long ull;
        /* STL containers */
        typedef vector <int>    vi;
        typedef vector <ll>     vll;
        typedef pair <int, int> pii;
        typedef pair <ll, ll>   pll;
        typedef vector < pii >  vpii;
        typedef vector < pll >  vpll;
        typedef vector <string> vs;
        typedef vector < vi >   vvi;
        typedef vector < vll >  vvll;
        typedef vector < vpii > vvpii;
        typedef set <int>       si;
    /* Macros */
        /* Loops */
        #define fl(i, a, b)     for(int i(a); i <= (b); i ++)
        #define rep(i, n)       fl(i, 1, (n))
        #define loop(i, n)      fl(i, 0, (n) - 1)
        #define rfl(i, a, b)    for(int i(a); i >= (b); i --)
        #define rrep(i, n)      rfl(i, (n), 1)
        /* Algorithmic functions */
        #define pow2(x) ((x)*(x))
        #define mod(x, m) ((((x) % (m)) + (m)) % (m))
        #define max3(a, b, c) max(a, max(b, c))
        #define min3(a, b, c) min(a, min(b, c))
        #define srt(v)          sort((v).begin(), (v).end())
        /* STL container methods */
        #define pb              push_back
        #define mp              make_pair
        #define eb              emplace_back
        /* String methods */
        #define dig(i)          (s[i] - '0')
        #define slen(s)         s.length()
        /* Shorthand notations */
        #define fr              first
        #define sc              second
        #define re              return 
        #define sz(x)           ((int) (x).size())
        #define all(x)          (x).begin(), (x).end()
        #define sqr(x)          ((x) * (x))
        #define fill(x, y)      memset(x, y, sizeof(x))
        #define clr(a)          fill(a, 0)
        #define endl            '\n'
        /* Mathematical */
        #define IINF            0x3f3f3f3f
        #define LLINF           1000111000111000111LL
        #define PI              3.14159265358979323
        #define NIL             -1
        /* Debugging purpose */
       #define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
        /* Fast Input Output */
        #define FAST_IO                  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
    /* Constants */
        const ll MOD = 1000000007LL;
        const ll MAX = 100010LL;
    /* Templates */
    template<class T> T abs(T x) { re x > 0 ? x : -x; }
    template<typename T> T gcd(T a, T b){ if(b == 0) return a; return gcd(b, a % b); }
    template<typename T> T power(T x, T y, ll m = MOD){T ans = 1; x %= m; while(y > 0){ if(y & 1LL) ans = (ans * x)%m; y >>= 1LL; x = (x*x)%m; } return ans%m; }
    /*input and output of non standard data types*/
    template<typename T> istream& operator >> (istream& cin,vector<T> &a){
        for(auto &i:a)cin>>i;
        return cin;
    }
    template<typename T> ostream& operator << (ostream& cout,vector<T> &a){
        for(auto &i:a)cout<<i<<" ";
        return cout;
    }
    template<typename T> ostream& operator << (ostream& cout,pair<T,T> &a){
        cout<<"("<<a.first<<","<<a.second<<")" ; 
        return cout;
    }
    /* additional*/
    #define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
    #define present(c,x) ((c).find(x) != (c).end())
    #define cpresent(c,x) (find(all(c),x) != (c).end())
    //double inf = 1.0/0.0;
    #define int long long
   
    signed main(){

  
        
        
        FAST_IO;

        int  n ;cin>> n ; 
        vector<vector<int> > c(n , vector<int> (n)) ; 
        loop(i , n ){
        	loop(j , n)
        		cin>>c[i][j] ; 
        }

        bool flag1 = true , flag2 = true  ; 
        vector<int> a , b ;  
        loop(i , n ){
        	
        	loop(j , n)
        		{
        			if( c[i][j] - c[0][j] != c[i][0] - c[0][0] )
        			{
        				flag1 = false ; 
        				break ; 
        			}
        			
        		}
        		a.push_back(c[i][0] - c[0][0]) ; 
        			
        }

        loop(i , n){
        	
        	loop(j , n)
        		{
        			if( c[j][i] - c[j][0] != c[0][i] - c[0][0] )
        			{
        				flag2 = false ; 
        				break ; 
        			}
        			
        		}
        				b.push_back(c[0][i] - c[0][0]) ; 
        }

        ///db(a , b );
        int  min_ind = 0 , min_num = 1000000007LL ; 
        loop( i , n )
        {
        	if( c[0][i] < min_num )
        	{
        		min_num = c[0][i] ; 
        		min_ind = i ; 
        	}
        }

        if( flag1 == false || flag2==false )
        	cout<<"No" ;
        else
        {
        	cout<<"Yes\n" ;	
        	loop( i , n  )
        		cout<<c[i][min_ind] <<" " ; 
        	cout<<endl ; 
        	loop( i , n  )
        		cout<<c[0][i] - min_num <<" " ; 
        	cout<<endl ; 
        	

        }

      
        
    
        return 0;
    }
    

Submission Info

Submission Time
Task B - Plus Matrix
User bingobong
Language C++ (GCC 9.2.1)
Score 400
Code Size 6029 Byte
Status AC
Exec Time 34 ms
Memory 5308 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 47
Set Name Test Cases
Sample sample00, sample01
All case02, case03, case04, case05, case06, case07, case08, case09, case10, case11, case12, case13, case14, case15, case16, case17, case18, case19, case20, case21, case22, case23, case24, case25, case26, case27, case28, case29, case30, case31, case32, case33, case34, case35, case36, case37, case38, case39, case40, case41, case42, case43, case44, case45, case46, sample00, sample01
Case Name Status Exec Time Memory
case02 AC 1 ms 3628 KB
case03 AC 2 ms 3520 KB
case04 AC 2 ms 3584 KB
case05 AC 1 ms 3480 KB
case06 AC 2 ms 3544 KB
case07 AC 1 ms 3472 KB
case08 AC 2 ms 3564 KB
case09 AC 3 ms 3492 KB
case10 AC 2 ms 3424 KB
case11 AC 2 ms 3552 KB
case12 AC 2 ms 3496 KB
case13 AC 1 ms 3600 KB
case14 AC 32 ms 5304 KB
case15 AC 4 ms 3500 KB
case16 AC 2 ms 3544 KB
case17 AC 33 ms 5212 KB
case18 AC 3 ms 3548 KB
case19 AC 27 ms 5248 KB
case20 AC 2 ms 3544 KB
case21 AC 34 ms 5252 KB
case22 AC 34 ms 5160 KB
case23 AC 32 ms 5256 KB
case24 AC 2 ms 3640 KB
case25 AC 2 ms 3592 KB
case26 AC 19 ms 4960 KB
case27 AC 5 ms 3620 KB
case28 AC 34 ms 5220 KB
case29 AC 5 ms 3568 KB
case30 AC 2 ms 3520 KB
case31 AC 2 ms 3580 KB
case32 AC 24 ms 5308 KB
case33 AC 10 ms 3700 KB
case34 AC 3 ms 3616 KB
case35 AC 28 ms 5260 KB
case36 AC 5 ms 3576 KB
case37 AC 2 ms 3600 KB
case38 AC 3 ms 3736 KB
case39 AC 3 ms 3588 KB
case40 AC 19 ms 5260 KB
case41 AC 20 ms 5148 KB
case42 AC 19 ms 5268 KB
case43 AC 27 ms 5148 KB
case44 AC 21 ms 5216 KB
case45 AC 19 ms 5136 KB
case46 AC 3 ms 3460 KB
sample00 AC 2 ms 3548 KB
sample01 AC 2 ms 3628 KB