-
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1205 from maspypy/fix_near_grid
テストケース追加(issue 1204)
- Loading branch information
Showing
8 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <utility> | ||
#include "random.h" | ||
#include "../params.h" | ||
|
||
using namespace std; | ||
|
||
using P = pair<int, int>; | ||
|
||
P random_point(Random& gen, int LIM) { | ||
int x = gen.uniform(-LIM, LIM); | ||
int y = gen.uniform(-LIM, LIM); | ||
return {x, y}; | ||
} | ||
|
||
void out(vector<vector<P>> ALL) { | ||
int T = ALL.size(); | ||
printf("%d\n", T); | ||
for (auto& S: ALL) { | ||
int n = S.size(); | ||
printf("%d\n", n); | ||
for (auto& [x, y]: S) { printf("%d %d\n", x, y); } | ||
} | ||
} | ||
|
||
int main(int, char* argv[]) { | ||
long long seed = atoll(argv[1]); | ||
auto gen = Random(seed); | ||
|
||
vector<vector<P>> ALL; | ||
int n = 1; | ||
while ((n + 1) * (n + 1) <= SUM_N_MAX) ++n; | ||
|
||
int eps = 100; | ||
/* | ||
x[0],x[1],...,x[N-1] | ||
*/ | ||
int LIM = X_AND_Y_ABS_MAX; | ||
int d = LIM / (n - 1); | ||
|
||
auto get = [&](int i) -> int { | ||
int x = i * d - (LIM / 2); | ||
return x + gen.uniform<int>(-eps, eps); | ||
}; | ||
|
||
vector<P> S; | ||
for (int i = 0; i < n; ++i) { | ||
for (int j = 0; j < n; ++j) { | ||
int x = get(i), y = get(j); | ||
S.emplace_back(x, y); | ||
} | ||
} | ||
ALL.emplace_back(S); | ||
|
||
out(ALL); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <utility> | ||
#include "random.h" | ||
#include "../params.h" | ||
|
||
using namespace std; | ||
|
||
using P = pair<int, int>; | ||
|
||
P random_point(Random& gen, int LIM) { | ||
int x = gen.uniform(-LIM, LIM); | ||
int y = gen.uniform(-LIM, LIM); | ||
return {x, y}; | ||
} | ||
|
||
void out(vector<vector<P>> ALL) { | ||
int T = ALL.size(); | ||
printf("%d\n", T); | ||
for (auto& S: ALL) { | ||
int n = S.size(); | ||
printf("%d\n", n); | ||
for (auto& [x, y]: S) { printf("%d %d\n", x, y); } | ||
} | ||
} | ||
|
||
int main(int, char* argv[]) { | ||
long long seed = atoll(argv[1]); | ||
auto gen = Random(seed); | ||
|
||
vector<vector<P>> ALL; | ||
int n = 1; | ||
while ((n + 1) * (n + 1) <= SUM_N_MAX) ++n; | ||
|
||
int eps = 100; | ||
/* | ||
x[0],x[1],...,x[N-1] | ||
*/ | ||
int LIM = X_AND_Y_ABS_MAX; | ||
int d = LIM / (n - 1); | ||
|
||
auto get = [&](int i) -> int { | ||
int x = i * d - (LIM / 2); | ||
return x + gen.uniform<int>(-eps, eps); | ||
}; | ||
|
||
vector<P> S; | ||
for (int i = 0; i < n; ++i) { | ||
for (int j = 0; j < n; ++j) { | ||
int x = get(i), y = get(j); | ||
S.emplace_back(x, y); | ||
} | ||
} | ||
ALL.emplace_back(S); | ||
|
||
out(ALL); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters