标签:out push 需要 ack target inf namespace ret acm
一道思维题,画过转换图之后会发现最多会出现四种矩阵,那么只需要判断最后是哪一种就好了。
同时对于连续的直接去重,因为两个连续相同的等于不操作。
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int a[N][N], a180m[N][N], am[N][N], a180[N][N];
vector<int> vec;
int main(){
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= n; j ++){
scanf("%d", &a[i][j]);
}
}
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= n; j ++){
a180[i][j] = a[n - i + 1][n - j + 1];
}
}
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= n; j ++){
a180m[i][j] = a[i][n - j + 1];
}
}
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= n; j ++){
am[i][j] = a[n - i + 1][j];
}
}
int q;
cin >> q;
int x;
cin >> x;
vec.push_back(x);
for(int i = 2; i <= q; i ++){
int x;
scanf("%d", &x);
if(x != vec.back())
vec.push_back(x);
else
vec.pop_back();
}
if(vec.size() == 0){
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= n; j ++){
cout << a[i][j] << ‘ ‘;
}
cout << endl;
}
}
for(int i = 0; i < vec.size(); i ++)
cout << vec[i] << ‘ ‘;
cout << endl;
int ans = 0;
for(int i = 0; i < vec.size(); i ++){
//cout << "vec = " << vec[i] << " ans = " << ans << endl;
if(vec[i] == 1 && ans == 0){
ans = 1;
}else if(vec[i] == 2 && ans == 0){
ans = 2;
}else if(vec[i] == 2 && ans == 1){
ans = 3;
}else if(vec[i] == 1 && ans == 2){
ans = 3;
}else if(vec[i] == 1 && ans == 3){
ans = 2;
}else if(vec[i] == 2 && ans == 3){
ans = 1;
}else if(vec[i] == ans){
ans = 0;
}
}
if(ans == 0){
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= n; j ++){
cout << a[i][j] << ‘ ‘;
}
cout << endl;
}
}else if(ans == 1){
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= n; j ++){
cout << a180[i][j] << ‘ ‘;
}
cout << endl;
}
}else if(ans == 2){
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= n; j ++){
cout << am[i][j] << ‘ ‘;
}
cout << endl;
}
}else if(ans == 3){
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= n; j ++){
cout << a180m[i][j] << ‘ ‘;
}
cout << endl;
}
}
return 0;
}
标签:out push 需要 ack target inf namespace ret acm
原文地址:https://www.cnblogs.com/pureayu/p/14826862.html