Submission #1869815
Source Code Expand
//while (clock()<=69*CLOCKS_PER_SEC) #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define sim template < class c #define ris return * this #define dor > debug & operator << #define eni(x) sim > typename \ enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c&) { ris; } #endif }; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " #define shandom_ruffle random_shuffle const int nax=107; int n, m; char wcz[nax]; int twa[nax][nax]; pair <int,int> pin; int wyn; int now[nax][nax]; int sum[nax][nax]; void sumsy() { for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+twa[i][j]; } inline int daj(int a, int b, int l, int p) { return sum[b][p]-sum[b][l-1]-sum[a-1][p]+sum[a-1][l-1]; } void obr() { for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) now[i][j]=twa[i][j]; for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) twa[j][n+1-i]=now[i][j]; swap(pin.first, pin.second); pin.second=n+1-pin.second; } void symet() { for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) now[i][j]=twa[i][j]; for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) twa[i][n+1-j]=now[i][j]; pin.second=n+1-pin.second; } void licz() { wyn=min(wyn, daj(1, pin.first, pin.second, n)); for (int i=1; i<=pin.first; i++) { for (int j=pin.second; j<=n; j++) { int tu=0; tu+=daj(i, pin.first, pin.second, j); tu+=daj(1, i-1, 1, j); tu+=daj(i, n, j+1, n); wyn=min(wyn, tu); } } for (int i=1; i<=pin.first; i++) { for (int ii=i; ii<=pin.first; ii++) { for (int j=1; j<=pin.second; j++) { for (int jj=pin.second; jj<=n; jj++) { int tu=0; tu+=daj(i, ii, j, jj); tu+=daj(ii+1, pin.first, pin.second, jj); tu+=daj(1, i-1, j, n); tu+=daj(i, n, 1, j-1); tu+=daj(ii+1, n, jj+1, n); wyn=min(wyn, tu); } } } } } int main() { scanf("%d%d", &n, &m); for (int i=1; i<=n; i++) { scanf("%s", wcz+1); for (int j=1; j<=m; j++) { if (wcz[j]=='P') pin={i, j}; if (wcz[j]=='#') twa[i][j]=1; } } n=max(n, m); wyn=n*n; for (int h=0; h<4; h++) { for (int p=0; p<2; p++) { sumsy(); licz(); symet(); } obr(); } printf("%d\n", wyn); return 0; }
Submission Info
Submission Time | |
---|---|
Task | H - Poor Penguin |
User | Stonefeang |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 3174 Byte |
Status | WA |
Exec Time | 4 ms |
Memory | 384 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:132:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &n, &m); ^ ./Main.cpp:135:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", wcz+1); ^
Judge Result
Set Name | sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1600 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
All | sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, 01-36.txt, 01-37.txt, 01-38.txt, 01-39.txt, 01-40.txt, 01-41.txt, 01-42.txt, 01-43.txt, 01-44.txt, 01-45.txt, 01-46.txt, 01-47.txt, 01-48.txt, 01-49.txt, 01-50.txt, 01-51.txt, 01-52.txt, 01-53.txt, 01-54.txt, 01-55.txt, 01-56.txt, 01-57.txt, 01-58.txt, 01-59.txt, 01-60.txt, 01-61.txt, 01-62.txt, 01-63.txt, 01-64.txt, 01-65.txt, 01-66.txt, 01-67.txt, 01-68.txt, 01-69.txt, 01-70.txt, 01-71.txt, 01-72.txt, 01-73.txt, 01-74.txt, 01-75.txt, 01-76.txt, 01-77.txt, 01-78.txt, 01-79.txt, 01-80.txt, 01-81.txt, 01-82.txt, 01-83.txt, 01-84.txt, 01-85.txt, 01-86.txt, 01-87.txt, 01-88.txt, 01-89.txt, 01-90.txt, 01-91.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 1 ms | 256 KB |
01-02.txt | AC | 1 ms | 256 KB |
01-03.txt | AC | 1 ms | 256 KB |
01-04.txt | AC | 3 ms | 256 KB |
01-05.txt | AC | 3 ms | 256 KB |
01-06.txt | AC | 4 ms | 256 KB |
01-07.txt | AC | 4 ms | 256 KB |
01-08.txt | AC | 4 ms | 256 KB |
01-09.txt | AC | 4 ms | 256 KB |
01-10.txt | AC | 4 ms | 256 KB |
01-11.txt | AC | 4 ms | 256 KB |
01-12.txt | AC | 4 ms | 256 KB |
01-13.txt | AC | 4 ms | 256 KB |
01-14.txt | AC | 4 ms | 256 KB |
01-15.txt | AC | 4 ms | 256 KB |
01-16.txt | AC | 3 ms | 256 KB |
01-17.txt | AC | 2 ms | 256 KB |
01-18.txt | WA | 4 ms | 256 KB |
01-19.txt | WA | 4 ms | 256 KB |
01-20.txt | WA | 4 ms | 256 KB |
01-21.txt | WA | 4 ms | 256 KB |
01-22.txt | WA | 4 ms | 256 KB |
01-23.txt | WA | 4 ms | 256 KB |
01-24.txt | WA | 4 ms | 256 KB |
01-25.txt | WA | 4 ms | 256 KB |
01-26.txt | WA | 4 ms | 256 KB |
01-27.txt | WA | 4 ms | 256 KB |
01-28.txt | WA | 4 ms | 256 KB |
01-29.txt | WA | 4 ms | 256 KB |
01-30.txt | AC | 4 ms | 256 KB |
01-31.txt | WA | 4 ms | 256 KB |
01-32.txt | AC | 4 ms | 256 KB |
01-33.txt | WA | 4 ms | 256 KB |
01-34.txt | AC | 4 ms | 256 KB |
01-35.txt | AC | 4 ms | 256 KB |
01-36.txt | WA | 4 ms | 256 KB |
01-37.txt | AC | 4 ms | 256 KB |
01-38.txt | AC | 4 ms | 256 KB |
01-39.txt | WA | 4 ms | 256 KB |
01-40.txt | AC | 4 ms | 256 KB |
01-41.txt | AC | 4 ms | 256 KB |
01-42.txt | WA | 4 ms | 256 KB |
01-43.txt | WA | 4 ms | 256 KB |
01-44.txt | WA | 4 ms | 256 KB |
01-45.txt | WA | 4 ms | 256 KB |
01-46.txt | WA | 4 ms | 256 KB |
01-47.txt | WA | 4 ms | 256 KB |
01-48.txt | WA | 4 ms | 256 KB |
01-49.txt | WA | 4 ms | 256 KB |
01-50.txt | WA | 4 ms | 256 KB |
01-51.txt | WA | 4 ms | 256 KB |
01-52.txt | WA | 4 ms | 256 KB |
01-53.txt | WA | 4 ms | 256 KB |
01-54.txt | WA | 4 ms | 256 KB |
01-55.txt | WA | 4 ms | 256 KB |
01-56.txt | WA | 4 ms | 256 KB |
01-57.txt | WA | 4 ms | 256 KB |
01-58.txt | WA | 4 ms | 256 KB |
01-59.txt | WA | 4 ms | 256 KB |
01-60.txt | WA | 4 ms | 256 KB |
01-61.txt | WA | 4 ms | 256 KB |
01-62.txt | WA | 4 ms | 256 KB |
01-63.txt | WA | 4 ms | 256 KB |
01-64.txt | WA | 4 ms | 256 KB |
01-65.txt | WA | 4 ms | 256 KB |
01-66.txt | WA | 4 ms | 256 KB |
01-67.txt | WA | 4 ms | 256 KB |
01-68.txt | WA | 4 ms | 256 KB |
01-69.txt | WA | 4 ms | 256 KB |
01-70.txt | WA | 4 ms | 256 KB |
01-71.txt | WA | 4 ms | 256 KB |
01-72.txt | WA | 4 ms | 256 KB |
01-73.txt | WA | 4 ms | 256 KB |
01-74.txt | WA | 4 ms | 256 KB |
01-75.txt | WA | 4 ms | 256 KB |
01-76.txt | WA | 4 ms | 256 KB |
01-77.txt | WA | 4 ms | 256 KB |
01-78.txt | WA | 4 ms | 256 KB |
01-79.txt | WA | 4 ms | 256 KB |
01-80.txt | WA | 4 ms | 256 KB |
01-81.txt | WA | 4 ms | 256 KB |
01-82.txt | WA | 4 ms | 256 KB |
01-83.txt | WA | 4 ms | 256 KB |
01-84.txt | WA | 4 ms | 256 KB |
01-85.txt | WA | 4 ms | 256 KB |
01-86.txt | WA | 4 ms | 256 KB |
01-87.txt | WA | 4 ms | 384 KB |
01-88.txt | WA | 4 ms | 256 KB |
01-89.txt | WA | 4 ms | 256 KB |
01-90.txt | WA | 4 ms | 256 KB |
01-91.txt | WA | 4 ms | 256 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |
sample-03.txt | AC | 4 ms | 256 KB |
sample-04.txt | AC | 1 ms | 256 KB |