A - Not Overflow
long long范围的数判断是否在int范围内,就可以强制转换
AC代码:
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <numeric>
#include <iomanip>
#include <functional>
using namespace std;
#define lowbit(x) ((x) & -(x))
#define IOS1 ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define IOS2 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
/*
Tips:
1.int? long long?
2.don't submit wrong answer
3.figure out logic first, then start writing please
4.know about the range
5.check if you have to input t or not
6.modulo of negative numbers is not a%b, it is a%b + abs(b)
*/
const int INF = 0x3f3f3f3f;
const int mod = 1000000007;
void solve() {
long long n;
cin >> n;
int m;
m = n;
if (m == n) {
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}
}
int main() {
IOS1;
//IOS2;
int __t = 1;
//cin >> __t;
for (int _t = 1; _t <= __t; _t++) {
solve();
}
return 0;
}
/*
*/
B - Matrix Transposition
AC代码:
二维,数据大可能会被卡空间的
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <map>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <numeric>
#include <iomanip>
#include <functional>
using namespace std;
#define lowbit(x) ((x) & -(x))
#define IOS1 ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define IOS2 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
/*
Tips:
1.int? long long?
2.don't submit wrong answer
3.figure out logic first, then start writing please
4.know about the range
5.check if you have to input t or not
6.modulo of negative numbers is not a%b, it is a%b + abs(b)
*/
const int INF = 0x3f3f3f3f;
const int mod = 1000000007;
void solve() {
int h, w;
cin >> h >> w;
int x = max(h, w);
vector<vector<int>> a(h + 5, vector<int>(w + 5, 0));
vector<vector<int>> b(w + 5, vector<int>(h + 5, 0));
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
cin >> a[i][j];
}
}
for (int i = 1; i <= w; i++) {
for (int j = 1; j <= h; j++) {
b[i][j] = a[j][i];
}
}
for (int i = 1; i <= w; i++) {
for (int j = 1; j <= h; j++) {
cout << b[i][j] << " \n"[j == h];
}
}
}
int main() {
IOS1;
//IOS2;
int __t = 1;
//cin >> __t;
for (int _t = 1; _t <= __t; _t++) {
solve();
}
return 0;
}
/*
*/
一维,要看好各个行列关系
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <map>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <numeric>
#include <iomanip>
#include <functional>
using namespace std;
#define lowbit(x) ((x) & -(x))
#define IOS1 ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define IOS2 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T>
T power(T a, int b) {
T res = 1;
for (; b; b >>= 1, a = a * a) {
if (b & 1) {
res = res * a;
}
}
return res;
}
template <typename T>
inline T
read() {
T sum = 0, fl = 1;
int ch = getchar();
for (; !isdigit(ch); ch = getchar())
if (ch == '-') fl = -1;
for (; isdigit(ch); ch = getchar()) sum = sum * 10 + ch - '0';
return sum * fl;
}
/*
Tips:
1.int? long long?
2.don't submit wrong answer
3.figure out logic first, then start writing please
4.know about the range
5.check if you have to input t or not
6.modulo of negative numbers is not a%b, it is a%b + abs(b)
*/
const int INF = 0x3f3f3f3f;
const int mod = 1000000007;
void solve() {
int h, w;
cin >> h >> w;
vector<int> a(100010);
for (int i = 1; i <= h * w; i++) {
cin >> a[i];
}
for (int i = 1; i <= w; i++) {
for (int j = 1; j <= h; j++) {
cout << a[(j - 1) * w + i] << " \n"[j == h];
}
}
}
int main() {
IOS1;
//IOS2;
int __t = 1;
//cin >> __t;
for (int _t = 1; _t <= __t; _t++) {
solve();
}
return 0;
}
/*
*/
C - kasaka
从开头添加若干个或零个a是否能成为回文字符串
AC代码:
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <map>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <numeric>
#include <iomanip>
#include <functional>
using namespace std;
#define lowbit(x) ((x) & -(x))
#define IOS1 ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define IOS2 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
/*
Tips:
1.int? long long?
2.don't submit wrong answer
3.figure out logic first, then start writing please
4.know about the range
5.check if you have to input t or not
6.modulo of negative numbers is not a%b, it is a%b + abs(b)
*/
const int INF = 0x3f3f3f3f;
const int mod = 1000000007;
void solve() {
string s;
cin >> s;
int len = s.length();
bool ok = true;
for (int i = 0; i < len / 2; i++) {
if (s[i] != s[len - 1 - i]) {
ok = false;
}
}
if (ok) {
cout << "Yes" << endl;
}
else {
int cnt = 0;
for (int i = len - 1; i >= 0; i--) {
if (s[i] == 'a') {
cnt++;
}
else {
break;
}
}
int cnt1 = 0;
for (int i = 0; i <= len - 1; i++) {
if (s[i] == 'a') {
cnt1++;
}
else {
break;
}
}
int cnt2 = abs(cnt1 - cnt);
if (cnt1 >= cnt) {
cout << "No" << endl;
return;
}
string s1 = "";
for (int i = 1; i <= cnt2; i++) {
s1 += 'a';
}
s1 += s;
ok = true;
int len1 = s1.length();
for (int i = 0; i < len1 / 2; i++) {
if (s1[i] != s1[len1 - 1 - i]) {
ok = false;
}
}
if (ok) {
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}
}
}
int main() {
IOS1;
//IOS2;
int __t = 1;
//cin >> __t;
for (int _t = 1; _t <= __t; _t++) {
solve();
}
return 0;
}
/*
*/
D
D - LR insertion
根据题意就是往当前数的左边或者右边添值,乍一看从正面好像不太好弄,那就可以考虑逆着来,数组开个1e6不会太大,直接逆序添加就好了,L就放右边,R就放左边
AC代码:
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <map>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <numeric>
#include <iomanip>
#include <functional>
using namespace std;
#define lowbit(x) ((x) & -(x))
#define IOS1 ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define IOS2 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T>
T power(T a, int b) {
T res = 1;
for (; b; b >>= 1, a = a * a) {
if (b & 1) {
res = res * a;
}
}
return res;
}
template <typename T>
inline T
read() {
T sum = 0, fl = 1;
int ch = getchar();
for (; !isdigit(ch); ch = getchar())
if (ch == '-') fl = -1;
for (; isdigit(ch); ch = getchar()) sum = sum * 10 + ch - '0';
return sum * fl;
}
/*
Tips:
1.int? long long?
2.don't submit wrong answer
3.figure out logic first, then start writing please
4.know about the range
5.check if you have to input t or not
6.modulo of negative numbers is not a%b, it is a%b + abs(b)
*/
const int INF = 0x3f3f3f3f;
const int mod = 1000000007;
void solve() {
int n;
cin >> n;
vector<int> a(1000010);
string s;
cin >> s;
int len = s.size();
int left = 500000 - 1, right = 500000 + 1;
int x = len - 1;
a[500000] = len;
for (int i = len - 1; i >= 0; i--) {
if (s[i] == 'L') {
a[right++] = x;
x--;
}
else {
a[left--] = x;
x--;
}
}
for (int i = left + 1; i < right; i++) {
cout << a[i] << " \n"[i == right - 1];
}
}
int main() {
IOS1;
//IOS2;
int __t = 1;
//cin >> __t;
for (int _t = 1; _t <= __t; _t++) {
solve();
}
return 0;
}
/*
*/