// ConsoleApplication15.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。
//
#include <iostream>
#include<vector>
using namespace std;
bool Palindrome(vector<char>list);
int main()
{
int count;
vector<char>list;
while (cin >> count) {
while (count--) {
int a, b;
char temp;
cin >> a >> b;
for (int i = 0; i < a * b; i++) {
cin >> temp;
list.push_back(temp);
}
if (Palindrome(list)) {
cout << "go forward" << endl;
}
else {
cout << "keep defending" << endl;
}
list.clear();
}
}
}
bool Palindrome(vector<char>list) {
for (int i = 0; i < list.size() / 2; ++i)
if (list[i] != list[list.size() - 1 - i])
return false;
return true;
}
注意 Input:
而接下會有N行,每一行會有M個數字 r (0<=r<231-1)
這裡 r 的範圍可能是 HTML 沒寫好,應該是 (0 <= r < 2^(31) - 1)
,範圍超出 char
,會讓你這行出錯
cin >> temp;
把 temp 宣告成 int
試試