Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
gzshawnliang committed Jan 31, 2019
1 parent 7141014 commit ce38ec5
Show file tree
Hide file tree
Showing 17 changed files with 10,412 additions and 21 deletions.
40 changes: 21 additions & 19 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
{
"configurations": [{
"name": "Win32",
"includePath": [
"${workspaceRoot}",
"${workspaceRoot}/**"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceRoot}",
"${workspaceRoot}/**"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"cStandard": "c11",
"cppStandard": "c++14"
}],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"${workspaceRoot}",
"${workspaceRoot}/**"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"cStandard": "c11",
"cppStandard": "c++14"
}
],
"version": 4
}
2 changes: 1 addition & 1 deletion Lib/high_resolution_clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using namespace std;
using namespace std::chrono;

//note:计时器,可拥有测量模块的允许时间
//note:计时器,可拥有测量模块的运行时间
struct Timer
{

Expand Down
2 changes: 1 addition & 1 deletion myCpps/!-OJcreater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using namespace std;

//***************************************
const string CPPfile = "largestSubmatrix_UVA836"; //*
const string CPPfile = "cityGame_UVA1330"; //*
//***************************************

ifstream fin(CPPfile + ".cpp");
Expand Down
65 changes: 65 additions & 0 deletions myCpps/area_UVA11951.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include <bits/stdc++.h>

using namespace std;

ifstream fin("area_UVA11951.in");
ofstream fout("area_UVA11951.out");

int main()
{
int testCase; fin >> testCase;
for (int t = 1; t <= testCase; ++t)
{
long long n, m, k; fin >> n >> m >> k;
vector<vector<long long>> a(n + 1, vector<long long>(m + 1, 0)), dp(n + 1, vector<long long>(m + 1, 0));

for (int y = 1; y <= n; ++y)
{
for (int x = 1; x <= m; ++x)
{
fin >> a[y][x];

dp[y][x] = dp[y][x - 1] + a[y][x];
}
}

long long ansS = 0, ansC = 0;
for (int x1 = 1; x1 <= m; ++x1)
{
for (int x2 = x1; x2 <= m; ++x2)
{
for (int y1 = 1; y1 <= n; ++y1)
{
long long sum = 0;
for (int y2 = y1; y2 <= n; ++y2)
{
long long size = (x2 - x1 + 1) * (y2 - y1 + 1);

sum += dp[y2][x2] - dp[y2][x1 - 1];

if (sum > k)
{
break;
}
else if (ansS <= size)
{
if (ansS == size)
{
ansC = min(ansC, sum);
}
else
{
ansC = sum;
}
ansS = size;
}
}
}
}
}

fout << "Case #" << t << ": " << ansS << ' ' << ansC << '\n';
}

return 0;
}
7 changes: 7 additions & 0 deletions myCpps/area_UVA11951.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1
5 6 15
10 1 10 20 10 10
30 1 1 5 1 1
50 1 1 20 1 1
10 5 5 10 5 1
40 10 90 1 10 10
1 change: 1 addition & 0 deletions myCpps/area_UVA11951.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Case #1: 6 10
67 changes: 67 additions & 0 deletions myCpps/area_UVA11951OJ.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <bits/stdc++.h>

using namespace std;


int main()
{
ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
int testCase; cin >> testCase;
for (int t = 1; t <= testCase; ++t)
{
long long n, m, k; cin >> n >> m >> k;
vector<vector<long long>> a(n + 1, vector<long long>(m + 1, 0)), dp(n + 1, vector<long long>(m + 1, 0));

for (int y = 1; y <= n; ++y)
{
for (int x = 1; x <= m; ++x)
{
cin >> a[y][x];

dp[y][x] = dp[y][x - 1] + a[y][x];
}
}

long long ansS = 0, ansC = 0;
for (int x1 = 1; x1 <= m; ++x1)
{
for (int x2 = x1; x2 <= m; ++x2)
{
for (int y1 = 1; y1 <= n; ++y1)
{
long long sum = 0;
for (int y2 = y1; y2 <= n; ++y2)
{
long long size = (x2 - x1 + 1) * (y2 - y1 + 1);

sum += dp[y2][x2] - dp[y2][x1 - 1];

if (sum > k)
{
break;
}
else if (ansS <= size)
{
if (ansS == size)
{
ansC = min(ansC, sum);
}
else
{
ansC = sum;
}
ansS = size;
}
}
}
}
}

cout << "Case #" << t << ": " << ansS << ' ' << ansC << '\n';
}

cout.flush();
return 0;
}

110 changes: 110 additions & 0 deletions myCpps/cityGame_UVA1330.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#include <bits/stdc++.h>

using namespace std;

ifstream fin("cityGame_UVA1330.in");
ofstream fout("cityGame_UVA1330.out");

int main()
{
int testCase; fin >> testCase;
for (int t = 1; t <= testCase; ++t)
{
int n, m; fin >> n >> m;

vector<vector<char>> a(n + 1, vector<char>(m + 1, 0));
for (int y = 1; y <= n; ++y)
{
for (int x = 1; x <= m; ++x)
{
fin >> a[y][x];
}
}

vector<vector<int>> maxH(n + 2, vector<int>(m + 2, 0)),
maxL(n + 2, vector<int>(m + 2, 0)),
maxR(n + 2, vector<int>(m + 2, 0));

for (int x = 1; x <= m; ++x)
{
maxL[0][x] = INT_MAX;
maxR[0][x] = INT_MAX;
}

for (int y = 1; y <= n; ++y)
{
int last = 0;

for (int x = 1; x <= m; ++x)
{
if (a[y][x] == 'R')
{
maxH[y][x] = 0;
}
else
{
maxH[y][x] = maxH[y - 1][x] + 1;
}
}

last = 0;
for (int x = 1; x <= m; ++x)
{
if (y == 1 && x == 1)
{
for (int __s = 0; __s == 0; ++__s);
}

if (a[y][x] == 'R')
{
last = x;
}
else
{
if (a[y - 1][x] == 'R')
{
maxL[y][x] = x - last - 1;
}
else
{
maxL[y][x] = min(maxL[y - 1][x], x - last - 1);
}
}
}

last = m + 1;
for (int x = m; x >= 1; --x)
{
if (a[y][x] == 'R')
{
last = x;
}
else
{
if (a[y - 1][x] == 'R')
{
maxR[y][x] = last - x - 1;
}
else
{
maxR[y][x] = min(maxR[y - 1][x], last - x - 1);
}
}
}
}

int ans = 0;
for (int y = 1; y <= n; ++y)
{
for (int x = 1; x <= m; ++x)
{
int size = maxH[y][x] * (maxL[y][x] + maxR[y][x] + 1);
ans = max(ans, size);
}
}

fout << ans * 3 << '\n';
}

return 0;
}
Loading

0 comments on commit ce38ec5

Please sign in to comment.