示例#1
0
文件: a2q1.cpp 项目: andsav/School
int main() {
    int n, m, i, j;
    cin >> n >> m;

    Cut c;

    while(cin >> i) {
        cin >> j;
        c.OG[i].push_back(j);
        c.visited[i] = c.visited[j] = false;
    }

    c.run()->out();
}
示例#2
0
void Blade::startCut( unsigned int n_buffer  )
{
	assert( n_buffer <= 25 );
	
	// Retrieve the correct audio buffer
	Cut *cut = &g_kitchen.m_cuts[ n_buffer ];

	if ( cut->m_writeOn ) return;

	cut->clear();
	
	cut->m_writeHead = 0; // Reset write head
	cut->m_writeOn = true; // Begin writing to buffer
	
	cout << "Writing to buffer " << n_buffer << endl;
}
示例#3
0
文件: Cut.cpp 项目: bloops/solved
// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
bool KawigiEdit_RunTest(int testNum, vector <int> p0, int p1, bool hasAnswer, int p2) {
	cout << "Test " << testNum << ": [" << "{";
	for (int i = 0; int(p0.size()) > i; ++i) {
		if (i > 0) {
			cout << ",";
		}
		cout << p0[i];
	}
	cout << "}" << "," << p1;
	cout << "]" << endl;
	Cut *obj;
	int answer;
	obj = new Cut();
	clock_t startTime = clock();
	answer = obj->getMaximum(p0, p1);
	clock_t endTime = clock();
	delete obj;
	bool res;
	res = true;
	cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl;
	if (hasAnswer) {
		cout << "Desired answer:" << endl;
		cout << "\t" << p2 << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << answer << endl;
	if (hasAnswer) {
		res = answer == p2;
	}
	if (!res) {
		cout << "DOESN'T MATCH!!!!" << endl;
	} else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) {
		cout << "FAIL the timeout" << endl;
		res = false;
	} else if (hasAnswer) {
		cout << "Match :-)" << endl;
	} else {
		cout << "OK, but is it right?" << endl;
	}
	cout << "" << endl;
	return res;
}
示例#4
0
文件: Cut.cpp 项目: S7012MY/topcoder
double test1() {
	int t0[] = {5, 5, 5, 5};
	vector <int> p0(t0, t0+sizeof(t0)/sizeof(int));
	int p1 = 2;
	Cut * obj = new Cut();
	clock_t start = clock();
	int my_answer = obj->getMaximum(p0, p1);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	int p2 = 0;
	cout <<"Desired answer: " <<endl;
	cout <<"\t" << p2 <<endl;
	cout <<"Your answer: " <<endl;
	cout <<"\t" << my_answer <<endl;
	if (p2 != my_answer) {
		cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
		return -1;
	}
	else {
		cout <<"Match :-)" <<endl <<endl;
		return (double)(end-start)/CLOCKS_PER_SEC;
	}
}
示例#5
0
void
CutCollection::AddCut(const Cut& cut_){
  fCuts.push_back(cut_.Clone());
}
示例#6
0
void HPGLEncoder::encode(std::ostream &out, Cut& encodee) {
  bool firstOperation = true;
  bool writingPolyline = false;

  int power_set = encodee.get(CutSettings::CPOWER);
  int speed_set = encodee.get(CutSettings::CSPEED);
  int freq_set = encodee.get(CutSettings::FREQUENCY);
  int beginX = -1, beginY = -1;
  int lastX = -1, lastY = -1;

  size_t cnt = 0;
  for(const SegmentPtr segPtr : segments(encodee)) {
    if(cnt % 100 == 0) {
      cnt = 0;
      if(!firstOperation) {
        if (writingPolyline)
          out << SEP;
        out << HPGL_END;
        out << SEP;
      }
      out << HPGL_START;
      out << V_INIT << SEP;
      out << format(V_POWER) % power_set << SEP;
      out << format(V_SPEED) % speed_set << SEP;
      out << format(V_FREQUENCY) % freq_set; // omit separator;

      firstOperation = false;

      lastX = -1;
      lastY = -1;
    }
    Segment& seg = *segPtr.get();
    int startX = seg[0][0];
    int startY = seg[0][1];
    int endX = seg[1][0];
    int endY = seg[1][1];

    if (lastX != startX || lastY != startY) {
      beginX = startX;
      beginY = startY;

      out << SEP << HPGL_PEN_UP;
      out << format("%d,%d") % startX % startY << SEP;
      out << HPGL_PEN_DOWN << format("%d,%d") % endX % endY;
      writingPolyline = true;
    }
    // ..else continue on polyline
    else {
      out << format(",%d,%d") % endX % endY;
    }

    lastX = endX;
    lastY = endY;

    // FIXME: This is a temporary hack to emulate the Epilog Windows driver,
    // which appears to repeat the first vertex in a closed polyline twice at the end.
    if (beginX == lastX && beginY == lastY)
      out << format(",%d,%d") % beginX % beginY;

    ++cnt;
  }

  if (writingPolyline) out << SEP;
  out << HPGL_END;
}