经GYZ、CLJ神牛指点,在N次Error后终于注册成功了……
Topcoder与NOI的规则区别:
【1】Topcoder的代码不是一个完整的代码(连main()都米有),而只是一个类,类里面只有一个方法(相当于main())。不用输入、输出,系统会将输入数据直接传递到这个方法的参数里,在方法执行完后将返回值直接传递到输出里。类名、方法名、输入参数类型、输出结果类型是在原题中规定的(但参数名、输出结果名可以自定义)。代码中可以(也必须)使用C++ STL。
【2】捉题的时候,题目描述下面的编码区里可以直接编代码,编好后点下面的Compile编译,再点Test测试(可以测试样例和自己的数据),测试完毕后,点Submit提交。所以,不必向其它OJ一样在IDE里编好再Ctrl+ACV提交。
其它的可以参照网上其他人写的东东。
本沙茶先在里面捉了几题(全是水题,神犇不要鄙视),代码:
SRM 506 DIV1 250:
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
using namespace std;
#define re(i, n) for (int i=0; i<n; i++)
#define re1(i, n) for (int i=1; i<=n; i++)
#define re2(i, l, r) for (int i=l; i<r; i++)
#define re3(i, l, r) for (int i=l; i<=r; i++)
#define rre(i, n) for (int i=n-1; i>=0; i--)
#define rre1(i, n) for (int i=n; i>0; i--)
#define rre2(i, r, l) for (int i=r-1; i>=l; i--)
#define rre3(i, r, l) for (int i=r; i>=l; i--)
#define debug(x) cout << #x << " = " << x << endl;
#define pb push_back
#define re_t(i,x) for(typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define all(x) x.begin(),x.end()
#define SORT(x) sort(all(x))
#define MP make_pair
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vi::iterator vit;
typedef set<int> si;
typedef si::iterator sit;
typedef map<int,int> mii;
typedef mii::iterator mit;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef istringstream ISS;
typedef ostringstream OSS;
const int MAXN = 175000, INF = ~0U >> 2;
class MathContest {
public:
int countBlack(string s0, int p)
{
string s = "";
bool a[MAXN];
re(i, p) s += s0;
int n = s.length(), res = 0;
re(i, n) a[i] = s[i] == 'B';
int i = 0, j = s.length() - 1;
bool reversed = 0, turned = 0, v;
while (i <= j) {
if (reversed) {
v = a[j--];
if (turned) v = !v;
} else {
v = a[i++];
if (turned) v = !v;
}
if (v) {res++; turned = !turned;} else reversed = !reversed;
}
return res;
}
};
SRM 506 DIV2 250:
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
using namespace std;
#define re(i, n) for (int i=0; i<n; i++)
#define re1(i, n) for (int i=1; i<=n; i++)
#define re2(i, l, r) for (int i=l; i<r; i++)
#define re3(i, l, r) for (int i=l; i<=r; i++)
#define rre(i, n) for (int i=n-1; i>=0; i--)
#define rre1(i, n) for (int i=n; i>0; i--)
#define rre2(i, r, l) for (int i=r-1; i>=l; i--)
#define rre3(i, r, l) for (int i=r; i>=l; i--)
#define debug(x) cout << #x << " = " << x << endl;
#define pb push_back
#define re_t(i,x) for(typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define all(x) x.begin(),x.end()
#define SORT(x) sort(all(x))
#define MP make_pair
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vi::iterator vit;
typedef set<int> si;
typedef si::iterator sit;
typedef map<int,int> mii;
typedef mii::iterator mit;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef istringstream ISS;
typedef ostringstream OSS;
const int MAXN = 10000, INF = ~0U >> 2;
class SlimeXSlimeRancher2 {
public:
int train(vector <int> a)
{
int n = a.size(), m = -INF, res = 0;
re(i, n) m = max(m, a[i]);
re(i, n) res += m - a[i];
return res;
}
};
SRM 506 DIV2 500:
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
using namespace std;
#define re(i, n) for (int i=0; i<n; i++)
#define re1(i, n) for (int i=1; i<=n; i++)
#define re2(i, l, r) for (int i=l; i<r; i++)
#define re3(i, l, r) for (int i=l; i<=r; i++)
#define rre(i, n) for (int i=n-1; i>=0; i--)
#define rre1(i, n) for (int i=n; i>0; i--)
#define rre2(i, r, l) for (int i=r-1; i>=l; i--)
#define rre3(i, r, l) for (int i=r; i>=l; i--)
#define debug(x) cout << #x << " = " << x << endl;
#define pb push_back
#define re_t(i,x) for(typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define all(x) x.begin(),x.end()
#define SORT(x) sort(all(x))
#define MP make_pair
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vi::iterator vit;
typedef set<int> si;
typedef si::iterator sit;
typedef map<int,int> mii;
typedef mii::iterator mit;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef istringstream ISS;
typedef ostringstream OSS;
const int MAXN = 10000, INF = ~0U >> 2;
class SlimeXSlimesCity {
public:
int merge(vector <int> a)
{
int n = a.size();
SORT(a);
ll s = 0, s1;
int res = 0;
bool ff;
re(i, n) {
s += a[i]; s1 = s; ff = 1;
re2(j, i + 1, n) {
if (s1 < a[j]) {ff = 0; break;}
s1 += a[j];
}
res += ff;
}
return res;
}
};