Submission #36416874
Source Code Expand
#include <bits/stdc++.h>
#define st first
#define nd second
#define db double
#define re register
#define pb push_back
#define mk make_pair
#define int long long
#define ldb long double
#define pii pair<int, int>
#define ull unsigned long long
#define mst(a, b) memset(a, b, sizeof(a))
using namespace std;
const int N = 4e5 + 10, INF = 1e16;
inline int read()
{
int s = 0, w = 1;
char ch = getchar();
while(ch < '0' || ch > '9') { if(ch == '-') w *= -1; ch = getchar(); }
while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
return s * w;
}
int n, t;
int a[N], b[N], c[N];
bool vis[N];
vector<int> G[N];
inline void DFS(int u)
{
vis[u] = true;
for(re int to : G[u]) if(!vis[to]) DFS(to);
}
signed main()
{
n = read(), c[++t] = 1;
for(re int i = 1; i <= n; i++)
a[i] = read(), b[i] = read(), c[++t] = a[i], c[++t] = b[i];
sort(c + 1, c + t + 1), t = unique(c + 1, c + t + 1) - c - 1;
for(re int i = 1; i <= n; i++){
a[i] = lower_bound(c + 1, c + t + 1, a[i]) - c;
b[i] = lower_bound(c + 1, c + t + 1, b[i]) - c;
G[a[i]].pb(b[i]), G[b[i]].pb(a[i]);
}
DFS(1);
for(re int i = t; i >= 1; i--)
if(vis[i]) printf("%lld\n", c[i]), exit(0);
return 0;
}
/*
1
10
9 9 4 7 3 10 10 8 4 3
*/
Submission Info
Submission Time
2022-11-12 21:11:29+0900
Task
C - Ladder Takahashi
User
Booksnow
Language
C++ (GCC 9.2.1)
Score
300
Code Size
1294 Byte
Status
AC
Exec Time
189 ms
Memory
31612 KiB
Compile Error
./Main.cpp: In function ‘void DFS(long long int)’:
./Main.cpp:30:14: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
30 | for(re int to : G[u]) if(!vis[to]) DFS(to);
| ^~
./Main.cpp: In function ‘int main()’:
./Main.cpp:35:14: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
35 | for(re int i = 1; i <= n; i++)
| ^
./Main.cpp:38:14: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
38 | for(re int i = 1; i <= n; i++){
| ^
./Main.cpp:44:14: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
44 | for(re int i = t; i >= 1; i--)
| ^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
300 / 300
Status
Set Name
Test Cases
Sample
example0.txt, example1.txt, example2.txt
All
example0.txt, example1.txt, example2.txt, handmade0.txt, handmade1.txt, handmade2.txt, killer0.txt, killer1.txt, killer2.txt, killer3.txt, killer4.txt, killer5.txt, killer6.txt, random0.txt, random1.txt, random2.txt, random3.txt, random4.txt
Case Name
Status
Exec Time
Memory
example0.txt
AC
13 ms
12900 KiB
example1.txt
AC
11 ms
13100 KiB
example2.txt
AC
17 ms
12900 KiB
handmade0.txt
AC
11 ms
12948 KiB
handmade1.txt
AC
14 ms
12952 KiB
handmade2.txt
AC
11 ms
12932 KiB
killer0.txt
AC
189 ms
31612 KiB
killer1.txt
AC
125 ms
23820 KiB
killer2.txt
AC
95 ms
23008 KiB
killer3.txt
AC
151 ms
25396 KiB
killer4.txt
AC
126 ms
26084 KiB
killer5.txt
AC
161 ms
27052 KiB
killer6.txt
AC
71 ms
23916 KiB
random0.txt
AC
137 ms
25044 KiB
random1.txt
AC
98 ms
21672 KiB
random2.txt
AC
140 ms
25276 KiB
random3.txt
AC
91 ms
21464 KiB
random4.txt
AC
161 ms
27560 KiB