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;
}