Please sign in first.
Submission #26266131
Source Code Expand
# include <bits/stdc++.h>
using namespace std;
// # define USING_STDIN
// # define NDEBUG
// # define NCHECK
# include <cassert>
namespace Elaina {
# define rep(i, l, r) for(int i=(l), i##_end_=(r); i <= i##_end_; ++i)
# define drep(i, l, r) for(int i=(l), i##_end_=(r); i >= i##_end_; --i)
# define fi first
# define se second
# define mp(a, b) make_pair(a, b)
# define Endl putchar('\n')
# define whole(v) ((v).begin()), ((v).end())
# define bitcnt(s) (__builtin_popcount(s))
# ifdef NCHECK
# define iputs(Content) ((void)0)
# define iprintf(Content, argvs...) ((void)0)
# else
# define iputs(Content) fprintf(stderr, Content)
# define iprintf(Content, argvs...) fprintf(stderr, Content, argvs)
# endif
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
template <class T> inline T fab(T x) { return x < 0? -x: x; }
template <class T> inline void getmin(T& x, const T rhs) { x=min(x, rhs); }
template <class T> inline void getmax(T& x, const T rhs) { x=max(x, rhs); }
# ifndef USING_STDIN
inline char freaGET() {
# define BUFFERSIZE 5000
static char BUF[BUFFERSIZE], *p1=BUF, *p2=BUF;
return p1 == p2 && (p2=(p1=BUF)+fread(BUF, 1, BUFFERSIZE, stdin), p1 == p2)? EOF: *p1++;
# undef BUFFERSIZE
}
# define CHARGET freaGET()
# else
# define CHARGET getchar()
# endif
template <class T> inline T readret(T x) {
x=0; int f=0; char c;
while((c=CHARGET) < '0' || '9' < c) if(c=='-') f=1;
for(x=(c^48); '0' <= (c=CHARGET) && c <= '9'; x=(x<<1)+(x<<3)+(c^48));
return f? -x: x;
}
template <class T> inline void readin(T& x) { x=readret(T(1)); }
template <class T, class... Args> inline void readin(T& x, Args&... args){
readin(x), readin(args...);
}
template <class T> inline void writc(T x, char s='\n') {
static int fwri_sta[55], fwri_ed=0;
if(x < 0) putchar('-'), x=-x;
do fwri_sta[++fwri_ed]=x%10, x/=10; while(x);
while(putchar(fwri_sta[fwri_ed--]^48), fwri_ed);
putchar(s);
}
} using namespace Elaina;
const int maxn=2e5;
struct node { int a, b; } p[maxn+5];
int n, m;
inline void input() {
readin(m, n);
rep(i, 1, n) readin(p[i].a, p[i].b);
sort(p+1, p+n+1, [](const node& x, const node& y) -> bool {
return x.a == y.a? x.b>y.b: x.a<y.a;
});
}
namespace saya {
int mx[maxn+5];
# define lowbit(i) (i&(-i))
inline int query(int i) {
int ret=0;
for(; i; i-=lowbit(i)) ret=max(ret, mx[i]);
return ret;
}
inline void insert(int i, int x) {
for(; i <= maxn; i+=lowbit(i)) mx[i]=max(mx[i], x);
}
# undef lowbit(i)
} // using namespace saya;
int dp[maxn+5];
inline void work() {
int ans=0;
rep(i, 1, n) {
dp[i]=saya::query(p[i].b-1)+1;
saya::insert(p[i].b, dp[i]);
ans=max(ans, dp[i]);
}
writc(ans);
}
signed main() {
input();
work();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Cross-free Matching |
| User | macslaytion |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 2946 Byte |
| Status | AC |
| Exec Time | 43 ms |
| Memory | 6744 KiB |
Compile Error
./Main.cpp:97:15: warning: extra tokens at end of #undef directive
97 | # undef lowbit(i)
| ^
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt |
| All | 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_rand_01.txt, 02_rand_02.txt, 02_rand_03.txt, 02_rand_04.txt, 02_rand_05.txt, 02_rand_06.txt, 02_rand_07.txt, 02_rand_08.txt, 02_rand_09.txt, 02_rand_10.txt, 02_rand_11.txt, 02_rand_12.txt, 02_rand_13.txt, 02_rand_14.txt, 02_rand_15.txt, 03_rand_dense_01.txt, 03_rand_dense_02.txt, 03_rand_dense_03.txt, 03_rand_dense_04.txt, 03_rand_dense_05.txt, 03_rand_dense_06.txt, 03_rand_dense_07.txt, 03_rand_dense_08.txt, 03_rand_dense_09.txt, 03_rand_dense_10.txt, 03_rand_dense_11.txt, 03_rand_dense_12.txt, 03_rand_dense_13.txt, 03_rand_dense_14.txt, 03_rand_dense_15.txt, 04_large_ans_01.txt, 04_large_ans_02.txt, 04_large_ans_03.txt, 04_large_ans_04.txt, 04_large_ans_05.txt, 04_large_ans_06.txt, 04_large_ans_07.txt, 04_large_ans_08.txt, 04_large_ans_09.txt, 04_large_ans_10.txt, 04_large_ans_11.txt, 04_large_ans_12.txt, 04_large_ans_13.txt, 04_large_ans_14.txt, 04_large_ans_15.txt, 05_small_ans_01.txt, 05_small_ans_02.txt, 05_small_ans_03.txt, 05_small_ans_04.txt, 05_small_ans_05.txt, 05_small_ans_06.txt, 05_small_ans_07.txt, 05_small_ans_08.txt, 05_small_ans_09.txt, 05_small_ans_10.txt, 05_small_ans_11.txt, 05_small_ans_12.txt, 05_small_ans_13.txt, 05_small_ans_14.txt, 05_small_ans_15.txt, 06_handmade_01.txt, 06_handmade_02.txt, 06_handmade_03.txt, 06_handmade_04.txt, 06_handmade_05.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01_sample_01.txt | AC | 7 ms | 3580 KiB |
| 01_sample_02.txt | AC | 2 ms | 3552 KiB |
| 01_sample_03.txt | AC | 3 ms | 3600 KiB |
| 02_rand_01.txt | AC | 39 ms | 6608 KiB |
| 02_rand_02.txt | AC | 35 ms | 5932 KiB |
| 02_rand_03.txt | AC | 43 ms | 6660 KiB |
| 02_rand_04.txt | AC | 37 ms | 5996 KiB |
| 02_rand_05.txt | AC | 36 ms | 5956 KiB |
| 02_rand_06.txt | AC | 37 ms | 6092 KiB |
| 02_rand_07.txt | AC | 38 ms | 6056 KiB |
| 02_rand_08.txt | AC | 33 ms | 6360 KiB |
| 02_rand_09.txt | AC | 36 ms | 6244 KiB |
| 02_rand_10.txt | AC | 40 ms | 6256 KiB |
| 02_rand_11.txt | AC | 36 ms | 6092 KiB |
| 02_rand_12.txt | AC | 39 ms | 6532 KiB |
| 02_rand_13.txt | AC | 35 ms | 6000 KiB |
| 02_rand_14.txt | AC | 40 ms | 6528 KiB |
| 02_rand_15.txt | AC | 36 ms | 5940 KiB |
| 03_rand_dense_01.txt | AC | 37 ms | 5788 KiB |
| 03_rand_dense_02.txt | AC | 40 ms | 5880 KiB |
| 03_rand_dense_03.txt | AC | 39 ms | 5876 KiB |
| 03_rand_dense_04.txt | AC | 34 ms | 5908 KiB |
| 03_rand_dense_05.txt | AC | 30 ms | 5760 KiB |
| 03_rand_dense_06.txt | AC | 35 ms | 5864 KiB |
| 03_rand_dense_07.txt | AC | 39 ms | 5856 KiB |
| 03_rand_dense_08.txt | AC | 39 ms | 5736 KiB |
| 03_rand_dense_09.txt | AC | 34 ms | 5868 KiB |
| 03_rand_dense_10.txt | AC | 37 ms | 5796 KiB |
| 03_rand_dense_11.txt | AC | 40 ms | 5728 KiB |
| 03_rand_dense_12.txt | AC | 35 ms | 5728 KiB |
| 03_rand_dense_13.txt | AC | 36 ms | 5852 KiB |
| 03_rand_dense_14.txt | AC | 36 ms | 5932 KiB |
| 03_rand_dense_15.txt | AC | 37 ms | 5732 KiB |
| 04_large_ans_01.txt | AC | 38 ms | 6668 KiB |
| 04_large_ans_02.txt | AC | 36 ms | 6660 KiB |
| 04_large_ans_03.txt | AC | 37 ms | 6508 KiB |
| 04_large_ans_04.txt | AC | 36 ms | 6540 KiB |
| 04_large_ans_05.txt | AC | 38 ms | 6668 KiB |
| 04_large_ans_06.txt | AC | 37 ms | 6684 KiB |
| 04_large_ans_07.txt | AC | 36 ms | 6676 KiB |
| 04_large_ans_08.txt | AC | 41 ms | 6656 KiB |
| 04_large_ans_09.txt | AC | 37 ms | 6484 KiB |
| 04_large_ans_10.txt | AC | 37 ms | 6544 KiB |
| 04_large_ans_11.txt | AC | 41 ms | 6744 KiB |
| 04_large_ans_12.txt | AC | 37 ms | 6672 KiB |
| 04_large_ans_13.txt | AC | 39 ms | 6664 KiB |
| 04_large_ans_14.txt | AC | 38 ms | 6728 KiB |
| 04_large_ans_15.txt | AC | 37 ms | 6636 KiB |
| 05_small_ans_01.txt | AC | 37 ms | 6544 KiB |
| 05_small_ans_02.txt | AC | 39 ms | 6524 KiB |
| 05_small_ans_03.txt | AC | 36 ms | 6488 KiB |
| 05_small_ans_04.txt | AC | 35 ms | 6552 KiB |
| 05_small_ans_05.txt | AC | 32 ms | 6608 KiB |
| 05_small_ans_06.txt | AC | 36 ms | 6660 KiB |
| 05_small_ans_07.txt | AC | 39 ms | 6724 KiB |
| 05_small_ans_08.txt | AC | 35 ms | 6608 KiB |
| 05_small_ans_09.txt | AC | 35 ms | 6488 KiB |
| 05_small_ans_10.txt | AC | 38 ms | 6680 KiB |
| 05_small_ans_11.txt | AC | 34 ms | 6640 KiB |
| 05_small_ans_12.txt | AC | 36 ms | 6672 KiB |
| 05_small_ans_13.txt | AC | 38 ms | 6684 KiB |
| 05_small_ans_14.txt | AC | 32 ms | 6656 KiB |
| 05_small_ans_15.txt | AC | 37 ms | 6604 KiB |
| 06_handmade_01.txt | AC | 2 ms | 3488 KiB |
| 06_handmade_02.txt | AC | 2 ms | 3564 KiB |
| 06_handmade_03.txt | AC | 5 ms | 3712 KiB |
| 06_handmade_04.txt | AC | 36 ms | 6684 KiB |
| 06_handmade_05.txt | AC | 33 ms | 6656 KiB |