https://cn.vjudge.net/contest/234044#overview
总体而言一部分傻逼题一部分难题
A.
傻逼题1
拿stack模拟一下即可。
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<vector>
using namespace std;
int main()
{
int n,i,j,k;
string str1,str2;
while(cin>>n){
cin>>str1>>str2;reverse(str2.begin(),str2.end());
vector<int>ans;
stack<int>sta1,sta2;
for(i=0;i<str2.size();i++)sta2.push(str2[i]);
for(i=0;i<str1.size();i++){
ans.push_back(1);sta1.push(str1[i]);
while(!sta1.empty()&&sta1.top()==sta2.top())
sta1.pop(),sta2.pop(),ans.push_back(2);
}
if(!sta1.empty()){
puts("No.");
}
else{
puts("Yes.");
for(i=0;i<ans.size();i++)
if(ans[i]==1)
puts("in");
else puts("out");
}
puts("FINISH");
}
return 0;
}
B.HDU1023
裸的卡特兰数,不知道的话这题可以弃疗了(比如像本蒟蒻,摔
要么打表,网上有卡特兰数的表,要么递推求,int128是水不过去的,老老实实写高精吧,或者赶紧学一波java(摔
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn = 1000;
struct bign{
int d[maxn], len;
void clean() { while(len > 1 && !d[len-1]) len--; }
bign() { memset(d, 0, sizeof(d)); len = 1; }
bign(int num) { *this = num; }
bign(char* num) { *this = num; }
bign operator = (const char* num){
memset(d, 0, sizeof(d)); len = strlen(num);
for(int i = 0; i < len; i++) d[i] = num[len-1-i] - '0';
clean();
return *this;
}
bign operator = (int num){
char s[20]; sprintf(s, "%d", num);
*this = s;
return *this;
}
bign operator + (const bign& b){
bign c = *this; int i;
for (i = 0; i < b.len; i++){
c.d[i] += b.d[i];
if (c.d[i] > 9) c.d[i]%=10, c.d[i+1]++;
}
while (c.d[i] > 9) c.d[i++]%=10, c.d[i]++;
c.len = max(len, b.len);
if (c.d[i] && c.len <= i) c.len = i+1;
return c;
}
bign operator - (const bign& b){
bign c = *this; int i;
for (i = 0; i < b.len; i++){
c.d[i] -= b.d[i];
if (c.d[i] < 0) c.d[i]+=10, c.d[i+1]--;
}
while (c.d[i] < 0) c.d[i++]+=10, c.d[i]--;
c.clean();
return c;
}
bign operator * (const bign& b)const{
int i, j; bign c; c.len = len + b.len;
for(j = 0; j < b.len; j++) for(i =