QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#423634 | #8591. Shops | cmk666 | 0 | 22ms | 21280kb | C++23 | 7.2kb | 2024-05-28 13:48:52 | 2024-05-28 13:48:53 |
Judging History
answer
/* _ _ _ _ __ __ __
/ \ _ _ | |_ | |__ ___ _ __ _ ___ _ __ ___ | | __ / /_ / /_ / /_
/ _ \ | | | | | __| | '_ \ / _ \ | '__| (_) / __| | '_ ` _ \ | |/ / | '_ \ | '_ \ | '_ \
/ ___ \ | |_| | | |_ | | | | | (_) | | | _ | (__ | | | | | | | < | (_) | | (_) | | (_) |
/_/ \_\ \__,_| \__| |_| |_| \___/ |_| (_) \___| |_| |_| |_| |_|\_\ \___/ \___/ \___/
[Created Time: 2024-05-28 13:45:27]
[Last Modified Time: 2024-05-28 13:48:10] */
#pragma GCC optimize("Ofast", "unroll-loops")
#include<bits/stdc++.h>
#ifdef LOCAL
#include"debug.h"
#else
#define D(...) ((void)0)
#endif
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
namespace FastIO
{
// ------------------------------
// #define DISABLE_MMAP
// ------------------------------
#if ( defined(LOCAL) || defined(_WIN32) ) && !defined(DISABLE_MMAP)
#define DISABLE_MMAP
#endif
#ifdef LOCAL
inline char gc() { return getchar(); }
inline void pc(char c) { putchar(c); }
#else
#ifdef DISABLE_MMAP
inline constexpr int _READ_SIZE = 1 << 18;
inline static char _read_buffer[_READ_SIZE], *_read_ptr = nullptr, *_read_ptr_end = nullptr;
inline char gc()
{
if ( __builtin_expect(_read_ptr == _read_ptr_end, false) )
{
_read_ptr = _read_buffer, _read_ptr_end = _read_buffer + fread(_read_buffer, 1, _READ_SIZE, stdin);
if ( __builtin_expect(_read_ptr == _read_ptr_end, false) ) return EOF;
}
return *_read_ptr++;
}
#else
#include<sys/mman.h>
inline static const char *_read_ptr = (const char *)mmap(nullptr, 0x7fffffff, 1, 2, 0, 0);
inline char gc() { return *_read_ptr++; }
#endif
inline constexpr int _WRITE_SIZE = 1 << 18;
inline static char _write_buffer[_WRITE_SIZE], *_write_ptr = _write_buffer;
inline void pc(char c)
{
*_write_ptr++ = c;
if ( __builtin_expect(_write_buffer + _WRITE_SIZE == _write_ptr, false) )
fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout), _write_ptr = _write_buffer;
}
inline struct _auto_flush
{
inline ~_auto_flush() { fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout); }
} _auto_flush;
#endif
template < class T > inline constexpr bool _is_signed = numeric_limits < T >::is_signed;
template < class T > inline constexpr bool _is_unsigned = numeric_limits < T >::is_integer && !_is_signed < T >;
#if __SIZEOF_LONG__ == 64
template <> inline constexpr bool _is_signed < __int128 > = true;
template <> inline constexpr bool _is_unsigned < __uint128_t > = true;
#endif
inline void read(char &c) { do c = gc(); while ( !isgraph(c) ); }
inline void read_cstr(char *s)
{
char c = gc(); while ( !isgraph(c) ) c = gc();
while ( isgraph(c) ) *s++ = c, c = gc(); *s = 0;
}
inline void read(string &s)
{
char c = gc(); s.clear(); while ( !isgraph(c) ) c = gc();
while ( isgraph(c) ) s.push_back(c), c = gc();
}
template < class T, enable_if_t < _is_signed < T >, int > = 0 >
inline void read(T &x)
{
char c = gc(); bool f = true; x = 0;
while ( !isdigit(c) ) { if ( c == 45 ) f = false; c = gc(); }
if ( f ) while ( isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
else while ( isdigit(c) ) x = x * 10 - ( c & 15 ), c = gc();
}
template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
inline void read(T &x)
{
char c = gc(); while ( !isdigit(c) ) c = gc();
x = 0; while ( isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
}
inline void write(char c) { pc(c); }
inline void write_cstr(const char *s) { while ( *s ) pc(*s++); }
inline void write(const string &s) { for ( char c : s ) pc(c); }
template < class T, enable_if_t < _is_signed < T >, int > = 0 >
inline void write(T x)
{
char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
if ( x >= 0 ) do buffer[digits++] = ( x % 10 ) | 48, x /= 10; while ( x );
else { pc(45); do buffer[digits++] = -( x % 10 ) | 48, x /= 10; while ( x ); }
while ( digits ) pc(buffer[--digits]);
}
template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
inline void write(T x)
{
char buffer[numeric_limits < T >::digits10]; int digits = 0;
do buffer[digits++] = ( x % 10 ) | 48, x /= 10; while ( x );
while ( digits ) pc(buffer[--digits]);
}
template < int N > struct _tuple_io_helper
{
template < class ...T > static inline void _read(tuple < T... > &x) { _tuple_io_helper < N - 1 >::_read(x), read(get<N - 1>(x)); }
template < class ...T > static inline void _write(const tuple < T... > &x) { _tuple_io_helper < N - 1 >::_write(x), pc(32), write(get<N - 1>(x)); }
};
template <> struct _tuple_io_helper < 1 >
{
template < class ...T > static inline void _read(tuple < T... > &x) { read(get<0>(x)); }
template < class ...T > static inline void _write(const tuple < T... > &x) { write(get<0>(x)); }
};
template < class ...T > inline void read(tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_read(x); }
template < class ...T > inline void write(const tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_write(x); }
template < class T1, class T2 > inline void read(pair < T1, T2 > &x) { read(x.first), read(x.second); }
template < class T1, class T2 > inline void write(const pair < T1, T2 > &x) { write(x.first), pc(32), write(x.second); }
template < class T1, class ...T2 > inline void read(T1 &x, T2 &...y) { read(x), read(y...); }
template < class ...T > inline void read_cstr(char *x, T *...y) { read_cstr(x), read_cstr(y...); }
template < class T1, class ...T2 > inline void write(const T1 &x, const T2 &...y) { write(x), write(y...); }
template < class ...T > inline void write_cstr(const char *x, const T *...y) { write_cstr(x), write_cstr(y...); }
template < class T > inline void print(const T &x) { write(x); }
inline void print_cstr(const char *x) { write_cstr(x); }
template < class T1, class ...T2 > inline void print(const T1 &x, const T2 &...y) { write(x), pc(32), print(y...); }
template < class ...T > inline void print_cstr(const char *x, const T *...y) { write_cstr(x), pc(32), print_cstr(y...); }
inline void println() { pc(10); } inline void println_cstr() { pc(10); }
template < class ...T > inline void println(const T &...x) { print(x...), pc(10); }
template < class ...T > inline void println_cstr(const T *...x) { print_cstr(x...), pc(10); }
} using FastIO::read, FastIO::read_cstr, FastIO::write, FastIO::write_cstr, FastIO::println, FastIO::println_cstr;
constexpr int inf = numeric_limits < int >::max() >> 1;
int n, m, u, v, w, c[500009]; pair < int, int > mn[500009];
inline void dfs(int u, int c) { ::c[u] = c; if ( !::c[mn[u].second] ) dfs(mn[u].second, 3 - c); }
int main()
{
read(n, m), fill(mn + 1, mn + n + 1, pair(inf, 0));
For(i, 1, m) read(u, v, w), mn[u] = min(mn[u], pair(w, v)), mn[v] = min(mn[v], pair(w, u));
println(max_element(mn + 1, mn + n + 1) -> first);
For(i, 1, n) if ( !c[i] ) dfs(i, 1);
For(i, 1, n) write(c[i] == 1 ? 'B' : 'D');
return println(), 0;
}
// 想上GM捏 想上GM捏 想上GM捏 想上GM捏 想上GM捏
// 伊娜可爱捏 伊娜贴贴捏
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 7
Accepted
time: 0ms
memory: 3552kb
input:
3 3 1 2 3 2 3 1 1 3 2
output:
2 BBD
result:
ok inconveniences = 2
Test #2:
score: 7
Accepted
time: 1ms
memory: 3680kb
input:
5 6 3 2 3 4 2 1 5 3 9 1 3 5 1 4 2 2 3 1
output:
9 BBDDB
result:
ok inconveniences = 9
Test #3:
score: 0
Wrong Answer
time: 3ms
memory: 5436kb
input:
8 135737 1 4 763713071 3 7 45141437 4 8 618418466 6 8 91803956 7 5 972595945 5 2 751163228 2 8 9886315 4 3 106470622 8 6 949495949 1 2 885918825 4 6 322040168 7 6 754489330 4 8 618968328 5 3 996860159 3 6 210132897 3 4 591744987 8 7 447985622 2 4 4833956 5 7 610154418 2 5 410116873 2 5 912717336 8 7...
output:
19258 BBBDBBDD
result:
wrong answer your claimed answer is 19258, but the inconveniences of your plan is actually 20770
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 16ms
memory: 21280kb
input:
500000 499999 1 2 776715136 2 3 406881694 3 4 265792290 4 5 507607272 5 6 182246639 6 7 997847597 7 8 164130256 8 9 278962226 9 10 411194641 10 11 363646402 11 12 672225656 12 13 494629089 13 14 717664153 14 15 121619271 15 16 476857704 16 17 301215244 17 18 810217743 18 19 850722975 19 20 10710274 ...
output:
998789691 BDBDBDBDBBDBDBDBDBBDBDBDBDBBBDBDBBBBDBDBBDBBDBBDBDBBDBDBDBDBBDBDBDBDBDBDBDBBDBDBBBBDBBBDBBDBBBDBBDBBDBDBDBBDBDBBDBBDBDBDBBBBDBBDBBBBDBBDBBBBDBBBDBDBDBBDBBDBBBBDBDBBDBBDBDBBDBBDBBDBBBDBDBBDBDBDBDBBBDBBBBDBDBDBBBDBBDBDBDBDBBDBBDBBBDBBDBBBDBBBBDBDBBBBDBDBBDBDBDBDBBDBBBBDBBDBBDBBBDBDBDBBDBDBDB...
result:
wrong answer your claimed answer is 998789691, but the inconveniences of your plan is actually 2788702999
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 22ms
memory: 14932kb
input:
366489 397001 2 127909 1 7 171229 1 8 158597 1 11 282213 1 14 356007 1 15 286102 1 16 93205 1 17 260111 1 18 138962 1 20 359938 1 29 223905 1 31 357684 1 32 259968 1 34 65205 1 37 200276 1 41 83195 1 43 159858 1 48 332277 1 50 320322 1 51 338467 1 53 262785 1 55 83815 1 56 173198 1 58 169473 1 63 19...
output:
1 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
result:
wrong answer your claimed answer is 1, but the inconveniences of your plan is actually 5
Subtask #5:
score: 0
Skipped
Dependency #1:
0%