Skip to content

Commit

Permalink
pF first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
littlecube committed Sep 11, 2023
1 parent ac24a4f commit 8324a14
Show file tree
Hide file tree
Showing 91 changed files with 26,468 additions and 346 deletions.
2 changes: 1 addition & 1 deletion .problems.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["B", "C"]
["A", "B", "C", "D", "E", "F"]
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
nothing:

import-pA:
cmsImportTask ./pA/ -u $(if $(s), , --no-statement)
import-pB:
cmsImportTask ./pB/ -u $(if $(s), , --no-statement)
import-pC:
cmsImportTask ./pC/ -u $(if $(s), , --no-statement)
import-pD:
cmsImportTask ./pD/ -u $(if $(s), , --no-statement)
import-pE:
cmsImportTask ./pE/ -u $(if $(s), , --no-statement)
import-pF:
cmsImportTask ./pF/ -u $(if $(s), , --no-statement)
8 changes: 4 additions & 4 deletions cover.tex
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
\begin{document}

\begin{center}
\textbf{\huge TODO競賽名稱}\\
\textbf{\huge 2023 臺南一中學科能力競賽 校內初選}\\
\vspace{5mm}
\textbf{\huge TODO競賽名稱\ 試題本}\\
\textbf{\huge 2023 臺南一中學科能力競賽 校內初選\ 試題本}\\
\vspace{10mm}
\rule{17cm}{2pt}\\
\vspace{5mm}
Expand All @@ -27,8 +27,8 @@
\fontsize{14pt}{20pt}\selectfont
\begin{enumerate}
\setlength\itemsep{0.5pt}
\item 競賽時間:202TODO/TODO/TODO TODO:TODO \textasciitilde \, TODO:TODO,共 TODO 小時。
\item 本次競賽試題共 TODO 題,每題皆有子任務。
\item 競賽時間:2023/9/14 13:30 \textasciitilde \, 16:30,共 3 小時。
\item 本次競賽試題共 6 題,每題皆有子任務。
\item 為了愛護地球,本次競賽題本僅提供電子檔,不提供紙本。
\item 每題的分數為該題所有子任務得分數加總;單筆子任務得分數為各筆繳交在該筆得到的最大分數。
\item 本次初選比照南區賽提供記分板,複選比照全國賽不提供記分板。
Expand Down
63 changes: 39 additions & 24 deletions pF/gen/data
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
@subtask samples
manual example.in
manual example-01.in
manual example-02.in

@subtask one
gen-one 1
gen-one 23
gen-one 51238
gen-one 100000
@subtask n4
manual 1x1.in
gen 100 100 2 1
gen 100 100 2 2
gen 100 100 2 3
gen 100 100 2 4
gen 100 100 2 5
gen 100 100 50 6
gen 100 100 50 7
gen 100 100 50 8
gen 100 100 50 9
gen 100 100 50 10

@subtask six
gen-six 1
gen-six 23
gen-six 51238
gen-six 100000
@subtask n3
@include n4
gen 500 500 2 11
gen 500 500 2 12
gen 500 500 2 13
gen 500 500 2 14
gen 500 500 2 15
gen 500 500 100 16
gen 500 500 100 17
gen 500 500 100 18
gen 500 500 100 19
gen 500 500 100 20

@subtask full
@include n3
gen 2000 2000 0 21
gen 2000 2000 2 22
gen 2000 2000 5 23
gen 2000 2000 10 24
gen 2000 2000 100 25
gen 2000 2000 100 26
gen 2000 2000 500 27
gen 2000 2000 1000 28
gen 2000 2000 2000 29
gen 2000 2000 40000000 30

@subtask all
@include one
@include six
gen 5
gen 6
gen 100000 a
gen 100000 b
gen 100000 c
gen 100000 d
gen 100000 e
gen 100000 f
gen-equal 100000 a
gen-equal 100000 b
24 changes: 0 additions & 24 deletions pF/gen/gen-equal.cpp

This file was deleted.

18 changes: 0 additions & 18 deletions pF/gen/gen-one.cpp

This file was deleted.

18 changes: 0 additions & 18 deletions pF/gen/gen-six.cpp

This file was deleted.

29 changes: 15 additions & 14 deletions pF/gen/gen.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#include <bits/stdc++.h>
#include "testlib.h"
using namespace std;

const int C = 1'000'000'000;

int main(int argc, char *argv[])
{
ios::sync_with_stdio(0);
cin.tie(0);
registerGen(argc, argv, 1);
#include <bits/stdc++.h>

int N = atoi(argv[1]);
using namespace std;

cout << N << '\n';
for (int i = 1; i <= N; i++)
cout << rnd.next(1, C) << " \n"[i == N];
int main(int argc, char* argv[]) {
registerGen(argc, argv, 1);
int n=atoi(argv[1]),m=atoi(argv[2]),c=atoi(argv[3]);
cout<<n<<" "<<m<<"\n";
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
int r=rnd.next(0,c);
if (r==0) cout<<1;
else cout<<0;
}
cout<<'\n';
}
return 0;
}
2 changes: 2 additions & 0 deletions pF/gen/manual/1x1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 1
0
6 changes: 6 additions & 0 deletions pF/gen/manual/example-01.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
5 5
00010
00000
00111
10000
01010
4 changes: 4 additions & 0 deletions pF/gen/manual/example-02.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
3 4
1000
0001
1000
2 changes: 0 additions & 2 deletions pF/gen/manual/example.in

This file was deleted.

8 changes: 4 additions & 4 deletions pF/problem.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"contest_name": "TPS範例題目",
"problem_label": "A",
"name": "partial-game",
"title": "有偏賽局",
"problem_label": "F",
"name": "park",
"title": "公園",
"memory_limit": 256,
"time_limit": 1.0,
"time_limit": 3.0,
"type": "Batch",
"description": "",
"tps_web_url": "",
Expand Down
15 changes: 0 additions & 15 deletions pF/solution/ac.cpp

This file was deleted.

47 changes: 47 additions & 0 deletions pF/solution/brute.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define int long long
#define pii pair<int,int>
#define x first
#define y second
#define N 3015
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
int n,m,arr[N][N],s[N][N];
int count(int x1,int y1,int x2,int y2){
return s[x2][y2]+s[x1-1][y1-1]-s[x1-1][y2]-s[x2][y1-1];
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>n>>m;
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
char c; cin>>c;
arr[i][j]=c-'0';
s[i][j]=s[i][j-1]+arr[i][j];
}
}
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++)
s[i][j]+=s[i-1][j];
}
int ans=0;
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
for (int ii=i;ii<=n;ii++){
for (int jj=j;jj<=m;jj++){
if (count(i,j,ii,jj)<=1)
ans=max(ans,(ii-i+1)*(jj-j+1));
}
}
}
}
cout<<ans<<'\n';
}
92 changes: 92 additions & 0 deletions pF/solution/divide.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define pii pair<int,int>
#define x first
#define y second
#define N 3015
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
int arr[N][N],n,m,ans;
int s[N][N],nxt0[N][N],nxt1[N][N];
void solve(int l,int r){
int mid=(l+r)>>1,tans=0;
for (int i=1;i<=n;i++){
for (int j=mid;j>=l;j--){
if (j==mid) s[i][j]=arr[i][j];
else s[i][j]=s[i][j+1]+arr[i][j];
}
for (int j=mid+1;j<=r;j++){
if (j==mid+1) s[i][j]=arr[i][j];
else s[i][j]=s[i][j-1]+arr[i][j];
}
}
for (int i=1;i<=n;i++){
for (int j=l;j<=r;j++){
s[i][j]+=s[i-1][j];
}
}
for (int j=l;j<=r;j++){
int p0=1,p1=1;
for (int i=1;i<=n;i++){
while (p0<=n&&s[i-1][j]==s[p0][j])
p0++;
while (p1<=n&&s[i-1][j]+1>=s[p1][j])
p1++;
nxt0[i][j]=p0-1;
nxt1[i][j]=p1-1;
}
}
for (int i=1;i<=n;i++){
int p0=mid+1,p1=mid+1;
for (int j=mid;j>=l;j--){
int now=0;
while (p0<=r&&nxt1[i][p0]>=nxt0[i][j])
p0++;
now=max(now,(p0-j)*(nxt0[i][j]-i+1));
while (p1<=r&&nxt0[i][p1]>=nxt1[i][j])
p1++;
now=max(now,(p1-j)*(nxt1[i][j]-i+1));
tans=max(tans,now);
}
p0=mid; p1=mid;
for (int j=mid+1;j<=r;j++){
int now=0;
while (p0>=l&&nxt1[i][p0]>=nxt0[i][j])
p0--;
now=max(now,(j-p0)*(nxt0[i][j]-i+1));
while (p1>=l&&nxt0[i][p1]>=nxt1[i][j])
p1--;
now=max(now,(j-p1)*(nxt1[i][j]-i+1));
tans=max(tans,now);
}
}
ans=max({ans,tans});
}
void Merge(int l,int r){
if (l==r){
solve(l,l);
return;
}
int mid=(l+r)>>1;
Merge(l,mid); Merge(mid+1,r);
solve(l,r);
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>n>>m;
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
char c; cin>>c;
arr[i][j]=c-'0';
}
}
Merge(1,m);
cout<<ans<<'\n';
}
Loading

0 comments on commit 8324a14

Please sign in to comment.