阿里编程测验,好难
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <cassert>
#include <map>
#include <algorithm>
using namespace std;
class Interval
{
public:
explicit Interval(size_t left, size_t right)
: mLeft(left),
mRight(right)
{
assert(left <= right);
}
size_t left() const
{
return mLeft;
}
size_t right() const
{
return mRight;
}
private:
size_t mLeft;
size_t mRight;
};
inline bool operator<(const Interval& a, const Interval& b)
{
return a.right() < b.left();
}
class TwoInterval
{
public:
explicit TwoInterval(const Interval& left, const Interval& right)
: mLeft(left),
mRight(right)
{
assert(left < right);
}
const Interval& left() const
{
return mLeft;
}
const Interval& right() const
{
return mRight;
}
private:
Interval mLeft;
Interval mRight;
};
inline bool within(const TwoInterval& a, const TwoInterval& b)
{
return b.left() < a.left() && a.right() < b.right();
}
void input(vector<TwoInterval>& twos)
{
int m = 0;
{
string s;
getline(cin, s);
istringstream is(s);
is >> m;
}
for(int i = 0; i < m; ++i) {
string s;
getline(cin, s);
istringstream is(s);
size_t a, b, c, d;
is >> a >> b >> c >> d;
Interval left(a, b);
Interval right(c, d);
twos.emplace_back(left, right);
}
}
// ====== 填入你自己的逻辑 ========
int intussusception(vector<TwoInterval>&)
{
}
// ====== 结束 ========
int main() {
vector<TwoInterval> twos;
input(twos);
cout << intussusception(twos) << endl;
return 0;
}
#include <string>
#include <vector>
#include <deque>
#include <cassert>
#include <map>
#include <algorithm>
using namespace std;
class Interval
{
public:
explicit Interval(size_t left, size_t right)
: mLeft(left),
mRight(right)
{
assert(left <= right);
}
size_t left() const
{
return mLeft;
}
size_t right() const
{
return mRight;
}
private:
size_t mLeft;
size_t mRight;
};
inline bool operator<(const Interval& a, const Interval& b)
{
return a.right() < b.left();
}
class TwoInterval
{
public:
explicit TwoInterval(const Interval& left, const Interval& right)
: mLeft(left),
mRight(right)
{
assert(left < right);
}
const Interval& left() const
{
return mLeft;
}
const Interval& right() const
{
return mRight;
}
private:
Interval mLeft;
Interval mRight;
};
inline bool within(const TwoInterval& a, const TwoInterval& b)
{
return b.left() < a.left() && a.right() < b.right();
}
void input(vector<TwoInterval>& twos)
{
int m = 0;
{
string s;
getline(cin, s);
istringstream is(s);
is >> m;
}
for(int i = 0; i < m; ++i) {
string s;
getline(cin, s);
istringstream is(s);
size_t a, b, c, d;
is >> a >> b >> c >> d;
Interval left(a, b);
Interval right(c, d);
twos.emplace_back(left, right);
}
}
// ====== 填入你自己的逻辑 ========
int intussusception(vector<TwoInterval>&)
{
}
// ====== 结束 ========
int main() {
vector<TwoInterval> twos;
input(twos);
cout << intussusception(twos) << endl;
return 0;
}
#阿里巴巴#