第2回早稲田大学プログラミングコンテスト

Submission #1757928

Source codeソースコード

// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;
typedef vector<string> VS;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;

int n,m,a,b,h,w;
ll k;
string s;
string f[30];
ll ans;

int main() {
	cin >> h >> w;
	REP(i, h) cin >> f[i];
	REP(i, min(h, w))REP(r,4)REP(y, h - i)REP(x, w - i){
		ll val = 0;
		bool fail = 0;
		REP(dy, i+1)REP(dx, i+1){
			if(dx < dy) continue;
			int ny = y + dy, nx = x + dx;

			if(r&1) ny = y + i - dy;
			if(r&2) nx = x + i - dx;

			if(f[ny][nx] == 'X') fail = 1;
			val += f[ny][nx] - '0';
		}
		if(!fail){
			ans = max(ans, val);
		}
	}

	cout << ans << endl;
}

Submission

Task問題 C - 至高のケーキ
User nameユーザ名 るまちゃそー
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 75
Source lengthソースコード長 1831 Byte
File nameファイル名
Exec time実行時間 14 ms
Memory usageメモリ使用量 256 KB

Test case

Set

Set name Score得点 / Max score Cases
All 75 / 75 case_000.txt,case_001.txt,case_002.txt,case_003.txt,case_004.txt,case_005.txt,case_006.txt,case_007.txt,case_008.txt,case_009.txt,case_010.txt,case_011.txt,case_012.txt,case_013.txt,case_014.txt,case_015.txt,case_016.txt,case_017.txt,case_018.txt,case_019.txt,case_020.txt,case_021.txt,case_022.txt,case_023.txt,case_024.txt,case_025.txt,case_026.txt,case_027.txt,case_028.txt,case_029.txt,case_030.txt,case_031.txt,case_032.txt,case_033.txt,case_034.txt,case_035.txt,case_036.txt,case_037.txt,case_038.txt,case_039.txt,case_040.txt,case_041.txt,case_042.txt,case_043.txt,case_044.txt,case_045.txt,case_046.txt,case_047.txt,case_048.txt,case_049.txt,case_050.txt,case_051.txt,case_052.txt,case_053.txt,case_054.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
case_000.txt AC 1 ms 256 KB
case_001.txt AC 1 ms 256 KB
case_002.txt AC 1 ms 256 KB
case_003.txt AC 1 ms 256 KB
case_004.txt AC 1 ms 256 KB
case_005.txt AC 1 ms 256 KB
case_006.txt AC 1 ms 256 KB
case_007.txt AC 1 ms 256 KB
case_008.txt AC 1 ms 256 KB
case_009.txt AC 1 ms 256 KB
case_010.txt AC 8 ms 256 KB
case_011.txt AC 8 ms 256 KB
case_012.txt AC 8 ms 256 KB
case_013.txt AC 1 ms 256 KB
case_014.txt AC 1 ms 256 KB
case_015.txt AC 2 ms 256 KB
case_016.txt AC 1 ms 256 KB
case_017.txt AC 2 ms 256 KB
case_018.txt AC 2 ms 256 KB
case_019.txt AC 4 ms 256 KB
case_020.txt AC 2 ms 256 KB
case_021.txt AC 14 ms 256 KB
case_022.txt AC 2 ms 256 KB
case_023.txt AC 11 ms 256 KB
case_024.txt AC 1 ms 256 KB
case_025.txt AC 1 ms 256 KB
case_026.txt AC 1 ms 256 KB
case_027.txt AC 2 ms 256 KB
case_028.txt AC 1 ms 256 KB
case_029.txt AC 5 ms 256 KB
case_030.txt AC 4 ms 256 KB
case_031.txt AC 2 ms 256 KB
case_032.txt AC 1 ms 256 KB
case_033.txt AC 1 ms 256 KB
case_034.txt AC 1 ms 256 KB
case_035.txt AC 1 ms 256 KB
case_036.txt AC 1 ms 256 KB
case_037.txt AC 1 ms 256 KB
case_038.txt AC 1 ms 256 KB
case_039.txt AC 1 ms 256 KB
case_040.txt AC 1 ms 256 KB
case_041.txt AC 1 ms 256 KB
case_042.txt AC 1 ms 256 KB
case_043.txt AC 1 ms 256 KB
case_044.txt AC 2 ms 256 KB
case_045.txt AC 1 ms 256 KB
case_046.txt AC 5 ms 256 KB
case_047.txt AC 2 ms 256 KB
case_048.txt AC 2 ms 256 KB
case_049.txt AC 2 ms 256 KB
case_050.txt AC 7 ms 256 KB
case_051.txt AC 4 ms 256 KB
case_052.txt AC 4 ms 256 KB
case_053.txt AC 3 ms 256 KB
case_054.txt AC 3 ms 256 KB