結果
問題 | No.866 レベルKの正方形 |
ユーザー |
![]() |
提出日時 | 2019-08-16 22:56:02 |
言語 | C++17(clang Beta) (clang 13.0.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 3,965 ms / 6,000 ms |
コード長 | 3,320 bytes |
コンパイル時間 | 1,049 ms |
使用メモリ | 410,228 KB |
最終ジャッジ日時 | 2023-01-06 19:32:55 |
合計ジャッジ時間 | 52,327 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,472 KB |
testcase_01 | AC | 2 ms
5,528 KB |
testcase_02 | AC | 2 ms
5,488 KB |
testcase_03 | AC | 2 ms
5,540 KB |
testcase_04 | AC | 2 ms
5,544 KB |
testcase_05 | AC | 2 ms
5,544 KB |
testcase_06 | AC | 2 ms
5,528 KB |
testcase_07 | AC | 2 ms
5,508 KB |
testcase_08 | AC | 3,264 ms
410,120 KB |
testcase_09 | AC | 3,773 ms
410,084 KB |
testcase_10 | AC | 3,965 ms
410,104 KB |
testcase_11 | AC | 3,943 ms
410,100 KB |
testcase_12 | AC | 3,304 ms
410,108 KB |
testcase_13 | AC | 3,929 ms
410,116 KB |
testcase_14 | AC | 3,120 ms
410,044 KB |
testcase_15 | AC | 3,954 ms
410,044 KB |
testcase_16 | AC | 3,690 ms
410,228 KB |
testcase_17 | AC | 3,965 ms
410,112 KB |
testcase_18 | AC | 3,923 ms
410,120 KB |
testcase_19 | AC | 2,954 ms
410,116 KB |
testcase_20 | AC | 2,773 ms
410,124 KB |
testcase_21 | AC | 2,665 ms
410,116 KB |
testcase_22 | AC | 2 ms
3,360 KB |
testcase_23 | AC | 2 ms
3,428 KB |
testcase_24 | AC | 2 ms
5,524 KB |
ソースコード
/* This Submission is to determine how many 120/240 min const. delivery point there are. //info 120 req. steps <= 5 test_case 1,6 == 50 delivery point 2,3,4,5,7 == 80 delivery point 8,9 == 90 delivery point 10 > 100 delivery point */ #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <algorithm> #include <utility> #include <functional> #include <cstring> #include <queue> #include <stack> #include <math.h> #include <iterator> #include <vector> #include <string> #include <set> #include <math.h> #include <iostream> #include <random> #include<map> #include <iomanip> #include <time.h> #include <stdlib.h> #include <list> #include <typeinfo> #include <list> #include <set> #include <cassert> #include<fstream> #include <unordered_map> #include <cstdlib> #include <complex> #include <cctype> #include <bitset> using namespace std; typedef string::const_iterator State; #define Ma_PI 3.141592653589793 #define eps 0.00000001 #define LONG_INF 1e18 #define GOLD 1.61803398874989484820458 #define MAX_MOD 1000000007 #define MOD 1000000007 #define seg_size 262144 #define REP(a,b) for(long long a = 0;a < b;++a) unsigned long xor128() { static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123; unsigned long t = (x ^ (x << 11)); x = y; y = z; z = w; return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))); } long long h, w; int cnt[2002][2002][26]; long long earn_point(int left_x, int left_y, int right_x, int right_y, int t) { long long ans = cnt[right_x][right_y][t]; ans -= cnt[left_x - 1][right_y][t]; ans -= cnt[right_x][left_y - 1][t]; ans += cnt[left_x - 1][left_y - 1][t]; return ans; } long long func(long long k) { long long ans = 0; for (int i = 1; i <= w; ++i) { long long now_x = 1; long long now_y = i; long long back = 0; for (int j = 0; now_y <= w && now_x <= h; ++j) { while (true) { int now_cnt = 0; back++; REP(t, 26) { if (earn_point(back + 1, back + i, now_x, now_y, t) >= 1) { now_cnt++; } } if (now_cnt < k) { back--; break; } } int now_cnt = 0; REP(t, 26) { if (earn_point(back+1, back + i, now_x, now_y, t) >= 1) { now_cnt++; } } if (now_cnt >= k) { ans += back + 1LL; } now_x++; now_y++; } } for (int i = 2; i <= h; ++i) { long long now_x = i; long long now_y = 1; long long back = 0; for (int j = 0; now_y <= w && now_x <= h; ++j) { while (true) { int now_cnt = 0; back++; REP(t, 26) { if (earn_point(back + i, back + 1, now_x, now_y, t) >= 1) { now_cnt++; } } if (now_cnt < k) { back--; break; } } int now_cnt = 0; REP(t, 26) { if (earn_point(back + i, back + 1, now_x, now_y, t) >= 1) { now_cnt++; } } if (now_cnt >= k) { ans += (back + 1LL); } now_x++; now_y++; } } return ans; } int main(){ iostream::sync_with_stdio(false); long long k; cin >> h >> w >> k; for (int i = 1; i <= h;++i) { string a; cin >> a; for (int q = 1; q <= w; ++q) { REP(j, 26) { cnt[i][q][j] += cnt[i][q - 1][j]; } cnt[i][q][a[q - 1] - 'a']++; } } for (int i = 1; i <= h; ++i) { for (int q = 1; q <= w; ++q) { REP(j, 26) { cnt[i][q][j] += cnt[i - 1][q][j]; } } } cout << func(k) - func(k+1) << endl; return 0; }