2019 icpc 银川站 B so easy

Posted 布图

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2019 icpc 银川站 B so easy相关的知识,希望对你有一定的参考价值。

代码

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <vector>
#include <limits.h>
#include <assert.h>
#include <functional>
#include <numeric>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define pb          push_back
#define ppb         pop_back
#define lbnd        lower_bound
#define ubnd        upper_bound
#define endl        '\\n'
#define mll         map<ll,ll>
#define msl         map<string,ll>
#define mls         map<ll, string>
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x)  for(auto& a : x)
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define vll         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define DEBUG       cerr<<"/n>>>I'm Here<<</n"<<endl;
#define display(x)  trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ini(a)      memset(a,0,sizeof(a))
#define ini2(a,b)   memset(a,b,sizeof(a))
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define case        ll T;read(T);for(ll Q=1;Q<=T;Q++)
#define lowbit(x)   x&(-x)
#define pr          printf
#define sc          scanf
#define _           0
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DBG(x) \\
    (void)(cout << "L" << __LINE__ \\
    << ": " << #x << " = " << (x) << '\\n')
#define TIE \\
    cin.tie(0);cout.tie(0);\\
    ios::sync_with_stdio(false);
//#define long long int

//using namespace __gnu_pbds;

template <typename T>  
void read(T &x) {  
    x = 0;  
    int f = 1;  
    char ch = getchar();  
    while (!isdigit(ch)) {  
        if (ch == '-') f = -1;  
        ch = getchar();  
    }  
    while (isdigit(ch)) { 
        x = x * 10 + (ch ^ 48);  
        ch = getchar();  
    }  
    x *= f;  
    return;  
}

inline void write(long long x) {
    if(x<0) putchar('-'), x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    putchar('\\n');
}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI    = acos(-1.0);
const double eps   = 1e-6;
const int    INF   = 0x3f3f3f3f;
const ll     LLINF = 0x3f3f3f3f3f3f3f3f;
const int    maxn  = 1009;
const ll     N     = 5;

int arr[maxn][maxn];
int mini[maxn];
int minj[maxn];

void solve(){
	for (int i=0; i<maxn; i++) {
		mini[i] = INF;
		minj[i] = INF;
	}
	int xi, xj;
	int n;
	cin>>n;
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=n; j++) {
			cin>>arr[i][j];
			if (arr[i][j] == -1) {
				xi = i;
				xj = j;
				arr[i][j] = INF;
			}
			if (mini[i] > arr[i][j]) mini[i] = arr[i][j];
//			if (minj[j] > arr[i][j]) minj[j] = arr[i][j];
			
		}
	}
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=n; j++) {
			arr[i][j] -= mini[i];
		}
	}
	for (int j=1; j<=n; j++) {//最小 
		for (int i=1; i<=n; i++) {
			if (minj[j] > arr[i][j]) {
				minj[j] = arr[i][j];
			}
		}
	}
	
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=n; j++) {
			arr[i][j] -= minj[j];
		}
	}
	
//	cout<<mini[xi]<<' '<<minj[xj]<<endl;
	cout<<mini[xi]+minj[xj]<<endl;
	
	
}


int main()
{
//	TIE;
//    #ifndef ONLINE_JUDGE
//    freopen ("in.txt" , "r", stdin );
//    freopen ("out.txt", "w", stdout);
//    #else
//    #endif
	solve();
//    case{solve();}
//    case{cout<<"Case "<<Q<<":"<<endl;solve();}
	return ~~(0^_^0);
}




 

以上是关于2019 icpc 银川站 B so easy的主要内容,如果未能解决你的问题,请参考以下文章

2019ICPC银川站 后记

2019 国际大学生程序设计竞赛(ICPC)亚洲区域赛(银川) 7题

2019 国际大学生程序设计竞赛(ICPC)亚洲区域赛(银川) 7题

2020-2021 ICPC 银川站ACMer退役纪念

第45届国际大学生程序设计竞赛(ICPC)银川站太原理工大学收获4枚奖牌

2019icpc银川网络赛-A Maximum(思维)