problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
luogu::P1205类 参考

洛谷 P1205 [USACO1.2] 方块转换 Transformations 更多...

#include <luogu.h>

静态 Public 成员函数

static bool equal (int n, char **start, char **end)
 
static int main (istream &cin, ostream &cout)
 
static char ** reflect (int n, char **start)
 
static char ** rorate180 (int n, char **start)
 
static char ** rorate270 (int n, char **start)
 
static char ** rorate90 (int n, char **start)
 

详细描述

洛谷 P1205 [USACO1.2] 方块转换 Transformations

在文件 luogu.h486 行定义.

成员函数说明

◆ equal()

bool luogu::P1205::equal ( int  n,
char **  start,
char **  end 
)
static

在文件 luogu.cpp1801 行定义.

1801 {
1802 for(int i = 0; i < n; i++) {
1803 for(int j = 0; j < n; j++) {
1804 if(start[i][j] != end[i][j]) {
1805 return false;
1806 }
1807 }
1808 }
1809 return true;
1810 }

被这些函数引用 main().

◆ main()

int luogu::P1205::main ( istream &  cin,
ostream &  cout 
)
static

在文件 luogu.cpp1681 行定义.

1681 {
1682 int ans = -1;
1683 int n;
1684 cin >> n;
1685 auto *start = new char *[n];
1686 auto *end = new char *[n];
1687 for(int i = 0; i < n; i++) {
1688 start[i] = new char[n];
1689 for(int j = 0; j < n; j++) {
1690 cin >> start[i][j];
1691 }
1692 }
1693 for(int i = 0; i < n; i++) {
1694 end[i] = new char[n];
1695 for(int j = 0; j < n; j++) {
1696 cin >> end[i][j];
1697 }
1698 }
1699 auto *const r90 = rorate90(n, start);
1700 auto *const r180 = rorate180(n, start);
1701 auto *const r270 = rorate270(n, start);
1702 auto *const r = reflect(n, start);
1703 auto *const rr90 = reflect(n, r90);
1704 auto *const rr180 = reflect(n, r180);
1705 auto *const rr270 = reflect(n, r270);
1706 if(equal(n, r90, end)) {
1707 ans = 1;
1708 } else if(equal(n, r180, end)) {
1709 ans = 2;
1710 } else if(equal(n, r270, end)) {
1711 ans = 3;
1712 } else if(equal(n, r, end)) {
1713 ans = 4;
1714 } else if(equal(n, rr90, end)) {
1715 ans = 5;
1716 } else if(equal(n, rr180, end)) {
1717 ans = 5;
1718 } else if(equal(n, rr270, end)) {
1719 ans = 5;
1720 } else if(equal(n, start, end)) {
1721 ans = 6;
1722 } else {
1723 ans = 7;
1724 }
1725 cout << ans;
1726 for(int i = 0; i < n; i++) {
1727 delete[] start[i];
1728 delete[] end[i];
1729 delete[] r90[i];
1730 delete[] r180[i];
1731 delete[] r270[i];
1732 delete[] r[i];
1733 delete[] rr90[i];
1734 delete[] rr180[i];
1735 delete[] rr270[i];
1736 }
1737 delete[] start;
1738 delete[] end;
1739 delete[] r90;
1740 delete[] r180;
1741 delete[] r270;
1742 delete[] r;
1743 delete[] rr90;
1744 delete[] rr180;
1745 delete[] rr270;
1746 return 0;
1747 }
static char ** rorate90(int n, char **start)
Definition: luogu.cpp:1749
static bool equal(int n, char **start, char **end)
Definition: luogu.cpp:1801
static char ** rorate180(int n, char **start)
Definition: luogu.cpp:1762
static char ** reflect(int n, char **start)
Definition: luogu.cpp:1788
static char ** rorate270(int n, char **start)
Definition: luogu.cpp:1775

引用了 equal(), reflect(), rorate180(), rorate270() , 以及 rorate90().

被这些函数引用 luogu::TEST().

◆ reflect()

char ** luogu::P1205::reflect ( int  n,
char **  start 
)
static

在文件 luogu.cpp1788 行定义.

1788 {
1789 auto *const cpy = new char *[n];
1790 for(int i = 0; i < n; i++) {
1791 cpy[i] = new char[n];
1792 }
1793 for(int i1 = 0, i2 = 0; i1 < n && i2 < n; i1++, i2++) {
1794 for(int j1 = 0, j2 = n - 1; j1 < n && j2 >= 0; j1++, j2--) {
1795 cpy[i1][j1] = start[i2][j2];
1796 }
1797 }
1798 return cpy;
1799 }

被这些函数引用 main().

◆ rorate180()

char ** luogu::P1205::rorate180 ( int  n,
char **  start 
)
static

在文件 luogu.cpp1762 行定义.

1762 {
1763 auto *const cpy = new char *[n];
1764 for(int i = 0; i < n; i++) {
1765 cpy[i] = new char[n];
1766 }
1767 for(int i1 = 0, i2 = n - 1; i1 < n && i2 >= 0; i1++, i2--) {
1768 for(int j1 = 0, j2 = n - 1; j1 < n && j2 >= 0; j1++, j2--) {
1769 cpy[i1][j1] = start[i2][j2];
1770 }
1771 }
1772 return cpy;
1773 }

被这些函数引用 main().

◆ rorate270()

char ** luogu::P1205::rorate270 ( int  n,
char **  start 
)
static

在文件 luogu.cpp1775 行定义.

1775 {
1776 auto *const cpy = new char *[n];
1777 for(int i = 0; i < n; i++) {
1778 cpy[i] = new char[n];
1779 }
1780 for(int i1 = 0, j2 = n - 1; i1 < n && j2 >= 0; i1++, j2--) {
1781 for(int j1 = 0, i2 = 0; j1 < n && i2 < n; j1++, i2++) {
1782 cpy[i1][j1] = start[i2][j2];
1783 }
1784 }
1785 return cpy;
1786 }

被这些函数引用 main().

◆ rorate90()

char ** luogu::P1205::rorate90 ( int  n,
char **  start 
)
static

在文件 luogu.cpp1749 行定义.

1749 {
1750 auto *const cpy = new char *[n];
1751 for(int i = 0; i < n; i++) {
1752 cpy[i] = new char[n];
1753 }
1754 for(int i1 = 0, j2 = 0; i1 < n && j2 < n; i1++, j2++) {
1755 for(int j1 = 0, i2 = n - 1; j1 < n && i2 >= 0; j1++, i2--) {
1756 cpy[i1][j1] = start[i2][j2];
1757 }
1758 }
1759 return cpy;
1760 }

被这些函数引用 main().


该类的文档由以下文件生成: