牛客 55994 2023牛客五一集训派对day3 D Points Construction Problem()-其他

牛客 55994 2023牛客五一集训派对day3 D Points Construction Problem()

D-Points Construction Problem_2023牛客五一集训派对day3 (nowcoder.com)

No
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
#include <functional>

#define i64 long long

bool sym = 0; i64 res = 0; char ch = getchar();
while (!isdigit(ch)) sym |= (ch == '-'), ch = getchar();
while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
return sym ? -res : res;
}

struct ANS {
int x, y;
};

int main() {
while (T--) {
int n = read(), m = read(), t = 1, cnt = 0;
ANS ans[n + 1];
if (m > 4 * n) {printf("No\n"); continue;}
if (n == 1 && m == 2) {printf("No\n"); continue;}
if (m % 2 == 1) {printf("No\n"); continue;}
while (m > 2 * n + 2) {
m -= 4; n--; ans[++cnt] = {t, t}; t++;
}
int inf = 1000, k = (2 * n + 2 - m) / 2;
if (!k) {
printf("Yes\n");
for (int i = 1; i <= n; i++) ans[++cnt] = {inf + t, inf + t + i - 1};
for (int i = 1; i <= cnt; i++) printf("%d %d\n", ans[i].x, ans[i].y);
continue;
}
for (int i = 1; n && k; i++) {
for (int j = 1; n && k && j <= i - 1; j++) {
if (j != 1) k--; n--;
ans[++cnt] = {inf + i, inf + j};
}
for (int j = 1; n && k && j <= i; j++) {
if (j != 1) k--; n--;
ans[++cnt] = {inf + j, inf + i};
}
}
if (k) {printf("No\n"); continue;}
for (int i = 1; i <= n; i++) ans[++cnt] = {inf + 1, inf - i + 1};
printf("Yes\n");
for (int i = 1; i <= cnt; i++) printf("%d %d\n", ans[i].x, ans[i].y);
}
return 0;
}
————————

D-Points Construction Problem_2023牛客五一集训派对day3 (nowcoder.com)

No
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
#include <functional>

#define i64 long long

bool sym = 0; i64 res = 0; char ch = getchar();
while (!isdigit(ch)) sym |= (ch == '-'), ch = getchar();
while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
return sym ? -res : res;
}

struct ANS {
int x, y;
};

int main() {
while (T--) {
int n = read(), m = read(), t = 1, cnt = 0;
ANS ans[n + 1];
if (m > 4 * n) {printf("No\n"); continue;}
if (n == 1 && m == 2) {printf("No\n"); continue;}
if (m % 2 == 1) {printf("No\n"); continue;}
while (m > 2 * n + 2) {
m -= 4; n--; ans[++cnt] = {t, t}; t++;
}
int inf = 1000, k = (2 * n + 2 - m) / 2;
if (!k) {
printf("Yes\n");
for (int i = 1; i <= n; i++) ans[++cnt] = {inf + t, inf + t + i - 1};
for (int i = 1; i <= cnt; i++) printf("%d %d\n", ans[i].x, ans[i].y);
continue;
}
for (int i = 1; n && k; i++) {
for (int j = 1; n && k && j <= i - 1; j++) {
if (j != 1) k--; n--;
ans[++cnt] = {inf + i, inf + j};
}
for (int j = 1; n && k && j <= i; j++) {
if (j != 1) k--; n--;
ans[++cnt] = {inf + j, inf + i};
}
}
if (k) {printf("No\n"); continue;}
for (int i = 1; i <= n; i++) ans[++cnt] = {inf + 1, inf - i + 1};
printf("Yes\n");
for (int i = 1; i <= cnt; i++) printf("%d %d\n", ans[i].x, ans[i].y);
}
return 0;
}