Пример #1
0
void init()
{
  //cin>>n;
  test.push_back( 1 , 2 );
  cout<<test.front->first<<" "<<test.front->second<<"\n";
  return ;
}
	void add(double timestamp, int type) {
		if (type==1) {
			lock_guard<mutex> guard(mx1);
			q1.push_back(timestamp);
			cv1.notify_one();
		} else {
			lock_guard<mutex> guard(mx2);
			q2.push_back(timestamp);
			cv2.notify_one();
		}
	}
	void print(vector<double> v1, vector<double> v2) {
		int m=v1.size(), n=v2.size(), i=0, j=0;
		while (i<m || j<n) {
			if (i==m) {
				q2.push_back(v2[j++]);
				print(q1, q2);
			}
			else if (j==n) {
				q1.push_back(v1[i++]);
				print(q2, q1);
			}
			else {
				if (v1[i]<v2[j]) {
					q1.push_back(v1[i++]);
					print(q1, q2);
				} else {
					q2.push_back(v2[j++]);
					print(q2, q1);
				}
			}
		}
	}
Пример #4
0
int ladder(string &starts, string &ends) {
	int len = 0;
	string wordNow = starts;
	while(true) {
		if(wordNow == ends)
			return len;
		path[]
		for(unordered_map<string, bool>::iterator it = dict.begin(); it != dict.end(); it++) {
			if(dist(*it, wordNow) == 1) {
				q.push_back(*it);
			}
		}
	}

}