div1 250pt:

  题意:有个机器人,从某一点出发,他只有碰到地形边缘或者碰到走过的点时才会改变运动方向,然后接着走,现在给出他的运动轨迹,判断他的运动是否合法,如果合法的话,那么整个地形的最小面积是多少。

  解法:先随便设定一个起点,然后模拟机器人走的路线,先确定出来运动的大致范围,然后判断运动轨迹是否合法,也就是出了最后一步可以手动终止之外,看其他的时候,它转变方向是不是合法。。。。

 // BEGIN CUT HERE

 // END CUT HERE
#line 5 "RotatingBot.cpp"
#include<cstdio>
#include<sstream>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cassert>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int vis[][];
int dir[][] = {,,,,-,,,-};
class RotatingBot
{
public:
int minArea(vector <int> moves){
//$CARETPOSITION$
memset(vis,-,sizeof(vis));
int cur_d = ;
int cur_x = ,cur_y = ;
vis[cur_x][cur_y] = ;
for(int i = ;i < moves.size();i++){
int len = moves[i];
while(len > ){
cur_x += dir[cur_d][];
cur_y += dir[cur_d][];
if(vis[cur_x][cur_y] != -)return -;
vis[cur_x][cur_y] = i;
len --;
}
cur_d = (cur_d + ) % ;
}
// cout << "done" <<endl;
int left = ,right = ,top = ,bottom = ;
for(int i = ;i < ;i++)
for(int j = ;j < ;j++){
if(vis[i][j] != -){
left = min(left,i);
right = max(right,i);
top = max(top,j);
bottom = min(bottom,j);
}
}
// cout <<"left: "<<left<<" right: "<<right <<" top: "<<top<<" bottom:"<<bottom<<endl;
cur_x = ,cur_y = ;cur_d = ;
for(int i = ;i < moves.size();i++){
int len = moves[i];
while(len > ){
cur_x += dir[cur_d][];
cur_y += dir[cur_d][];
len --;
}
if(i == moves.size() - )continue;
int next_x = cur_x + dir[cur_d][];
int next_y = cur_y + dir[cur_d][];
if(next_x >= left && next_x <= right && next_y >= bottom && next_y <= top){
if(vis[next_x][next_y] == -)return -;
if(vis[next_x][next_y] > i)return -;
}
cur_d = (cur_d + ) % ;
}
return (right - left + ) * (top - bottom + ); } // BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -) || (Case == )) test_case_0(); if ((Case == -) || (Case == )) test_case_1(); if ((Case == -) || (Case == )) test_case_2(); if ((Case == -) || (Case == )) test_case_3(); if ((Case == -) || (Case == )) test_case_4(); if ((Case == -) || (Case == )) test_case_5(); if ((Case == -) || (Case == )) test_case_6(); if ((Case == -) || (Case == )) test_case_7(); }
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
void test_case_0() { int Arr0[] = {}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[]))); int Arg1 = ; verify_case(, Arg1, minArea(Arg0)); }
void test_case_1() { int Arr0[] = {,}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[]))); int Arg1 = ; verify_case(, Arg1, minArea(Arg0)); }
void test_case_2() { int Arr0[] = {,,,}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[]))); int Arg1 = -; verify_case(, Arg1, minArea(Arg0)); }
void test_case_3() { int Arr0[] = {,,,,,,}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[]))); int Arg1 = ; verify_case(, Arg1, minArea(Arg0)); }
void test_case_4() { int Arr0[] = {,,,,,,,,,,,,,,,,,,,,,,,,,,,,}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[]))); int Arg1 = ; verify_case(, Arg1, minArea(Arg0)); }
void test_case_5() { int Arr0[] = {,,,}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[]))); int Arg1 = -; verify_case(, Arg1, minArea(Arg0)); }
void test_case_6() { int Arr0[] = {,,}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[]))); int Arg1 = ; verify_case(, Arg1, minArea(Arg0)); }
void test_case_7() { int Arr0[] = {,,,,}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[]))); int Arg1 = ; verify_case(, Arg1, minArea(Arg0)); } // END CUT HERE };
// BEGIN CUT HERE
int main(){
RotatingBot ___test;
___test.run_test(-);
return ;
}
// END CUT HERE

250pt

div1 500pt:

  题意:两个人在一个无限大的格子里涂色,第一个人先在(0,0)涂色,然后接下来的每一轮,对于所有的点(x,y),如果(x-1,y-1)和(x-2,y)中有且只有一个点被涂色了,那么就把这个点也涂了,问经过t轮之后,某个区域的染色情况。

  解法:先在纸上模拟一下前几轮的情况,我们很容易发现,被涂色的区域就是{x>=0,y>=0并且x<=y}这部分区域,而且被涂色点的分布很像一个杨辉三角,其中被涂色的部分就是杨辉三角中奇数的点。。。于是问题就变成判断C(n,m)奇偶性的问题了,有个结论C(n,m)是奇数当且仅当n&m==n。。。

 // BEGIN CUT HERE

 // END CUT HERE
#line 5 "CheckerExpansion.cpp"
#include<cstdio>
#include<sstream>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cassert>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
class CheckerExpansion
{
public:
vector <string> resultAfter(long long t, long long x0, long long y0, int w, int h){
//$CARETPOSITION$
vector<string> ret;
// t = 5;x0 = 0;y0 = 0;w = 10;h = 10;
for(int i = ;i < h;i++){
string tmp = "";
for(int j = ;j < w;j++){
char will;
long long x = x0 + j;
long long y = y0 + h - i - ;
// if(x == y)cout <<"x : " <<x<<" y:"<<y<<endl;
if((x + y) % == ){
if(x < y){
will = '.';
}else{
long long row = (x + y) / ;
long long column = abs(x - row);
if(row + > t){
will = '.';
}else if((row & column) == column){
if(row % == ){
will = 'A';
}else{
will = 'B';
}
}else{
will = '.';
}
}
}else{
will = '.';
}
// if(x == y)cout<<will<<endl;
tmp += will;
}
ret.push_back(tmp);
// cout << tmp << endl; }
return ret; } // BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -) || (Case == )) test_case_0(); if ((Case == -) || (Case == )) test_case_1(); if ((Case == -) || (Case == )) test_case_2(); if ((Case == -) || (Case == )) test_case_3(); }
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const vector <string> &Expected, const vector <string> &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: " << print_array(Expected) << endl; cerr << "\tReceived: " << print_array(Received) << endl; } }
void test_case_0() { long long Arg0 = 1LL; long long Arg1 = 0LL; long long Arg2 = 0LL; int Arg3 = ; int Arg4 = ; string Arr5[] = {"....", "....", "....", "A..." }; vector <string> Arg5(Arr5, Arr5 + (sizeof(Arr5) / sizeof(Arr5[]))); verify_case(, Arg5, resultAfter(Arg0, Arg1, Arg2, Arg3, Arg4)); }
void test_case_1() { long long Arg0 = 5LL; long long Arg1 = 4LL; long long Arg2 = 1LL; int Arg3 = ; int Arg4 = ; string Arr5[] = {"A..", "...", "B..", ".B." }; vector <string> Arg5(Arr5, Arr5 + (sizeof(Arr5) / sizeof(Arr5[]))); verify_case(, Arg5, resultAfter(Arg0, Arg1, Arg2, Arg3, Arg4)); }
void test_case_2() { long long Arg0 = 1024LL; long long Arg1 = 1525LL; long long Arg2 = 512LL; int Arg3 = ; int Arg4 = ; string Arr5[] = {"B...B...B...........", ".B.A.B.A.B.........." }; vector <string> Arg5(Arr5, Arr5 + (sizeof(Arr5) / sizeof(Arr5[]))); verify_case(, Arg5, resultAfter(Arg0, Arg1, Arg2, Arg3, Arg4)); }
void test_case_3() { long long Arg0 = 53LL; long long Arg1 = 85LL; long long Arg2 = 6LL; int Arg3 = ; int Arg4 = ; string Arr5[] = {".....", ".....", "B....", ".B.A.", ".....", ".....", ".....", ".....", ".....", ".....", "B....", ".B...", "..B..", ".A.B." }; vector <string> Arg5(Arr5, Arr5 + (sizeof(Arr5) / sizeof(Arr5[]))); verify_case(, Arg5, resultAfter(Arg0, Arg1, Arg2, Arg3, Arg4)); } // END CUT HERE };
// BEGIN CUT HERE
int main(){
CheckerExpansion ___test;
___test.run_test(-);
return ;
}
// END CUT HERE

500pt

topcoder srm 550的更多相关文章

  1. topcoder srm 550 div1

    problem1 link 因为数据比较小,直接开一个二维数组记录哪些格子已经遍历,哪些还没有.进行模拟即可. problem2 link 模拟一些小数据,可以发现,AB的形状以及要求的区间是下面的样 ...

  2. TopCoder SRM 560 Div 1 - Problem 1000 BoundedOptimization & Codeforces 839 E

    传送门:https://284914869.github.io/AEoj/560.html 题目简述: 定义"项"为两个不同变量相乘. 求一个由多个不同"项"相 ...

  3. Topcoder SRM 643 Div1 250<peter_pan>

    Topcoder SRM 643 Div1 250 Problem 给一个整数N,再给一个vector<long long>v; N可以表示成若干个素数的乘积,N=p0*p1*p2*... ...

  4. Topcoder Srm 726 Div1 Hard

    Topcoder Srm 726 Div1 Hard 解题思路: 问题可以看做一个二分图,左边一个点向右边一段区间连边,匹配了左边一个点就能获得对应的权值,最大化所得到的权值的和. 然后可以证明一个结 ...

  5. TopCoder SRM 667 Div.2题解

    概览: T1 枚举 T2 状压DP T3 DP TopCoder SRM 667 Div.2 T1 解题思路 由于数据范围很小,所以直接枚举所有点,判断是否可行.时间复杂度O(δX × δY),空间复 ...

  6. Topcoder Srm 673 Div2 1000 BearPermutations2

    \(>Topcoder \space Srm \space 673 \space Div2 \space 1000 \space BearPermutations2<\) 题目大意 : 对 ...

  7. Topcoder Srm 671 Div2 1000 BearDestroysDiv2

    \(>Topcoder \space Srm \space 671 \space Div2 \space 1000 \space BearDestroysDiv2<\) 题目大意 : 有一 ...

  8. [topcoder]SRM 646 DIV 2

    第一题:K等于1或者2,非常简单.略.K更多的情况,http://www.cnblogs.com/lautsie/p/4242975.html,值得思考. 第二题:http://www.cnblogs ...

  9. [topcoder]SRM 633 DIV 2

    第一题,http://community.topcoder.com/stat?c=problem_statement&pm=13462&rd=16076 模拟就可以了. #includ ...

随机推荐

  1. k8s集群之master节点部署

    apiserver的部署 api-server的部署脚本 [root@mast-1 k8s]# cat apiserver.sh #!/bin/bash MASTER_ADDRESS=$1 主节点IP ...

  2. QT+信号有参数与无参数的实现+QT4和QT5在信号和槽使用上的区别

    在QT5中,信号有参数和无参数 #ifndef SUBWIDGET_H #define SUBWIDGET_H #include <QWidget> #include <QPushB ...

  3. Ubuntu18.04 NVIDIA显卡驱动 安装大全

    离线安装NVIDIA显卡驱动 费了一天的劲,走了好多的坑,最主要的原因是gcc版本的问题,一定要用最新版本的gcc!!! 1)官网下载显卡驱动 2)apt 下载gcc包及其依赖包,可用apt-cach ...

  4. Mysql 一对多关系建立(在navicat中)

    一个孩子只有一个妈妈,而一个妈妈可以有多个孩子,这是典型的一对多的关系,这里采用navicat图形化界面建立二者的关系. 第一步:创建mother表,如下图: 第二步:创建children表,在chi ...

  5. Java之浅拷贝与深拷贝

    ----?浅拷贝 --- 概念 被复制对象的所有变量都含有与原来的对象相同的值,而所有的对其他对象的引用仍然指向原来的对象.简单说,浅拷贝就是只复制所考虑的对象,而不复制它所引用的对象 --- 实现方 ...

  6. Jenkins中部署Sonar代码检查

    1 安装并启动sonarqube docker pull sonarqube:7.5-community docker run \ --name sonarqube \ --network ci \ ...

  7. ubuntu 宝塔安装一条龙服务

    ubuntu 安装 1, wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && sudo bash ...

  8. 基于tiny4412的u-boot移植(二)(转)

    http://www.cnblogs.com/pengdonglin137/archive/2015/12/27/5080645.html

  9. 【笔记】linux x86漏洞利用

    0x1任意代码执行是如何实现的? 任意代码执行使用一种叫“覆盖返回地址”的技术来实现.这种方式使得攻击者重写位于栈上的返回地址,这将导致任意代码执行.

  10. Git上传的使用步骤

    Git上传的使用步骤 首先 git branch 查看当前的分支是否为本地自己分支 接着 git stash 保存本地自己的保存 git checkout earemote 查看本地共有开发分支 gi ...