Submission #66780597
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------
int N;
int V[404040];
vector<int> len[404040];
template<class V,int NV> class SegTree_1 {
public:
vector<V> val;
static V const def=0;
V comp(V l,V r){ return max(l,r);};
SegTree_1(){val=vector<V>(NV*2,def);};
V getval(int x,int y,int l=0,int r=NV,int k=1) { // x<=i<y
if(r<=x || y<=l) return def;
if(x<=l && r<=y) return val[k];
return comp(getval(x,y,l,(l+r)/2,k*2),getval(x,y,(l+r)/2,r,k*2+1));
}
void update(int entry, V v) {
entry += NV;
val[entry]=comp(v,val[entry]); //上書きかチェック
while(entry>1) entry>>=1, val[entry]=comp(val[entry*2],val[entry*2+1]);
}
};
SegTree_1<int,1<<20> st;
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N;
FOR(i,N) {
cin>>x>>y;
if(x>y) swap(x,y);
V[y]=x;
}
for(i=1;i<=2*N;i++) {
x=V[y];
if(x>0) {
k=st.getval(x,y);
st.update(x,k+1);
}
}
cout<<st.getval(0,2*N+2)<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
cout.tie(0); solve(); return 0;
}
Submission Info
| Submission Time |
|
| Task |
G - Longest Chord Chain |
| User |
kmjp |
| Language |
C++ 20 (gcc 12.2) |
| Score |
0 |
| Code Size |
1743 Byte |
| Status |
WA |
| Exec Time |
84 ms |
| Memory |
12904 KiB |
Compile Error
Main.cpp: In function ‘void solve()’:
Main.cpp:41:15: warning: unused variable ‘j’ [-Wunused-variable]
41 | int i,j,k,l,r,x,y; string s;
| ^
Main.cpp:41:19: warning: unused variable ‘l’ [-Wunused-variable]
41 | int i,j,k,l,r,x,y; string s;
| ^
Main.cpp:41:21: warning: unused variable ‘r’ [-Wunused-variable]
41 | int i,j,k,l,r,x,y; string s;
| ^
Main.cpp: In function ‘int main(int, char**)’:
Main.cpp:6:19: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
6 | #define FOR(x,to) for(x=0;x<(to);x++)
| ^~~
Main.cpp:65:9: note: in expansion of macro ‘FOR’
65 | FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
| ^~~
Main.cpp:6:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
6 | #define FOR(x,to) for(x=0;x<(to);x++)
| ^~~
Main.cpp:65:45: note: in expansion of macro ‘FOR’
65 | FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
| ^~~
Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
6 | #define FOR(x,to) for(x=0;x<(to);x++)
| ^
Main.cpp:65:45: note: in expansion of macro ‘FOR’
65 | FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
| ^~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
0 / 575 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
| All |
random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, sample_01.txt, sample_02.txt, sample_03.txt |
| Case Name |
Status |
Exec Time |
Memory |
| random_01.txt |
WA |
79 ms |
12720 KiB |
| random_02.txt |
WA |
77 ms |
12904 KiB |
| random_03.txt |
WA |
76 ms |
12748 KiB |
| random_04.txt |
WA |
19 ms |
11500 KiB |
| random_05.txt |
WA |
80 ms |
12796 KiB |
| random_06.txt |
WA |
38 ms |
12020 KiB |
| random_07.txt |
WA |
83 ms |
12772 KiB |
| random_08.txt |
WA |
46 ms |
12224 KiB |
| random_09.txt |
WA |
84 ms |
12752 KiB |
| random_10.txt |
WA |
31 ms |
11728 KiB |
| random_11.txt |
WA |
81 ms |
12840 KiB |
| random_12.txt |
WA |
76 ms |
12816 KiB |
| random_13.txt |
WA |
81 ms |
12760 KiB |
| random_14.txt |
WA |
57 ms |
12152 KiB |
| random_15.txt |
WA |
80 ms |
12752 KiB |
| random_16.txt |
WA |
70 ms |
12500 KiB |
| random_17.txt |
WA |
77 ms |
12676 KiB |
| random_18.txt |
WA |
21 ms |
11488 KiB |
| random_19.txt |
WA |
75 ms |
12680 KiB |
| random_20.txt |
WA |
77 ms |
12812 KiB |
| random_21.txt |
WA |
6 ms |
11132 KiB |
| random_22.txt |
WA |
60 ms |
12664 KiB |
| random_23.txt |
WA |
63 ms |
12804 KiB |
| random_24.txt |
WA |
76 ms |
11964 KiB |
| random_25.txt |
WA |
77 ms |
11956 KiB |
| random_26.txt |
WA |
81 ms |
11980 KiB |
| random_27.txt |
WA |
74 ms |
11996 KiB |
| sample_01.txt |
WA |
6 ms |
11152 KiB |
| sample_02.txt |
WA |
6 ms |
11048 KiB |
| sample_03.txt |
WA |
6 ms |
11200 KiB |