My solution for SRM 306 DIV2 [250]

原创 2006年06月09日 09:05:00
Problem Statement: http://www.topcoder.com/stat?c=problem_statement&pm=6413&rd=9986

My solution:

#include <iostream>
#include <vector>

using namespace std;

class SortMachine  {
 
public:
  SortMachine () {}
 
public:
  int countMoves(vector <int> a) {
    int countMove = 0;

    while(1) {
      int move = -1;
      int minInversion = 1001;
     
      for (unsigned int i = 0; i < a.size() - 1; ++i) {
        for (unsigned int j = i + 1; j < a.size(); ++j) {
          if (a[i] > a[j] && a[i] < minInversion) {
            move = i;
            minInversion = a[i];
            break;
          }
        }
      }
     
      if (move == -1) {
        break;
      }
     
      int temp = a[move];     
      for (unsigned int i = move; i < a.size() - 1; ++i) {
        a[i] = a[i + 1];
      }
      a[a.size() - 1] = temp;

      ++countMove;
    }
   
    return countMove;
  }
};

Topcoder SRM 709 DIV 2 250pt Robofactory solution

Problem Statement      Hero owns a factory. There are n robots working at the factory. The rob...
  • Gerry99
  • Gerry99
  • 2017年02月22日 04:22
  • 139

Codeforces Round #306 div 2 solution

这场总的来说打的还行吧,不过fst了一题很郁闷。。感觉从pkusc回来看CF的英文题面就和看中文一样。。出AB的速度我觉得还是不错的。。没什么难题完全可以AK的,但是构造题有细节理不清,要加强处理复杂...

【topcoder SRM 702 DIV 2 250】TestTaking

Problem StatementRecently, Alice had to take a test. The test consisted of a sequence of true/false ...

SRM 145 DIV 2 250

class ImageDithering { public: int count(string dithered, vector screen) { int count...

SRM 599 div2 250 500

Problem Statement   Dachshund is a popular dog breed. In this problem, a miniature dachshun...

srm 535 div2 250&500

250:题意:知道A+B,B-C,A-B ,B+C ,的值求ABC的值,很水吧- - 做法是,先什么都不考虑就把ABC算出来,然后回过头验证是否符合 : AminusB ...
  • cqlf__
  • cqlf__
  • 2012年03月04日 23:21
  • 444

SRM 670 DIV 2 Cdgame 250-point

Problem StatementTwo players are playing a cooperative game. At the beginning of the game each play...

[TC] SRM 633 div2 250

Problem Statement   Here at [topcoder], we call a contestant a "target" if their rating is ...
  • modiz
  • modiz
  • 2014年12月11日 21:58
  • 567

SRM 597 DIV2 250

Problem Statement   Little Elephant from the Zoo of Lviv likes integers. You are give...

SRM 667 DIV 2 PointDistance 250-point

Problem StatementYou are given two distinct points A and B in the two-dimensional plane. Your task i...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:My solution for SRM 306 DIV2 [250]
举报原因:
原因补充:

(最多只允许输入30个字)