結果

問題 No.655 E869120 and Good Triangles
ユーザー ふっぴーふっぴー
提出日時 2018-02-26 00:40:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,012 bytes
コンパイル時間 1,755 ms
コンパイル使用メモリ 175,520 KB
実行使用メモリ 379,264 KB
最終ジャッジ日時 2024-04-18 10:00:27
合計ジャッジ時間 30,388 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 960 ms
378,880 KB
testcase_26 AC 962 ms
378,752 KB
testcase_27 WA -
testcase_28 AC 905 ms
378,752 KB
testcase_29 WA -
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
//int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
int dx[6] = { 0, 1, 1, 0, -1, -1 }, dy[6] = { 1, 1, 0, -1, -1, 0 };

int main() {
	ll n, k, p;
	cin >> n >> k >> p;
	vll a(n, vl(n, INF));
	vi x(n), y(n);
	queue<pii> que;
	rep(i, k) {
		cin >> x[i] >> y[i];
		x[i]--; y[i]--;
		a[x[i]][y[i]] = 0;
		que.push(pii(x[i], y[i]));
	}
	while (!que.empty()) {
		pii now = que.front();
		que.pop();
		int i0 = now.first, j0 = now.second;
		int d = a[i0][j0];
		rep(i, 6) {
			int in = i0 + dx[i], jn = j0 + dy[i];
			if (in < 0 || in >= n || jn < 0 || jn >= n) {
				continue;
			}
			if (jn > in) {
				continue;
			}
			if (a[in][jn] > d + 1) {
				a[in][jn] = d + 1;
				que.push(pii(in, jn));
			}
		}
	}

	
	vll rnaname(n, vl(n + 1)), lnaname(n, vl(n + 1));
	rep(i, n) {
		rnaname[i][0] = 0;
		for (int j = i; j < n; j++) {
			rnaname[i][j + 1] = rnaname[i][j] + a[j][j - i];
		}
	}
	rep(i, n) {
		lnaname[i][0] = 0;
		for (int j = i; j < n; j++) {
			lnaname[i][j + 1] = lnaname[i][j] + a[j][i];
		}
	}
	/*
	rep(i, n) {
		rep(j, n) {
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
	rep(i, n) {
		rep(j, n + 1) {
			cout << rnaname[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
	rep(i, n) {
		rep(j, n + 1) {
			cout << lnaname[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
	//*/
	int ans = 0;
	rep(i, n) {
		//DEBUG(i);
		int l = 0, r = 1;
		int score = a[i][0];
		bool pre = false;
		bool first = true;
		while (true) {
			//printf("l: %d, r: %d, score: %d \n", l, r, score);
			if (score >= p) {
				if (first) {
					ans += (l + 1) * (i - r + 2);
					first = false;
				}
				else {
					ans += (i - r + 2);
				}
				/*
				cout << '-' << endl;
				DEBUG(i + 1);
				DEBUG(i - r + l);
				//*/
				score -= (lnaname[l][i + 1] - lnaname[l][i - (r - 1 - l)]);
				l++;
				pre = true;
			}
			else {
				if (r > i) {
					break;
				}
				/*
				cout << '+' << endl;
				DEBUG(i + 1);
				DEBUG(i - (r - l));
				//*/
				score += (rnaname[i - r][i + 1] - rnaname[i - r][i - (r - l)]);
				r++;
				pre = false;
			}
			//DEBUG(ans);
		}
		//printf("l: %d, r: %d, score: %d\n", l, r, score);
	}
	cout << ans << endl;
}
0