답안 #67021

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67021 2018-08-13T08:29:21 Z osmanorhan Maxcomp (info1cup18_maxcomp) C++17
100 / 100
361 ms 27528 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define For( i , a ) for(int i=1;i<=a;i++)
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf
#define set multiset

using namespace std;

typedef long long Lint;
typedef double db;
typedef pair<int,int> ii;
typedef pair<int,char> ic;
typedef pair<db,db> dd;
typedef pair<int,ii> iii;
typedef pair<ii,ii> i4;

const int maxn = 1020;
const int maxm = 1000020;
const int MOd = 998244353;

int ar[maxn][maxn];
bool used[maxn][maxn];
queue<iii> q;
int yol[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};
vector<iii> v;

int main() {

    //freopen("asd.in","r",stdin);
    //freopen("output17.txt","w",stdout);

    int a, b;
    scanf("%d %d",&a,&b);
    for(int i=1;i<=a;i++)
    	for(int j=1;j<=b;j++) {
    		scanf("%d",&ar[i][j]);
    		v.pb( iii( ar[i][j], ii( i, j ) ) );
    	}
    sort( all( v ) );
    int last = v.size()-1;
    int ans = -1e9;
    q.push( v[last--] );
    while( !q.empty() ) {
    	int mal = q.front().fi;
    	int x = q.front().se.fi;
    	int y = q.front().se.se;
    	q.pop();
    	if( used[x][y] ) continue;
    	used[x][y]=1;
    	while( last >= 0 && v[last].fi == mal )
    		q.push( v[last--] );
    	umax( ans, mal-ar[x][y]-1 );
    	for(int i=0;i<4;i++) {
    		int gox = x + yol[i][0];
    		int goy = y + yol[i][1];
    		if( 0 < gox && gox <= a && 0 < goy && goy <= b && !used[gox][goy] )
    			q.push( iii( mal-1, ii( gox, goy ) ) );
    	}
    }
    cout << ans << endl;
	return 0;
}

Compilation message

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:53:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&a,&b);
     ~~~~~^~~~~~~~~~~~~~~
maxcomp.cpp:56:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d",&ar[i][j]);
       ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 3 ms 680 KB Output is correct
3 Correct 2 ms 680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Correct 3 ms 896 KB Output is correct
10 Correct 3 ms 896 KB Output is correct
11 Correct 4 ms 896 KB Output is correct
12 Correct 3 ms 896 KB Output is correct
13 Correct 3 ms 896 KB Output is correct
14 Correct 3 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 680 KB Output is correct
11 Correct 2 ms 680 KB Output is correct
12 Correct 3 ms 896 KB Output is correct
13 Correct 3 ms 896 KB Output is correct
14 Correct 4 ms 896 KB Output is correct
15 Correct 3 ms 896 KB Output is correct
16 Correct 3 ms 896 KB Output is correct
17 Correct 3 ms 896 KB Output is correct
18 Correct 346 ms 17432 KB Output is correct
19 Correct 349 ms 17600 KB Output is correct
20 Correct 331 ms 17600 KB Output is correct
21 Correct 361 ms 17600 KB Output is correct
22 Correct 346 ms 17600 KB Output is correct
23 Correct 334 ms 17600 KB Output is correct
24 Correct 243 ms 27528 KB Output is correct