P4924 [1007] 魔法少女小Scarlet
对模拟题摸不着头脑。
看题解之后的源码 本来想把变量塞进for循环结果莫名re
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<unordered_map>
#define DEBUG
#define MAXN 500001
#define debug(...) fprintf(stdout,__VA_ARGS__)
using namespace std;
typedef long long ll;
const int INF =0x3f3f3f3f;
const ll INFLL = (1LL<<60);
template<typename T>
T read(T &x){
x = 0;
T w = 1;
char ch = 0;
while(ch < '0' || ch > '9')
{
if(ch == '-') w = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9')
{
x = x * 10 + (ch - '0');
ch = getchar();
}
x *= w;
return x;
}
template <typename T>
inline void write(T x)
{
if(x < 0){
putchar('-');
x = -x;
}
static int sta[35]; int top = 0;
do sta[top++] = x % 10, x /= 10;
while(x);
while(top) putchar(sta[--top] + 48);
}
template <typename T>
inline void writeln(T x)
{
write(x);
putchar('\n');
}
template <typename T>
inline void writespace(T x)
{
write(x);
putchar(' ');
}
int n,m,x,y,r,z;
int arr[1000][1000];
int temp[1000][1000];
void solve0() {
for(int i = x-r; i <= x+r; i++) {
for(int j = y-r; j <= y+r; j++) {
temp[i][j] = arr[i][j];
}
}
for(int i = x-r, x1 = x+r, y1 = y-r; i <= x+r; i++, y1++) {
for(int j = y-r; j <= y+r; j++) {
arr[i][j] = temp[x1--][y1];
}
}
}
void solve1() {
for(int i = x-r; i <= x+r; i++) {
for(int j = y-r; j <= y+r; j++) {
temp[i][j] = arr[i][j];
}
}
for(int i = x-r, x1 = x-r, y1 = y+r; i <= x+r; i++, y1--) {
for(int j = y-r; j <= y+r; j++) {
arr[i][j] = temp[x1++][y1];
}
}
}
int main(){
// #ifdef DEBUG
// freopen("in.in","r",stdin);
// #endif
// std::ios::sync_with_stdio(false);
// std::cin.tie(0);
// /* START */
//
//
//
// /* END */
// #ifdef DEBUG
// fclose(stdin);
// #endif
// read(n);read(m);
// int tp = 0;
// for(int i = 1; i <= n; i++) {
// for(int j = 1; j <= n; j++) {
// arr[i][j] = ++tp;
// }
// }
// for(int i = 0; i < m; i++) {
// read(x);read(y);read(r);read(z);
// if(z) {
// solve1();
// } else {
// solve0();
// }
// }
// for(int i = 1; i <= n; i++) {
// for(int j = 1; j <= n; j++) {
// write(arr[i][j]);cout<<' ';
// }
// cout<<endl;
// }
return 0;
}
后面按照题解格式写了之后就好了,不过不知道为什么
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<unordered_map>
#define DEBUG
#define MAXN 500001
#define debug(...) fprintf(stdout,__VA_ARGS__)
using namespace std;
typedef long long ll;
const int INF =0x3f3f3f3f;
const ll INFLL = (1LL<<60);
template<typename T>
T read(T &x){
x = 0;
T w = 1;
char ch = 0;
while(ch < '0' || ch > '9')
{
if(ch == '-') w = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9')
{
x = x * 10 + (ch - '0');
ch = getchar();
}
x *= w;
return x;
}
template <typename T>
inline void write(T x)
{
if(x < 0){
putchar('-');
x = -x;
}
static int sta[35]; int top = 0;
do sta[top++] = x % 10, x /= 10;
while(x);
while(top) putchar(sta[--top] + 48);
}
template <typename T>
inline void writeln(T x)
{
write(x);
putchar('\n');
}
template <typename T>
inline void writespace(T x)
{
write(x);
putchar(' ');
}
int n,m,x,y,r,z;
int arr[1000][1000];
int temp[1000][1000];
void solve0() {
for(int i = x-r; i <= x+r; i++) {
for(int j = y-r; j <= y+r; j++) {
temp[i][j] = arr[i][j];
}
}
int x1 = x+r, y1 = y-r;
for(int i = x-r; i <= x+r; i++) {
for(int j = y-r; j <= y+r; j++) {
arr[i][j] = temp[x1][y1];
x1--;
}
y1++;x1 = x+r;
}
}
void solve1() {
for(int i = x-r; i <= x+r; i++) {
for(int j = y-r; j <= y+r; j++) {
temp[i][j] = arr[i][j];
}
}
int x1 = x-r, y1 = y+r;
for(int i = x-r; i <= x+r; i++) {
for(int j = y-r; j <= y+r; j++) {
arr[i][j] = temp[x1][y1];
x1++;
}
y1--;x1 = x-r;
}
}
int main(){
// #ifdef DEBUG
// freopen("in.in","r",stdin);
// #endif
// std::ios::sync_with_stdio(false);
// std::cin.tie(0);
// /* START */
//
//
//
// /* END */
// #ifdef DEBUG
// fclose(stdin);
// #endif
read(n);read(m);
int tp = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
arr[i][j] = ++tp;
}
}
for(int i = 0; i < m; i++) {
read(x);read(y);read(r);read(z);
if(z) {
solve1();
} else {
solve0();
}
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
write(arr[i][j]);cout<<' ';
}
cout<<endl;
}
return 0;
}
__EOF__

本文作者:Kdlyh
本文链接:https://www.cnblogs.com/kdlyh/p/17776975.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
本文链接:https://www.cnblogs.com/kdlyh/p/17776975.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
分类:
做题报告(2023+)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下