# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74238 | admin | Parachute rings (IOI12_rings) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("OFast")
#include "bits/stdc++.h"
using namespace std;
int N;
struct dsu {
int other[1000010];
int len[1000010];
int cycle_cnt;
int cycle_sum;
bool bad;
int no_of_nodes;
int del_node;
void init (int n) {
no_of_nodes = n;
del_node = -1;
for(int i = 0; i < no_of_nodes; i++) {
other[i] = i;
len[i] = 1;
}
cycle_cnt = 0;
cycle_sum = 0;
bad = false;
}
void add(int x, int y) {
if(del_node == x || del_node == y) return ;
if(bad) return ;
if(other[x] == y) {
other[x] = -1;
other[y] = -1;
cycle_cnt += 1;
cycle_sum += len[x];
} else {
if(other[x] == -1 || other[y] == -1) {
bad = true;
return ;
}
int p = other[y];
int q = other[x];
other[p] = q;
other[q] = p;
int sum = len[x] + len[y];
len[p] = len[q] = sum;
if(x != p && x != q) {
other[x] = -1;
}
if(y != p && y != q) {
other[y] = -1;
}
}
}
int count() {
if(bad) return 0;
if(cycle_cnt <= 1) {
if(cycle_cnt == 1) return cycle_sum;
else return no_of_nodes;
}
return 0;
}
} T[4];
int deg[1000010];
vector <int> l, r;
bool found_cand;
void Init(int N_) {
N = N_;
T[0].init(N);
for(int i = 0; i < N; i++) {
deg[i] = 0;
}
l.clear(); r.clear();
found_cand = false;
}
void Link(int A, int B) {
if(found_cand) {
for(int i = 0; i < 4; i++) {
T[i].add(A, B);
}
return ;
}
++deg[A]; ++deg[B];
l.emplace_back(A);
r.emplace_back(B);
if(deg[A] == 3 || deg[B] == 3) {
vector <int> v;
int can = deg[A] == 3 ? A : B;
v.emplace_back(can);
for(int i = 0; i < (int) l.size(); i++) {
if(l[i] == can || r[i] == can) {
v.emplace_back(l[i] ^ r[i] ^ can);
}
}
for(int i = 0; i < 4; i++) {
T[i].init(N);
T[i].del_node = v[i];
}
found_cand = true;
} else {
T[0].add(A, B);
}
if(found_cand) {
for(int i = 0; i < (int)l.size(); i++) {
Link(l[i], r[i]);
}
l.clear(); r.clear();
}
}
int CountCritical() {
if(found_cand) {
int ans = 0;
for(int i = 0; i < 4; i++) {
if(T[i].cycle_cnt == 0 && !T[i].bad) {
++ans;
}
}
return ans;
}
return T[0].count();
}
Compilation message (stderr)
rings.cpp:1:29: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' #pragma GCC optimize("OFast") ^ In file included from /usr/include/c++/7/cassert:44:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33, from rings.cpp:3: /usr/include/assert.h:71:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __THROW __attribute__ ((__noreturn__)); ^ /usr/include/assert.h:71:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/assert.h:76:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __THROW __attribute__ ((__noreturn__)); ^ /usr/include/assert.h:76:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/assert.h:82:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __THROW __attribute__ ((__noreturn__)); ^ /usr/include/assert.h:82:43: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' In file included from /usr/include/endian.h:60:0, from /usr/include/ctype.h:39, from /usr/include/c++/7/cctype:42, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:35, from rings.cpp:3: /usr/include/x86_64-linux-gnu/bits/byteswap.h:45:31: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __bswap_32 (unsigned int __bsx) ^ /usr/include/x86_64-linux-gnu/bits/byteswap.h:109:29: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __bswap_64 (__uint64_t __bsx) ^ In file included from /usr/include/c++/7/cctype:42:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:35, from rings.cpp:3: /usr/include/ctype.h:80:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __THROW __attribute__ ((__const__)); ^ /usr/include/ctype.h:80:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:82:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __THROW __attribute__ ((__const__)); ^ /usr/include/ctype.h:82:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:84:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __THROW __attribute__ ((__const__)); ^ /usr/include/ctype.h:84:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' In file included from /usr/include/features.h:367:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533, from /usr/include/c++/7/cassert:43, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33, from rings.cpp:3: /usr/include/ctype.h:110:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (isalnum); ^ /usr/include/ctype.h:110:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:111:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (isalpha); ^ /usr/include/ctype.h:111:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:112:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (iscntrl); ^ /usr/include/ctype.h:112:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:113:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (isdigit); ^ /usr/include/ctype.h:113:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:114:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (islower); ^ /usr/include/ctype.h:114:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:115:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (isgraph); ^ /usr/include/ctype.h:115:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:116:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (isprint); ^ /usr/include/ctype.h:116:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:117:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (ispunct); ^ /usr/include/ctype.h:117:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:118:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (isspace); ^ /usr/include/ctype.h:118:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:119:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (isupper); ^ /usr/include/ctype.h:119:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:120:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (isxdigit); ^ /usr/include/ctype.h:120:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:124:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern int tolower (int __c) __THROW; ^ /usr/include/ctype.h:124:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:127:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern int toupper (int __c) __THROW; ^ /usr/include/ctype.h:127:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:136:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (isblank); ^ /usr/include/ctype.h:136:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:143:42: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern int isctype (int __c, int __mask) __THROW; ^ /usr/include/ctype.h:143:42: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:150:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern int isascii (int __c) __THROW; ^ /usr/include/ctype.h:150:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:154:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern int toascii (int __c) __THROW; ^ /usr/include/ctype.h:154:30: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:158:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (_toupper); ^ /usr/include/ctype.h:158:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:159:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype (_tolower); ^ /usr/include/ctype.h:159:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:271:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype_l (isalnum_l); ^ /usr/include/ctype.h:271:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:272:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype_l (isalpha_l); ^ /usr/include/ctype.h:272:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:273:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype_l (iscntrl_l); ^ /usr/include/ctype.h:273:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:274:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype_l (isdigit_l); ^ /usr/include/ctype.h:274:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:275:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype_l (islower_l); ^ /usr/include/ctype.h:275:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:276:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype_l (isgraph_l); ^ /usr/include/ctype.h:276:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:277:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype_l (isprint_l); ^ /usr/include/ctype.h:277:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:278:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype_l (ispunct_l); ^ /usr/include/ctype.h:278:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:279:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype_l (isspace_l); ^ /usr/include/ctype.h:279:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:280:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype_l (isupper_l); ^ /usr/include/ctype.h:280:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:281:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype_l (isxdigit_l); ^ /usr/include/ctype.h:281:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:283:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __exctype_l (isblank_l); ^ /usr/include/ctype.h:283:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:287:50: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern int __tolower_l (int __c, __locale_t __l) __THROW; ^ /usr/include/ctype.h:287:50: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:288:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern int tolower_l (int __c, __locale_t __l) __THROW; ^ /usr/include/ctype.h:288:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:291:50: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern int __toupper_l (int __c, __locale_t __l) __THROW; ^ /usr/include/ctype.h:291:50: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/ctype.h:292:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern int toupper_l (int __c, __locale_t __l) __THROW; ^ /usr/include/ctype.h:292:48: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' In file included from /usr/include/errno.h:35:0, from /usr/include/c++/7/cerrno:42, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:36, from rings.cpp:3: /usr/include/x86_64-linux-gnu/bits/errno.h:50:71: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern int *__errno_location (void) __THROW __attribute__ ((__const__)); ^ /usr/include/x86_64-linux-gnu/bits/errno.h:50:71: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' In file included from /usr/include/features.h:367:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533, from /usr/include/c++/7/cassert:43, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33, from rings.cpp:3: /usr/include/locale.h:124:63: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern char *setlocale (int __category, const char *__locale) __THROW; ^ /usr/include/locale.h:124:63: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/locale.h:127:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern struct lconv *localeconv (void) __THROW; ^ /usr/include/locale.h:127:40: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/locale.h:152:28: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __locale_t __base) __THROW; ^ /usr/include/locale.h:152:28: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/locale.h:186:52: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern __locale_t duplocale (__locale_t __dataset) __THROW; ^ /usr/include/locale.h:186:52: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/locale.h:190:47: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern void freelocale (__locale_t __dataset) __THROW; ^ /usr/include/locale.h:190:47: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/locale.h:197:52: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' extern __locale_t uselocale (__locale_t __dataset) __THROW; ^ /usr/include/locale.h:197:52: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' In file included from /usr/include/c++/7/cmath:42:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from rings.cpp:3: /usr/include/c++/7/bits/cpp_type_traits.h:408:32: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __miter_base(_Iterator __it) ^ In file included from /usr/include/c++/7/cmath:43:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41, from rings.cpp:3: /usr/include/c++/7/ext/type_traits.h:152:35: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __is_null_pointer(_Type* __ptr) ^ /usr/include/c++/7/ext/type_traits.h:157:28: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __is_null_pointer(_Type) ^ /usr/include/c++/7/ext/type_traits.h:162:35: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __is_null_pointer(std::nullptr_t) ^ In file included from /usr/include/features.h:367:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533, from /usr/include/c++/7/cassert:43, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33, from rings.cpp:3: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:54:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __MATHCALL (acos,, (_Mdouble_ __x)); ^ /usr/include/x86_64-linux-gnu/bits/mathcalls.h:54:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/x86_64-linux-gnu/bits/mathcalls.h:54:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __MATHCALL (acos,, (_Mdouble_ __x)); ^ /usr/include/x86_64-linux-gnu/bits/mathcalls.h:54:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/x86_64-linux-gnu/bits/mathcalls.h:56:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __MATHCALL (asin,, (_Mdouble_ __x)); ^ /usr/include/x86_64-linux-gnu/bits/mathcalls.h:56:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/x86_64-linux-gnu/bits/mathcalls.h:56:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __MATHCALL (asin,, (_Mdouble_ __x)); ^ /usr/include/x86_64-linux-gnu/bits/mathcalls.h:56:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/x86_64-linux-gnu/bits/mathcalls.h:58:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __MATHCALL (atan,, (_Mdouble_ __x)); ^ /usr/include/x86_64-linux-gnu/bits/mathcalls.h:58:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/x86_64-linux-gnu/bits/mathcalls.h:58:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __MATHCALL (atan,, (_Mdouble_ __x)); ^ /usr/include/x86_64-linux-gnu/bits/mathcalls.h:58:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/x86_64-linux-gnu/bits/mathcalls.h:60:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x)); ^ /usr/include/x86_64-linux-gnu/bits/mathcalls.h:60:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/x86_64-linux-gnu/bits/mathcalls.h:60:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x)); ^ /usr/include/x86_64-linux-gnu/bits/mathcalls.h:60:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/x86_64-linux-gnu/bits/mathcalls.h:63:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __MATHCALL_VEC (cos,, (_Mdouble_ __x)); ^ /usr/include/x86_64-linux-gnu/bits/mathcalls.h:63:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/x86_64-linux-gnu/bits/mathcalls.h:63:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' __MATHCALL_VEC (cos,, (_Mdouble_ __x)); ^ /usr/include/x86_64-linux-gnu/bits/mathcalls.h:63:1: error: argument to '-O' should be a non-negative integer, 'g', 's' or 'fast' /usr/include/x86_64-linux-gnu/bits/mathcalls.h:65:1: error: argument to '-O' should be a non