Example #1
0
int main()
{
	int i;
	FILE *fin  = fopen ("fence4.in", "r");
    FILE *fout = fopen ("fence4.out", "w");
	fscanf(fin,"%d",&total);
	fscanf(fin,"%d %d",&tx,&ty);
	for(i=1;i<=total;i++)
		fscanf(fin,"%d %d",&p[i][0],&p[i][1]);
	for(i=2;i<=total;i++)
	{
		v[i-1].sx=p[i-1][0];
		v[i-1].sy=p[i-1][1];
		v[i-1].ex=p[i][0];
		v[i-1].ey=p[i][1];
	}
	v[total].sx=p[total][0];
	v[total].sy=p[total][1];
	v[total].ex=p[1][0];
	v[total].ey=p[1][1];
	for(i=3;i<total;i++)
	{
		if(Judge(1,i))
		{
			fprintf(fout,"NOFENCE\n");
			return 0;
		}
	}
	if(Judge(2,total))
	{
		fprintf(fout,"NOFENCE\n");
		return 0;
	}
	for(i=1;i<=total;i++)
	{
		Compute(i);
	}
	for(i=1;i<=total;i++)
	{
		if(find(i))
		{
			ans++;
			is[i]=1;
		}
	}
	fprintf(fout,"%d\n",ans);
	for(i=1;i<total-1;i++)
	{
		if(is[i])
			fprintf(fout,"%d %d %d %d\n",v[i].sx,v[i].sy,v[i].ex,v[i].ey);
	}
	if(is[total])
		fprintf(fout,"%d %d %d %d\n",v[total].ex,v[total].ey,v[total].sx,v[total].sy);
	if(is[total-1])
		fprintf(fout,"%d %d %d %d\n",v[total-1].sx,v[total-1].sy,v[total-1].ex,v[total-1].ey);
	return 0;
}
Example #2
0
File: 1133.c Project: xdbaqiao/OJ
int main(int argc,char *argv[])
{
    char str1[110],str2[110];
    int J1,J2;
    while(scanf("%s%s",str1,str2)!=EOF)
    {

        J1=Judge(str1);
        J2=Judge(str2);
        if(J1>J2) printf("wm\n");
        else if(J1<J2) printf("zyf\n");
        else printf("neither\n");
    }
    return 0;
}
Example #3
0
double SimpleMonteCarlo::operator()(const GameState& state, int ms)
{	
	int wins = 0;
	for(int i = 0; i < playoutCount_; ++i)
		wins += Judge(playoutAi1_, playoutAi2_, state).run().whoWon() == me_;
	return ((double) wins) / playoutCount_;
}
Example #4
0
int main()
{
    int i, Max, Maxi, y;
    scanf("%s", Str);
    for(i = 0; Str[i + 9] != '\0'; ++i) {
        Judge(i);
    }
    for(Max = 0, i = 365 * 3; i > 0; --i) {
        if(Hash[i] > Max) {
            Max = Hash[i];
            Maxi = i;
        }
    }
    if(Maxi % 365 == 0) {
        printf("31-12-%d\n", 2012 + Maxi / 365);
        return 0;
    }
    y = Maxi / 365 + 2013;
    Maxi %= 365;
    for(i = 1; i < 13; ++i) {
        if(Maxi <= Date[i]) {
            break;
        }
        Maxi -= Date[i];
    }
    printf("%02d-%02d-%d\n", Maxi, i, y);
    return 0;
}
Example #5
0
void MainWindow::setBox()
{
	
		scene->textItem[scene->GeoNum]->setParam(boxpage->returnParam());

		Judge();
	
}
Example #6
0
void MainWindow::setCylinder()
{
	
		scene->textItem[scene->GeoNum]->setParam(cylinderpage->returnParam());

		Judge();
	
}
Example #7
0
void MainWindow::setCone()
{
	
		scene->textItem[scene->GeoNum]->setParam(conepage->returnParam());

		Judge();
	
}
Example #8
0
void MainWindow::setFix()
{
	
		
		scene->actItem[scene->RotNum]->setParam(fixpage->returnParam());
		Judge();
	
}
Example #9
0
void MainWindow::senInserted(SensorItem *item)
{
	buttonGroup->button(InsertsenButton)->setChecked(false);
    scene->setMode(MoveItem);
	c->CHECK = false;
	Judge();

}
Example #10
0
void MainWindow::camInserted(CameraItem *item)
{
	buttonGroup->button(InsertcamButton)->setChecked(false);
    scene->setMode(MoveItem);
	c->CHECK = false;
	Judge();

}
Example #11
0
void MainWindow::setSphere()
{
	
		scene->textItem[scene->GeoNum]->setParam(spherepage->returnParam());

		Judge();

	
}
Example #12
0
void MainWindow::textInserted(BodyItem *item)
{
	buttonGroup->button(InsertTextButton)->setChecked(false);
    scene->setMode(MoveItem);
	c->CHECK = false;
	Judge();
	

}
Example #13
0
//触控结束事件的处理方法
void SpriteManager::myOnTouchEnded(Touch *touch, Event *event)
{
	isTouchMove = false;
	//获取的当前触摸的对象,并转化为精灵类型
	Sprite* targetSp = static_cast<Sprite*>(event->getCurrentTarget());
	//获取当前坐标
	Point location = targetSp->convertToNodeSpace(touch->getLocation());
	Judge(targetSp, location);
}
Example #14
0
int main()
{
    int a[]={19,25,13,10,2,5,1,8,7,9};
    int len=sizeof(a)/sizeof(a[0]);
    QuickSort(a,0,len-1);
    int sum;
    printf("Please input the sum:");
    scanf("%d",&sum);
    Judge(a,len,sum);
}
Example #15
0
void MainWindow::setPolygon()
{
	
		
	
		scene->textItem[scene->GeoNum]->setParam(polygonpage->returnParam());

		Judge();
	
}
void main()
{
	int i,iCount;
	while(cin>>iHeight>>iWidth && iHeight>0)
	{
		for(i=0;i<iHeight;i++)cin>>cBoard[i];
		if((iCount=Judge())>=0)cout<<"There are "<<iCount<<" ships."<<endl;
		else cout<<"Bad placement."<<endl;
	}
}
Example #17
0
void MainWindow::actInserted(JointItem *item)
{
	buttonGroup->button(InsertactButton)->setChecked(false);
    scene->setMode(MoveItem);
	Judge();
	c->CHECK = false;

		
	//c->LoadNode();
}
Example #18
0
//开始触控事件的处理方法
bool SpriteManager::myOnTouchBegan(Touch *touch, Event *event)
{
	isTouchBegin = true;

	//获取的当前触摸的对象,并转化为精灵类型
	Sprite* targetSp = static_cast<Sprite*>(event->getCurrentTarget());
	//获取当前坐标
	Point location = targetSp->convertToNodeSpace(touch->getLocation());

	return Judge(targetSp, location);
}
Example #19
0
int main(void)
{
    int Judge(unsigned char str[]);//函数声明
    int judge(int a);

    unsigned char str[30];//定义一个数组长度为30的字符串数组

    while (gets (str) != NULL)//无限输入字符串
        printf(Judge(str) ? "Y\n" : "N\n");//调用函数Judge并判断

    return 0;
}
Example #20
0
void MainWindow::deleteItem()
{
   scene->deleteItem();
   	/*c->setNum(scene->ReturnItemCount());
	for(int i=0;i<scene->ReturnItemCount();i++)
	{
		c->setBody(i,scene->ReturnGeom(i),scene->ReturnParam(i),scene->returnFlag(i),scene->returnTip(i));
	}*/
    Judge();
	c->update();
	c->CHECK = false;
}
Example #21
0
int Is(int tar)
{
	int i,flag=0;
	for(i=2;i<11;i++)
	{
		if(tar%i==0)
			continue;
		flag+=Judge(tar,i);
		if(flag>=2)
			return 1;
	}
	return 0;
}
Example #22
0
int main(int ac, char **av)
{
  unsigned char **p;
  int X, Y;
  int x, y;
  char buf[256];
  FILE *fp;
  int xs, ys, xe, ye;
  int th1, th2;

  if (ac == 1){ fprintf(stderr, "usage: %s *.pgm\n", av[0]); exit(1);}
  fp = fopen(av[1], "rb");
  if (ac == 2){ th1 = BLACK; th2 = 0;}
  else if (ac == 3){ th1 = atoi(av[2]); th2 = 0;}
  else {th1 = atoi(av[2]); th2 = atoi(av[3]);}

  fgets(buf, 255, fp);
  fgets(buf, 255, fp);
  while(buf[0] == '#')
    fgets(buf, 255, fp);
  X = atoi(strtok(buf, " \t\n"));
  Y = atoi(strtok(NULL, " \t\n"));
  fgets(buf, 255, fp);
  p = (unsigned char **)malloc(sizeof(unsigned char *) * X);
  for (x = 0; x < X; x++)
    p[x] = (unsigned char *)malloc(sizeof(unsigned char) * Y);

  for (y = 0; y < Y; y++)
    for (x = 0; x < X; x++)
      p[x][y] = (unsigned char)fgetc(fp);

  // fill orthological corner
  for (y = 0; y < Y - 1; y++){
    for (x = 0; x < X - 1; x++){
      int p00, p01, p10, p11;
      p00 = Judge(p[x][y], th1, th2);
      p10 = Judge(p[x+1][y], th1, th2);
      p01 = Judge(p[x][y+1], th1, th2);
      p11 = Judge(p[x+1][y+1], th1, th2);
      if (p00 == 0 && p10 == 1 && p01 == 1 && p11 == 0) p[x+1][y+1] = p[x][y+1];
      if (p00 == 1 && p10 == 0 && p01 == 0 && p11 == 1) p[x][y+1] = p[x+1][y+1];
    }
  }

  printf("l %d\n", LAYER);
  for (y = 0; y < Y; y++){
    xs = -1;
    for (x = 0; x < X; x++){
      if (Judge(p[x][y], th1, th2) == 1 && xs == -1)	xs = x;
      if ((Judge(p[x][y], th1, th2) != 1 || x == X-1) && xs != -1){
	xe = x;
	printf("B %d %d %d %d\n", xs*STEP, -y*STEP, xe*STEP, -(y+1)*STEP);
	xs = -1;
      }
    }
  }
  fclose(fp);
  return(0);
}
void P(int a[],int m,int n)
{
     int i;
     if(n==m)
     {
        for(i=0;i<n;i++)
            printf("%d",a[i]); 
        printf("\n");
     }
     else
        for(i=0;i<6;i++)
        {
             a[m]=t[i];
             if(Judge(a,m)==1)
                 P(a,m+1,n);
        }
}
Example #24
0
int main(int argc, char *argv[])
{
	NS  n;
	OS  o;
	char s[50];

	InitNumStack(&n);
	InitOperationStack(&o);
	printf("请输入多项式(以‘#’结束):");
	scanf("%s",s);
	printf("%s\n",s);
	Judge(&n,&o,s);


	
	return EXIT_SUCCESS;
}
Example #25
0
int main(int argc, char* argv[]) {
	// argv[1] = source_name 
	// argv[2] = problem_id
	// argv[3] = time_limit
	// argv[4] = memory_limit 
	// argv[5] = language

	// make helper class
	Helper helper;

	// initializing submission informaion.
	const std::string source_path = std::string(argv[1]);
	const std::string problem_id = std::string(argv[2]);
	const int time_limit = helper.string_to_int(std::string(argv[3])) * 1000;
	const int memory_limit = helper.string_to_int(std::string(argv[4]));
	const int language = helper.string_to_int(std::string(argv[5]));
	const std::string submission_id = std::string(argv[6]);

	// initializing judge data.
	const std::string result_file_path = "/home/minho/Judge_Program/executionresult";
	const std::string judge_data_path = "/home/minho/Judge_Data";

	// make compiler instance
	Compiler compiler(language, source_path);

	// source code compile.
	compiler.source_compile();

	// check binary file.
	std::string json;
	if(!helper.path_file_exist(compiler.get_binary_path())) {
		// is not exist set result compile error and exit judge program.
		json = helper.make_json_syntax(COMPILE_ERROR, 0, 0, 0);
	}
	else {
		// sucess compile, make judge class and judging!!
		// exeption or svae result work in Judge class.
		json = Judge(result_file_path, judge_data_path, problem_id, submission_id, compiler.get_binary_path(), time_limit, memory_limit, language).execution();
	}

	helper.make_file(judge_data_path + "/result", submission_id + ".res.json", json);

	return 0;
}
Example #26
0
void Construct(Cube space,Piece p[8],int p_num){
  int x,y,z,rxy,rz;
  int next_p_num;
  int existing,i;
 
  for(z=1;z<=3;z++){for(y=1;y<=3;y++){for(x=1;x<=3;x++){
 
	for(rxy=0;rxy<6;rxy++){
	  for(rz=0;rz<4;rz++){
 
	    if(Judge(space,p,p_num,x,y,z)==1){
	      space=PutPiece(space,p,p_num,x,y,z);
	      printf("[[%d]] (%d,%d,%d)\n\n",p_num,x,y,z);
	      ShowSpace(space);
 
	      if(p_num<PIECENUM){
		if(ImpossibleBreak(space)==0){
		  next_p_num=p_num+1;
		  Construct(space,p,next_p_num);
		}
	      }else{ //completed
		existing=0;i=0;
		while(i<=ansnum&&existing==0){
		  if(CompareCube(space,ans[i])==1){existing=1;}
		  i++;
		}
		if(existing==0){ansnum++;ans[ansnum]=space;}
	      }
 
	      space=RemovePiece(space,p_num);
	      if(p_num==PIECENUM){goto noRotation;}
	    }
	    if(p_num==1){goto noRotation;}
 
	    p[p_num]=Rotate(p[p_num],2,0,1); //rotate z
	  }
	  if(rxy<=3){p[p_num]=Rotate(p[p_num],1,2,0);} //rotate x
	  else if(rxy==4){p[p_num]=Rotate(p[p_num],0,1,2);} //rotate y
	  else if(rxy==5){p[p_num]=Rotate(p[p_num],0,1,2);
	    p[p_num]=Rotate(p[p_num],0,1,2);}
	}
      noRotation:;
      }}}
}
Example #27
0
void count(int (*map)[N], int x, int y) {
    for (int i = 1; i <= N; i++) {
        if (Judge(map, x, y, i)) {  // Judge(map, x, y, i)用于判断map[x][y] = i是否满足要求
            map[x][y] = i;
            if (y == N - 1 && x < N - 1) {
                count(map, x + 1, 0);
                map[x][y] = 0;
            } else if (y < N - 1) {
                count(map, x, y + 1);
                map[x][y] = 0;
            } else if (y == N - 1 && x == N - 1) {
                Count++;
                map[x][y] = 0;
                printf("%d\n", Count);
            }
        }
    }
    return;
}
Example #28
0
int main()
{
	int i,j;
	FILE *fin  = fopen ("castle.in", "r");
    FILE *fout = fopen ("castle.out", "w");
	fscanf(fin,"%d %d",&n,&m);
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
			fscanf(fin,"%d",&map[i][j]);
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(room[i][j])
				continue;
			tot++;
			search(i,j);
		}
	}
	fprintf(fout,"%d\n",tot);
	for(i=1,max=0;i<=tot;i++)
	{
		if(rt[i]>max)
			max=rt[i];
	}
	fprintf(fout,"%d\n",max);
	for(j=1,max=0;j<=n;j++)
	{
		for(i=m;i>=1;i--)
		{
			Judge(i,j);
		}
	}
	fprintf(fout,"%d\n",max);
	fprintf(fout,"%d %d ",ci,cj);
	if(cd==1)
		fprintf(fout,"N\n");
	else
		fprintf(fout,"E\n");
	return 0;
}
 int main()
 {
    FILE *fin , *fout;
    fin = freopen("crypt1.in" , "r" , stdin);
    fout = freopen("crypt1.out" , "w" , stdout);
    int temp ,  n , i , j , k , v , w  , a[6];
    int count = 0 ;
    char num[10] ;
    scanf( "%d" , &n );
    
    /*ÊäÈëÊý×Ö*/
    getchar();
    for( i = 0; i < n - 1;i ++ ){
        num[i] = getchar();
        getchar();
    }
    num[n - 1] = getchar();
    num[n] = '\0';

    for( i = 0;i < n ;i ++ ){
         a[0] = num[i] - '0';
        for( j = 0;j < n;j ++ ){
            a[1] = num[j] - '0';
            for( k = 0;k < n;k ++ ){
                a[2] = num[k] - '0';
                for( v = 0;v < n;v ++ ){
                    a[3] = num[v] - '0';
                    for( w = 0;w < n;w ++ ){
                        a[4] = num[w] - '0';
                        /*´ÖÂÔÅжϣ¬ÓÃÓÚ¼ôÖ¦*/   //  + a[1] * a[3] / 10     + a[1] * a[4] / 10
                        if((a[0] * a[3] > 10)||(a[4] * a[0]  > 10))
                            continue;
                        //if(a[0] != 3)
                        //printf( "%d %d %d %d %d\n" , a[0] , a[1],a[2],a[3],a[4] );
                        if(Judge(a , num , n)) count ++;
                    }
                }
            }
        }
    }
     printf( "%d\n" ,count );
    return 0;
 }
Example #30
0
void DrawWidget::mouseReleaseEvent(QMouseEvent *)  //鼠标释放事件
{
    Judge(arr, myIndex);  //调用处理函数
    //将找到的字显示在右边? 先打印输出
    //QDebug("%s", chinese_result[0]);
    //将char *类型的chinese_result中的汉字转换为QString类型的,然后在按钮上显示
    //使用:QTextCodec *codec = QTextCodec::codecForName("GBK");
    //     QString strText = codec->toUnicode(string);
    QTextCodec *codec = QTextCodec::codecForName("utf8");
    QString strText;
    for (int i = 0; i < 8; i++) {
        strText = codec->toUnicode(chinese_result[i]);
        //qDebug() << strText;
        mBtn[i]->setText(strText);
        // connect(colorBtn, SIGNAL(clicked()), this, SLOT(slotColor()));
    }

    myIndex = 0;  //复位
    memset(arr, 0, sizeof(arr));
}