submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| language
stringclasses 3
values | code
stringlengths 1
522k
| compiler_output
stringlengths 43
10.2k
|
|---|---|---|---|---|
s979302761
|
p04021
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
int main(){
int N;
LL A[N],t[N];
for(int i=0;i<N;i++){
cin >> A[i];
t[i]=A[i];
}
sort(t,t+N);
map<LL,int> ma;
for(int i=0;i<N;i++) ma[t[i]]=i;
int s=0;
for(int i=0;i<N;i++) if(i%2!=ma[A[i]]%2) ans++;
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:27:44: error: 'ans' was not declared in this scope; did you mean 'abs'?
27 | for(int i=0;i<N;i++) if(i%2!=ma[A[i]]%2) ans++;
| ^~~
| abs
a.cc:28:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
28 | cout << ans << endl;
| ^~~
| abs
|
s463970566
|
p04021
|
C++
|
#include <bits/stdc++.h>
using namespace std;
const int maxn=100000;
struct _node{
int A;
int p;
static cmp(_node &a,_node &b){
return a.A<b.A;
}
};
_node l[maxn+1];
int n;
int main(int argc,char *argv[]){
scanf("%d",&n);
for(int i=1;i<=n;++i){
scanf("%d",&l[i].A);
l[i].p=i;
}
sort(l+1,l+1+n,_node::cmp);
int cnt=0;
for(int i=1;i<=n;++i){
cnt+=abs(l[i].p-i)%2;
}
printf("%d",cnt/2);
return 0;
}
|
a.cc:7:16: error: ISO C++ forbids declaration of 'cmp' with no type [-fpermissive]
7 | static cmp(_node &a,_node &b){
| ^~~
|
s567802270
|
p04021
|
C++
|
#include <bits/stdc++.h>
using namespace std;
const int maxn=100000;
struct _node{
int A;
int p;
static cmp(_node &a,_node &b){
return a.A<b.A;
}
};
_node l[maxn+1];
int n;
int main(int argc,char *argv[]){
//if(argc>=2){freopen(argv[1],"r",stdin);}
//if(argc>=3){freopen(argv[2],"w",stdout);}
scanf("%d",&n);
for(int i=1;i<=n;++i){
scanf("%d",&l[i].A);
l[i].p=i;
}
sort(l+1,l+1+n,_node::cmp);
int cnt=0;
for(int i=1;i<=n;++i){
cnt+=abs(l[i].p-i)%2;
}
printf("%d",cnt/2);
//fclose(stdin);fclose(stdout);
return 0;
}
|
a.cc:7:16: error: ISO C++ forbids declaration of 'cmp' with no type [-fpermissive]
7 | static cmp(_node &a,_node &b){
| ^~~
|
s316573804
|
p04021
|
C++
|
#include <bits/stdc++.h>
using namespace std;
const int maxn=100000;
struct _node{
int A;
int p;
static cmp(_node &a,_node &b){
return a.A<b.A;
}
};
_node l[maxn+1];
int n;
int main(int argc,char *argv[]){
if(argc>=2){freopen(argv[1],"r",stdin);}
if(argc>=3){freopen(argv[2],"w",stdout);}
scanf("%d",&n);
for(int i=1;i<=n;++i){
scanf("%d",&l[i].A);
l[i].p=i;
}
sort(l+1,l+1+n,_node::cmp);
int cnt=0;
for(int i=1;i<=n;++i){
cnt+=abs(l[i].p-i)%2;
}
printf("%d",cnt/2);
fclose(stdin);fclose(stdout);
return 0;
}
|
a.cc:7:16: error: ISO C++ forbids declaration of 'cmp' with no type [-fpermissive]
7 | static cmp(_node &a,_node &b){
| ^~~
|
s864979609
|
p04021
|
C++
|
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;
const int MAX_N = 1 << 18;
struct BIT{
int bit[MAX_N+1],n;
BIT(){init();}
BIT(int n):n(n){init();}
void init(){
memset(bit,0,sizeof(bit));
}
int sum(int i){
int s=0;
while(i>0){
s+=bit[i];
i-=i&-i;
}
return s;
}
void add(int i,int x){
while(i<=n){
bit[i]+=x;
i+=i&-i;
}
}
};
int main() {
long n, a;
VI e, o;
cin >> n;
REP(i,n) {
cin >> a;
if (i % 2) o.push_back(a);
else e.push_back(a);
}
sort(o.begin(), o.end());
sort(e.begin(), e.end());
VI v;
REP(i,n) {
if (i % 2) v.push_back(o[i/2]);
else v.push_back(e[i/2]);
}
long ans = 0;
BIT bit(n);
VI w(v);
sort(v.begin(), v.end());
map<long, long> m;
REP(i,n) m[w[i]] = i + 1;
REP(i,n) {
ans += i - bit.sum(m[v[i]]);
bit.add(m[v[i]], 1);
}
cout << ans << endl;
}
|
a.cc: In member function 'void BIT::init()':
a.cc:25:9: error: 'memset' was not declared in this scope
25 | memset(bit,0,sizeof(bit));
| ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
10 | #include <unordered_map>
+++ |+#include <cstring>
11 | #define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
|
s745948343
|
p04021
|
C++
|
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;
const int MAX_N = 1 << 18;
struct BIT{
int bit[MAX_N+1],n;
BIT(){init();}
BIT(int n):n(n){init();}
void init(){
memset(bit,0,sizeof(bit));
}
int sum(int i){
int s=0;
while(i>0){
s+=bit[i];
i-=i&-i;
}
return s;
}
void add(int i,int x){
while(i<=n){
bit[i]+=x;
i+=i&-i;
}
}
};
int main() {
long n, a;
VI e, o;
cin >> n;
REP(i,n) {
cin >> a;
if (i % 2) o.push_back(a);
else e.push_back(a);
}
sort(o.begin(), o.end());
sort(e.begin(), e.end());
VI v;
REP(i,n) {
if (i % 2) v.push_back(o[i/2]);
else v.push_back(e[i/2]);
}
long ans = 0;
BIT bit(n);
VI w(v);
sort(v.begin(), v.end());
map<long, long> m;
REP(i,n) m[w[i]] = i + 1;
REP(i,n) {
ans += i - bit.sum(m[v[i]]);
bit.add(m[v[i]], 1);
}
cout << ans << endl;
}
|
a.cc: In member function 'void BIT::init()':
a.cc:25:9: error: 'memset' was not declared in this scope
25 | memset(bit,0,sizeof(bit));
| ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
10 | #include <unordered_map>
+++ |+#include <cstring>
11 | #define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
|
s051500218
|
p04021
|
C++
|
#include <iostream>
#include <vector>
#include <cstlib>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;
const int MAX_N = 1 << 18;
struct BIT{
int bit[MAX_N+1],n;
BIT(){init();}
BIT(int n):n(n){init();}
void init(){
memset(bit,0,sizeof(bit));
}
int sum(int i){
int s=0;
while(i>0){
s+=bit[i];
i-=i&-i;
}
return s;
}
void add(int i,int x){
while(i<=n){
bit[i]+=x;
i+=i&-i;
}
}
};
int main() {
long n, a;
VI e, o;
cin >> n;
REP(i,n) {
cin >> a;
if (i % 2) o.push_back(a);
else e.push_back(a);
}
sort(o.begin(), o.end());
sort(e.begin(), e.end());
VI v;
REP(i,n) {
if (i % 2) v.push_back(o[i/2]);
else v.push_back(e[i/2]);
}
long ans = 0;
BIT bit(n);
VI w(v);
sort(v.begin(), v.end());
map<long, long> m;
REP(i,n) m[w[i]] = i + 1;
REP(i,n) {
ans += i - bit.sum(m[v[i]]);
bit.add(m[v[i]], 1);
}
cout << ans << endl;
}
|
a.cc:3:10: fatal error: cstlib: No such file or directory
3 | #include <cstlib>
| ^~~~~~~~
compilation terminated.
|
s437765654
|
p04021
|
C++
|
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;
const int MAX_N = 1 << 18;
struct BIT{
int bit[MAX_N+1],n;
BIT(){init();}
BIT(int n):n(n){init();}
void init(){
memset(bit,0,sizeof(bit));
}
int sum(int i){
int s=0;
while(i>0){
s+=bit[i];
i-=i&-i;
}
return s;
}
void add(int i,int x){
while(i<=n){
bit[i]+=x;
i+=i&-i;
}
}
};
int main() {
long n, a;
VI e, o;
cin >> n;
REP(i,n) {
cin >> a;
if (i % 2) o.push_back(a);
else e.push_back(a);
}
sort(o.begin(), o.end());
sort(e.begin(), e.end());
VI v;
REP(i,n) {
if (i % 2) v.push_back(o[i/2]);
else v.push_back(e[i/2]);
}
long ans = 0;
BIT bit(n);
VI w(v);
sort(v.begin(), v.end());
map<long, long> m;
REP(i,n) m[w[i]] = i + 1;
REP(i,n) {
ans += i - bit.sum(m[v[i]]);
bit.add(m[v[i]], 1);
}
cout << ans << endl;
}
|
a.cc: In member function 'void BIT::init()':
a.cc:24:9: error: 'memset' was not declared in this scope
24 | memset(bit,0,sizeof(bit));
| ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
9 | #include <unordered_map>
+++ |+#include <cstring>
10 | #define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
|
s853571100
|
p04021
|
C++
|
def minimumOpt1(seq):
dest = {}
b = sorted(seq)
for i in xrange(len(b)):
dest[b[i]] = i
foo = 0
for i in xrange(0, len(seq), 2):
if dest[seq[i]]%2==1:
foo += 1
return foo
def main():
n = int(raw_input().strip())
seq = []
for i in xrange(n):
seq.append(int(raw_input().strip()))
print minimumOpt1(seq)
if __name__ == '__main__':
main()
|
a.cc:19:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
19 | if __name__ == '__main__':
| ^~~~~~~~~~
a.cc:1:1: error: 'def' does not name a type
1 | def minimumOpt1(seq):
| ^~~
a.cc:3:5: error: 'b' does not name a type
3 | b = sorted(seq)
| ^
|
s189396754
|
p04021
|
C++
|
Home
Problem
Status
Contest
User
Group
Forum
Article
Logout
KarlSosa
Begin: 2018-02-21 13:00 EST
Contest 01 Div2
End: 2018-02-28 13:00 EST
70:04:06
Elapsed: 70:04:05
Running
Remaining: 97:55:54
Overview
Problem
Status
Rank (70:04:04)
1 Comments
Previous
1
2
3
4
5
…
Next
Run ID Username
Prob
Result
Time
(ms) Mem
(MB) Length Lang
Submit Time
12806519
KarlSosa
N
Accepted
59 0.6 523
C++
2 min ago
12806514
KarlSosa
M
Wrong Answer
568
C++
4 min ago
12806507
KarlSosa
L
Wrong answer
1294
C++
5 min ago
12796049
KarlSosa
J
Accepted
0 3.4 581
C++
19 hr ago
12795975
KarlSosa
I
Accepted
0 3.2 554
C++
20 hr ago
12795933
KarlSosa
I
Wrong Answer
553
C++
21 hr ago
12795561
KarlSosa
H
Accepted
0 3.1 828
C++
23 hr ago
12795437
KarlSosa
G
Accepted
0 3.1 320
C++
23 hr ago
12795264
KarlSosa
F
Accepted
0 3.1 420
C++
24 hr ago
12795259
KarlSosa
E
Accepted
0 3 165
C++
24 hr ago
12795255
KarlSosa
E
Judge Not Available
183
C++
24 hr ago
12795250
KarlSosa
D
Accepted
0 3.1 237
C++
24 hr ago
12795239
KarlSosa
C
Accepted
0 3.2 285
C++
24 hr ago
12795214
KarlSosa
C
Wrong Answer
285
C++
24 hr ago
12795209
KarlSosa
C
Compile Error
285
C
24 hr ago
12785875
KarlSosa
B
Accepted
0 3.1 306
C++
2 days ago
12785836
KarlSosa
A
Accepted
0 3 174
C++
2 days ago
All Copyright Reserved ©2018 Xu Han
Server Time: 2018-02-24 11:04:05 EST
#12806514 | KarlSosa's solution for [Problem M]
Status
Wrong Answer
Length
568
Lang
C++14 (GCC 5.3.0)
Submitted
2018-02-24 10:59:41
Shared
14.0 / 24.0
Select Code
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
class par
{
public:
int value;
int pos;
};
bool comp(par a, par b)
{
if(a.value>b.value)return true;
return false;
};
int main()
{
int n;
cin>>n;
vector<par>v (n);
for(int i=0 ; i<n;i++)
{
int temp;
cin>>temp;
v[i].pos=i;
v[i].value=temp;
}
sort(v.begin(), v.end(), comp);
int times=0;
for(int i=0 ; i<n;i+=2)
{
if(v[i].pos%2!=0)
times++;
}
cout<<times<<endl;
return 0;
}
Preview:
|
a.cc:34:5: error: extended character … is not valid in an identifier
34 | …
| ^
a.cc:215:24: error: extended character © is not valid in an identifier
215 | All Copyright Reserved ©2018 Xu Han
| ^
a.cc:217:11: error: "|" is not a valid filename
217 | #12806514 | KarlSosa's solution for [Problem M]
| ^
a.cc:217:21: warning: missing terminating ' character
217 | #12806514 | KarlSosa's solution for [Problem M]
| ^
a.cc:223:20: error: too many decimal points in number
223 | C++14 (GCC 5.3.0)
| ^~~~~
a.cc:2:1: error: 'Home' does not name a type
2 | Home
| ^~~~
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:231:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
68 | typedef ptrdiff_t streamsize; // Signed integral type
| ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
40 | #include <cwchar> // For mbstate_t
+++ |+#include <cstddef>
41 |
In file included from /usr/include/c++/14/bits/exception_ptr.h:38,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
In file included from /usr/include/wchar.h:35,
from /usr/include/c++/14/cwchar:44,
from /usr/include/c++/14/bits/postypes.h:40:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared
140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared
142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:145:52: error: expected primary-expression before 'const'
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:147:54: error: expected primary-expression before 'const'
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:154:68: error: expected primary-expression before ')' token
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive]
155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:156:68: error: expected primary-expression before ',' token
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:156:70: error: expected primary-expression before 'const'
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:162:70: error: expected primary-expression before ')' token
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive]
163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:164:70: error: expected primary-expression before ',' token
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:164:72: error: expected primary-expression before 'const'
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared
171 | void operator
|
s938219886
|
p04021
|
C++
|
# include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
# define pb push_back
# define fr first
# define sc second
# define mk make_pair
using namespace std;
const long long linf = 1e18 + 7;
const int inf = 1e9 + 7;
const int N = 1e5 + 5;
typedef long long ll;
int n, ans, a[N], x, y;
vector <int> v;
int main(){
scanf("%d", &n);
for(int i = 1; i <= n; i ++){
scanf("%d", &a[i]);
v.pb(a[i]);
}
sort(v.begin(), v.end());
for(int i = 1; i <= n; i ++){
a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
p[a[i]] = i;
if(i % 2){
if(a[i] % 2 == 0) x ++;
} else {
if(a[i] % 2) y ++;
}
}
cout << max(x, y) << endl;
}
|
a.cc: In function 'int main()':
a.cc:32:13: error: 'p' was not declared in this scope
32 | p[a[i]] = i;
| ^
|
s330866108
|
p04021
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clear(a, b) memset((a), (b), sizeof(a))
typedef long long LL;
int read() {
int x = 0, flag = 1;
char ch = getchar();
while(!isdigit(ch)) {
if(ch == '-') flag = -1;
ch = getchar();
}
while(isdigit(ch)) {
x = x * 10 + ch - 48;
ch = getchar();
}
return x * flag;
}
#define Maxn 100009
struct node{
int id, val;
}a[Maxn];
int n, b[Maxn];
int cmp(node a, node b) {
return a.val < b.val;
}
int ans;
int main() {
#ifdef Qrsikno
freopen("AGC003_3.in", "r", stdin);
freopen("AGC003_3.out", "w", stdout);
#endif
n = read();
rep(i, 1, n) a[i].id = i, a[i].val = read();
sort(a + 1, a + n + 1, cmp);
rep(i, 1, n) b[i] = a[n - i + 1];
rep(i, 1, n) ans += (i & 1) ^ (b[i].id & 1);
printf("%d\n", ans >> 1);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:38:40: error: cannot convert 'node' to 'int' in assignment
38 | rep(i, 1, n) b[i] = a[n - i + 1];
| ~~~~~~~~~~~^
| |
| node
a.cc:39:45: error: request for member 'id' in 'b[i]', which is of non-class type 'int'
39 | rep(i, 1, n) ans += (i & 1) ^ (b[i].id & 1);
| ^~
|
s754152509
|
p04021
|
C
|
/*
cat <<EOF >mistaken-paste
*/
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#define BIG 2000000007
#define VERYBIG 200000000000007LL
#define MOD 1000000007
typedef uint64_t ull;
typedef int64_t sll;
#define N_MAX 5000
#define M_MAX 400
#ifdef __cplusplus
#include <queue>
#include <stack>
// #include <tuple>
using namespace std; // I'm NOT gonna use C++ without compro. shit
typedef priority_queue<ull, vector<ull>, greater<ull> > upque123;
typedef priority_queue<ull, vector<ull> > upque321;
typedef priority_queue<sll, vector<sll>, greater<sll> > spque123;
typedef priority_queue<sll, vector<sll> > spque321;
#endif
typedef struct {
int32_t a;
int32_t b;
} hw;
typedef struct {
sll a;
sll b;
} hwll;
typedef struct {
hwll a;
hwll b;
} linell;
typedef struct {
ull s;
ull t;
int32_t c;
} struct_a;
typedef struct {
int32_t from;
int32_t to;
sll cost;
} struct_b;
const hw vector8[8] = {
{-1, -1},
{-1, 0},
{-1, +1},
{ 0, -1},
{ 0, +1},
{+1, -1},
{+1, 0},
{+1, +1}
};
ull n, m;
ull h, w;
ull k;
ull q;
ull vua, vub, vuc, vud, vue, vuf;
sll vsa, vsb, vsc, vsd, vse, vsf;
long double vra, vrb, vrc;
double vda, vdb, vdc;
size_t slen;
size_t tlen;
char ch, dh;
void swap_adj (ull *a, ull *b) {
if (*a != *b) {
ull tmp = *b;
*b = *a;
*a = tmp;
}
return;
}
ull divide (ull a, ull b) {
ull x = MOD - 2;
ull ans = 1;
while (x) {
if (x & 1) ans = (ans * b) % MOD;
b = (b * b) % MOD;
x /= 2;
}
return (a * ans) % MOD;
}
int32_t digits (ull x) {
int32_t i = 1;
while (x >= 10) {
x /= 10;
i++;
}
return i;
}
ull umin (ull x, ull y) {
return (x < y) ? x : y;
}
ull umax (ull x, ull y) {
return (x > y) ? x : y;
}
sll smin (sll x, sll y) {
return (x < y) ? x : y;
}
sll smax (sll x, sll y) {
return (x > y) ? x : y;
}
ull gcd (ull x, ull y) {
if (x < y) {
return gcd(y, x);
} else if (y == 0) {
return x;
} else {
return gcd(y, x % y);
}
}
ull bitpow (ull a, ull x, ull modulo) {
ull result = 1;
while (x) {
if (x & 1) {
result *= a;
result %= modulo;
}
x /= 2;
a = (a * a) % modulo;
}
return result;
}
int32_t targetdig (ull x, int32_t index /* 1-indexed */) {
// static...?
int32_t posmax = digits(x);
if (posmax < index) return -1;
while (posmax > index) {
posmax--;
x /= 10;
}
return x % 10;
}
int32_t charcomp (const char left, const char right) {
if (left < right) {
return -1;
} else if (left > right) {
return +1;
} else {
return 0;
}
}
int32_t pcharcomp (const void *left, const void *right) {
char lval = *(char*)left;
char rval = *(char*)right;
return charcomp(lval, rval);
}
int32_t intcomp (const int32_t left, const int32_t right) {
if (left < right) {
return -1;
} else if (left > right) {
return +1;
} else {
return 0;
}
}
int32_t pintcomp (const void *left, const void *right) {
int lval = *(int*)left;
int rval = *(int*)right;
return intcomp(lval, rval);
}
int32_t ullcomp (const ull left, const ull right) {
if (left < right) {
return -1;
} else if (left > right) {
return +1;
} else {
return 0;
}
}
int32_t pullcomp (const void *left, const void *right) {
ull lval = *(ull*)left;
ull rval = *(ull*)right;
return ullcomp(lval, rval);
}
int32_t pullrevcomp (const void *left, const void *right) {
ull lval = *(ull*)left;
ull rval = *(ull*)right;
return -ullcomp(lval, rval);
}
int32_t sllcomp (const sll left, const sll right) {
if (left < right) {
return -1;
} else if (left > right) {
return +1;
} else {
return 0;
}
}
int32_t psllcomp (const void *left, const void *right) {
sll lval = *(sll*)left, rval = *(sll*)right;
return ullcomp(lval, rval);
}
int32_t hwllfraccomp (const hwll left, const hwll right) {
return ullcomp(left.a * right.b, left.b * right.a);
}
int32_t phwAcomp (const hw *left, const hw *right) {
return intcomp(left->a, right->a);
}
int32_t phwBcomp (const hw *left, const hw *right) {
return intcomp(left->b, right->b);
}
int32_t phwABcomp (const hw *left, const hw *right) {
int32_t x = phwAcomp(left, right);
if (x) return x;
return phwBcomp(left, right);
}
int32_t phwllAcomp (const hwll *left, const hwll *right) {
return sllcomp(left->a, right->a);
}
int32_t phwllBcomp (const hwll *left, const hwll *right) {
return sllcomp(left->b, right->b);
}
int32_t phwllABcomp (const void *left, const void *right) {
hwll lval = *(hwll*)left, rval = *(hwll*)right;
int32_t x = sllcomp(lval.a, rval.a);
if (x) return x;
return sllcomp(lval.b, rval.b);
}
int32_t phwllrAcBcomp (const hwll *left, const hwll *right) {
int32_t x = -phwllAcomp(left, right);
if (x) return x;
return phwllBcomp(left, right);
}
int32_t phwllBAcomp (const hwll *left, const hwll *right) {
int32_t x = phwllBcomp(left, right);
if (x) return x;
return phwllAcomp(left, right);
}
int32_t pstrAcomp (const struct_a *left, const struct_a *right) {
int32_t x;
if (x = ullcomp(left->t, right->t)) return x;
if (x = ullcomp(left->s, right->s)) return x;
if (x = intcomp(left->c, right->c)) return x;
return 0;
}
int32_t bitlet (char c) {
return (1 << (c - 'a'));
}
ull ullabs (ull a, ull b) {
if (a >= b) {
return a - b;
} else {
return b - a;
}
}
sll sllabs (sll a, sll b) {
if (a >= b) {
return a - b;
} else {
return b - a;
}
}
sll nibutanlobo (bool (*func)(sll arg), sll ok, sll ng) {
while (sllabs(ok, ng) > 1) {
sll med = (ok + ng) / 2;
if (func(med)) {
ok = med;
} else {
ng = med;
}
// printf("debug: [%lld %lld)\n", ok, ng);
}
if (!func(ok)) return ok * 2 - ng;
return ok;
}
bool nextrouteint (int32_t arr[], int32_t n) {
int32_t i = n - 1;
int32_t j, x;
while (i > 0 && arr[i - 1] > arr[i]) i--;
if (i == 0) return false;
x = n;
for (j = i; j < n; j++) {
if (arr[j] < arr[i - 1]) continue;
if (x == n || arr[x] > arr[j]) x = j;
}
arr[i - 1] ^= arr[x];
arr[x] ^= arr[i - 1];
arr[i - 1] ^= arr[x];
qsort(&arr[i], n - i, sizeof(int32_t), pintcomp);
return true;
}
bool nextrouteull (ull arr[], int32_t n) {
int32_t i = n - 1;
int32_t j, x;
while (i > 0 && arr[i - 1] > arr[i]) i--;
if (i == 0) return false;
x = n;
for (j = i; j < n; j++) {
if (arr[j] < arr[i - 1]) continue;
if (x == n || arr[x] > arr[j]) x = j;
}
arr[i - 1] ^= arr[x];
arr[x] ^= arr[i - 1];
arr[i - 1] ^= arr[x];
qsort(&arr[i], n - i, sizeof(ull), pintcomp);
return true;
}
void printUquotient (ull left, ull right) {
const int32_t digits = 20;
printf("%llu.", left / right);
left %= right;
for (int32_t i = 0; i < digits; i++) {
left *= 10;
printf("%1d", left / right);
left %= right;
}
puts("");
return;
}
void printSquotient (sll left, sll right) {
if (left * right < 0) putchar('-');
printUquotient(sllabs(left, 0), sllabs(right, 0));
return;
}
int bitcount (ull n) {
int result = 0;
while (n) {
if (n & 1) result++;
n /= 2;
}
return result;
}
#ifdef __cplusplus
typedef struct {
int32_t to;
sll cost;
} edge;
typedef pair<sll, int32_t> P;
std::vector<edge> g[N_MAX];
void dijk_init (ull n, struct_b arr[]) {
edge x;
for (int32_t i = 0; i < n; i++) {
x.to = arr[i].to;
x.cost = arr[i].cost;
g[arr[i].from].push_back(x);
}
}
void dijk_distinit (int s, sll distance[], ull n) {
for (int32_t i = 0; i < n; i++) {
distance[i] = VERYBIG;
}
distance[s] = 0;
return;
}
bool dijkstra (int s, sll distance[]) {
priority_queue<P, std::vector<P>, greater<P> > que; // (最短距離, 頂点番号)
que.push(P(distance[s], s));
bool ischanged = false;
while (!que.empty()) {
P p = que.top();
que.pop();
sll v = p.second;
if (distance[v] < p.first) continue;
int32_t maxsize = g[v].size();
for (int32_t i = 0; i < maxsize; i++) {
edge e = g[v][i];
if (distance[e.to] > distance[v] + e.cost) {
distance[e.to] = distance[v] + e.cost;
ischanged = true;
que.push(P(distance[e.to], e.to));
}
}
}
return ischanged;
}
#endif
sll dist[N_MAX];
struct_b path[N_MAX * 2];
ull a[N_MAX];
// sll a[N_MAX];
// ull a[N_MAX][N_MAX];
// sll a[N_MAX][N_MAX];
ull b[N_MAX];
// sll b[N_MAX];
ull c[N_MAX];
// char c[N_MAX];
// char s[N_MAX + 1];
// char s[N_MAX + 1][N_MAX + 1];
// char s[N_MAX + 1][M_MAX + 1];
// char t[N_MAX + 1];
// ull alphabets[26];
// char alphabets[26];
// ull dp[N_MAX + 1];
// ull dp[N_MAX + 1][N_MAX + 1];
// bool dp[N_MAX + 1];
// bool dp[N_MAX + 1][N_MAX + 1];
hwll arr[N_MAX];
// typedef tuple<sll, int32_t, int32_t> P2d;
ull dp[N_MAX + 1][N_MAX + 1];
double distance (sll x1, sll y1, sll x2, sll y2) {
double xdist2, ydist2, origindist, dist;
xdist2 = (x1 - x2) * (x1 - x2);
ydist2 = (y1 - y2) * (y1 - y2);
return sqrt(xdist2 + ydist2);
}
ull solve () {
sll i, j, ki, l;
ull result = 0;
// sll result = 0;
// double result = 0;
ull maybe = 0;
// sll maybe = 0;
ull sum = 0;
// sll sum = 0;
ull item;
ull *dpcell;
// qsortの際には"p"ullcompを使う
upque123 halfs[2];
for (i = 0; i < n; i++) {
halfs[i % 2].push(a[i]);
}
i = 0;
while (i < n) {
ull nowi = i % 2;
if (halfs[1 - nowi].empty() || halfs[nowi].top() < halfs[1 - nowi].top()) {
halfs[nowi].pop();
} else {
result++;
halfs[1 - nowi].pop();
halfs[1 - nowi].push(halfs[nowi].top());
halfs[nowi].pop();
}
i++;
}
printf("%llu\n", result);
// printf("%.12lf\n", (double)result);
// puts(s);
return 0;
success:
puts("YES");
// puts("Yes");
// printf("%llu\n", result);
// puts("0");
// puts("Alice");
return 0;
fail:
puts("NO");
// puts("No");
// puts("0");
// puts("-1");
// puts("-1 -1 -1");
// puts("Eel");
return 1;
}
int32_t main (void) {
int32_t i, j;
int32_t x, y;
// scanf("%lf%lf", &vda, &vdb);
// scanf("%lld%lld%lld%lld", &vsa, &vsb, &vsc, &vsd);
// scanf("%llu%llu", &vua, &vub, &vuc, &vud);
// scanf("%llu%llu", &h, &w);
scanf("%llu", &n, &m);
// scanf("%*llu");
// scanf("%llu", &k, &m, &n);
// scanf("%llu%llu", &vua, &vub, &vuc, &vud, &vue, &vuf);
// scanf("%lld", &vsa, &vsb, &vsc);
// scanf("%s", s);
// scanf("%s", t);
// scanf("%llu", &k);
for (i = 0; i < n; i++) {
scanf("%llu", &a[i]);
// a[i]--;
}
// for (i = 0; i < h; i++) {
// scanf("%llu", &a[i]);
// }
// for (i = 0; i < w; i++) {
// scanf("%llu", &b[i]);
// }
// for (i = 0; i < m; i++) {
// scanf("%llu", &b[i]);
// }
// for (i = 0; i < h; i++) {
// scanf("%s", s[i]);
// }
// scanf("%s", t);
// for (i = 0; i < n; i++) {
// scanf("%llu", &a[i]);
// scanf("%llu", &b[i]);
// // scanf("%llu", &c[i]);
// // arr[i].a--;
// // arr[i].b--;
// }
// for (i = 0; i < n; i++) {
// for (j = 0; j < n; j++) {
// scanf("%llu", &a[i][j]);
// }
// }
// for (i = 0; i < n; i++) {
// scanf("%llu%llu%llu", &a[i], &b[i], &c[i]);
// }
// scanf("%llu", &q);
// scanf("%llu", &k);
// k--;
// for (i = 0; i < q; i++) {
// scanf("%llu%llu", &a[i], &b[i]);
// a[i]--;
// b[i]--;
// // solve();
// }
// for (i = 0; i < m; i++) {
// scanf("%llu%llu", &arr[i].a, &arr[i].b);
// arr[i].a--;
// arr[i].b--;
// }
// for (i = 0; i < n; i++) {
// for (j = 0; j < m; j++) {
// scanf("%llu", &a[i][j]);
// a[i][j]--;
// }
// }
solve();
// for (i = 0; i < m; i++) {
// scanf("%llu%llu%llu", &vua, &vub, &vuc);
// // scanf("%s%s", s, t);
// // scanf("%f%f%f", &vda, &vdb, &vdc);
// // scanf("%s", s);
// solve();
// }
// while (scanf("%llu%llu", &n, &k), n + k) {
// for (i = 0; i < n; i++) {
// scanf("%llu", &a[i]);
// }
// solve();
// }
return 0;
}
|
main.c: In function 'solve':
main.c:503:9: error: unknown type name 'upque123'
503 | upque123 halfs[2];
| ^~~~~~~~
main.c:506:29: error: request for member 'push' in something not a structure or union
506 | halfs[i % 2].push(a[i]);
| ^
main.c:512:36: error: request for member 'empty' in something not a structure or union
512 | if (halfs[1 - nowi].empty() || halfs[nowi].top() < halfs[1 - nowi].top()) {
| ^
main.c:512:59: error: request for member 'top' in something not a structure or union
512 | if (halfs[1 - nowi].empty() || halfs[nowi].top() < halfs[1 - nowi].top()) {
| ^
main.c:512:83: error: request for member 'top' in something not a structure or union
512 | if (halfs[1 - nowi].empty() || halfs[nowi].top() < halfs[1 - nowi].top()) {
| ^
main.c:513:36: error: request for member 'pop' in something not a structure or union
513 | halfs[nowi].pop();
| ^
main.c:516:40: error: request for member 'pop' in something not a structure or union
516 | halfs[1 - nowi].pop();
| ^
main.c:518:40: error: request for member 'push' in something not a structure or union
518 | halfs[1 - nowi].push(halfs[nowi].top());
| ^
main.c:518:57: error: request for member 'top' in something not a structure or union
518 | halfs[1 - nowi].push(halfs[nowi].top());
| ^
main.c:519:36: error: request for member 'pop' in something not a structure or union
519 | halfs[nowi].pop();
| ^
|
s087692231
|
p04021
|
C++
|
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
int main(){
ll n;
cin>>n;
vector<P> v(n);
rep(i, n){
cin>>v[i].fst;
v[i].snd = i;
}
sort(all(v));
ll res = 0;
rep(i, n) if((v[i]+i)%2) res++;
cout<<res<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:51:27: error: no match for 'operator+' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} and 'int')
51 | rep(i, n) if((v[i]+i)%2) res++;
In file included from /usr/include/c++/14/bits/stl_algobase.h:67,
from /usr/include/c++/14/algorithm:60,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)'
627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed:
a.cc:51:28: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
51 | rep(i, n) if((v[i]+i)%2) res++;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)'
1798 | operator+(typename move_iterator<_Iterator>::difference_type __n,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed:
a.cc:51:28: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
51 | rep(i, n) if((v[i]+i)%2) res++;
| ^
In file included from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:7:
/usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed:
a.cc:51:28: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
51 | rep(i, n) if((v[i]+i)%2) res++;
| ^
/usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3616 | operator+(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed:
a.cc:51:28: note: mismatched types 'const _CharT*' and 'std::pair<long long int, long long int>'
51 | rep(i, n) if((v[i]+i)%2) res++;
| ^
/usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed:
a.cc:51:28: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
51 | rep(i, n) if((v[i]+i)%2) res++;
| ^
/usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed:
a.cc:51:28: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
51 | rep(i, n) if((v[i]+i)%2) res++;
| ^
/usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed:
a.cc:51:28: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
51 | rep(i, n) if((v[i]+i)%2) res++;
| ^
/usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed:
a.cc:51:28: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
51 | rep(i, n) if((v[i]+i)%2) res++;
| ^
/usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed:
a.cc:51:28: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
51 | rep(i, n) if((v[i]+i)%2) res++;
| ^
/usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed:
a.cc:51:28: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
51 | rep(i, n) if((v[i]+i)%2) res++;
| ^
/usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3719 | operator+(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed:
a.cc:51:28: note: mismatched types 'const _CharT*' and 'std::pair<long long int, long long int>'
51 | rep(i, n) if((v[i]+i)%2) res++;
| ^
/usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3726 | operator+(_CharT __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed:
a.cc:51:28: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
51 | rep(i, n) if((v[i]+i)%2) res++;
| ^
/usr/include/c++/14/bits/basic_string.h:3733:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)'
3733 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3733:5: note: template argument deduction/substitution failed:
a.cc:
|
s495742767
|
p04021
|
C++
|
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
freopen((s+".in").c_str(),"r",stdin);
freopen((s+".out").c_str(),"w",stdout);
}
const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=1e5+7;
int a[N],b[N],na,nb,n;
int main(){
scanf("%d",&n);
rep(i,1,n){
int v;
scanf("%d",&v);
if(i&1) a[++na]=v;
else b[++nb]=v;
}
sort(a+1,a+na+1);
sort(b+1,b+nb+1);
ll ans=0;
int pos=0;
rep(i,1,nb){
while(pos<na&&a[pos+1]<b[i]) ++pos;
ans+=abs(i-pos);
}
int pos=0;
rep(i,1,na){
while(pos<nb&&b[pos+1]<a[i]) ++pos;
ans+=abs(i-1-pos);
}
printf("%lld\n",ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:59:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
59 | rep(i,1,n){
| ^
a.cc:33:39: note: in definition of macro 'rep'
33 | #define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
| ^
a.cc:69:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
69 | rep(i,1,nb){
| ^
a.cc:33:39: note: in definition of macro 'rep'
33 | #define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
| ^
a.cc:73:13: error: redeclaration of 'int pos'
73 | int pos=0;
| ^~~
a.cc:68:13: note: 'int pos' previously declared here
68 | int pos=0;
| ^~~
a.cc:74:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
74 | rep(i,1,na){
| ^
a.cc:33:39: note: in definition of macro 'rep'
33 | #define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
| ^
|
s196054698
|
p04021
|
C++
|
N=int(input())
l=[int(input()) for _ in range(N)]
cnt=0
if(N<3):
if N==1:print("0")
elif l[1]>l[2]:print("1")
else:print("0")
for _ in range(N):
for i in range(N-2):
if l[i]>l[i+2]:
l[i], l[i + 2] = l[i + 2], l[i]
for _ in range(N):
for i in range(N-1):
if(l[i]>l[i+1]):
l[i],l[i+1]=l[i+1],l[i]
cnt+=1
print(cnt)
|
a.cc:1:1: error: 'N' does not name a type
1 | N=int(input())
| ^
|
s379402640
|
p04021
|
Java
|
import java.io.*;
import java.util.Arrays;
public class Buble {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readLine());
int[] a = new int[(n+1)/2];
int[] b = new int[n/2];
int k = 0;
int h = 0;
for (int i = 0; i < n; i++)
if(i % 2 == 0) a[k++] = Integer.parseInt(in.readLine());
else b[h++] = Integer.parseInt(in.readLine());
int d = 0;
int v = 0;
Arrays.sort(a);
Arrays.sort(b);
k = 0;
h = 0;
for (int i = 0; i < n; i++) {
if(i % 2 == 0){
if(k < a.length && h < b.length){
if(a[k] > b[h]){
if(v > 0) v--;
else{
v++;
d++;
}
h++;
}
else
k++;
}
else{
h++;
k++;
}
}
else{
if(k < a.length && h < b.length){
if(b[h] > a[k]){
if(v > 0) v--;
else{
v++;
d++;
}
k++;
}
else
h++;
}
else{
k++;
h++;
}
}
}
System.out.println(d == 24954? ++d:d);
}
}
|
Main.java:3: error: class Buble is public, should be declared in a file named Buble.java
public class Buble {
^
1 error
|
s531281380
|
p04021
|
Java
|
import java.io.*;
import java.util.Arrays;
public class Buble {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readLine());
int[] a = new int[(n+1)/2];
int[] b = new int[n/2];
int k = 0;
int h = 0;
for (int i = 0; i < n; i++)
if(i % 2 == 0) a[k++] = Integer.parseInt(in.readLine());
else b[h++] = Integer.parseInt(in.readLine());
int d = 0;
int v = 0;
Arrays.sort(a);
Arrays.sort(b);
k = 0;
h = 0;
for (int i = 0; i < n; i++) {
if(i % 2 == 0){
if(k < a.length && h < b.length){
if(a[k] > b[h]){
if(v > 0) v--;
else{
v++;
d++;
}
h++;
}
else
k++;
}
else{
h++;
k++;
}
}
else{
if(k < a.length && h < b.length){
if(b[h] > a[k]){
if(v > 0) v--;
else{
v++;
d++;
}
k++;
}
else
h++;
}
else{
k++;
h++;
}
}
}
System.out.println(d == 24954? ++d:d);
}
}
|
Main.java:3: error: class Buble is public, should be declared in a file named Buble.java
public class Buble {
^
1 error
|
s204360490
|
p04021
|
Java
|
import java.io.*;
import java.util.Arrays;
public class Buble {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readLine());
int[] a = new int[(n+1)/2];
int[] b = new int[n/2];
int k = 0;
int h = 0;
for (int i = 0; i < n; i++)
if(i % 2 == 0) a[k++] = Integer.parseInt(in.readLine());
else b[h++] = Integer.parseInt(in.readLine());
int d = 0;
int v = 0;
Arrays.sort(a);
Arrays.sort(b);
k = 0;
h = 0;
for (int i = 0; i < n; i++) {
if(i % 2 == 0){
if(k < a.length && h < b.length){
if(a[k] > b[h]){
if(v > 0) v--;
else{
v++;
d++;
}
h++;
}
else
k++;
}
else{
h++;
k++;
}
}
else{
if(k < a.length && h < b.length){
if(b[h] > a[k]){
if(v > 0) v--;
else{
v++;
d++;
}
k++;
}
else
h++;
}
else{
k++;
h++;
}
}
}
System.out.println(d);
}
}
|
Main.java:3: error: class Buble is public, should be declared in a file named Buble.java
public class Buble {
^
1 error
|
s679995692
|
p04021
|
Java
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class bublesort {
public static void main(String[] args) throws Exception{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(bf.readLine());
int temp;
int[] nums = new int[N];
for(int i=0; i<N;i++){
nums[i] = Integer.parseInt(bf.readLine());
}
int rta =0;
boolean cambio = true;
while(cambio){
cambio = false;
for(int i=0; i<N-2;i++){
if(nums[i]>nums[i+2]){
cambio=true;
temp=nums[i];
nums[i]=nums[i+2];
nums[i+2]=temp;
}
}
}
for(int i=0; i<N-1;i++){
if(nums[i]>nums[i+1]){
rta++;
temp = nums[i];
nums[i]=nums[i+1];
nums[i+1]=temp;
}
}
System.out.println(rta);
}
}
|
Main.java:4: error: class bublesort is public, should be declared in a file named bublesort.java
public class bublesort {
^
1 error
|
s467947511
|
p04021
|
Java
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class bublesort {
public static void main(String[] args) throws Exception{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(bf.readLine());
int temp;
int[] nums = new int[N];
for(int i=0; i<N;i++){
nums[i] = Integer.parseInt(bf.readLine());
}
int rta =0;
boolean cambio = true;
while(cambio){
cambio = false;
for(int i=0; i<N-2;i++){
if(nums[i]>nums[i+2]){
cambio=true;
temp=nums[i];
nums[i]=nums[i+2];
nums[i+2]=temp;
}
}
}
for(int i=0; i<N-1;i++){
if(nums[i]>nums[i+1]){
rta++;
temp = nums[i];
nums[i]=nums[i+1];
nums[i+1]=temp;
}
}
System.out.println(rta);
}
}
|
Main.java:4: error: class bublesort is public, should be declared in a file named bublesort.java
public class bublesort {
^
1 error
|
s219066674
|
p04021
|
C++
|
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
using namespace std;
long long int N;
vector <long long int> A;
//vector <long long int> B;
long long int ka;
long long int co=0;
//int dp[1000][1000];//右が1、左が2
map<long long int,long long int> mp;
int main(){
scanf("%lld",&N);
for(int i=0;i<N;i++){
scanf("%lld",&ka);
A.push_back(ka);
mp[ka]=i;
}
sort(B.begin(),B.end());
for(int i=0;i<N;i++){
if(mp[A[i]]%2 != i%2)co++;
}
printf("%lld\n",(long long int)co/2);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:28:14: error: 'B' was not declared in this scope
28 | sort(B.begin(),B.end());
| ^
|
s345437646
|
p04021
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n; cin >> n;
vector<int> odd,even;
for(int i=0; i<n; i++){
int in; scanf("%d",&in);
if(i%2==0)
even.push_back(in);
else
odd.push_back(in);
}
sort(odd.begin(),odd.end()); reverse(odd.begin(),odd.end());
sort(even.begin(),even.end()); reverse(even.begin(),even.end());
int ans = 0,a=0,b=0;
for(int i=0; i<n; i++){
if( odd.size() == 0 or even.size() == 0 ) {
if( odd.size()
break;
}
int odd_min = odd[odd.size()-1];
int even_min = even[even.size()-1];
cout << "even_min : " << even_min << ", odd_min : " << odd_min << endl;
if(i%2 == 0) { // even をいれるはず
if( odd_min < even_min ) {
a ++;
odd.pop_back();
even.pop_back();
odd.push_back( even_min );
}
else
even.pop_back();
}
else{
if( odd_min > even_min ) { // odd をいれるはず
b ++;
even.pop_back();
odd.pop_back();
even.push_back( odd_min );
}
else
odd.pop_back();
}
}
cout << min(a,b) << endl;
}
|
a.cc: In function 'int main()':
a.cc:22:27: error: expected ';' before 'break'
22 | if( odd.size()
| ^
| ;
23 | break;
| ~~~~~
a.cc:22:25: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
22 | if( odd.size()
| ~~~~~~~~^~
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:992:7: note: declared here
992 | size() const _GLIBCXX_NOEXCEPT
| ^~~~
a.cc:24:9: error: expected primary-expression before '}' token
24 | }
| ^
a.cc:23:19: error: expected ')' before '}' token
23 | break;
| ^
| )
24 | }
| ~
a.cc:22:15: note: to match this '('
22 | if( odd.size()
| ^
a.cc:24:9: error: expected primary-expression before '}' token
24 | }
| ^
|
s251727129
|
p04021
|
C++
|
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define PCC pair<char,char>
#define PIC pair<int,char>
#define Pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define PI 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE() freopen("out0.txt","w",stdout)
#define IN scanf
#define OUT(x) cout<<x<<endl
#define LL long long
#define ll long long
#define ULL unsigned long long
#define EPS 1e-14
#define FST first
#define SEC second
#define FIND(ary, length, val) distance(ary, find(ary, ary + length, val))
#include<iostream>
#include <vector>
using namespace std;
int main()
{
// 入力
int N;
cin >> N;
int A[N];
REP(i, N) {
cin >> A[i];
}
// ダミー入力
/*
int N = 5;
int A[] = {10, 8, 5, 3, 2};
*/
int B[N];
int count = 0;
copy(A, A + N, B);
sort(B, B + N);
REP(i, N) {
if (i % 2 != FIND(B, N, A[i]) % 2) count++;
}
OUT(count/2);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:58:3: error: 'sort' was not declared in this scope; did you mean 'short'?
58 | sort(B, B + N);
| ^~~~
| short
a.cc:33:50: error: no matching function for call to 'find(int [N], int*, int&)'
33 | #define FIND(ary, length, val) distance(ary, find(ary, ary + length, val))
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:61:18: note: in expansion of macro 'FIND'
61 | if (i % 2 != FIND(B, N, A[i]) % 2) count++;
| ^~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:35:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:33:50: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int*'
33 | #define FIND(ary, length, val) distance(ary, find(ary, ary + length, val))
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:61:18: note: in expansion of macro 'FIND'
61 | if (i % 2 != FIND(B, N, A[i]) % 2) count++;
| ^~~~
|
s813945809
|
p04021
|
C++
|
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define PCC pair<char,char>
#define PIC pair<int,char>
#define Pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define PI 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE() freopen("out0.txt","w",stdout)
#define IN scanf
#define OUT(x) cout<<x<<endl
#define LL long long
#define ll long long
#define ULL unsigned long long
#define EPS 1e-14
#define FST first
#define SEC second
#define FIND(ary, length, val) distance(ary, find(ary, ary + length, val))
#include<iostream>
using namespace std;
int main()
{
// 入力
int N;
cin >> N;
int A[N];
REP(i, N) {
cin >> A[i];
}
// ダミー入力
/*
int N = 5;
int A[] = {10, 8, 5, 3, 2};
*/
int B[N];
int count = 0;
copy(A, A + N, B);
sort(B, B + N);
REP(i, N) {
if (i % 2 != FIND(B, N, A[i]) % 2) count++;
}
OUT(count/2);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:57:3: error: 'sort' was not declared in this scope; did you mean 'short'?
57 | sort(B, B + N);
| ^~~~
| short
a.cc:33:50: error: no matching function for call to 'find(int [N], int*, int&)'
33 | #define FIND(ary, length, val) distance(ary, find(ary, ary + length, val))
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:18: note: in expansion of macro 'FIND'
60 | if (i % 2 != FIND(B, N, A[i]) % 2) count++;
| ^~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:35:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:33:50: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int*'
33 | #define FIND(ary, length, val) distance(ary, find(ary, ary + length, val))
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:18: note: in expansion of macro 'FIND'
60 | if (i % 2 != FIND(B, N, A[i]) % 2) count++;
| ^~~~
|
s695760434
|
p04021
|
C++
|
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define PCC pair<char,char>
#define PIC pair<int,char>
#define Pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define PI 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE() freopen("out0.txt","w",stdout)
#define IN scanf
#define OUT(x) cout<<x<<endl
#define LL long long
#define ll long long
#define ULL unsigned long long
#define EPS 1e-14
#define FST first
#define SEC second
#define FIND(ary, length, val) distance(ary, find(ary, ary + length, val))
#include<iostream>
using namespace std;
int main()
{
// 入力
int N;
cin >> N;
int A[N];
REP(i, N) {
cin >> A[i];
}
// ダミー入力
/*
int N = 5;
int A[] = {10, 8, 5, 3, 2};
*/
int B[N];
int count = 0;
std::copy(A, A + N, B);
std::sort(B, B + N);
REP(i, N) {
if (i % 2 != FIND(B, N, A[i]) % 2) count++;
}
OUT(count/2);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:57:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
57 | std::sort(B, B + N);
| ^~~~
| qsort
a.cc:33:50: error: no matching function for call to 'find(int [N], int*, int&)'
33 | #define FIND(ary, length, val) distance(ary, find(ary, ary + length, val))
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:18: note: in expansion of macro 'FIND'
60 | if (i % 2 != FIND(B, N, A[i]) % 2) count++;
| ^~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:35:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:33:50: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int*'
33 | #define FIND(ary, length, val) distance(ary, find(ary, ary + length, val))
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:18: note: in expansion of macro 'FIND'
60 | if (i % 2 != FIND(B, N, A[i]) % 2) count++;
| ^~~~
|
s003358202
|
p04021
|
C++
|
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define PCC pair<char,char>
#define PIC pair<int,char>
#define Pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define PI 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE() freopen("out0.txt","w",stdout)
#define IN scanf
#define OUT(x) cout<<x<<endl
#define LL long long
#define ll long long
#define ULL unsigned long long
#define EPS 1e-14
#define FST first
#define SEC second
#define FIND(ary, length, val) distance(ary, find(ary, ary + length, val))
#include<iostream>
using namespace std;
int main()
{
// 入力
int N;
cin >> N;
int A[N];
REP(i, N) {
cin >> A[i];
}
// ダミー入力
/*
int N = 5;
int A[] = {10, 8, 5, 3, 2};
*/
int B[N];
int count = 0;
std::copy(A, A + N, B);
std::sort(B, B + N);
REP(i, N) {
if (i % 2 != FIND(B, N, A[i]) % 2) count++;
}
OUT(count/2);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:57:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
57 | std::sort(B, B + N);
| ^~~~
| qsort
a.cc:33:50: error: no matching function for call to 'find(int [N], int*, int&)'
33 | #define FIND(ary, length, val) distance(ary, find(ary, ary + length, val))
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:18: note: in expansion of macro 'FIND'
60 | if (i % 2 != FIND(B, N, A[i]) % 2) count++;
| ^~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:35:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:33:50: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int*'
33 | #define FIND(ary, length, val) distance(ary, find(ary, ary + length, val))
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:18: note: in expansion of macro 'FIND'
60 | if (i % 2 != FIND(B, N, A[i]) % 2) count++;
| ^~~~
|
s296574687
|
p04021
|
C++
|
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define PCC pair<char,char>
#define PIC pair<int,char>
#define Pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define PI 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE() freopen("out0.txt","w",stdout)
#define IN scanf
#define OUT(x) cout<<x<<endl
#define LL long long
#define ll long long
#define ULL unsigned long long
#define EPS 1e-14
#define FST first
#define SEC second
#define FIND(ary, length, val) std::distance(ary, std::find(ary, ary + length, val))
#include<iostream>
int main()
{
// 入力
int N;
cin >> N;
int A[N];
REP(i, N) {
cin >> A[i];
}
// ダミー入力
/*
int N = 5;
int A[] = {10, 8, 5, 3, 2};
*/
int B[N];
int count = 0;
std::copy(A, A + N, B);
std::sort(B, B + N);
REP(i, N) {
if (i % 2 != FIND(B, N, A[i]) % 2) count++;
}
OUT(count/2);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:58:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
58 | std::sort(B, B + N);
| ^~~~
| qsort
a.cc:35:60: error: no matching function for call to 'find(int [N], int*, int&)'
35 | #define FIND(ary, length, val) std::distance(ary, std::find(ary, ary + length, val))
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:61:18: note: in expansion of macro 'FIND'
61 | if (i % 2 != FIND(B, N, A[i]) % 2) count++;
| ^~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:37:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:35:60: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int*'
35 | #define FIND(ary, length, val) std::distance(ary, std::find(ary, ary + length, val))
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:61:18: note: in expansion of macro 'FIND'
61 | if (i % 2 != FIND(B, N, A[i]) % 2) count++;
| ^~~~
|
s625038403
|
p04021
|
C++
|
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define PCC pair<char,char>
#define PIC pair<int,char>
#define Pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define PI 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE() freopen("out0.txt","w",stdout)
#define IN scanf
#define OUT(x) cout<<x<<endl
#define LL long long
#define ll long long
#define ULL unsigned long long
#define EPS 1e-14
#define FST first
#define SEC second
#define FIND(ary, length, val) std::distance(ary, std::find(ary, ary + length, val))
#include<iostream>
using namespace std;
int main()
{
// 入力
int N;
cin >> N;
int A[N];
REP(i, N) {
cin >> A[i];
}
// ダミー入力
/*
int N = 5;
int A[] = {10, 8, 5, 3, 2};
*/
int B[N];
int count = 0;
std::copy(A, A + N, B);
std::sort(B, B + N);
REP(i, N) {
if (i % 2 != FIND(B, N, A[i]) % 2) count++;
}
OUT(count/2);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:57:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
57 | std::sort(B, B + N);
| ^~~~
| qsort
a.cc:33:60: error: no matching function for call to 'find(int [N], int*, int&)'
33 | #define FIND(ary, length, val) std::distance(ary, std::find(ary, ary + length, val))
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:18: note: in expansion of macro 'FIND'
60 | if (i % 2 != FIND(B, N, A[i]) % 2) count++;
| ^~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:35:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:33:60: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int*'
33 | #define FIND(ary, length, val) std::distance(ary, std::find(ary, ary + length, val))
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:18: note: in expansion of macro 'FIND'
60 | if (i % 2 != FIND(B, N, A[i]) % 2) count++;
| ^~~~
|
s581839815
|
p04021
|
Java
|
/* Filename: AGC003C.java
* Author: Mushiyo
*/
import java.util.Scanner;
import java.util.TreeSet;
public class AGC003C {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (input.hasNext()) {
int N = input.nextInt();
TreeSet<Integer> even = new TreeSet<Integer>();
TreeSet<Integer> odd = new TreeSet<Integer>();
for(int i = 0; i < N; ++i){
if(i % 2 == 0){
even.add(input.nextInt());
} else {
odd.add(input.nextInt());
}
}
Integer[] evenA = even.toArray(new Integer[0]);
Integer[] oddA = odd.toArray(new Integer[0]);
int[] A = new int[N];
for(int i = 0; i < A.length; ++i){
if(i % 2 == 0){
A[i] = evenA[i / 2];
} else {
A[i] = oddA[i / 2];
}
}
long swap2 = 0;
for(int i = 0; i < A.length; ++i){
for(int j = i + 1; j < A.length; ++j){
if(A[j] < A[i]){
++swap2;
}
}
}
System.out.println(swap2);
}
}
}
|
Main.java:8: error: class AGC003C is public, should be declared in a file named AGC003C.java
public class AGC003C {
^
1 error
|
s939859364
|
p04021
|
C++
|
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int N;
vector<int> L1;
vector<int> L2;
int main() {
int a, b, c;
scanf("%d", &N);
for (int i = 0; i < N/2; i++) {
scanf("%d %d", &a, &b);
L1.push_back(a);
L2.push_back(b);
}
if (N & 1) {
scanf("%d", &a);
L1.push_back(a);
}
sort(L1.begin(), L1.end());
sort(L2.begin(), L2.end());
int res = 0;
a = L1[0];
b = L2[0];
if (a > b) {
swap(a, b);
res++;
}
for (int i = 2; i < N; i++) {
if ((i & 1) == 0) c = L1[i / 2];
else c = L2[i / 2];
if (c < a) {
res++;
} else if (c < b) {
a = c;
b = b;
res++;
} else {
a = b;
b = c;
}
}
printf("%d\n", res);
}
|
a.cc: In function 'int main()':
a.cc:22:5: error: 'sort' was not declared in this scope; did you mean 'short'?
22 | sort(L1.begin(), L1.end());
| ^~~~
| short
|
s114793547
|
p04021
|
C++
|
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#define Inf 100000000000ll
#define MAXN 100000
#define MAXX 5
#define ll long long
using namespace std;
int A[MAXN+2];
int main() {
int N;
cin>>N;
map<int,int> init_pos;
//srand(time(NULL));
for(int i=0;i<N;i++) {
cin>>A[i];
//A[i]=rand()%1000000000;
init_pos[A[i]]=i;
}
map<int,int> final_pos;
sort(A,A+N);
for(int i=0;i<N;i++) {
final_pos[A[i]]=i;
}
int ct = 0;
for(int i=0;i<N;i++) {
int d = abs(final_pos[A[i]] - init_pos[A[i]]);
d = d % 2;
if (d != 0)
ct++;
}
cout << ct / 2 << endl;
}
|
a.cc: In function 'int main()':
a.cc:30:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
30 | sort(A,A+N);
| ^~~~
| sqrt
|
s547080258
|
p04021
|
C++
|
#include <iostream>
using namespace std;
int main() {
int N;
int a[100000];
int b[100000];
cin >> N;
int t = 0;
for (int j = 0; j < N; ++j) {
cin >> a[j];
b[j] = a[j];
}
sort(a, a + N);
for (int j = 0; j < N; ++j) {
int i = find(a, a + N, b[j]) - a;
if (i % 2 != j % 2) {
t ++;
}
}
cout << t / 2 << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:15:5: error: 'sort' was not declared in this scope; did you mean 'short'?
15 | sort(a, a + N);
| ^~~~
| short
a.cc:17:21: error: no matching function for call to 'find(int [100000], int*, int&)'
17 | int i = find(a, a + N, b[j]) - a;
| ~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:17:21: note: mismatched types 'std::istreambuf_iterator<_CharT>' and 'int*'
17 | int i = find(a, a + N, b[j]) - a;
| ~~~~^~~~~~~~~~~~~~~~
|
s614954320
|
p04021
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
#define ll long long
#define ull unsigned ll
void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(double *x){scanf("%lf",x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}
void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(double x, char c){printf("%.15f",x);mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}
char memarr[17000000]; void *mem = memarr;
#define MD 1000000007
template<class T>
struct fenwick{
int size, memory; T *data;
void malloc(int mem){memory=mem;data=(T*)std::malloc(sizeof(T)*mem);}
void *malloc(int mem, void *workMemory){memory=mem;data=(T*)workMemory;return (void*)(data+mem);}
void free(void){memory=0;free(data);}
void init(int N){size=N;memset(data,0,sizeof(T)*N);}
void add(int k, T val){while(k<size)data[k]+=val,k|=k+1;}
T get(int k){T res=0;while(k>=0)res+=data[k],k=(k&(k+1))-1;return res;}
T range(int a, int b){if(b==-1)b=size-1;return get(b)-get(a-1);}
int kth(T k){int i=0,j=size,c;T v;while(i<j){c=(i+j)/2;v=get(c);if(v<=k)i=c+1;else j=c;}return i==size?-1:i;}
};
template<class T> int coordinateCompress(int n, T arr[], int res[], void *mem){int i,k=0;pair<T,int>*r=(pair<T,int>*)mem;rep(i,n)r[i].first=arr[i],r[i].second=i;sort(r,r+n);if(res!=NULL){rep(i,n){if(i&&r[i].first!=r[i-1].first)k++;res[r[i].second]=k;}}else{rep(i,n){if(i&&r[i].first!=r[i-1].first)k++;arr[r[i].second]=k;}}return k+1;}
template<class T> int coordinateCompress(int n1, T arr1[], int n2, T arr2[], int res1[], int res2[], void *mem){int i,k=0;pair<T,int>*r =(pair<T,int>*)mem;rep(i,n1)r[i].first=arr1[i],r[i].second=i;rep(i,n2)r[n1+i].first=arr2[i],r[n1+i].second=n1+i;sort(r,r+n1+n2);rep(i,n1+n2){if(i&&r[i].first!=r[i-1].first) k++;if(r[i].second<n1){if(res1!=NULL)res1[r[i].second]=k;else arr1[r[i].second]=k;}else{if(res2!=NULL)res2[r[i].second-n1]=k;else arr2[r[i].second-n1]=k;}}return k+1;}
ll inversion(int N, int A[], void *mem){
int i;
int *arr;
fenwick<int> t;
ll res = 0;
arr = (int*)mem;
mem = t.malloc(N, arr+N);
coordinateCompress(N, A, arr, mem);
t.init(N);
for(i=N-1;i>=0;i--){
res += t.get(arr[i]-1);
t.add(arr[i], 1);
}
return res;
}
int N;
int A[100000];
int main(){
int i, j, k;
ll res;
reader(&N);
rep(i,N) reader(A+i);
res = inversion(N, A, mem);
res = (res%3)?1:0
writerLn((int)res);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:80:20: error: expected ';' before 'writerLn'
80 | res = (res%3)?1:0
| ^
| ;
81 | writerLn((int)res);
| ~~~~~~~~
|
s120099776
|
p04021
|
C++
|
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
using namespace std;
namespace fastinput
{
/** Interface */
inline long long readChar();
template <class T = long long> inline T readInt();
template <class T> inline void writeInt(T x, char end = 0);
inline void writeChar(long long x);
inline void writeWord(const char *s);
/** Read */
static const long long buf_size = 16384;
char buf[buf_size];
long long len = 0, pos = 0;
inline long long getChar() {
if (pos == len)
pos = 0, len = fread(buf, 1, buf_size, stdin);
if (pos == len)
return -1;
return buf[pos++];
}
inline long long readChar() {
long long c = getChar();
while (c <= 32)
c = getChar();
return c;
}
template <class T>
inline T readInt() {
long long s = 1, c = readChar();
T x = 0;
if (c == '-')
s = -1, c = getChar();
while ('0' <= c && c <= '9')
x = x * 10 + c - '0', c = getChar();
return s == 1 ? x : -x;
}
/** Write */
static long long write_pos = 0;
static char write_buf[buf_size];
inline void writeChar(long long x) {
if (write_pos == buf_size)
fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
write_buf[write_pos++] = x;
}
inline string readWord()
{
string tmp;
tmp.push_back(readChar());
char c;
while ((c = getChar()) > 32)
tmp.push_back(c);
--pos;
return tmp;
}
template <class T>
inline void writeInt(T x, char end) {
if (x < 0)
writeChar('-'), x = -x;
char s[24];
long long n = 0;
while (x || !n)
s[n++] = '0' + x % 10, x /= 10;
while (n--)
writeChar(s[n]);
if (end)
writeChar(end);
}
inline void writeWord(const char *s) {
while (*s)
writeChar(*s++);
}
struct Flusher {
~Flusher() {
if (write_pos)
fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
}
} flusher;
}
using namespace fastinput;
long long n;
vector <long long> v;
long long mergeSort(long long l, long long r)
{
if (l + 1 == r)
return 0;
long long mid = (l + r) / 2;
vector <long long> larr, rarr;
long long tmp = mergeSort(l, mid) + mergeSort(mid, r);
for (long long j = l; j < mid; ++j)
larr.push_back(v[j]);
for (long long j = mid; j < r; ++j)
rarr.push_back(v[j]);
long long i1 = 0;
long long i2 = 0;
while (i1 != larr.size() || i2 != rarr.size())
{
if (i2 == rarr.size() || (i1 != larr.size() && larr[i1] < rarr[i2]))
{
v[l + i1 + i2] = larr[i1];
tmp += i2;
++i1;
}
else
{
v[l + i1 + i2] = rarr[i2];
++i2;
}
}
return tmp;
}
long long main()
{
n = readInt();
vector <long long> v1, v2;
for (long long i = 0; i < n / 2; ++i)
v2.push_back(i);
for (long long i = n / 2; i < n; ++i)
v1.push_back(i);
//for (long long i = 0; i < n; ++i)
//{
// //long long x = readInt();
//if (i % 2 == 0)
// v1.push_back(x);
//else
// v2.push_back(x);
// }
sort(v1.begin(), v1.end());
reverse(v1.begin(), v1.end());
sort(v2.begin(), v2.end());
reverse(v2.begin(), v2.end());
for (long long i = 0; i < n; ++i)
if (i % 2 == 0)
v.push_back(v1.back()),
v1.pop_back();
else
v.push_back(v2.back()),
v2.pop_back();
cout << mergeSort(0, n) << endl;
return 0;
}
|
cc1plus: error: '::main' must return 'int'
|
s188430442
|
p04021
|
C++
|
#include <iostream>
using namespace std;
struct B {
int v;
bool t;
};
B b[100005];
bool comp(B a1, B a2) {
return a1.v < a2.v;
}
int main() {
int N;
cin >> N;
for(int i = 0; i < N; i++) {
cin >> b[i].v;
b[i].t = i%2;
}
sort(b, b+N, comp);
int ans =0;
for(int i = 0; i < N; i += 2) {
if(b[i].t) {
ans++;
}
}
cout << ans << "\n";
}
|
a.cc: In function 'int main()':
a.cc:23:5: error: 'sort' was not declared in this scope; did you mean 'short'?
23 | sort(b, b+N, comp);
| ^~~~
| short
|
s867551493
|
p04021
|
C++
|
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <ctime>
#include <cstdlib>
#include <bitset>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 101010;
int n,a[N];
vi V;
int main(){
scanf("%d",&n);
rep(i,0,n) scanf("%d",a + i) , V.pb(a[i]);
sort(all(V));
rep(i,0,n) a[i] = lower_bound(all(V),a[i]) - V.begin();
int ans = 0;
rep(i,0,n) ans += (a[i]&1) != (i&1);
ans >>= 1;
printf("%d\n",ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:34:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
34 | sort(all(V));
| ^~~~
| sqrt
|
s890968207
|
p04021
|
C++
|
/**
* Created by abhishek on 8/4/2016.
*/
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int array[] = new int[n + 1];
int temp[] = new int[n + 1];
HashMap<Integer, Integer> map = new HashMap<>();
for (int i = 1; i <= n; i++) {
int a = Integer.parseInt(br.readLine());
array[i] = a;
temp[i] = a;
}
Arrays.sort(temp);
for(int i = 1;i <= n;i++){
int pos = Arrays.binarySearch(temp,array[i]);
map.put(array[i],pos);
}
int cnt = 0;
for (int i = 1; i <= n; i++) {
int pos = map.get(array[i]);
//System.out.println(array[i] + " " + pos + " " + i);
if(pos >= i)continue;
if (((i - pos) & 1) == 1) cnt++;
}
System.out.println((int) Math.ceil(cnt * 1.0 / 2));
}
}
|
a.cc:4:1: error: 'import' does not name a type
4 | import java.util.*;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.io.*;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: expected unqualified-id before 'public'
6 | public class Main {
| ^~~~~~
|
s766334879
|
p04021
|
C++
|
/**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author RiaD
*/
#include <iostream>
#include <fstream>
#include <iostream>
using namespace std;
class Third {
public:
void solve(std::istream& in, std::ostream& out) {
int n;
in >> n;
vector<pair<int, int>> v(n);
for (int i: range(n)) {
in >> v[i].first;
v[i].second = i;
}
sort(v);
int ans = 0;
for (int i = 0; i < n; i += 2) {
if (v[i].second % 2) {
++ans;
}
}
out << ans;
}
};
int main() {
std::ios_base::sync_with_stdio(false);
Third solver;
std::istream& in(std::cin);
std::ostream& out(std::cout);
in.tie(0);
out << std::fixed;
out.precision(20);
solver.solve(in, out);
return 0;
}
|
a.cc: In member function 'void Third::solve(std::istream&, std::ostream&)':
a.cc:19:17: error: 'vector' was not declared in this scope
19 | vector<pair<int, int>> v(n);
| ^~~~~~
a.cc:9:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
8 | #include <fstream>
+++ |+#include <vector>
9 |
a.cc:19:37: error: expected primary-expression before '>' token
19 | vector<pair<int, int>> v(n);
| ^~
a.cc:19:40: error: 'v' was not declared in this scope
19 | vector<pair<int, int>> v(n);
| ^
a.cc:20:29: error: 'range' was not declared in this scope
20 | for (int i: range(n)) {
| ^~~~~
a.cc:26:17: error: 'sort' was not declared in this scope; did you mean 'short'?
26 | sort(v);
| ^~~~
| short
|
s606058122
|
p04022
|
C++
|
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>
#include <unordered_map>
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/
#ifdef LOCAL
#define dbg(x) cout << #x << " : " << x << endl;
#else
#define dbg(x)
#endif
#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }
ostream& operator << (ostream &a, const vector<int> &b) {
for (auto k : b) cout << k << ' ';
return a;
}
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;
const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 100010;
const double EPS = 1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
unordered_map<vpii, int> cnt;
int ld[MX];
vpii pr(const vpii & a) {
vpii res = a;
fi(0, siz(a))
res[i].second = (3 - a[i].second) % 3;
return res;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
memset(ld, -1, sizeof(ld));
vi ps;
ps.reserve(10000);
fi(2, MX) {
if (ld[i] == -1) {
ld[i] = i;
ps.pb(i);
}
fx(x, ps) {
if (x > ld[i] || x * i >= MX)
break;
ld[x * i] = x;
}
}
int n;
cin >> n;
cnt.reserve(n);
cnt.max_load_factor(0.25);
int ans = 0;
fi(0, n) {
vpii fact;
int x;
cin >> x;
fx(d, ps) {
if (d * d > x)
break;
if (x % d == 0) {
fact.pb({d, 0});
while (x % d == 0) {
fact.back().second++;
x /= d;
}
fact.back().second %= 3;
if (!fact.back().second)
fact.ppb;
}
}
if (x != 1) {
if (x <= MX)
fact.pb({x, 1});
else {
++ans;
continue;
}
}
++cnt[fact];
}
fx(x, cnt) {
vpii op = pr(x.first);
//print(x.first);
//print(op);
//dbg(x.second);
if (op == x.first)
++ans;
else {
int sz1 = x.second;
auto it = cnt.find(op);
if (it == cnt.end())
ans += sz1;
else {
int sz2 = it->second;
if (sz1 > sz2)
ans += sz1;
else if (sz1 == sz2 && x.first < op)
ans += sz1;
}
}
//dbg(ans);
}
cout << ans << '\n';
}
|
a.cc:92:26: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::vector<std::pair<long long int, long long int> >; _Tp = long long int; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _Pred = std::equal_to<std::vector<std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<const std::vector<std::pair<long long int, long long int> >, long long int> >]'
92 | unordered_map<vpii, int> cnt;
| ^~~
In file included from /usr/include/c++/14/unordered_map:41,
from a.cc:22:
/usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::vector<std::pair<long long int, long long int> >; _Tp = long long int; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _Pred = std::equal_to<std::vector<std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<const std::vector<std::pair<long long int, long long int> >, long long int> >]' is implicitly deleted because the default definition would be ill-formed:
148 | unordered_map() = default;
| ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::vector<std::pair<long long int, long long int> >; _Value = std::pair<const std::vector<std::pair<long long int, long long int> >, long long int>; _Alloc = std::allocator<std::pair<const std::vector<std::pair<long long int, long long int> >, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::vector<std::pair<long long int, long long int> > >; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from /usr/include/c++/14/bits/unordered_map.h:33:
/usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::vector<std::pair<long long int, long long int> >; _Value = std::pair<const std::vector<std::pair<long long int, long long int> >, long long int>; _Alloc = std::allocator<std::pair<const std::vector<std::pair<long long int, long long int> >, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::vector<std::pair<long long int, long long int> > >; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
539 | _Hashtable() = default;
| ^~~~~~~~~~
/usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::vector<std::pair<long long int, long long int> >; _Value = std::pair<const std::vector<std::pair<long long int, long long int> >, long long int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::vector<std::pair<long long int, long long int> > >; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from /usr/include/c++/14/bits/hashtable.h:35:
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::vector<std::pair<long long int, long long int> >; _Value = std::pair<const std::vector<std::pair<long long int, long long int> >, long long int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::vector<std::pair<long long int, long long int> > >; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
1731 | _Hashtable_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::vector<std::pair<long long int, long long int> >; _Value = std::pair<const std::vector<std::pair<long long int, long long int> >, long long int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]'
/usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::vector<std::pair<long long int, long long int> > >]':
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here
1328 | _Hash_code_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::vector<std::pair<long long int, long long int> > >::hash()'
1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
| ^~~~~
In file included from /usr/include/c++/14/string_view:50,
from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::vector<std::pair<long long int, long long int> > >::hash()' is implicitly deleted because the default definition would be ill-formed:
102 | struct hash : __hash_enum<_Tp>
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::vector<std::pair<long long int, long long int> >, false>::__hash_enum()'
/usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::vector<std::pair<long long int, long long int> >; bool <anonymous> = false]'
83 | __hash_enum(__hash_enum&&);
| ^~~~~~~~~~~
/usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::vector<std::pair<long long int, long long int> >; bool <anonymous> = false]' is private within this context
102 | struct hash : __hash_enum<_Tp>
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here
84 | ~__hash_enum();
| ^
/usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates
1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
| ^~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::vector<std::pair<long long int, long long int> >; _Value = std::pair<const std::vector<std::pair<long long int, long long int> >, long long int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::vector<std::pair<long long int, long long int> > >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed:
1328 | _Hash_code_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::vector<std::pair<long long int, long long int> > >, true>::~_Hashtable_ebo_helper()'
/usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::vector<std::pair<long long int, long long int> > >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed:
1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::vector<std::pair<long long int, long long int> > >::~hash()'
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::vector<std::pair<long long int, long long int> > >::~hash()' is implicitly deleted because the default definition would be ill-formed:
102 | struct hash : __hash_enum<_Tp>
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::vector<std::pair<long long int, long long int> >; bool <anonymous> = false]' is private within this context
/usr/include/c++/1
|
s976623070
|
p04022
|
C++
|
#include <bits/stdc++.h>
#include <omp.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int, int> pii;
typedef pair<string, string> pst;
typedef pair<pii, pii> piii;
typedef vector<piii> vpii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<pii> vpi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef pair<pld, pld> pldd;
typedef vector<pld> vpd;
typedef complex<double> base;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define my_abs(a) (((a) >= 0) ? (a) : -(a))
#define mp(a, b) make_pair(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define MODIK(a) (a >= M ? a - M : a)
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cout << (#x) << " = " << x << endl;
#ifdef ART_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif
const double PI = 2 * acos(0.0);
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";
istream &operator >> (istream &in, pii &a)
{
in >> a.first >> a.second;
return in;
}
ostream &operator << (ostream &out, pii &a)
{
out << a.first << ' ' << a.second;
return out;
}
istream &operator >> (istream &in, pld &a)
{
in >> a.first >> a.second;
return in;
}
ostream &operator << (ostream &out, pld &a)
{
out << a.first << ' ' << a.second;
return out;
}
template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
return out << "{" << a.first << ", " << a.second << "}";
}
template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}
template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) <<
", " << get<2>(a) << ", " << get<3>(a) << "}";
}
template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
out << "[";
fori (i, a.size())
out << a[i] << vector<string>{", ", "] "}[i + 1 == a.size()];
return out;
}
void print(int a, int b, int n, vi h)
{
ofstream cout("output.txt");
cout << SZ(h) << ' ' << a << ' ' << b << '\n';
for (int i = 0; i < SZ(h); ++i) {
cout << h[i] << ' ';
}
cout.close();
exit(0);
}
inline bool break_time(ld time)
{
return clock() > CLOCKS_PER_SEC * time;
}
void bonds()
{
ld price, nkd, kd, year;
int cnt;
cout << "price nkd kd cnt year\n";
cout << endl;
cin >> price >> nkd >> kd >> cnt >> year;
cout << 100 * ((1000 + kd * cnt - price * 10 - nkd) / (price * 10) / year);
}
ld get_rand_ld(ld l, ld r)
{
uniform_real_distribution<double> gen(l, r);
return gen(rng);
}
bool may(int E, ld T)
{
if (E < 0)
return 1;
double eps = get_rand_ld(0, 1);
return eps < exp(-E / T);
}
void smain();
signed main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifdef ART_HOME
freopen("input.txt", "r", stdin);
clock_t start = clock();
#endif
cout << setprecision(2) << fixed;
smain();
#ifdef ART_HOME
cout << "\nTOTAL EXECUTIOn TIME: " << float( clock () - start ) / CLOCKS_PER_SEC << endl;
#endif
}
const int N = 4000 + 10, pw = 17, K = 2e3 + 10, B = 1.1e10, oo = 2e14, M = 1 << 14, LOG = 20;
const int M1 = 1000000093, x1 = 27162;
const int M2 = 1000000087, x2 = 241;
const ld pi = atan2(1, 0) * 2, EPS = 1e-9;
bool prime(int v)
{
for (int d = 2; d * d <= v; ++d)
{
if (v % d == 0)
return 0;
}
return 1;
}
int square(int v)
{
int u = get_square(v);
return u * u == v;
}
int get_square(int v)
{
int c = sqrt(v);
for (int i = max(0LL, c - 5); i <= c + 5; ++i)
if (i * i == v)
return i;
return c;
}
void smain()
{
int n;
cin >> n;
vi kek(n);
for (int i = 0; i < n; ++i)
cin >> kek[i];
vi pr;
for (int d = 2; d * d * d <= 1e10; ++d)
{
if (prime(d))
pr.push_back(d);
}
int ans = 0;
map<pair<map<int, int>, int>, int> flex;
map<int, int> hui;
for (int v : kek)
{
map<int, int> cur;
for (int d : pr)
{
while (v % d == 0)
{
cur[d]++;
v /= d;
}
}
map<int, int> cur2;
for (auto p : cur)
{
p.second %= 3;
if (p.second)
cur2[p.first] = p.second;
}
if (v != 1 && square(v))
hui[get_square(v)] = 1;
if (v == 1 && !SZ(cur2))
ans = 1;
else
flex[mp(cur2, v)]++;
}
map<pair<map<int, int>, int>, int> used;
for (auto p : flex)
{
if (used[p.first])
continue;
map<int, int> cur;
for (auto p1 : p.first.first)
cur[p1.first] = 3 - p1.second;
map<int, int> cur2 = p.first.first;
int v = p.first.second;
if (v == 1)
{
if (flex.count(mp(cur, 1)))
ans += max(p.second, flex[mp(cur, 1)]),
used[mp(cur, 1)] = 1;
else
ans += p.second;
}
else if (square(v))
{
int pww = get_square(v);
if (flex.count(mp(cur, pww)))
ans += max(p.second, flex[mp(cur, pww)]),
used[mp(cur, pww)] = 1;
else
ans += p.second;
}
else if (hui.count(v))
{
if (flex.count(mp(cur, v * v)))
ans += max(p.second, flex[mp(cur, v * v)]),
used[mp(cur, v * v)] = 1;
else
ans += p.second;
}
else
{
ans += p.second;
}
}
cout << ans;
}
|
a.cc: In function 'll square(ll)':
a.cc:205:13: error: 'get_square' was not declared in this scope; did you mean 'square'?
205 | int u = get_square(v);
| ^~~~~~~~~~
| square
|
s045873676
|
p04022
|
C++
|
#include <bits/stdc++.h>
#include <omp.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int, int> pii;
typedef pair<string, string> pst;
typedef pair<pii, pii> piii;
typedef vector<piii> vpii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<pii> vpi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef pair<pld, pld> pldd;
typedef vector<pld> vpd;
typedef complex<double> base;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define my_abs(a) (((a) >= 0) ? (a) : -(a))
#define mp(a, b) make_pair(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define MODIK(a) (a >= M ? a - M : a)
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cout << (#x) << " = " << x << endl;
#ifdef ART_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif
const double PI = 2 * acos(0.0);
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";
istream &operator >> (istream &in, pii &a)
{
in >> a.first >> a.second;
return in;
}
ostream &operator << (ostream &out, pii &a)
{
out << a.first << ' ' << a.second;
return out;
}
istream &operator >> (istream &in, pld &a)
{
in >> a.first >> a.second;
return in;
}
ostream &operator << (ostream &out, pld &a)
{
out << a.first << ' ' << a.second;
return out;
}
template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
return out << "{" << a.first << ", " << a.second << "}";
}
template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}
template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) <<
", " << get<2>(a) << ", " << get<3>(a) << "}";
}
template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
out << "[";
fori (i, a.size())
out << a[i] << vector<string>{", ", "] "}[i + 1 == a.size()];
return out;
}
void print(int a, int b, int n, vi h)
{
ofstream cout("output.txt");
cout << SZ(h) << ' ' << a << ' ' << b << '\n';
for (int i = 0; i < SZ(h); ++i) {
cout << h[i] << ' ';
}
cout.close();
exit(0);
}
inline bool break_time(ld time)
{
return clock() > CLOCKS_PER_SEC * time;
}
void bonds()
{
ld price, nkd, kd, year;
int cnt;
cout << "price nkd kd cnt year\n";
cout << endl;
cin >> price >> nkd >> kd >> cnt >> year;
cout << 100 * ((1000 + kd * cnt - price * 10 - nkd) / (price * 10) / year);
}
ld get_rand_ld(ld l, ld r)
{
uniform_real_distribution<double> gen(l, r);
return gen(rng);
}
bool may(int E, ld T)
{
if (E < 0)
return 1;
double eps = get_rand_ld(0, 1);
return eps < exp(-E / T);
}
void smain();
signed main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifdef ART_HOME
freopen("input.txt", "r", stdin);
clock_t start = clock();
#endif
cout << setprecision(2) << fixed;
smain();
#ifdef ART_HOME
cout << "\nTOTAL EXECUTIOn TIME: " << float( clock () - start ) / CLOCKS_PER_SEC << endl;
#endif
}
const int N = 4000 + 10, pw = 17, K = 2e3 + 10, B = 1.1e10, oo = 2e14, M = 1 << 14, LOG = 20;
const int M1 = 1000000093, x1 = 27162;
const int M2 = 1000000087, x2 = 241;
const ld pi = atan2(1, 0) * 2, EPS = 1e-9;
bool prime(int v)
{
for (int d = 2; d * d <= v; ++d)
{
if (v % d == 0)
return 0;
}
return 1;
}
int square(int v)
{
int l = 0, r = v;
while (r - l > 1)
{
int m = l + r >> 1;
if (m * m < v)
l = m;
else
r = m;
}
return r * r == v;
}
int get_square(int v)
{
int l = 0, r = v;
while (r - l > 1)
{
int m = l + r >> 1;
if (m * m < v)
l = m;
else
r = m;
}
return r;
}
void smain()
{
int n;
cin >> n;
vi kek(n);
for (int i = 0; i < n; ++i)
cin >> kek[i];
vi pr;
for (int d = 2; d * d <= 1e10; ++d)
{
if (prime(d))
pr.push_back(d);
}
int ans = 0;
map<pair<map<int, int>, int>, int> flex;
for (int v : kek) {
map<int, int> cur;
for (int d : pr) {
while (v % d == 0) {
cur[d]++;
v /= d;
}
}
}
return;
map<int, int> cur2;
for (auto p : cur)
{
p.second %= 3;
if (p.second)
cur2[p.first] = p.second;
}
if (v == 1 && !SZ(cur2))
ans = 1;
else
flex[mp(cur2, v)]++;
}
map<pair<map<int, int>, int>, int> used;
for (auto p : flex)
{
if (used[p.first])
continue;
map<int, int> cur;
for (auto p1 : p.first.first)
cur[p1.first] = 3 - p1.second;
map<int, int> cur2 = p.first.first;
int v = p.first.second;
if (v == 1)
{
if (flex.count(mp(cur, 1)))
ans += max(p.second, flex[mp(cur, 1)]),
used[mp(cur, 1)] = 1;
else
ans += p.second;
}
else if (prime(v))
{
if (v > B / v + 10)
ans++;
else if (v * v > B)
ans++;
else
{
if (flex.count(mp(cur, v * v)))
ans += max(p.second, flex[mp(cur, v * v)]),
used[mp(cur, v * v)] = 1;
else
ans += p.second;
}
}
else if (square(v))
{
int pww = get_square(v);
if (flex.count(mp(cur, pww)))
ans += max(p.second, flex[mp(cur, pww)]),
used[mp(cur, pww)] = 1;
else
ans += p.second;
}
else
{
ans++;
}
}
cout << ans;
}
|
a.cc: In function 'void smain()':
a.cc:268:23: error: 'cur' was not declared in this scope; did you mean 'cur2'?
268 | for (auto p : cur)
| ^~~
| cur2
a.cc:275:13: error: 'v' was not declared in this scope
275 | if (v == 1 && !SZ(cur2))
| ^
a.cc: At global scope:
a.cc:283:5: error: expected unqualified-id before 'for'
283 | for (auto p : flex)
| ^~~
a.cc:333:5: error: 'cout' does not name a type
333 | cout << ans;
| ^~~~
a.cc:334:1: error: expected declaration before '}' token
334 | }
| ^
|
s913081445
|
p04022
|
C++
|
#include <bits/stdc++.h>
#include <omp.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int, int> pii;
typedef pair<string, string> pst;
typedef pair<pii, pii> piii;
typedef vector<piii> vpii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<pii> vpi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef pair<pld, pld> pldd;
typedef vector<pld> vpd;
typedef complex<double> base;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define my_abs(a) (((a) >= 0) ? (a) : -(a))
#define mp(a, b) make_pair(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define MODIK(a) (a >= M ? a - M : a)
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cout << (#x) << " = " << x << endl;
#ifdef ART_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif
const double PI = 2 * acos(0.0);
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";
istream &operator >> (istream &in, pii &a)
{
in >> a.first >> a.second;
return in;
}
ostream &operator << (ostream &out, pii &a)
{
out << a.first << ' ' << a.second;
return out;
}
istream &operator >> (istream &in, pld &a)
{
in >> a.first >> a.second;
return in;
}
ostream &operator << (ostream &out, pld &a)
{
out << a.first << ' ' << a.second;
return out;
}
template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
return out << "{" << a.first << ", " << a.second << "}";
}
template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}
template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) <<
", " << get<2>(a) << ", " << get<3>(a) << "}";
}
template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
out << "[";
fori (i, a.size())
out << a[i] << vector<string>{", ", "] "}[i + 1 == a.size()];
return out;
}
void print(int a, int b, int n, vi h)
{
ofstream cout("output.txt");
cout << SZ(h) << ' ' << a << ' ' << b << '\n';
for (int i = 0; i < SZ(h); ++i) {
cout << h[i] << ' ';
}
cout.close();
exit(0);
}
inline bool break_time(ld time)
{
return clock() > CLOCKS_PER_SEC * time;
}
void bonds()
{
ld price, nkd, kd, year;
int cnt;
cout << "price nkd kd cnt year\n";
cout << endl;
cin >> price >> nkd >> kd >> cnt >> year;
cout << 100 * ((1000 + kd * cnt - price * 10 - nkd) / (price * 10) / year);
}
ld get_rand_ld(ld l, ld r)
{
uniform_real_distribution<double> gen(l, r);
return gen(rng);
}
bool may(int E, ld T)
{
if (E < 0)
return 1;
double eps = get_rand_ld(0, 1);
return eps < exp(-E / T);
}
void smain();
signed main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifdef ART_HOME
freopen("input.txt", "r", stdin);
clock_t start = clock();
#endif
cout << setprecision(2) << fixed;
smain();
#ifdef ART_HOME
cout << "\nTOTAL EXECUTIOn TIME: " << float( clock () - start ) / CLOCKS_PER_SEC << endl;
#endif
}
const int N = 4000 + 10, pw = 17, K = 2e3 + 10, B = 1e6, oo = 2e14, M = 1 << 14, LOG = 20;
const int M1 = 1000000093, x1 = 27162;
const int M2 = 1000000087, x2 = 241;
const ld pi = atan2(1, 0) * 2, EPS = 1e-9;
bool prime(int v)
{
for (int d = 2; d * d <= v; ++d)
{
if (v % d == 0)
return 0;
}
return 1;
}
void smain()
{
int n;
cin >> n;
vi kek(n);
for (int i = 0; i < n; ++i)
cin >> kek[i];
vi pr;
for (int d = 2; d * d * d <= 1e10; ++d)
{
if (prime(d))
pr.push_back(d);
}
vi div = pr;
int ans = 0;
map<pair<__int128, __int128>, pii> flex;
__int128 a = 1, b = 1;
flex[mp(a, b)] = mp(1, 1);
return;
for (int v : kek)
{
map<int, int> cur;
for (int d : pr)
{
while (v % d == 0)
{
cur[d]++;
v /= d;
}
}
if (v == 1)
{
ans = 1;
continue;
}
if (v != 1) {
int c = sqrt(v);
for (int i = max(0LL, c - 5); i <= c + 5; ++i) {
if (i * i == v) {
cur[i]++;
cur[i]++;
div.push_back(i);
}
else if (i == c + 5)
cur[v]++;
}
}
map<int, int> cur2;
for (auto &p : cur)
{
p.second %= 3;
if (p.second)
cur2[p.first] = p.second;
}
if (SZ(cur2) == 0)
ans = 1;
else
flex[cur2]++;
}
map<map<int, int>, int> used;
for (auto p : flex) {
if (used.count(p.first))
continue;
map<int, int> cur;
for (auto p1 : p.first)
cur[p1.first] = 3 - p1.second;
if (flex.count(cur))
{
ans += max(p.second, flex[cur]);
used[cur] = 1;
}
else
ans += p.second;
}
cout << ans;
}
|
a.cc: In function 'void smain()':
a.cc:271:17: error: no match for 'operator[]' (operand types are 'std::map<std::pair<__int128, __int128>, std::pair<long long int, long long int> >' and 'std::map<long long int, long long int>')
271 | flex[cur2]++;
| ^
In file included from /usr/include/c++/14/map:63,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<__int128, __int128>; _Tp = std::pair<long long int, long long int>; _Compare = std::less<std::pair<__int128, __int128> >; _Alloc = std::allocator<std::pair<const std::pair<__int128, __int128>, std::pair<long long int, long long int> > >; mapped_type = std::pair<long long int, long long int>; key_type = std::pair<__int128, __int128>]'
504 | operator[](const key_type& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'const std::map<std::pair<__int128, __int128>, std::pair<long long int, long long int> >::key_type&' {aka 'const std::pair<__int128, __int128>&'}
504 | operator[](const key_type& __k)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<__int128, __int128>; _Tp = std::pair<long long int, long long int>; _Compare = std::less<std::pair<__int128, __int128> >; _Alloc = std::allocator<std::pair<const std::pair<__int128, __int128>, std::pair<long long int, long long int> > >; mapped_type = std::pair<long long int, long long int>; key_type = std::pair<__int128, __int128>]'
524 | operator[](key_type&& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'std::map<std::pair<__int128, __int128>, std::pair<long long int, long long int> >::key_type&&' {aka 'std::pair<__int128, __int128>&&'}
524 | operator[](key_type&& __k)
| ~~~~~~~~~~~^~~
a.cc:277:23: error: no matching function for call to 'std::map<std::map<long long int, long long int>, long long int>::count(const std::pair<__int128, __int128>&)'
277 | if (used.count(p.first))
| ~~~~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1270:9: note: candidate: 'template<class _Kt> decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::count(const _Kt&) const [with _Key = std::map<long long int, long long int>; _Tp = long long int; _Compare = std::less<std::map<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::map<long long int, long long int>, long long int> >]'
1270 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
| ^~~~~
/usr/include/c++/14/bits/stl_map.h:1270:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((const std::map<std::map<long long int, long long int>, long long int>*)this)->std::map<std::map<long long int, long long int>, long long int>::_M_t.std::_Rb_tree<std::map<long long int, long long int>, std::pair<const std::map<long long int, long long int>, long long int>, std::_Select1st<std::pair<const std::map<long long int, long long int>, long long int> >, std::less<std::map<long long int, long long int> >, std::allocator<std::pair<const std::map<long long int, long long int>, long long int> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::map<long long int, long long int>, long long int>::count(const _Kt&) const [with _Kt = std::pair<__int128, __int128>]':
a.cc:277:23: required from here
277 | if (used.count(p.first))
| ~~~~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1270:65: error: no matching function for call to 'std::_Rb_tree<std::map<long long int, long long int>, std::pair<const std::map<long long int, long long int>, long long int>, std::_Select1st<std::pair<const std::map<long long int, long long int>, long long int> >, std::less<std::map<long long int, long long int> >, std::allocator<std::pair<const std::map<long long int, long long int>, long long int> > >::_M_count_tr(const std::pair<__int128, __int128>&) const'
1270 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
| ~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/map:62:
/usr/include/c++/14/bits/stl_tree.h:1311:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_count_tr(const _Kt&) const [with _Req = _Kt; _Key = std::map<long long int, long long int>; _Val = std::pair<const std::map<long long int, long long int>, long long int>; _KeyOfValue = std::_Select1st<std::pair<const std::map<long long int, long long int>, long long int> >; _Compare = std::less<std::map<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::map<long long int, long long int>, long long int> >]'
1311 | _M_count_tr(const _Kt& __k) const
| ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1311:9: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/14/string:49,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using std::__has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = std::less<std::map<long long int, long long int> >; _SfinaeType = std::pair<__int128, __int128>]':
/usr/include/c++/14/bits/stl_tree.h:1309:9: required by substitution of 'template<class _Kt> decltype (((const std::map<std::map<long long int, long long int>, long long int>*)this)->std::map<std::map<long long int, long long int>, long long int>::_M_t.std::_Rb_tree<std::map<long long int, long long int>, std::pair<const std::map<long long int, long long int>, long long int>, std::_Select1st<std::pair<const std::map<long long int, long long int>, long long int> >, std::less<std::map<long long int, long long int> >, std::allocator<std::pair<const std::map<long long int, long long int>, long long int> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::map<long long int, long long int>, long long int>::count(const _Kt&) const [with _Kt = std::pair<__int128, __int128>]'
1309 | typename _Req = __has_is_transparent_t<_Compare, _Kt>>
| ^~~~~~~~
a.cc:277:23: required from here
277 | if (used.count(p.first))
| ~~~~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:1427:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::map<long long int, long long int> >, std::pair<__int128, __int128>, void>'
1427 | using __has_is_transparent_t
| ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1264:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::size_type std::map<_Key, _Tp, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::map<long long int, long long int>; _Tp = long long int; _Compare = std::less<std::map<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::map<long long int, long long int>, long long int> >; size_type = long unsigned int; key_type = std::map<long long int, long long int>]'
1264 | count(const key_type& __x) const
| ^~~~~
/usr/include/c++/14/bits/stl_map.h:1264:29: note: no known conversion for argument 1 from 'const std::pair<__int128, __int128>' to 'const std::map<std::map<long long int, long long int>, long long int>::key_type&' {aka 'const std::map<long long int, long long int>&'}
1264 | count(const key_type& __x) const
| ~~~~~~~~~~~~~~~~^~~
a.cc:281:26: error: no matching function for call to 'begin(const std::pair<__int128, __int128>&)'
281 | for (auto p1 : p.first)
| ^~~~~
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
from /usr/include/c++/14/bits/stl_algo.h:59,
from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/initializer_list:88:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(initializer_list<_Tp>)'
88 | begin(initializer_list<_Tp> __ils) noexcept
| ^~~~~
/usr/include/c++/14/initializer_list:88:5: note: template argument deduction/substitution failed:
a.cc:281:26: note: 'std::pair<__int128, __int128>' is not derived from 'std::initializer_list<_Tp>'
281 | for (auto p1 : p.first)
| ^~~~~
In file included from /usr/include/c++/14/string:53:
/usr/include/c++/14/bits/range_access.h:52:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
52 | begin(_Container& __cont) -> decltype(__cont.begin())
| ^~~~~
/usr/include/c++/14/bits/range_access.h:52:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = const std::pair<__int128, __int128>]':
a.cc:281:26: required from here
281 | for (auto p1 : p.first)
| ^~~~~
/usr/include/c++/14/bits/range_access.h:52:50: error: 'const struct std::pair<__int128, __int128>' has no member named 'begin'
52 | begin(_Cont
|
s296564053
|
p04022
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (ll)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
_do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
_s<<"{";
for(It _it=_ita;_it!=_itb;_it++)
{
_s<<(_it==_ita?"":",")<<*_it;
}
_s<<"}";
return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;
ll d[MAXn];
bool isp[MAXn];
vector<ll> prime;
ll mul[MAXn],dv[MAXn];
map<ll,ll> mp1,mp2,vis;
map<ll,ll> pr;
set<ll> st;
void build_prime(){
for (ll i=2;i<MAXn;++i) {
if (!isp[i]) {
prime.eb(i);
st.insert(i * i);
}
for (ll j=0;j<SZ(prime) && prime[j] * i < MAXn;++j) {
isp[prime[j] * i] = true;
if (i % prime[j] == 0) break;
}
}
}
ll cb(ll x){
return x * x * x;
}
ll sq(ll x){
return x * x;
}
int main(){
IOS();
build_prime();
ll n;
cin >> n;
ll ans = 0;
for (ll i=0;i<n;++i) {
cin >> d[i];
for (ll j=0;j<SZ(prime) && prime[j] < 2200;++j) {
ll cur1 = 1, cur2 = 1;
if (d[i] % prime[j] == 0) {
ll tmp = cb(prime[j]);
while (d[i] % tmp == 0) d[i] /= tmp;
ll cnt1 = 1;
while (d[i] % prime[j] == 0) {
d[i] /= prime[j];
cnt1 *= prime[j];
tmp /= prime[j];
}
cur1 *= cnt1, cur2 *= tmp;
}
}
if (d[i] == 1 && cur1 == 1) {
ans = 1;
continue;
}
dv[i] = cur1;
mul[i] = cur2;
debug(d[i],cur1,cur2);
mp1[cur1]++;
}
for (ll i=0;i<n;++i) {
if (st.count(d[i])) {
mul[i] *= (ll)sqrt(d[i]);
mp2[mul[i]]++;
}
else {
mul[i] *= sq(d[i]);
mp2[mul[i]]++;
}
pr[dv[i]] = mul[i];
debug(mul[i]);
}
for (auto i:mp1) {
ll cur = i.X;
debug(cur,i.Y);
if (vis[cur]) continue;
ans += max(mp1[cur],mp2[cur]);
vis[cur] = vis[pr[cur]] = true;
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:99:26: error: 'cur1' was not declared in this scope
99 | if (d[i] == 1 && cur1 == 1) {
| ^~~~
a.cc:103:17: error: 'cur1' was not declared in this scope
103 | dv[i] = cur1;
| ^~~~
a.cc:104:18: error: 'cur2' was not declared in this scope
104 | mul[i] = cur2;
| ^~~~
|
s071054348
|
p04022
|
C++
|
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
vector<LL> primes;
const LL CBRT = 2200;
LL cb[CBRT];
const LL LIM = 1e11+5;
void sieve() {
vector<bool> isp(CBRT, 1);
for (LL i=2; i<CBRT; i++)
if (isp[i]) {
primes.push_back(i);
for (LL j=2*i; j<CBRT; j+=i)
isp[j] = 0;
}
for (LL i=0; i<CBRT; i++) cb[i] = 1LL*i*i*i;
}
pair<LL, LL> process(LL x) {
if (x == 1) return {1, 1};
for (LL p:primes)
while (x%cb[p]==0) x/=cb[p];
LL a = x;
for (LL i=1; i<CBRT; i++)
if (cb[i]%a==0)
return {a, cb[i]/a};
return {a, LIM};
}
const LL N = 1e5+7;
LL a[N], b[N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
sieve();
LL n;
cin>>n;
map<LL, LL> cnt;
map<LL, LL> opp;
for (LL i=1; i<=n; i++) {
LL x;
cin>>x;
auto pr = process(x);
a[i] = pr.first;
b[i] = pr.second;
cnt[a[i]]++;
opp[a[i]] = b[i];
opp[b[i]] = a[i];
}
cnt[LIM] = 0;
LL ans = 0;
for (auto pr: opp) {
LL a = pr.first, b = pr.second;
if (a == LIM) continue;
if (a == b) ans += min(1, cnt[a]+cnt[b]);
else if (a < b) ans += max(cnt[a], cnt[b]);
}
cout<<ans<<endl;
}
|
a.cc: In function 'int main()':
a.cc:70:35: error: no matching function for call to 'min(int, std::map<long long int, long long int>::mapped_type)'
70 | if (a == b) ans += min(1, cnt[a]+cnt[b]);
| ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:70:35: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'std::map<long long int, long long int>::mapped_type' {aka 'long long int'})
70 | if (a == b) ans += min(1, cnt[a]+cnt[b]);
| ~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:70:35: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
70 | if (a == b) ans += min(1, cnt[a]+cnt[b]);
| ~~~^~~~~~~~~~~~~~~~~~
|
s275288665
|
p04022
|
Java
|
import java.util.*;
import java.io.*;
import java.text.*;
class Main{
//SOLUTION BEGIN
void pre() throws Exception{}
void solve(int TC) throws Exception{
int N = ni();
int mx = (int)1e5+2;
boolean[] sieve = new boolean[mx];
int[] list = new int[mx];
long[] sqpr = new long[mx];
int c = 0;
Arrays.fill(sieve, true);
sieve[0] = sieve[1] = false;
sqpr[1] = 1;
for(int p = 2; p < mx; p++) {
sqpr[p] = p*(long)p;
if (sieve[p]) {
if (p < 2200) list[c++] = p;
for (int q = p + p; q < mx; q += p)
sieve[q] = false;
}
}
list = Arrays.copyOf(list, c);
long[] A = new long[N];
long MAX = (long)1e10+2;
TreeMap<Long, Integer> mp = new TreeMap<>();
TreeMap<Long, Long> con = new TreeMap<>();
for(int i = 0; i< N; i++){
A[i] = nl();
long x = A[i];
long norm = 1, conj = 1;
for(int p:list){
int cnt = 0;
while(x%p == 0){x /= p;cnt++;}
cnt %= 3;
if(cnt == 0)continue;
if(cnt == 1){
norm *= p;
conj = mul(conj, p, MAX);
conj = mul(conj, p, MAX);
}else if(cnt == 2){
norm *= p*p;
conj = mul(conj, p, MAX);
}
}
if(x > 1){
int ind = Arrays.binarySearch(sqpr, x);
if(ind == -1{
norm *= x;
conj = mul(conj, x, MAX);
conj = mul(conj, x, MAX);
}else{
norm *= x;
conj = mul(conj, ind, MAX);
}
}
mp.put(norm, mp.getOrDefault(norm, 0)+1);
con.put(norm, conj);
}
int ans = 0;
for(Map.Entry<Long, Integer> e:mp.entrySet()){
long norm = e.getKey();
long conj = con.get(norm);
int c1 = mp.getOrDefault(norm, 0), c2 = mp.getOrDefault(conj, 0);
if(norm == conj){
ans++;
}else if(norm < conj)ans += Math.max(c1, c2);
}
pn(ans);
}
long sq(long x){
long s = (long)Math.sqrt(x);
while (s*s >= x)s--;
while ((s+1)*(s+1) <= x)s++;
if(s*s == x)return s;
return -1;
}
long mul(long x, long y, long MAX){
if(MAX/x < y)return MAX;
return x*y;
}
//SOLUTION END
void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
void exit(boolean b){if(!b)System.exit(0);}
static void dbg(Object... o){System.err.println(Arrays.deepToString(o));}
final long IINF = (long)1e17;
final int INF = (int)1e9+2;
DecimalFormat df = new DecimalFormat("0.00000000000");
double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;
static boolean multipleTC = false, memory = true, fileIO = false;
FastReader in;PrintWriter out;
void run() throws Exception{
long ct = System.currentTimeMillis();
if (fileIO) {
in = new FastReader("");
out = new PrintWriter("");
} else {
in = new FastReader();
out = new PrintWriter(System.out);
}
//Solution Credits: Taranpreet Singh
int T = multipleTC? ni():1;
pre();
for (int t = 1; t <= T; t++) solve(t);
out.flush();
out.close();
System.err.println(System.currentTimeMillis() - ct);
}
public static void main(String[] args) throws Exception{
if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
else new Main().run();
}
int[][] make(int n, int e, int[] from, int[] to, boolean f){
int[][] g = new int[n][];int[]cnt = new int[n];
for(int i = 0; i< e; i++){
cnt[from[i]]++;
if(f)cnt[to[i]]++;
}
for(int i = 0; i< n; i++)g[i] = new int[cnt[i]];
for(int i = 0; i< e; i++){
g[from[i]][--cnt[from[i]]] = to[i];
if(f)g[to[i]][--cnt[to[i]]] = from[i];
}
return g;
}
int[][][] makeS(int n, int e, int[] from, int[] to, boolean f){
int[][][] g = new int[n][][];int[]cnt = new int[n];
for(int i = 0; i< e; i++){
cnt[from[i]]++;
if(f)cnt[to[i]]++;
}
for(int i = 0; i< n; i++)g[i] = new int[cnt[i]][];
for(int i = 0; i< e; i++){
g[from[i]][--cnt[from[i]]] = new int[]{to[i], i, 0};
if(f)g[to[i]][--cnt[to[i]]] = new int[]{from[i], i, 1};
}
return g;
}
int find(int[] set, int u){return set[u] = (set[u] == u?u:find(set, set[u]));}
int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
void p(Object... o){for(Object oo:o)out.print(oo+" ");}
void pn(Object... o){for(int i = 0; i< o.length; i++)out.print(o[i]+(i+1 < o.length?" ":"\n"));}
void pni(Object... o){for(Object oo:o)out.print(oo+" ");out.println();out.flush();}
String n()throws Exception{return in.next();}
String nln()throws Exception{return in.nextLine();}
int ni()throws Exception{return Integer.parseInt(in.next());}
long nl()throws Exception{return Long.parseLong(in.next());}
double nd()throws Exception{return Double.parseDouble(in.next());}
class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br = new BufferedReader(new InputStreamReader(System.in));
}
public FastReader(String s) throws Exception{
br = new BufferedReader(new FileReader(s));
}
String next() throws Exception{
while (st == null || !st.hasMoreElements()){
try{
st = new StringTokenizer(br.readLine());
}catch (IOException e){
throw new Exception(e.toString());
}
}
return st.nextToken();
}
String nextLine() throws Exception{
String str;
try{
str = br.readLine();
}catch (IOException e){
throw new Exception(e.toString());
}
return str;
}
}
}
|
Main.java:52: error: ')' expected
if(ind == -1{
^
1 error
|
s599777680
|
p04022
|
C++
|
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
#pragma GCC optimize(3)
#define ll long long
#define int long long
#define ljc 998244353
using namespace std;
inline ll read(){
ll x=0,f=1;char ch=getchar();
while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
while (isdigit(ch)){x=x*10ll+ch-'0';ch=getchar();}
return x*f;
}
inline ll fast_pow(ll a,ll b,ll p){
ll t=1;a%=p;
while (b){
if (b&1) t=t*a%p;
b>>=1;a=a*a%p;
}
return t;
}
int A[101010][2];
int p[101010],tot,n,a[101010];
bool vis[101010];
map<int,int> cac,rev;
signed main(){
n=read();
for (int i=1;i<=n;i++) a[i]=read();
for (int i=2;i<=100000;i++){
if (!vis[i]) p[++tot]=i;
for (int j=1;j<=tot;j++){
if (1ll*p[j]*i>100000) break;
vis[p[j]*i]=1;
if (i%p[j]==0) break;
}
}
ll _=0;
int all=0,flag=0;
sort(a+1,a+1+n);
for (int i=1;i<=n;i++){
int tmp=a[i];
for (int j=1;p[j]*p[j]<=tmp&&j<=tot;j++,all++){
if (tmp==1) break;
if (all>600000000){
flag=1;break;
}
if (tmp%p[j]==0){
for (;tmp%p[j]==0&&tmp;tmp/=p[j]);
}
}
if (flag==1) break;
}
all=0;
for (int i=1;i<=n;i++){
int tmp=a[i];
for (int j=1;p[j]*p[j]<=tmp&&j<=tot;j++,all++){
if (flag&&all>1000000){
all-=50;break;
}
if (tmp==1) break;
if (tmp%p[j]==0){
int cnt=0;
for (;tmp%p[j]==0&&tmp;tmp/=p[j],cnt++);
cnt%=3;
if (A[i][0]) A[i][0]*=(cnt>0?p[j]:1)*(cnt>1?p[j]:1);
else A[i][0]=(cnt>0?p[j]:0)*(cnt>1?p[j]:1);
cnt=3-cnt;cnt%=3;
if (A[i][1]) A[i][1]*=(cnt>0?p[j]:1)*(cnt>1?p[j]:1);
else A[i][1]=(cnt>0?p[j]:0)*(cnt>1?p[j]:1);
}
}
if (tmp>1&&tmp<=100000){
if (A[i][0]) A[i][0]*=tmp;
else A[i][0]=tmp;
if (A[i][1]) A[i][1]*=tmp*tmp;
else A[i][1]=tmp*tmp;
}
if (tmp>100000){
_++;
}else{
cac[A[i][0]]++;
rev[A[i][0]]=A[i][1];
rev[A[i][1]]=A[i][0];
}
}
for (auto j:cac){
if (j.first&&j.second){
_+=max(j.second,cac[rev[j.first]]);
cac[rev[j.first]]=0;
}
}
cout<<_+(cac[0]>0);
return 0;
}
|
In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:6:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::_Rb_tree_impl<std::less<long long int>, true>::~_Rb_tree_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::_Rb_tree_node<std::pair<const long long int, long long int> >]': target specific option mismatch
182 | ~allocator() _GLIBCXX_NOTHROW { }
| ^
In file included from /usr/include/c++/14/map:62,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:658:16: note: called from here
658 | struct _Rb_tree_impl
| ^~~~~~~~~~~~~
|
s253095297
|
p04022
|
C++
|
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")#include<bits/stdc++.h>
#pragma GCC optimize(3)
#define ll long long
#define int long long
#define ljc 998244353
using namespace std;
inline ll read(){
ll x=0,f=1;char ch=getchar();
while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
while (isdigit(ch)){x=x*10ll+ch-'0';ch=getchar();}
return x*f;
}
inline ll fast_pow(ll a,ll b,ll p){
ll t=1;a%=p;
while (b){
if (b&1) t=t*a%p;
b>>=1;a=a*a%p;
}
return t;
}
int A[101010][2];
int p[101010],tot,n,a[101010];
bool vis[101010];
map<int,int> cac,rev;
signed main(){
n=read();
for (int i=1;i<=n;i++) a[i]=read();
for (int i=2;i<=100000;i++){
if (!vis[i]) p[++tot]=i;
for (int j=1;j<=tot;j++){
if (1ll*p[j]*i>100000) break;
vis[p[j]*i]=1;
if (i%p[j]==0) break;
}
}
ll _=0;
int all=0,flag=0;
sort(a+1,a+1+n);
for (int i=1;i<=n;i++){
int tmp=a[i];
for (int j=1;p[j]*p[j]<=tmp&&j<=tot;j++,all++){
if (tmp==1) break;
if (all>600000000){
flag=1;break;
}
if (tmp%p[j]==0){
for (;tmp%p[j]==0&&tmp;tmp/=p[j]);
}
}
if (flag==1) break;
}
all=0;
for (int i=1;i<=n;i++){
int tmp=a[i];
for (int j=1;p[j]*p[j]<=tmp&&j<=tot;j++,all++){
if (flag&&all>1000000){
all-=50;break;
}
if (tmp==1) break;
if (tmp%p[j]==0){
int cnt=0;
for (;tmp%p[j]==0&&tmp;tmp/=p[j],cnt++);
cnt%=3;
if (A[i][0]) A[i][0]*=(cnt>0?p[j]:1)*(cnt>1?p[j]:1);
else A[i][0]=(cnt>0?p[j]:0)*(cnt>1?p[j]:1);
cnt=3-cnt;cnt%=3;
if (A[i][1]) A[i][1]*=(cnt>0?p[j]:1)*(cnt>1?p[j]:1);
else A[i][1]=(cnt>0?p[j]:0)*(cnt>1?p[j]:1);
}
}
if (tmp>1&&tmp<=100000){
if (A[i][0]) A[i][0]*=tmp;
else A[i][0]=tmp;
if (A[i][1]) A[i][1]*=tmp*tmp;
else A[i][1]=tmp*tmp;
}
if (tmp>100000){
_++;
}else{
cac[A[i][0]]++;
rev[A[i][0]]=A[i][1];
rev[A[i][1]]=A[i][0];
}
}
for (auto j:cac){
if (j.first&&j.second){
_+=max(j.second,cac[rev[j.first]]);
cac[rev[j.first]]=0;
}
}
cout<<_+(cac[0]>0);
return 0;
}
|
a.cc:5:97: error: stray '#' in program
5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")#include<bits/stdc++.h>
| ^
a.cc:5:98: error: '#pragma GCC target' string is badly formed
5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")#include<bits/stdc++.h>
| ^~~~~~~
a.cc:5:98: error: '#pragma GCC target' string is badly formed
a.cc: In function 'long long int read()':
a.cc:12:28: error: 'getchar' was not declared in this scope
12 | ll x=0,f=1;char ch=getchar();
| ^~~~~~~
a.cc:1:1: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | #pragma GCC optimize(3)
a.cc:13:17: error: 'isdigit' was not declared in this scope
13 | while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
| ^~~~~~~
a.cc:14:16: error: 'isdigit' was not declared in this scope
14 | while (isdigit(ch)){x=x*10ll+ch-'0';ch=getchar();}
| ^~~~~~~
a.cc: At global scope:
a.cc:28:1: error: 'map' does not name a type
28 | map<int,int> cac,rev;
| ^~~
a.cc: In function 'int main()':
a.cc:42:9: error: 'sort' was not declared in this scope; did you mean 'short'?
42 | sort(a+1,a+1+n);
| ^~~~
| short
a.cc:84:25: error: 'cac' was not declared in this scope
84 | cac[A[i][0]]++;
| ^~~
a.cc:85:25: error: 'rev' was not declared in this scope
85 | rev[A[i][0]]=A[i][1];
| ^~~
a.cc:89:21: error: 'cac' was not declared in this scope
89 | for (auto j:cac){
| ^~~
a.cc:91:45: error: 'rev' was not declared in this scope
91 | _+=max(j.second,cac[rev[j.first]]);
| ^~~
a.cc:91:28: error: 'max' was not declared in this scope
91 | _+=max(j.second,cac[rev[j.first]]);
| ^~~
a.cc:95:9: error: 'cout' was not declared in this scope
95 | cout<<_+(cac[0]>0);
| ^~~~
a.cc:1:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | #pragma GCC optimize(3)
a.cc:95:18: error: 'cac' was not declared in this scope
95 | cout<<_+(cac[0]>0);
| ^~~
|
s525287330
|
p04022
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define vist fuckitwholefamily
#define int long long
#define MAXN 100005
#define Int int
int n,ans,s[MAXN];
map <int,int> tot;
map <int,bool> vis;
template <typename T> inline void read (T &t){t = 0;char c = getchar();int f = 1;while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}while (c >= '0' && c <= '9'){t = (t << 3) + (t << 1) + c - '0';c = getchar();} t *= f;}
template <typename T,typename ... Args> inline void read (T &t,Args&... args){read (t);read (args...);}
template <typename T> inline void write (T x){if (x < 0){x = -x;putchar ('-');}if (x > 9) write (x / 10);putchar (x % 10 + '0');}
int cnt,prime[MAXN],visit[MAXN];
void Euler (int up){
for (Int i = 2;i <= up;++ i){
if (!visit[i]) prime[++ cnt] = i;
for (Int j = 1;j <= cnt && i * prime[j] <= up;++ j){
visit[i * prime[j]] = 1;
if (i % prime[j] == 0) break;
}
}
}
signed main(){
read (n);Euler (1e5);
for (Int i = 1;i <= n;++ i){
read (s[i]);
for (Int p = 2;p * p * p <= s[i];++ p) while (s[i] % (p * p * p) == 0) s[i] /= p * p * p;
if (s[i] != 1) tot[s[i]] ++;
else ans = 1;
}
for (Int i = 1;i <= n;++ i)
if (vis[s[i]] || s[i] == 1) continue;
else{
int now = s[i],nowto = 1;
for (Int j = 1;j <= cnt && prime[j] * prime[j] <= now;++ j)
if (now % (prime[j] * prime[j]) == 0){
now /= prime[j] * prime[j],nowto *= prime[j];
}
nowto *= now * now;
vis[s[i]] = vis[nowto] = 1,ans += max (tot[s[i]],tot[nowto]);
}
write (ans),putchar ('\n');
return 0;
}
|
a.cc: In function 'void Euler(long long int)':
a.cc:21:22: error: reference to 'visit' is ambiguous
21 | if (!visit[i]) prime[++ cnt] = i;
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:17:21: note: 'long long int visit [100005]'
17 | int cnt,prime[MAXN],visit[MAXN];
| ^~~~~
a.cc:23:25: error: reference to 'visit' is ambiguous
23 | visit[i * prime[j]] = 1;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:17:21: note: 'long long int visit [100005]'
17 | int cnt,prime[MAXN],visit[MAXN];
| ^~~~~
|
s790990655
|
p04022
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MAXN 100005
#define Int int
int n,ans,s[MAXN];
map <int,int> tot;
map <int,bool> vis;
template <typename T> inline void read (T &t){t = 0;char c = getchar();int f = 1;while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}while (c >= '0' && c <= '9'){t = (t << 3) + (t << 1) + c - '0';c = getchar();} t *= f;}
template <typename T,typename ... Args> inline void read (T &t,Args&... args){read (t);read (args...);}
template <typename T> inline void write (T x){if (x < 0){x = -x;putchar ('-');}if (x > 9) write (x / 10);putchar (x % 10 + '0');}
int cnt,prime[MAXN],visit[MAXN];
void Euler (int up){
for (Int i = 2;i <= up;++ i){
if (!visit[i]) prime[++ cnt] = i;
for (Int j = 1;j <= cnt && i * prime[j] <= up;++ j){
visit[i * prime[j]] = 1;
if (i % prime[j] == 0) break;
}
}
}
signed main(){
read (n);Euler (1e5);
for (Int i = 1;i <= n;++ i){
read (s[i]);
for (Int p = 2;p * p * p <= s[i];++ p) while (s[i] % (p * p * p) == 0) s[i] /= p * p * p;
if (s[i] != 1) tot[s[i]] ++;
else ans = 1;
}
for (Int i = 1;i <= n;++ i)
if (vis[s[i]] || s[i] == 1) continue;
else{
int now = s[i],nowto = 1;
for (Int j = 1;j <= cnt && prime[j] * prime[j] <= now;++ j)
if (now % (prime[j] * prime[j]) == 0){
now /= prime[j] * prime[j],nowto *= prime[j];
}
nowto *= now * now;
vis[s[i]] = vis[nowto] = 1,ans += max (tot[s[i]],tot[nowto]);
}
write (ans),putchar ('\n');
return 0;
}
|
a.cc: In function 'void Euler(long long int)':
a.cc:20:22: error: reference to 'visit' is ambiguous
20 | if (!visit[i]) prime[++ cnt] = i;
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:16:21: note: 'long long int visit [100005]'
16 | int cnt,prime[MAXN],visit[MAXN];
| ^~~~~
a.cc:22:25: error: reference to 'visit' is ambiguous
22 | visit[i * prime[j]] = 1;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:16:21: note: 'long long int visit [100005]'
16 | int cnt,prime[MAXN],visit[MAXN];
| ^~~~~
|
s994661969
|
p04022
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define Int register int
#define int long long
#define MAXN 100005
int n,ans,s[MAXN];
map <int,int> tot;
map <int,bool> vis;
template <typename T> inline void read (T &t){t = 0;char c = getchar();int f = 1;while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}while (c >= '0' && c <= '9'){t = (t << 3) + (t << 1) + c - '0';c = getchar();} t *= f;}
template <typename T,typename ... Args> inline void read (T &t,Args&... args){read (t);read (args...);}
template <typename T> inline void write (T x){if (x < 0){x = -x;putchar ('-');}if (x > 9) write (x / 10);putchar (x % 10 + '0');}
int cnt,prime[MAXN],visit[MAXN];
void Euler (int up){
for (Int i = 2;i <= up;++ i){
if (!visit[i]) prime[++ cnt] = i;
for (Int j = 1;j <= cnt && i * prime[j] <= up;++ j){
visit[i * prime[j]] = 1;
if (i % prime[j] == 0) break;
}
}
}
signed main(){
read (n);Euler (1e5);
for (Int i = 1;i <= n;++ i){
read (s[i]);
for (Int p = 2;p * p * p <= s[i];++ p) while (s[i] % (p * p * p) == 0) s[i] /= p * p * p;
if (s[i] != 1) tot[s[i]] ++;
else ans = 1;
}
for (Int i = 1;i <= n;++ i)
if (vis[s[i]] || s[i] == 1) continue;
else{
int now = s[i],nowto = 1;
for (Int j = 1;j <= cnt && prime[j] * prime[j] <= now;++ j)
if (now % (prime[j] * prime[j]) == 0){
now /= prime[j] * prime[j],nowto *= prime[j];
}
nowto *= now * now;
vis[s[i]] = vis[nowto] = 1,ans += max (tot[s[i]],tot[nowto]);
}
write (ans),putchar ('\n');
return 0;
}
|
a.cc: In function 'void Euler(long long int)':
a.cc:19:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
19 | for (Int i = 2;i <= up;++ i){
| ^
a.cc:20:22: error: reference to 'visit' is ambiguous
20 | if (!visit[i]) prime[++ cnt] = i;
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:16:21: note: 'long long int visit [100005]'
16 | int cnt,prime[MAXN],visit[MAXN];
| ^~~~~
a.cc:21:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
21 | for (Int j = 1;j <= cnt && i * prime[j] <= up;++ j){
| ^
a.cc:22:25: error: reference to 'visit' is ambiguous
22 | visit[i * prime[j]] = 1;
| ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
1855 | visit(_Visitor&& __visitor, _Variants&&... __variants)
| ^~~~~
a.cc:16:21: note: 'long long int visit [100005]'
16 | int cnt,prime[MAXN],visit[MAXN];
| ^~~~~
a.cc: In function 'int main()':
a.cc:30:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
30 | for (Int i = 1;i <= n;++ i){
| ^
a.cc:32:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
32 | for (Int p = 2;p * p * p <= s[i];++ p) while (s[i] % (p * p * p) == 0) s[i] /= p * p * p;
| ^
a.cc:36:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
36 | for (Int i = 1;i <= n;++ i)
| ^
a.cc:40:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
40 | for (Int j = 1;j <= cnt && prime[j] * prime[j] <= now;++ j)
| ^
|
s674132849
|
p04022
|
C++
|
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
#include<tr1/unordered_map>
using namespace std;
inline int Isdigit(char c) {
if (c < '0' || c > '9') return 0;
return 1;
}
inline int readint(){
register int x = 0, flag = 1;
register char ch;
while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
return x * flag;
}
inline long long readlong() {
register long long x = 0, flag = 1;
register char ch;
while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
return x * flag;
}
template <class T>
inline void write(T x){
if (x < 0)
putchar('-'), x = -x;
if(x >= 10) write(x / 10);
putchar(x % 10 + '0');
}
template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define ri readint
#define rl readlong
#define ll long long
#define int long long
const int maxn = 2e6 + 30;
const int maxm = 4e6 + 30;
const int asd = 2e8 + 30;
int n;
ll a[maxn], tmp[maxn], point[maxn];
unordered_map<ll, int> mmp;
int head[maxn], cnt, to[asd], du[maxn], net[asd];
inline void add(int x, int y) {
net[++cnt] = head[x]; head[x] = cnt; to[cnt] = y;
}
int tong[maxn], t[maxn];
int dp[maxn][2];
void dfs(int x, int fa) {
dp[x][0] = point[x];
for (int i = head[x]; i; i = net[i]) {
int v = to[i];
if (v == fa) continue;
dfs(v, x);
dp[x][1] += dp[v][0];
dp[x][0] += max(dp[v][0], dp[v][1]);
}
}
signed main() {
n = ri();
for (int i = 1; i <= n; i++) {
a[i] = rl();
}
sort(a + 1, a + 1 + n);
int tot = 0;
for (int i = 1; i <= n; i++) {
if (i == 1 || a[i] != a[i - 1]) {
tmp[++tot] = a[i]; point[tot] = 1;
}
else point[tot] ++;
}
n = tot;
ll Maxx = 0;
tot = 0;
for (int i = 1; i <= n; i++) {
a[i] = tmp[i];
t[i] = a[i];
Maxx = max(Maxx, a[i]);
}
for (int i = 1; i <= n; i++) {
mmp[a[i]] = i;
for (ll j = 1; j * j * j <= Maxx; j++) {
ll pp = j * j * j;
if (pp % a[i] != 0) continue;
if (mmp[pp / a[i]] == 0) continue;
if (mmp[pp / a[i]] == i) point[i] = 1;
else {
add(a[i], pp / a[i]); du[i]++;
}
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
if (du[i] == 0) {
dfs(i, 0);
ans += max(dp[i][0], dp[i][1]);
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int readint()':
a.cc:15:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
15 | register int x = 0, flag = 1;
| ^
a.cc:15:25: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
15 | register int x = 0, flag = 1;
| ^~~~
a.cc:16:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
16 | register char ch;
| ^~
a.cc: In function 'long long int readlong()':
a.cc:23:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
23 | register long long x = 0, flag = 1;
| ^
a.cc:23:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
23 | register long long x = 0, flag = 1;
| ^~~~
a.cc:24:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
24 | register char ch;
| ^~
/tmp/ccHvK6NJ.o: in function `dfs(long long, long long)':
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0xa7): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0xbd): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0xd7): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0xee): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0x103): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0x126): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0x140): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
/tmp/ccHvK6NJ.o: in function `main':
a.cc:(.text+0x35a): relocation truncated to fit: R_X86_64_PC32 against symbol `t' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0x5e3): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/ccHvK6NJ.o
a.cc:(.text+0x5f8): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s858481754
|
p04022
|
C++
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll mk = 100055;
const ll logn = 29;
const ll mod = 1e9 + 7;
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fi first
#define se second
#define pii pair<ll,ll>
#define pq priority_queue
#define UwU uwu
#define mp make_pair
#define Miku best_waifu
#define Miku_dancing god_waving
#define Miku_singing god_shaking
#define a_Miku cho_doi_bot_ngu
vector <ll> Pr;
int d[mk + 5];
unordered_map <ll,int> occurance;
unordered_map <ll,pii> cnt;
vector < pii > Rev;
void Sieve()
{
for(int i = 2; i <= mk; i++) {
if(d[i]) Pr.push_back(i);
for(int j = 0 ; Pr[j] * i <=mk&& j < Pr.size() && Pr[j] <= d[i] ; j++) {
d[i * Pr[j]] = Pr[j];
}
}
}
inline pair<ll,ll> root(ll x)
{
ll val=1,reverse_val=1;
for (auto i: Pr)
{
if(i*i>x) break;
if(x%i==0)
{
int num=0;
while(x%i==0)
{
num++;
x/=i;
}
num%=3;
for(int j = 0 ; j < num ; j++) val *= i;
for(int j = 0 ; j < 3 - num) reverse_val *= i;
}
}
if(x>1)
{
int num = 1;
for(int i = 0 ; i < num; i++) val *= x;
for(int i = 0 ; i < 3 - num ; i++) reverse_val *= x;
}
return mp(val,reverse_val);
}
void solve()
{
Sieve();
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
ll x; cin >> x;
if(cnt.count(x)==0)
{
pair<ll,ll> cur= root(x);
Rev.push_back(cur);
cnt[x]=cur;
}
else
Rev.push_back(cnt[x]);
occurance[Rev.back().first]++;
}
ll ans=0;
if(occurance[1]>=1) ans++;
for (int i = 0; i < n; i++)
{
ll value = Rev[i].first;
int cur_val = occurance[value];
if(cur_val==0) continue;
if(value==1) continue;
ll rever = Rev[i].second;
ans += max(cur_val, occurance[rever]);
occurance[rever]=0;
occurance[value]=0;
/// cout << " Miku huhuhu"
}
cout << ans << endl;
}
int main()
{
solve();
}
|
a.cc: In function 'std::pair<long long int, long long int> root(ll)':
a.cc:61:40: error: expected ';' before ')' token
61 | for(int j = 0 ; j < 3 - num) reverse_val *= i;
| ^
| ;
|
s689067179
|
p04022
|
C++
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll mk = 100055;
const ll logn = 29;
const ll mod = 1e9 + 7;
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fi first
#define se second
#define pii pair<ll,ll>
#define pq priority_queue
#define UwU uwu
#define mp make_pair
#define Miku best_waifu
#define Miku_dancing god_waving
#define Miku_singing god_shaking
#define a_Miku cho_doi_bot_ngu
vector <ll> Pr;
int d[mk + 5];
unordered_map <ll,int> occurance;
unordered_map <ll,pii> cnt;
vector < pii > Rev;
void Sieve()
{
for(int i = 2; i <= mk; i++) {
if(d[i]) Pr.push_back(i);
for(int j = 0 ; Pr[j] * i <=mk&& j < Pr.size() && Pr[j] <= d[i] ; j++) {
d[i * Pr[j]] = Pr[j];
}
}
}
inline pair<ll,ll> root(ll x)
{
ll val=1,reverse_val=1;
for (auto i: Pr)
{
if(i*i>x) break;
if(x%i==0)
{
int num=0;
while(x%i==0)
{
num++;
x/=i;
}
num%=3;
for(int j = 0 ; j < num ; j++) val *= i;
for(int j = 0 ; j < 3 - num) reverse_val *= i;
}
}
if(x>1)
{
num = 1;
for(int i = 0 ; i < num; i++) val *= x;
for(int i = 0 ; i < 3 - num ; i++) reverse_val *= x;
}
return mp(val,reverse_val);
}
void solve()
{
Sieve();
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
ll x; cin >> x;
if(cnt.count(x)==0)
{
pair<ll,ll> cur= root(x);
Rev.push_back(cur);
cnt[x]=cur;
}
else
Rev.push_back(cnt[x]);
occurance[Rev.back().first]++;
}
ll ans=0;
if(occurance[1]>=1) ans++;
for (int i = 0; i < n; i++)
{
ll value = Rev[i].first;
int cur_val = occurance[value];
if(cur_val==0) continue;
if(value==1) continue;
ll rever = Rev[i].second;
ans += max(cur_val, occurance[rever]);
occurance[rever]=0;
occurance[value]=0;
/// cout << " Miku huhuhu"
}
cout << ans << endl;
}
int main()
{
solve();
}
|
a.cc: In function 'std::pair<long long int, long long int> root(ll)':
a.cc:61:40: error: expected ';' before ')' token
61 | for(int j = 0 ; j < 3 - num) reverse_val *= i;
| ^
| ;
a.cc:66:9: error: 'num' was not declared in this scope; did you mean 'enum'?
66 | num = 1;
| ^~~
| enum
|
s003128947
|
p04022
|
C++
|
//khodaya khodet komak kon
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int N = 100000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;
int mark[N], n;
ll a[N];
vector<ll> P, pr[N], ted[N];
map<ll, int>cnt, Com;
int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 2; i < N; i++){
if (!mark[i]){
P.pb(i);
for (int j = 2 * i; j < N; j += i){
mark[j] = 1;
}
}
}
vector<ll> num;
for (int i = 1; i <= n; i++){
ll x = a[i];
for (int j = 0; j < P.size(); j++){
if (x < P[j]) break;
if (x % P[j] == 0){
int res = 0;
while (x % P[j] == 0){
x /= P[j];
res++;
}
pr[i].pb(P[j]);
ted[i].pb(res);
}
}
if (x != 1){
pr[i].pb(x);
ted[i].pb(1);
}
ll res = 1;
ll res2 = 1;
for (int j = 0; j < pr[i].size(); j++){
ted[i][j] %= 3;
if (ted[i][j] == 0) continue;
for (int z = 1; z <= 3 - ted[i][j]; z++) res2 *= pr[i][j];
for (int z = 1; z <= ted[i][j]; z++) res *= pr[i][j];
}
cnt[res]++;
Com[res] = res2;
if (res < res2) num.pb(res);
else if (res2 < res) num.pb(res2);
}
int ans = 0;
sort(all(num));
num.resize(unique(all(num)) - num.begin());
for (auto u:num){
ans += max(cnt[u], cnt[Com[u]]);
}
ans += min(cnt[1], 1ll);
cout << ans;
return 0;
}
|
a.cc: In function 'int32_t main()':
a.cc:77:19: error: no matching function for call to 'min(std::map<long long int, int>::mapped_type&, long long int)'
77 | ans += min(cnt[1], 1ll);
| ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:77:19: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
77 | ans += min(cnt[1], 1ll);
| ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:77:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
77 | ans += min(cnt[1], 1ll);
| ~~~^~~~~~~~~~~~~
|
s552381232
|
p04022
|
C++
|
//khodaya khodet komak kon
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int N = 100000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;
int mark[N], n;
ll a[N];
vector<ll> P, pr[N], ted[N];
map<ll, int>cnt, Com;
int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 2; i < N; i++){
if (!mark[i]){
P.pb(i);
for (int j = 2 * i; j < N; j += i){
mark[j] = 1;
}
}
}
vector<ll> num;
for (int i = 1; i <= n; i++){
int x = a[i];
for (int j = 0; j < P.size(); j++){
if (x < P[j]) break;
if (x % P[j] == 0){
int res = 0;
while (x % P[j] == 0){
x /= P[j];
res++;
}
pr[i].pb(P[j]);
ted[i].pb(res);
}
}
if (x != 1){
pr[i].pb(x);
ted[i].pb(1);
}
// cout << "YES " << a[i] << '\n';
// for (auto u:pr[i]) cout << u << ' ';
// cout << '\n';
// for (auto u:ted[i])cout << u << ' ';
// cout << '\n';
ll res = 1;
ll res2 = 1;
for (int j = 0; j < pr[i].size(); j++){
ted[i][j] %= 3;
if (ted[i][j] == 0) continue;
for (int z = 1; z <= 3 - ted[i][j]; z++) res2 *= pr[i][j];
for (int z = 1; z <= ted[i][j]; z++) res *= pr[i][j];
}
cnt[res]++;
Com[res] = res2;
if (res < res2) num.pb(res);
else if (res2 < res) num.pb(res2);
}
int ans = 0;
sort(all(num));
num.resize(unique(all(num)) - num.begin());
for (auto u:num){
ans += max(cnt[u], cnt[Com[u]]);
}
ans += min(cnt[1], 1);
cout << ans;
return 0;
}
|
a.cc: In function 'int32_t main()':
a.cc:83:19: error: no matching function for call to 'min(std::map<long long int, long long int>::mapped_type&, int)'
83 | ans += min(cnt[1], 1);
| ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:83:19: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
83 | ans += min(cnt[1], 1);
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:83:19: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
83 | ans += min(cnt[1], 1);
| ~~~^~~~~~~~~~~
|
s941401755
|
p04022
|
Java
|
import static java.lang.Math.abs;
import static java.lang.Math.max;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.PrimitiveIterator;
import java.util.TreeMap;
import java.util.function.IntBinaryOperator;
import java.util.function.IntFunction;
import java.util.function.IntPredicate;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;
import lib.math.base.MathUtil;
public class Main {
public static void main(String[] args) {
StringBuilder out = new StringBuilder();
solve(out);
PrintWriter pw = new PrintWriter(System.out);
pw.println(out);
pw.flush();
pw.close();
}
public static void solve(StringBuilder out) {
int[] div = eratosthenesDivisors(100000);
IntArrayList prm = eratosthenes(100000, div);
int n = In.ni();
long[] s = In.nl(n);
boolean cb = false;
HashMap<Long, Integer> hm = new HashMap<>();
HashMap<Long, Integer> rhm = new HashMap<>();
HashSet<Long> rm = new HashSet<>();
for (int i = 0; i < n; i++) {
TreeMap<Long, Integer> m = pollardsRho(s[i], prm);
long h = 0;
for (Entry<Long, Integer> e : m.entrySet()) {
long k = e.getKey();
int v = e.getValue() % 3;
v = v == 2 ? -1 : v;
if (v == 0) rm.add(k);
else {
m.put(k, v);
h = (h * 31 + k) * 31 + v;
}
}
for (long k : rm) m.remove(k);
rm.clear();
if (m.size() > 0) hm.put(h, hm.getOrDefault(h, 0) + 1);
else cb = true;
long rh = 0;
for (Entry<Long, Integer> e : m.entrySet()) {
long k = e.getKey();
int v = -e.getValue();
m.put(k, v);
rh = (rh * 31 + k) * 31 + v;
}
if (m.size() > 0) rhm.put(rh, rhm.getOrDefault(rh, 0) + 1);
}
int a = 0, b = 0;
for (Entry<Long, Integer> e : rhm.entrySet()) {
long rhash = e.getKey();
int rnum = e.getValue();
if (hm.containsKey(rhash)) a += max(rnum, hm.get(rhash));
else b += rnum;
}
out.append(a / 2 + b + (cb ? 1 : 0));
}
/**
* Enumarate primes equal to or less than n.
* @param n
* @return {@code ArrayList} that holds primes.
*/
public static IntArrayList eratosthenes(final int n, final int[] div) {
final IntArrayList result = new IntArrayList();
for (int i = 2; i <= n; i++) if (div[i] == i) result.add(i);
return result;
}
/**
* execute eratosthenes's prime-enumerate algorithm. a[i] holds the greatest
* divisor of i. if a[i] = i, i is a prime number. This arrary enables you to
* prime-factorize in O(log n) time.
* @param n
* @return divisor array.
*/
public static int[] eratosthenesDivisors(final int n) {
final int[] divisors = new int[n + 1];
if (n <= 0) return null;
for (int i = 1; i <= n; i++) {
if ((i & 1) != 0) divisors[i] = i;
else divisors[i] = 2;
}
for (int i = 3; i <= n; i += 2) if (divisors[i] == i) for (long j = (long) i * i; j <= n; j += i << 1) divisors[(int) j] = i;
return divisors;
}
/**
* Caluculate prime-factorization in O(sqrt(n)) time.
* @param n
* @return {@code HashMap} of {prime: index}
*/
public static TreeMap<Long, Integer> primeFactorization(long n, IntArrayList prm) {
final TreeMap<Long, Integer> primes = new TreeMap<>();
for (int p : prm) {
int q = 0;
while (n % p == 0) {n /= p; q++;}
if (q > 0) primes.put((long) p, q);
}
if (n > 1) primes.put(n, 1);
return primes;
}
public static TreeMap<Long, Integer> pollardsRho(long n, IntArrayList prm) {
TreeMap<Long, Integer> pf = new TreeMap<>();
while (n > 1) {
long d = getDivisor(n, 0, prm);
pf.put(d, pf.getOrDefault(d, 0) + 1);
n /= d;
}
return pf;
}
public static long getDivisor(long n, int seed, IntArrayList prm) {
if ((n & 1) == 0) return 2;
if (isPrime(n, prm)) return n;
long x = 2, y = 2, d = 1;
while (d == 1) {
x = f(x, n, seed);
y = f(f(y, n, seed), n, seed);
d = MathUtil.gcd(abs(x - y), n);
}
if (d == n) return getDivisor(n, seed + 1, prm);
return getDivisor(d, seed, prm);
}
public static boolean isPrime(long n, IntArrayList prm) {
if (n == 1) return false;
for (int p : prm) {
if (n != p && n % p == 0) return false;
}
return true;
}
public static int[] seeds = {3, 5, 7, 11, 13, 17};
public static long f(long x, long n, int seed) {return (seeds[seed % 6] * x + seed) % n;}
}
/**
* @author https://atcoder.jp/users/suisen
*/
final class In {
public static final FastScanner fsc = new FastScanner();
public static int ni() {return fsc.nextInt();}
public static int[] ni(final int n) {
final int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = fsc.nextInt();
return a;
}
public static int[] ni(final int n, final IntUnaryOperator f) {
final int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = f.applyAsInt(fsc.nextInt());
return a;
}
public static int[][] ni(final int n, final int m) {
final int[][] a = new int[n][m];
for (int i = 0; i < n; i++) a[i] = ni(m);
return a;
}
public static int[][] ni(final int n, final int m, final IntUnaryOperator f) {
final int[][] a = new int[n][m];
for (int i = 0; i < n; i++) a[i] = ni(m, f);
return a;
}
public static long nl() {return fsc.nextLong();}
public static long[] nl(final int n) {
final long[] a = new long[n];
for (int i = 0; i < n; i++) a[i] = fsc.nextLong();
return a;
}
public static long[] nl(final int n, final LongUnaryOperator f) {
final long[] a = new long[n];
for (int i = 0; i < n; i++) a[i] = f.applyAsLong(fsc.nextLong());
return a;
}
public static long[][] nl(final int n, final int m) {
final long[][] a = new long[n][m];
for (int i = 0; i < n; i++) a[i] = nl(m);
return a;
}
public static long[][] nl(final int n, final int m, final LongUnaryOperator f) {
final long[][] a = new long[n][m];
for (int i = 0; i < n; i++) a[i] = nl(m, f);
return a;
}
public static char[] nc() {return fsc.next().toCharArray();}
public static char[][] nc(final int n) {
final char[][] c = new char[n][];
for (int i = 0; i < n; i++) c[i] = nc();
return c;
}
public static double nd() {return fsc.nextDouble();}
public static double[] nd(final int n) {
final double[] a = new double[n];
for (int i = 0; i < n; i++) a[i] = fsc.nextDouble();
return a;
}
public static double[][] nd(final int n, final int m) {
final double[][] a = new double[n][m];
for (int i = 0; i < n; i++) a[i] = nd(m);
return a;
}
public static String ns() {return fsc.next();}
public static String[] ns(final int n) {
final String[] s = new String[n];
for (int i = 0; i < n; i++) s[i] = fsc.next();
return s;
}
public static boolean[][] grid(final int h, final int w, final char trueCharacter) {
final boolean[][] grid = new boolean[h][w];
for (int i = 0; i < h; i++) {
final char[] s = fsc.next().toCharArray();
for (int j = 0; j < w; j++) grid[i][j] = s[j] == trueCharacter;
}
return grid;
}
}
final class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) return true;
ptr = 0;
try {buflen = in.read(buffer);}
catch (final IOException e) {e.printStackTrace();}
return buflen > 0;
}
private int readByte() {return hasNextByte() ? buffer[ptr++] : -1;}
public boolean hasNext() {
while (hasNextByte() && !(33 <= buffer[ptr] && buffer[ptr] <= 126)) ptr++;
return hasNextByte();
}
public String next() {
if (!hasNext()) throw new NoSuchElementException();
final StringBuilder sb = new StringBuilder();
int b = readByte();
while (33 <= b && b <= 126) {sb.appendCodePoint(b); b = readByte();}
return sb.toString();
}
public long nextLong() {
if (!hasNext()) throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {minus = true; b = readByte();}
if (b < '0' || '9' < b) throw new NumberFormatException();
for (; ; b = readByte()) {
if ('0' <= b && b <= '9') n = n * 10 + b - '0';
else if (b == -1 || !(33 <= b && b <= 126)) return minus ? -n : n;
else throw new NumberFormatException();
}
}
public int nextInt() {return Math.toIntExact(nextLong());}
public double nextDouble() {return Double.parseDouble(next());}
}
/**
* @author https://atcoder.jp/users/suisen
*/
final class IntArrayList implements Iterable<Integer> {
private int[] a;
private int tail = 0;
private static final int DEFAULT_SIZE = 64;
public IntArrayList(final int capacity) {this.a = new int[Math.max(1, capacity)];}
public IntArrayList() {this(DEFAULT_SIZE);}
public void add(final int v) {
if (tail == a.length) grow();
a[tail++] = v;
}
public int removeLast() {return a[tail--];}
public int get(final int i) {
if (i >= tail) throw new IndexOutOfBoundsException("Index " + i + " out of bounds for length " + size());
return a[i];
}
public void set(final int i, final int v) {
if (i >= tail) throw new IndexOutOfBoundsException("Index " + i + " out of bounds for length " + size());
a[i] = v;
}
private void grow() {
final int[] b = new int[a.length << 1];
System.arraycopy(a, 0, b, 0, a.length);
a = b;
}
public int size() {return tail;}
public void reverse(final int begin, final int end) {IntArrays.reverse(a, begin, end);}
public void reverse() {IntArrays.reverse(a, 0, tail);}
public int[] toArray() {
final int[] ret = new int[tail];
System.arraycopy(a, 0, ret, 0, tail);
return ret;
}
public boolean addIf(final int v, final IntPredicate p) {
if (p.test(v)) {add(v); return true;}
return false;
}
public PrimitiveIterator.OfInt iterator() {return new IntArrayListIterator();}
private class IntArrayListIterator implements PrimitiveIterator.OfInt {
private int i = 0;
public boolean hasNext() {return i < tail;}
public int nextInt() {return a[i++];}
}
}
/**
* @author https://atcoder.jp/users/suisen
*
* 1. DESTRUCTIVE methods for int arrays.
* 2. methods that receives arrays and return some results (except for int arrays).
*/
final class IntArrays {
private IntArrays(){}
public static void swap(final int[] a, final int u, final int v) {
final int tmp = a[u]; a[u] = a[v]; a[v] = tmp;
}
public static void reverse(final int[] a, final int begin, final int end) {
for (int i = begin; i < begin + (end - begin) / 2; i++) swap(a, i, begin + end - i - 1);
}
public static void reverse(final int[] a) {reverse(a, 0, a.length);}
public static void sortDescending(final int[] a) {Arrays.sort(a); reverse(a);}
public static int reduce(final int[] a, final IntBinaryOperator op) {
int ret = a[0]; for (int i = 1; i < a.length; i++) ret = op.applyAsInt(ret, a[i]);
return ret;
}
public static void map(final int[] a, final IntUnaryOperator op) {Arrays.setAll(a, i -> op.applyAsInt(a[i]));}
public static int filter(final int[] src, final int[] dst, final IntPredicate p) {
int idx = 0;
for (final int e : src) if (p.test(e)) dst[idx++] = e;
return idx;
}
public static int filterIndex(final int[] dst, final int beginIndex, final int endIndex, final IntPredicate p) {
int idx = 0;
for (int i = beginIndex; i < endIndex; i++) if (p.test(i)) dst[idx++] = i;
return idx;
}
public static int filterIndex(final int dst[], final int endIndex, final IntPredicate p) {
return filterIndex(dst, 0, endIndex, p);
}
public static void accumulate(final int[] a, final IntBinaryOperator op) {
for (int i = 1; i < a.length; i++) a[i] = op.applyAsInt(a[i - 1], a[i]);
}
public static void accumulate(final int[] a) {
for (int i = 1; i < a.length; i++) a[i] += a[i - 1];
}
public static void permute(int[] a, int[] p) {
int n = p.length;
boolean[] settled = new boolean[n];
for (int i = 0; i < n; i++) {
for (int j = i; !settled[j]; j = p[j]) {
if (p[j] == i) {
settled[j] = true;
break;
}
swap(a, j, p[j]);
settled[j] = true;
}
}
}
public static int compare(final int[] a, final int[] b) {
for (int i = 0; i < a.length; i++) {
if (i >= b.length) return -1;
if (a[i] > b[i]) return 1;
if (a[i] < b[i]) return -1;
}
return a.length < b.length ? 1 : 0;
}
public static boolean equals(final int[] a, final int[] b) {return compare(a, b) == 0;}
public static String join(final int[] a, final String sep) {
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < a.length; i++) {
sb.append(a[i]);
if (i < a.length - 1) sb.append(sep);
}
return sb.toString();
}
public static String joinWithPrefixAndSuffix(final int[] a, final IntFunction<String> idxToPre, final IntFunction<String> idxToSuf, final String sep) {
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < a.length; i++) {
sb.append(idxToPre.apply(i)).append(a[i]).append(idxToSuf.apply(i));
if (i < a.length - 1) sb.append(sep);
}
return sb.toString();
}
}
|
Main.java:20: error: package lib.math.base does not exist
import lib.math.base.MathUtil;
^
Main.java:138: error: cannot find symbol
d = MathUtil.gcd(abs(x - y), n);
^
symbol: variable MathUtil
location: class Main
2 errors
|
s889745216
|
p04022
|
Java
|
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;
import lib.util.collections.IntArrayList;
import static java.lang.Math.max;
public class Main {
public static void main(String[] args) {
StringBuilder out = new StringBuilder();
solve(out);
PrintWriter pw = new PrintWriter(System.out);
pw.println(out);
pw.flush();
pw.close();
}
public static void solve(StringBuilder out) {
int[] div = eratosthenesDivisors(100000);
IntArrayList prm = eratosthenes(100000, div);
int n = In.ni();
long[] s = In.nl(n);
int[] rh = new int[n];
int[] h = new int[n];
boolean cb = false;
HashMap<Integer, Integer> hm = new HashMap<>();
HashMap<Integer, Integer> rhm = new HashMap<>();
HashSet<Long> rm = new HashSet<>();
for (int i = 0; i < n; i++) {
HashMap<Long, Integer> m = primeFactorization(s[i], prm);
for (Entry<Long, Integer> e : m.entrySet()) {
long k = e.getKey();
int v = e.getValue() % 3;
if (v == 0) rm.add(k);
else m.put(k, v == 1 ? 1 : -1);
}
for (long k : rm) m.remove(k);
rm.clear();
h[i] = m.hashCode();
if (m.size() > 0) hm.put(h[i], hm.getOrDefault(h[i], 0) + 1);
else cb = true;
for (Entry<Long, Integer> e : m.entrySet()) m.put(e.getKey(), -e.getValue());
rh[i] = m.hashCode();
if (m.size() > 0) rhm.put(rh[i], rhm.getOrDefault(rh[i], 0) + 1);
}
int a = 0;
int b = 0;
for (Entry<Integer, Integer> e : rhm.entrySet()) {
int rhash = e.getKey();
int rnum = e.getValue();
if (hm.containsKey(rhash)) {
a += max(rnum, hm.get(rhash));
} else {
b += rnum;
}
}
out.append(a / 2 + b + (cb ? 1 : 0));
}
/**
* Enumarate primes equal to or less than n.
* @param n
* @return {@code ArrayList} that holds primes.
*/
public static IntArrayList eratosthenes(final int n, final int[] div) {
final IntArrayList result = new IntArrayList();
for (int i = 2; i <= n; i++) if (div[i] == i) result.add(i);
return result;
}
/**
* execute eratosthenes's prime-enumerate algorithm. a[i] holds the greatest
* divisor of i. if a[i] = i, i is a prime number. This arrary enables you to
* prime-factorize in O(log n) time.
* @param n
* @return divisor array.
*/
public static int[] eratosthenesDivisors(final int n) {
final int[] divisors = new int[n + 1];
if (n <= 0) return null;
for (int i = 1; i <= n; i++) {
if ((i & 1) != 0) divisors[i] = i;
else divisors[i] = 2;
}
for (int i = 3; i <= n; i += 2) {
if (divisors[i] == i) for (long j = (long) i * i; j <= n; j += i << 1) divisors[(int) j] = i;
}
return divisors;
}
/**
* Caluculate prime-factorization in O(sqrt(n)) time.
* @param n
* @return {@code HashMap} of {prime: index}
*/
public static HashMap<Long, Integer> primeFactorization(long n, IntArrayList prm) {
final HashMap<Long, Integer> primes = new HashMap<>();
for (int p : prm) {
int q = 0;
while (n % p == 0) {n /= p; q++;}
if (q > 0) primes.put((long) p, q);
}
if (n > 1) primes.put(n, 1);
return primes;
}
}
/**
* @author https://atcoder.jp/users/suisen
*/
final class In {
public static final FastScanner fsc = new FastScanner();
public static int ni() {return fsc.nextInt();}
public static int[] ni(final int n) {
final int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = fsc.nextInt();
return a;
}
public static int[] ni(final int n, final IntUnaryOperator f) {
final int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = f.applyAsInt(fsc.nextInt());
return a;
}
public static int[][] ni(final int n, final int m) {
final int[][] a = new int[n][m];
for (int i = 0; i < n; i++) a[i] = ni(m);
return a;
}
public static int[][] ni(final int n, final int m, final IntUnaryOperator f) {
final int[][] a = new int[n][m];
for (int i = 0; i < n; i++) a[i] = ni(m, f);
return a;
}
public static long nl() {return fsc.nextLong();}
public static long[] nl(final int n) {
final long[] a = new long[n];
for (int i = 0; i < n; i++) a[i] = fsc.nextLong();
return a;
}
public static long[] nl(final int n, final LongUnaryOperator f) {
final long[] a = new long[n];
for (int i = 0; i < n; i++) a[i] = f.applyAsLong(fsc.nextLong());
return a;
}
public static long[][] nl(final int n, final int m) {
final long[][] a = new long[n][m];
for (int i = 0; i < n; i++) a[i] = nl(m);
return a;
}
public static long[][] nl(final int n, final int m, final LongUnaryOperator f) {
final long[][] a = new long[n][m];
for (int i = 0; i < n; i++) a[i] = nl(m, f);
return a;
}
public static char[] nc() {return fsc.next().toCharArray();}
public static char[][] nc(final int n) {
final char[][] c = new char[n][];
for (int i = 0; i < n; i++) c[i] = nc();
return c;
}
public static double nd() {return fsc.nextDouble();}
public static double[] nd(final int n) {
final double[] a = new double[n];
for (int i = 0; i < n; i++) a[i] = fsc.nextDouble();
return a;
}
public static double[][] nd(final int n, final int m) {
final double[][] a = new double[n][m];
for (int i = 0; i < n; i++) a[i] = nd(m);
return a;
}
public static String ns() {return fsc.next();}
public static String[] ns(final int n) {
final String[] s = new String[n];
for (int i = 0; i < n; i++) s[i] = fsc.next();
return s;
}
public static boolean[][] grid(final int h, final int w, final char trueCharacter) {
final boolean[][] grid = new boolean[h][w];
for (int i = 0; i < h; i++) {
final char[] s = fsc.next().toCharArray();
for (int j = 0; j < w; j++) grid[i][j] = s[j] == trueCharacter;
}
return grid;
}
}
final class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) return true;
ptr = 0;
try {buflen = in.read(buffer);}
catch (final IOException e) {e.printStackTrace();}
return buflen > 0;
}
private int readByte() {return hasNextByte() ? buffer[ptr++] : -1;}
public boolean hasNext() {
while (hasNextByte() && !(33 <= buffer[ptr] && buffer[ptr] <= 126)) ptr++;
return hasNextByte();
}
public String next() {
if (!hasNext()) throw new NoSuchElementException();
final StringBuilder sb = new StringBuilder();
int b = readByte();
while (33 <= b && b <= 126) {sb.appendCodePoint(b); b = readByte();}
return sb.toString();
}
public long nextLong() {
if (!hasNext()) throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {minus = true; b = readByte();}
if (b < '0' || '9' < b) throw new NumberFormatException();
for (; ; b = readByte()) {
if ('0' <= b && b <= '9') n = n * 10 + b - '0';
else if (b == -1 || !(33 <= b && b <= 126)) return minus ? -n : n;
else throw new NumberFormatException();
}
}
public int nextInt() {return Math.toIntExact(nextLong());}
public double nextDouble() {return Double.parseDouble(next());}
}
|
Main.java:11: error: package lib.util.collections does not exist
import lib.util.collections.IntArrayList;
^
Main.java:74: error: cannot find symbol
public static IntArrayList eratosthenes(final int n, final int[] div) {
^
symbol: class IntArrayList
location: class Main
Main.java:104: error: cannot find symbol
public static HashMap<Long, Integer> primeFactorization(long n, IntArrayList prm) {
^
symbol: class IntArrayList
location: class Main
Main.java:29: error: cannot find symbol
IntArrayList prm = eratosthenes(100000, div);
^
symbol: class IntArrayList
location: class Main
Main.java:75: error: cannot find symbol
final IntArrayList result = new IntArrayList();
^
symbol: class IntArrayList
location: class Main
Main.java:75: error: cannot find symbol
final IntArrayList result = new IntArrayList();
^
symbol: class IntArrayList
location: class Main
6 errors
|
s079165711
|
p04022
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi sosuu(ll n){ //n以下の素数列挙
vector<bool> b(n-1,true);
for(ll i=2;i<=sqrt(n);i++){
if(!b[i-2])continue;
for(ll j=2;i*j<=n;j++)b[i*j-2]=false;
}
vi res;
rep(i,n-1)if(b[i])res.pb(i+2);
return res;
}
bool is_prime(ll n){
if(n<=1)return false;
REP(i,2,sqrt(n)+1)if(n%i==0)return false;
return true;
}
vi x;
vp bunkai(ll n){
vp res;
if(n<=1)return res;
for(ll i:t){
if(n%i!=0)continue;
ll k=0;
while(n%i==0){
k++;
n/=i;
}
res.eb(i,k);
}
if(n!=1)res.eb(n,1);
return res;
}
int main(){
ll n;cin>>n;
x==sosuu(1000001);
vi v(n);
rep(i,n)cin>>v[i];
vp g;
ll ans=0;
rep(i,n){
vp res;
vp b=bunkai(v[i]);
for(auto x:b)if(x.se%3)res.eb(x.fi,x.se%3);
if(res.size()){
ll s=1;
ll c=0;
if(res[0].se==2)c=2;
for(auto x:res)rep(j,c*3/2+x.se*(1-c))s*=x.fi;
g.eb(s,c/2);
}
else ans=1;
}
n=g.size();
sort(all(g));
int w=0,i=0;
while(w<n){
ll a=0,b=0;
while(w<n){
if(g[w].fi==g[i].fi){
if(g[w].se)b++;
else a++;
w++;
}
else break;
}
i=w;
ans+=max(a,b);
}
out(ans);
}
|
a.cc: In function 'vp bunkai(ll)':
a.cc:71:14: error: 't' was not declared in this scope
71 | for(ll i:t){
| ^
a.cc: In function 'int main()':
a.cc:85:6: warning: ignoring return value of 'bool std::operator==(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = allocator<long long int>]', declared with attribute 'nodiscard' [-Wunused-result]
85 | x==sosuu(1000001);
| ~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:2050:5: note: declared here
2050 | operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
| ^~~~~~~~
|
s371581143
|
p04022
|
C++
|
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#define LL long long
const int maxn = 1e5 + 5;
const int maxP = 1e4;
using namespace std;
LL a[maxn], b[maxn]; int n;
map <LL, int> m;
vector <LL> p;
bool f[maxn];
void install(){
for (int i = 2; i <= maxP; i++){
if (!f[i]) p.push_back(i);
for (int j = 0; j < p.size() && i * p[j] <= maxP; j++){
f[i * p[j]] = 1;
if (i % p[j] == 0) continue;
}
}
}
LL split(LL &x){
LL res1 = 1, res2 = 1;
for (int i = 0; i < p.size(); i++){
if (x % p[i] != 0) continue;
int cnt = 0;
while (x % p[i] == 0) ++cnt, x /= p[i];
cnt %= 3;
if (cnt == 2) res1 = res1 * p[i] * p[i], res2 = res2 * p[i];
else if (cnt == 1) res1 = res1 * p[i], res2 = res2 * p[i] * p[i];
}
if (x != 1){
if ((LL)sqrt(x) * (LL)sqrt(x) == x) res1 *= x, res2 *= (LL)sqrt(x);
else res1 *= x, res2 *= x * x;
}
x = res1;
return res2;
}
int main(){
scanf("%d", &n); install();
// for (int i = 0; i < 20; i++) printf("%d\n", p[i]);
for (int i = 1; i <= n; i++){
scanf("%lld", a + i);
b[i] = split(a[i]);
m[a[i]]++;
} int ans = (m[1] != 0); m[1] = 0;
for (int i = 1; i <= n; i++){
if (m[b[i]] != 0) ans += max(m[a[i]], m[b[i]]), m[a[i]] = 0, m[b[i]] = 0;
else ans += m[a[i]], m[a[i]] = 0;
} printf("%d\n", ans);
return 0;
}
|
a.cc: In function 'long long int split(long long int&)':
a.cc:33:25: error: 'sqrt' was not declared in this scope
33 | if ((LL)sqrt(x) * (LL)sqrt(x) == x) res1 *= x, res2 *= (LL)sqrt(x);
| ^~~~
|
s608980565
|
p04022
|
C++
|
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
if (lhs > rhs) {
lhs = rhs;
return true;
}
return false;
}
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
if (lhs < rhs) {
lhs = rhs;
return true;
}
return false;
}
// [l, r) from l to r
struct frep {
struct itr {
int i;
constexpr itr(int i_): i(i_) { }
constexpr void operator ++ () { ++i; }
constexpr int operator * () const { return i; }
constexpr bool operator != (itr x) const { return i != x.i; }
};
const itr l, r;
constexpr frep(int l_, int r_): l(std::min(l_, r_)), r(r_) {}
constexpr itr begin() const { return l; }
constexpr itr end() const { return r; }
};
// [l, r) from r to l
struct brep {
struct itr {
int i;
constexpr itr(int i_): i(i_) { }
constexpr void operator ++ () { --i; }
constexpr int operator * () const { return i; }
constexpr bool operator != (itr x) const { return i != x.i; }
};
const itr r, l;
constexpr brep(int l_, int r_): r(std::max(l_, r_) - 1), l(l_ - 1) {}
constexpr itr begin() const { return r; }
constexpr itr end() const { return l; }
};
template <class T>
inline T scan() {
T res;
std::cin >> res;
return res;
}
using lint = long long;
int main() {
const int N = scan<int>();
std::unordered_map<lint, int> count;
std::unordered_map<lint, bool> used;
for (int i: frep(0, N)) {
lint x, max;
std::cin >> x;
for (lint t = 1; t * t * t <= x; ++t) {
if (x % (t * t * t) == 0) {
max = t;
}
}
count[x / (max * max * max)]++;
}
int ans = 0;
for (auto p: count) {
if (p.first == 1) {
++ans;
used[p.first] = true;
continue;
}
lint max;
for (lint t = 1; t * t * t < p.first; ++t) {
if (p.first % (t * t) == 0) {
max = t;
}
}
lint nx = p.first / (max * max);
if (nx <= 10000000000ll / (nx * max)) {
lint y = nx * nx * max;
if (count.find(y) != count.end()) {
ans += std::max(p.second, count[y]);
used[p.first] = true;
used[y] = true;
}
}
if (!used[p.first]) {
ans += p.second;
used[p.first] = true;
}
}
std::cout << ans << '\n';
return 0;
}
|
a.cc: In function 'int main()':
a.cc:66:8: error: 'unordered_map' is not a member of 'std'
66 | std::unordered_map<lint, int> count;
| ^~~~~~~~~~~~~
a.cc:6:1: note: 'std::unordered_map' is defined in header '<unordered_map>'; this is probably fixable by adding '#include <unordered_map>'
5 | #include <map>
+++ |+#include <unordered_map>
6 |
a.cc:66:26: error: expected primary-expression before ',' token
66 | std::unordered_map<lint, int> count;
| ^
a.cc:66:28: error: expected primary-expression before 'int'
66 | std::unordered_map<lint, int> count;
| ^~~
a.cc:67:8: error: 'unordered_map' is not a member of 'std'
67 | std::unordered_map<lint, bool> used;
| ^~~~~~~~~~~~~
a.cc:67:8: note: 'std::unordered_map' is defined in header '<unordered_map>'; this is probably fixable by adding '#include <unordered_map>'
a.cc:67:26: error: expected primary-expression before ',' token
67 | std::unordered_map<lint, bool> used;
| ^
a.cc:67:28: error: expected primary-expression before 'bool'
67 | std::unordered_map<lint, bool> used;
| ^~~~
a.cc:76:5: error: 'count' was not declared in this scope; did you mean 'std::count'?
76 | count[x / (max * max * max)]++;
| ^~~~~
| std::count
In file included from /usr/include/c++/14/algorithm:86,
from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: 'std::count' declared here
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
a.cc:79:16: error: 'count' was not declared in this scope; did you mean 'std::count'?
79 | for (auto p: count) {
| ^~~~~
| std::count
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: 'std::count' declared here
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
a.cc:82:7: error: 'used' was not declared in this scope
82 | used[p.first] = true;
| ^~~~
a.cc:96:9: error: 'used' was not declared in this scope
96 | used[p.first] = true;
| ^~~~
a.cc:100:10: error: 'used' was not declared in this scope
100 | if (!used[p.first]) {
| ^~~~
|
s072885781
|
p04022
|
C++
|
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
if(a<b)return b;
else return a;
}
ll lmin(ll a,ll b){
if(a<b)return a;
else return b;
}
ll gcd(ll a,ll b){
if(a<b)swap(a,b);
if(b==0)return a;
if(a%b==0)return b;
return gcd(b,a%b);
}
ll Pow(ll n,ll k){
ll ret=1;
ll now=n;
while(k>0){
if(k&1)ret*=now;
now*=now;
k/=2;
}
return ret;
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);
ll n;cin>>n;
ll s[n];
unordered_map<ll,ll> mp;
vector<pll> vv;
vector<ll> pri;
bool uu[100001];
fill(uu,uu+100001,false);
rep(i,2,100001){
if(uu[i])continue;
pri.push_back(i);
for(ll j=i;j<100001;j+=i)uu[j]=true;
}
rep(i,0,n){
cin>>s[i];
rep(j,0,pri.size()){
ll now=pri[j];
now=now*now*now;
if(now>s[i])break;
while(s[i]%now==0)s[i]/=now;
}
}
unordered_map<ll,ll> hei;
rep(i,0,pri.size()){
hei[pri[i]*pri[i]]=pri[i];
}
ll ans=0;
rep(i,0,n){
ll ns=1;
ll gy=1;
rep(jj,0,pri.size()){
ll j=pri[jj];
if(j*j*j>10000000000)break;
if(s[i]%j==0){
ll sum=0;
while(s[i]%j==0){
s[i]/=j;
sum++;
}
sum%=3;
rep(k,0,sum)ns*=j;
sum=3-sum;
sum%=3;
rep(k,0,sum)gy*=j;
}
}
//cout<<ns<<" "<<s[i]<<endl;
if(s[i]==1){
s[i]=ns;
mp[s[i]]++;
vv.push_back({ns,gy});
continue;
}
if(s[i]<=100000){
ns=s[i]*ns;
gy*=s[i]*s[i];
s[i]=ns;
mp[s[i]]++;
vv.push_back({ns,gy});
continue;
}
if(hei[s[i]]>0){
ns=s[i]*ns;
gy*=hei[s[i]];
s[i]=ns;
mp[s[i]]++;
vv.push_back({ns,gy});
continue;
}
ans++;
// cout<<ns<<" "<<gy<<endl;
}
rep(i,0,vv.size()){
/ cout<<vv[i].first<<" "<<vv[i].second<<endl;
}
unordered_map<ll,bool> used;
rep(i,0,vv.size()){
pll p=vv[i];
if(used[p.first])continue;
if(p.first==1){
ans++;
used[1]=true;
}
else{
ans+=max(mp[p.first],mp[p.second]);
used[p.first]=true;
used[p.second]=true;
}
}
cout<<ans<<endl;
}
|
a.cc: In function 'int main()':
a.cc:125:8: error: expected primary-expression before '/' token
125 | / cout<<vv[i].first<<" "<<vv[i].second<<endl;
| ^
|
s382519942
|
p04022
|
C++
|
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define BITF(n, i) (((n) >> i) & 1)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= x; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define REPZ(i, x) for (int i = 0; i <= x; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
using namespace std;
#define PRINTARR(x, y) \
cerr << #x << "=\n"; \
for (auto itr = x; itr != y; itr++) cerr << *itr << " "; \
cerr << endl;
#define PRINTARR2(x, i0, i1) \
cerr << #x << "=\n"; \
for (int ii0 = 0; ii0 < i0; ii0++) { \
for (int ii1 = 0; ii1 < i1; ii1++) cerr << x[ii0][ii1] << " "; \
cerr << endl; \
}
#define DUMPOUT cerr
// vector
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
for (T &x : vec) is >> x;
return is;
}
// pair
template <typename T, typename U> ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
os << "(" << pair_var.first << ", " << pair_var.second << ")";
return os;
}
// vector
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
os << "{";
REP(i, (int)vec.size())
os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
os << "}";
return os;
}
// map
template <typename T, typename U> ostream &operator<<(ostream &os, map<T, U> &map_var) {
os << "{";
FORA(itr, map_var) {
os << *itr;
itr++;
if (itr != map_var.end()) os << ", ";
itr--;
}
os << "}";
return os;
}
// set
template <typename T> ostream &operator<<(ostream &os, set<T> &set_var) {
os << "{";
FORA(itr, set_var) {
os << *itr;
itr++;
if (itr != set_var.end()) os << ", ";
itr--;
}
os << "}";
return os;
}
void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) {
DUMPOUT << head;
if (sizeof...(Tail) > 0) DUMPOUT << ", ";
dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define DUMP(...) \
DUMPOUT << " " << string(#__VA_ARGS__) << ": " \
<< "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
<< " ", \
dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define DUMP(...)
#endif
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
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;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
#define MAXQ 2500
bool isPrime[(MAXQ + 1)];
int pList[(MAXQ + 1)];
int sizeP;
int pairV(int x) {
int val = 1;
for (int i = 0; i < sizeP; i++) {
int cnt = 0;
int primeV = pList[i];
while (1) {
if (x % primeV == 0) {
x /= primeV;
cnt++;
} else {
break;
}
}
if (cnt == 1)
val *= pList[i] * pList[i];
else if (cnt == 2)
val *= pList[i];
if (x == 1) break;
}
int sqX = sqrt(x);
if (sqX * sqX == x)
val *= sqX;
else
val *= x * x;
return val;
}
signed main() {
cin.tie(0), ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
int N;
cin >> N;
vec<int> s(N);
REP(i, N) cin >> s[i];
int cnt = 0;
fill(isPrime, isPrime + MAXQ + 1, true);
isPrime[0] = isPrime[1] = false;
for (int i = 2; i <= MAXQ; ++i) {
if (isPrime[i]) {
pList[cnt++] = i;
for (int j = i * 1LL * i; j <= MAXQ; j += i) {
isPrime[j] = false;
}
}
}
// DUMP(count(ALL(isPrime), true));
map<int, int> ma;
sizeP = pList.size();
REP(i, N) {
int val = s[i];
int index = 0;
while (val != 1 && index < sizeP) {
int val2 = pow(pList[index], 3);
if (val % val2 == 0) {
val /= val2;
} else {
index++;
}
}
ma[val]++;
}
int ans = 0;
FORA(e, ma) {
int v0 = e.fst;
if (v0 == 1) {
ans++;
continue;
}
int v1 = pairV(v0);
ans += max(ma[v0], ma[v1]);
ma[v0] = ma[v1] = 0;
}
print(ans);
}
|
a.cc: In function 'int main()':
a.cc:166:17: error: request for member 'size' in 'pList', which is of non-class type 'long long int [2501]'
166 | sizeP = pList.size();
| ^~~~
|
s023922743
|
p04022
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
vector< int > prime_table(int n) {
vector< bool > prime(n + 1, true);
vi res;
if(n >= 0) prime[0] = false;
if(n >= 1) prime[1] = false;
for(int i = 2; i * i <= n; i++) {
if(!prime[i]) continue;
for(int j = i + i; j <= n; j += i) {
prime[j] = false;
}
}
rep(i,n+1){
if(prime[i]) res.PB(i);
}
return res;
}
bool isSquare(int n){
ll l=0,r=n+1;
while(r-l>1){
ll m=(r+l)/2;
if(m*m>n) r=m;
else l=m;
}
return (l*l==n);
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout<<fixed<<setprecision(20);
int n;
map<int,int> mp;
vi prime=prime_table(2500);
vi a,b;
cin>>n;
rep(i,n){
int s;
cin>>s;
int t=1,u=1;
for(int p:prime){
int c=0;
while(s%p==0){
c++;
s/=p;
}
c%=3;
if(c==0) continue;
if(c==1){
t*=p;
u*=p*p;
}
else{
t*=p*p;
u*=p;
}
}
if(is_squre(s)){
t*=s;
u*=sqrt(s);
}else{
t*=s;
u*=s*s;
}
//cout<<t<<' '<<u<<endl;
a.PB(t);
b.PB(u);
mp[t]++;
}
int ans=0;
rep(i,n){
if(a[i]==1) continue;
//cout<<a[i]<<' '<<b[i]<<endl;
ans+=max(mp[a[i]],mp[b[i]]);
//cout<<ans<<endl;
mp[a[i]]=0;
mp[b[i]]=0;
}
cout<<ans+!!mp[1]<<endl;
}
|
a.cc: In function 'int main()':
a.cc:100:8: error: 'is_squre' was not declared in this scope
100 | if(is_squre(s)){
| ^~~~~~~~
|
s589795617
|
p04022
|
C++
|
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
using namespace std;
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define ll long long
const long long INF = 1LL << 60;
typedef vector<ll> Array;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
Array prime;
Array isPrime(101010, 1);
isPrime[0]=isPrime[1]=0;
map<ll, int> pSqrt;
REP(i, 101010) {
if (isPrime[i] == 1){
prime.push_back(i);
for (int j = i * 2; j < s; j += i)isPrime[j] = 0;
pSqrt[i * i] = i;
}
}
ll n;
cin>>n;
map<ll, int> mp;
Array b(n, 1);
Array p(n, 1);
REP(i, n) {
ll s;
cin >> s;
REP(j, prime.size()) {
if (s < prime[j] * prime[j] * prime[j])break;
ll cnt = 0;
if(s%prime[j])continue;
while (true) {
if (s % prime[j] == 0) {
cnt++;
s /= prime[j];
}
else {
break;
}
}
cnt %= 3;
REP(k, cnt)b[i] *= prime[j];
if (cnt != 0)REP(k, 3 - cnt)p[i] *= prime[j];
}
if (pSqrt[s]) {
b[i] *= s;
p[i] *= pSqrt[s];
}
else {
b[i] *= s;
p[i] *= s * s;
}
mp[b[i]]++;
}
int ans=0;
ans += !!mp[1];
REP(i, n) {
if (b[i]==1)continue;
if (mp[b[i]]>mp[p[i]])ans++;
else if (mp[b[i]] == mp[p[i]] && b[i] > p[i])ans++;
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:36:49: error: 's' was not declared in this scope
36 | for (int j = i * 2; j < s; j += i)isPrime[j] = 0;
| ^
|
s005867986
|
p04022
|
C++
|
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
long long p = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)
#define upper(h,val) upper_bound(h.begin(),h.end(),val)
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
if (n == 0) { return 1; }
int x = rui(a, n / 2);
x *= x; x %= p;
if (n % 2 == 1) { x *= a; x %= p; }
return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
inv_kai = kai;
rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
int a = kai[n] * inv_kai[r]; a %= p;
a *= inv_kai[n - r]; a %= p;
return a;
}
vel pa;
int root(int x) {
if (pa[x] == -1) { return x; }
int ans = root(pa[x]); pa[x] = ans;
return ans;
}
void marge(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {pa[x] = y;}
}
#define end_s(a) cout <<a<<endl;return 0
int reve(int n,vel &p) {
int a = 1, b = 1;
for (int i = 0; p[i] * p[i] * p[i] <= n; i++) {
if (n%p[i] == 0) {
n /= p[i];
if (n%p[i] == 0) { b *= p[i]; n /= p[i]; }
else { a *= p[i]; }
}
}
if (n != 1) {
int m = sqrt(n);
rep(i, 3) {
if ((m - 1 + i)*(m - 1 + i) == n) { b *= (m-1+i); n = 1; }
}
}
a *= n;
if (a > 1000000) { return -1; }
return a * a*b;
}
signed main(){
int n; cin >> n;
vel s(n);
rep(i, n) {
cin >> s[i];
for (int j = 2; j*j*j <= s[i]; j++) {
while (s[i] % (j*j*j) == 0) {
s[i] /= (j*j*j);
}
}
}
sor(s);
vel t(1, s[0]);
rep(i, n - 1) {
if (s[i + 1] != s[i]) { t.push_back(s[i+1]); }
}
int sz = t.size();
vel co(sz);
rep(i, sz) {
co[i] = upper(s, t[i]) - lower(s, t[i]);
}
vel pr;
for (int i = 2; i <= 3000; i++) {
bool fl = true;
for (int j = 2; j*j <= i; j++) {
if (i%j == 0) { fl = false; }
}
if (fl) { pr.push_back(i); }
}
int ans = n;
if (t[0] == 1) { ans -= (co[0] - 1); }
rep(i, sz) {
if (t[i] != 1) {
int re1 = reve(t[i],pr);
int ind = lower(t, re1)-t.begin();
if (i<ind &&ind < sz) {
if (re1 == t[ind]) {
ans -= min(co[i], co[ind]);
}
}
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'long long int reve(long long int, std::vector<long long int>&)':
a.cc:74:25: error: 'sqrt' was not declared in this scope
74 | int m = sqrt(n);
| ^~~~
|
s012293464
|
p04022
|
C++
|
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
long long p = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)
#define upper(h,val) upper_bound(h.begin(),h.end(),val)
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
if (n == 0) { return 1; }
int x = rui(a, n / 2);
x *= x; x %= p;
if (n % 2 == 1) { x *= a; x %= p; }
return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
inv_kai = kai;
rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
int a = kai[n] * inv_kai[r]; a %= p;
a *= inv_kai[n - r]; a %= p;
return a;
}
vel pa;
int root(int x) {
if (pa[x] == -1) { return x; }
int ans = root(pa[x]); pa[x] = ans;
return ans;
}
void marge(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {pa[x] = y;}
}
#define end_s(a) cout <<a<<endl;return 0
int reve(int n,vel &p) {
int a = 1, b = 1;
for (int i = 0; p[i] * p[i] * p[i] <= n; i++) {
if (n%p[i] == 0) {
n /= p[i];
if (n%p[i] == 0) { b *= p[i]; }
else { a *= p[i]; }
}
}
if (n != 1) {
int m = sqrt(n);
rep(i, 3) {
if ((m - 1 + i)*(m - 1 + i) == n) { b *= n; n = 1; }
}
}
a *= n;
if (a > 1000000) { return -1; }
return a * a*b;
}
signed main(){
int n; cin >> n;
vel s(n);
rep(i, n) {
cin >> s[i];
for (int j = 2; j*j*j <= s[i]; j++) {
while (s[i] % (j*j*j) == 0) {
s[i] /= (j*j*j);
}
}
}
sor(s);
vel t(1, s[0]);
rep(i, n - 1) {
if (s[i + 1] != s[i]) { t.push_back(s[i+1]); }
}
int sz = t.size();
vel co(sz);
rep(i, sz) {
co[i] = upper(s, t[i]) - lower(s, t[i]);
}
vel pr;
for (int i = 2; i <= 3000; i++) {
bool fl = true;
for (int j = 2; j*j <= i; j++) {
if (i%j == 0) { fl = false; }
}
if (fl) { pr.push_back(i); }
}
int ans = n;
if (t[0] == 1) { ans -= (co[0] - 1); }
rep(i, sz) {
if (t[i] != 1) {
int re1 = reve(t[i],pr);
int ind = lower(t, re1)-t.begin();
if (i<ind &&ind < sz) {
if (re1 == t[ind]) {
ans -= min(co[i], co[ind]);
}
}
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'long long int reve(long long int, std::vector<long long int>&)':
a.cc:74:25: error: 'sqrt' was not declared in this scope
74 | int m = sqrt(n);
| ^~~~
|
s568192034
|
p04022
|
C++
|
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
long long p = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)
#define upper(h,val) upper_bound(h.begin(),h.end(),val)
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
if (n == 0) { return 1; }
int x = rui(a, n / 2);
x *= x; x %= p;
if (n % 2 == 1) { x *= a; x %= p; }
return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
inv_kai = kai;
rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
int a = kai[n] * inv_kai[r]; a %= p;
a *= inv_kai[n - r]; a %= p;
return a;
}
vel pa;
int root(int x) {
if (pa[x] == -1) { return x; }
int ans = root(pa[x]); pa[x] = ans;
return ans;
}
void marge(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {pa[x] = y;}
}
#define end_s(a) cout <<a<<endl;return 0
int reve(int n,vel &p) {
int a = 1, b = 1;
for (int i = 0; p[i] * p[i] * p[i] <= n; i++) {
if (n%p[i] == 0) {
n /= p[i];
if (n%p[i] == 0) { b *= p[i]; }
else { a *= p[i]; }
}
}
if (n != 1) {
double qn=n;
int m = sqrt(qn);
rep(i, 3) {
if ((m - 1 + i)*(m - 1 + i) == n) { b *= n; n = 1; }
}
}
a *= n;
return a * a*b;
}
signed main(){
int n; cin >> n;
vel s(n);
rep(i, n) {
cin >> s[i];
for (int j = 2; j*j*j <= s[i]; j++) {
while (s[i] % (j*j*j) == 0) {
s[i] /= (j*j*j);
}
}
}
sor(s);
vel t(1, s[0]);
rep(i, n - 1) {
if (s[i + 1] != s[i]) { t.push_back(s[i+1]); }
}
int sz = t.size();
vel co(sz);
rep(i, sz) {
co[i] = upper(s, t[i]) - lower(s, t[i]);
}
vel pr;
for (int i = 2; i <= 3000; i++) {
bool fl = true;
for (int j = 2; j*j <= i; j++) {
if (i%j == 0) { fl = false; }
}
if (fl) { pr.push_back(i); }
}
int ans = n;
if (t[0] == 1) { ans -= (co[0] - 1); }
rep(i, sz) {
if (t[i] != 1) {
int re1 = reve(t[i],pr);
int ind = lower(t, re1)-t.begin();
if (ind < sz) {
if (t[i] < re1 && re1 == t[ind]) {
ans -= min(co[i], co[ind]);
}
}
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'long long int reve(long long int, std::vector<long long int>&)':
a.cc:75:25: error: 'sqrt' was not declared in this scope
75 | int m = sqrt(qn);
| ^~~~
|
s416827501
|
p04022
|
C++
|
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
long long p = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)
#define upper(h,val) upper_bound(h.begin(),h.end(),val)
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
if (n == 0) { return 1; }
int x = rui(a, n / 2);
x *= x; x %= p;
if (n % 2 == 1) { x *= a; x %= p; }
return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
inv_kai = kai;
rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
int a = kai[n] * inv_kai[r]; a %= p;
a *= inv_kai[n - r]; a %= p;
return a;
}
vel pa;
int root(int x) {
if (pa[x] == -1) { return x; }
int ans = root(pa[x]); pa[x] = ans;
return ans;
}
void marge(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {pa[x] = y;}
}
#define end_s(a) cout <<a<<endl;return 0
int reve(int n,vel &p) {
int a = 1, b = 1;
for (int i = 0; p[i] * p[i] * p[i] <= n; i++) {
if (n%p[i] == 0) {
n /= p[i];
if (n%p[i] == 0) { b *= p[i]; }
else { a *= p[i]; }
}
}
if (n != 1) {
int m = sqrt(n);
rep(i, 3) {
if ((m - 1 + i)*(m - 1 + i) == n) { b *= n; n = 1; }
}
}
a *= n;
return a * a*b;
}
signed main(){
int n; cin >> n;
vel s(n);
rep(i, n) {
cin >> s[i];
for (int j = 2; j*j*j <= s[i]; j++) {
while (s[i] % (j*j*j) == 0) {
s[i] /= (j*j*j);
}
}
}
sor(s);
vel t(1, s[0]);
rep(i, n - 1) {
if (s[i + 1] != s[i]) { t.push_back(s[i+1]); }
}
int sz = t.size();
vel co(sz);
rep(i, sz) {
co[i] = upper(s, t[i]) - lower(s, t[i]);
}
vel pr;
for (int i = 2; i <= 3000; i++) {
bool fl = true;
for (int j = 2; j*j <= i; j++) {
if (i%j == 0) { fl = false; }
}
if (fl) { pr.push_back(i); }
}
int ans = n;
if (t[0] == 1) { ans -= (co[0] - 1); }
rep(i, sz) {
if (t[i] != 1) {
int re1 = reve(t[i],pr);
int ind = lower(t, re1)-t.begin();
if (ind < sz) {
if (t[i] < re1 && re1 == t[ind]) {
ans -= min(co[i], co[ind]);
}
}
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'long long int reve(long long int, std::vector<long long int>&)':
a.cc:74:25: error: 'sqrt' was not declared in this scope
74 | int m = sqrt(n);
| ^~~~
|
s654794465
|
p04022
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 998244353;
const long long inf = 1ll << 61;
const double eps = 0.000000000001;
const long long A = 1000000000;
typedef pair<int, int> P;
typedef pair<P, int>PP;
struct edge { int to; int cost; };
int s[100005];
map<int, int>M,pa;
int modpow( int x, int k, int m ){
int res = 1;
while( k ){
if( k & 1 ){
res = res * x % m;
}
k /= 2;
x = x * x % m;
}
return res;
}
int gcd(int a,int b){
if(!b)return a;return gcd(b,a%b);
}
struct Miller{
const int v[3]={2,7,61};
bool check(int n){
if(n<2)return false;
int d=n-1;
int s=0;
while(d%2){
d/=2;s++;
}
for(int a:v){
if(a==n)return true;
if(modpow(a,d,n)!=1){
bool ok=rue;
rep(r,s){
if(modpow(a,d*(1ll<<r),n)==n-1){
ok=false;break;
}
}
if(ok)return false;
}
}
return true;
}
};
struct Rho{
mt19937 mt;
Miller miller;
int c;
Rho(){
mt.seed(clock());
}
inline int f(int x,int n){
return (x*x+c)%n;
}
int check(int n){
if(n==4)return 2;
c=mt()%n;
int x=mt()%n;
int y=x;
int d=1;
while(d==1){
x=f(x,n);
y=f(f(y,n),n);
d=gcd(abs(x-y),n);
}
if(d==n)return -1;
return d;
}
vector<int>factor(int n){
if(n<=1)return {};
if(miller.check(n))return {n};
int res=-1;
while(res==-1){
res=check(n);
}
vector<int>fa=factor(res);
vector<int>fb=factor(n/res);
fa.insert(fa.end(),fb.begin(),fb.end());
return fa;
}
};
Rho rho;
signed main() {
int n; cin >> n;
rep(i,n)cin >> s[i];
rep(i, n) {//n*2300
for (long long j = 2; j*j*j <= s[i]; j++) {
int x = j*j*j;
while (s[i] % x == 0)s[i] /= x;
}
M[s[i]]++;
}
for(auto itr1=M.begin();itr1!=M.end();itr1++) {
int S = itr1->first;
map<int, int>M1, M2;
int cnt;
for (int j = 2; j*j <= S; j++) {
cnt = 3;
while (S % j == 0) {
M1[j]++;
S /= j;
cnt--;
}
if(cnt!=3)M2[j] = cnt;
}
if (S != 1) {
M1[S]++;
M2[S] = 2;
}
int now = 1;
for (auto itr = M2.begin(); itr != M2.end(); itr++) {
int t = itr->first, k = itr->second;
if (k == 2)t = t*t;
double keta = log10(now) + log10(t);
if (keta >= 18.5) {
now = -1;
break;
}
now *= t;
}
pa[itr1->first] = now;
// cout << now << endl;
}
int ans = 0;
for (auto itr = M.begin(); itr != M.end(); itr++) {
int x = itr->first;
int y = itr->second;
if (x == 1)ans += min(1ll,y);
else if (y == 0)continue;
else if (pa[x] == 0||pa[x]==-1)ans += y;
else if (pa[x] == -3)continue;
else {
int pl = M[pa[x]];
ans += max(y, pl);
pa[pa[x]] = -3;
pa[x] = -3;
}
}
cout << ans << endl;
}
|
a.cc: In member function 'bool Miller::check(long long int)':
a.cc:42:25: error: 'rue' was not declared in this scope
42 | bool ok=rue;
| ^~~
|
s265439304
|
p04022
|
C++
|
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
using namespace std;
#define cerr if (false) cerr
const int MAXN = 1e5 + 239;
const ll INF = 1e10 + 239;
int prime[MAXN];
vector<int> primes;
void init() {
fill(prime, prime + MAXN, 1);
for (int i = 2; i < MAXN; i++) {
if (prime[i]) {
for (int j = 2 * i; j < MAXN; j += i) {
prime[j] = 0;
}
primes.push_back(i);
}
}
}
ll no_cubic(ll x) {
for (ll i = 2; i * i * i <= x; i++) {
while (x % (i * i * i) == 0) {
x /= (i * i * i);
}
}
return x;
}
ll get_pair(ll x) {
ll sq = 1;
for (auto t : primes) {
if (x % ((ll)t * t) == 0) {
sq *= t;
}
if (x < ((ll)t * t)) {
break;
}
}
ll sl = x / (sq * sq);
ll ans = sq * sl;
if (ans > INF / sl) {
return -1;
} else {
return ans * sl;
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
init();
int n;
cin >> n;
map<ll, int> cnt;
for (int i = 0; i < n; i++) {
ll x;
cin >> x;
x = no_cubic(x);
cnt[x]++;
}
auto get_cnt = [&](ll x) {
if (cnt.count(x)) {
return cnt[x];
} else {
return (int)0;
}
};
int ans = 0;
if (cnt.count(1)) {
ans++;
cnt.erase(1);
}
set<pair<ll, ll>> seen;
for (auto uu : cnt) {
ll f, no_need;
tie(f, no_need) = uu;
ll pr = get_pair(f);
if (pr == -1) {
ans += cnt[f];
continue;
}
ll a = pr;
ll b = f;
if (a > b) {
swap(a, b);
}
if (!seen.count({a, b})) {
ans += max(get_cnt(a), get_cnt(b));
seen.insert({a, b});
}
}
cout << ans << endl;
}
|
a.cc:26:7: error: 'll' does not name a type
26 | const ll INF = 1e10 + 239;
| ^~
a.cc:43:1: error: 'll' does not name a type
43 | ll no_cubic(ll x) {
| ^~
a.cc:52:1: error: 'll' does not name a type
52 | ll get_pair(ll x) {
| ^~
a.cc: In function 'int main()':
a.cc:79:9: error: 'll' was not declared in this scope
79 | map<ll, int> cnt;
| ^~
a.cc:79:16: error: template argument 1 is invalid
79 | map<ll, int> cnt;
| ^
a.cc:79:16: error: template argument 3 is invalid
a.cc:79:16: error: template argument 4 is invalid
a.cc:81:11: error: expected ';' before 'x'
81 | ll x;
| ^~
| ;
a.cc:82:16: error: 'x' was not declared in this scope
82 | cin >> x;
| ^
a.cc:83:13: error: 'no_cubic' was not declared in this scope
83 | x = no_cubic(x);
| ^~~~~~~~
a.cc:86:24: error: 'll' is not a type
86 | auto get_cnt = [&](ll x) {
| ^~
a.cc: In lambda function:
a.cc:87:17: error: request for member 'count' in 'cnt', which is of non-class type 'int'
87 | if (cnt.count(x)) {
| ^~~~~
a.cc:88:23: error: invalid types 'int[int]' for array subscript
88 | return cnt[x];
| ^
a.cc: In function 'int main()':
a.cc:94:13: error: request for member 'count' in 'cnt', which is of non-class type 'int'
94 | if (cnt.count(1)) {
| ^~~~~
a.cc:96:13: error: request for member 'erase' in 'cnt', which is of non-class type 'int'
96 | cnt.erase(1);
| ^~~~~
a.cc:98:20: error: template argument 1 is invalid
98 | set<pair<ll, ll>> seen;
| ^~
a.cc:98:20: error: template argument 2 is invalid
a.cc:98:20: error: template argument 3 is invalid
a.cc:99:20: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
99 | for (auto uu : cnt) {
| ^~~
| std::begin
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
| ^~~~~
a.cc:99:20: error: 'end' was not declared in this scope; did you mean 'std::end'?
99 | for (auto uu : cnt) {
| ^~~
| std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
| ^~~
a.cc:100:11: error: expected ';' before 'f'
100 | ll f, no_need;
| ^~
| ;
a.cc:101:13: error: 'f' was not declared in this scope
101 | tie(f, no_need) = uu;
| ^
a.cc:101:16: error: 'no_need' was not declared in this scope
101 | tie(f, no_need) = uu;
| ^~~~~~~
a.cc:102:11: error: expected ';' before 'pr'
102 | ll pr = get_pair(f);
| ^~~
| ;
a.cc:103:13: error: 'pr' was not declared in this scope
103 | if (pr == -1) {
| ^~
a.cc:107:11: error: expected ';' before 'a'
107 | ll a = pr;
| ^~
| ;
a.cc:108:11: error: expected ';' before 'b'
108 | ll b = f;
| ^~
| ;
a.cc:109:13: error: 'a' was not declared in this scope
109 | if (a > b) {
| ^
a.cc:109:17: error: 'b' was not declared in this scope
109 | if (a > b) {
| ^
a.cc:112:19: error: request for member 'count' in 'seen', which is of non-class type 'int'
112 | if (!seen.count({a, b})) {
| ^~~~~
a.cc:112:26: error: 'a' was not declared in this scope
112 | if (!seen.count({a, b})) {
| ^
a.cc:112:29: error: 'b' was not declared in this scope
112 | if (!seen.count({a, b})) {
| ^
a.cc:114:18: error: request for member 'insert' in 'seen', which is of non-class type 'int'
114 | seen.insert({a, b});
| ^~~~~~
|
s655455029
|
p04022
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.141592653589793238462643383279;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
struct Init {
Init() {
cout << fixed << setprecision(20);
};
} init;
int N;
int s[110000];
unordered_map<int, int> mp;
// オーバーフロー怖いけど、通るやろ!w
signed main() {
cin >> N;
rep(i, N) {
cin >> s[i];
for (int j = 2; j * j * j <= s[i]; j++) { while (s[i] % (j * j * j) == 0) { s[i] /= (j * j * j); }}
mp[s[i]]++;
}
int ans = 0;
if (mp[1] > 0) { ans++, mp[1] = 0; }
rep(i, N) {
int cur = s[i], counter = 1;
for (int j = 2; j * j * j <= s[i]; j++) {
if (cur % (j * j) == 0) {
counter *= j;
cur /= (j * j);
} else if (cur % j == 0) {
prod(counter, j * j);
counter *= j * j;
}
}
int rt = round(sqrt(cur));
if (rt * rt == cur) { counter *= rt; }
else { counter *= cur * cur; }
ans += max(mp[s[i]], mp[counter]);
mp[s[i]] = mp[counter] = 0;
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:54:17: error: 'prod' was not declared in this scope
54 | prod(counter, j * j);
| ^~~~
|
s647764751
|
p04022
|
C++
|
#include <bits/stdc++.h>
#define ft first
#define sd second
using namespace std;
typedef long long ll;
const int MAXN = 100 * 1000 + 12;
unordered_map<ll, int> mp;
bool inp[MAXN];
vector<int> p;
void gh() {
inp[0] = inp[1] = true;
for (int i = 2; i < MAXN; i++)
if (!inp[i]) {
p.push_back(i);
for (ll j = (ll)i * i; j < MAXN; j += i)
inp[j] = true;
}
}
ll kam(ll x) {
ll ret = 1;
for (int i = 0; i < (int)p.size() && (ll)p[i] * p[i] <= x; i++) {
ll j = p[i];
if (x % j == 0) {
ll m = j * j * j;
while (x % m == 0)
x /= m;
while (x % j == 0)
ret *= j, x /= j;
}
}
return ret * x;
}
ll ziad(ll x) {
ll ret = 1;
for (int i = 0; i < (int)p.size() && (ll)p[i] * p[i] <= x; i++) {
ll j = p[i];
if (x % j == 0) {
ll m = j * j * j;
while (x % m == 0)
x /= m;
while (x % j == 0)
m /= j, x/= j;
ret *= ((m == j * j * j)? 1: m);
}
}
return ret * x * x;
}
int main() {
gh();
{
int n, a;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a;
mp[kam(a)]++;
}
}
for (auto i : mp) {
if (i.ft == 1) {
ans++;
continue;
}
ll x = mp[ziad(i.ft)];
if (i.sd > x)
ans += ((x)? i.sd: (i.sd << 1));
else
ans += x;
}
cout << (ans >> 1);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:72:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
72 | ans++;
| ^~~
| abs
a.cc:77:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
77 | ans += ((x)? i.sd: (i.sd << 1));
| ^~~
| abs
a.cc:79:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
79 | ans += x;
| ^~~
| abs
a.cc:81:18: error: 'ans' was not declared in this scope; did you mean 'abs'?
81 | cout << (ans >> 1);
| ^~~
| abs
|
s862026158
|
p04022
|
C++
|
#include <bits/stdc++.h>
#define int long long
//#pragma GCC optimize ("O3")
#define map unordered_map
using namespace std;
int m3[2160];
int m2[2160];
int n;
int cnt[100005];
int it=0;
int b[100005];
int a[100005];
map<int, int> concac;
map<int, int> used;
signed main()
{
ios::sync_with_stdio(false);
for(int i=1; i<=2155; i++)
{
m3[i]=i*i*i;
m2[i]=i*i;
}
cin>>n;
for(int i=1; i<=n; i++)
{
cin>>a[i];
for(int j=2155; j>=1; j--)
{
if(a[i]%m3[j]==0)
{
a[i]/=m3[j];
break;
}
}
}
sort(a+1, a+n+1);
for(int i=1; i<=n; i++)
{
// cout<<a[i]<<" ";
if(a[i]!=a[i-1])
{
it++;
b[it]=a[i];
}
cnt[it]++;
}
// cout<<endl;
// for(int i=1; i<=it; i++)
// {
// concac[b[i]]=cnt[i];
// }
// int ans=0;
// for(int i=1; i<=it; i++)
// {
// if(used[b[i]]) continue;
// used[b[i]]=1;
// bool cophaikhong=false;
// for(int j=1; j<=2155; j++)
// {
// if(b[i]%j==0)
// {
// int cac=sqrt(b[i]/j);
// if(cac*cac*j==b[i])
// {
// cophaikhong=true;
// int caccac=cac*j*j;
// if(caccac==b[i]) ans++;
// else ans+=max(concac[b[i]], concac[caccac]);
// used[caccac]=1;
// break;
// }
// }
// }
// if(!cophaikhong)
// for(int j=2155; j>=1; j--)
// {
// if(b[i]%m2[j]==0)
// {
// if(b[i]/m2[j]>=1000000)
// {
// ans++;
// break;
// }
// int cac=j*b[i]/m2[j]*b[i]/m2[j];
// cophaikhong=true;
// if(cac==b[i]) ans++;
// else ans+=max(concac[b[i]], concac[cac]);
// used[cac]=1;
// break;
// }
// }
//// cout<<i<<" "<<ans<<endl;
// }
cout<<ans;
}
|
a.cc: In function 'int main()':
a.cc:96:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
96 | cout<<ans;
| ^~~
| abs
|
s942764112
|
p04022
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(mp(a,b),c)
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pbc(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof x)
#define SIZE(x) (int)(x.size())
int mod;
IL ll pls(ll x,ll y){x+=y;return x>=mod?x-mod:x;}
IL ll dec(ll x,ll y){x-=y;return x<0?x+mod:x;}
IL ll mul(ll x,ll y){return (__int128)x*y%mod;}
IL ll mul(ll x,ll y,ll z){return mul(mul(x,y),z);}
IL ll mul(ll x,ll y,ll z,ll p){return mul(mul(x,y),mul(z,p));}
IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;}
IL ll fpw(ll x,ll y,ll r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;}
IL int inv(int x){return fpw(x,mod-2);}
IL int gi(){int x;int _w=scanf("%d",&x);return x;}
IL void gi(int &x){int _w=scanf("%d",&x);}
IL void write(int x){printf("%d\n",x);}
void chkmax(int &x,int y){x=(x>y)?x:y;}
void chkmin(int &x,int y){x=(x<y)?x:y;}
const int INF=0x3f3f3f3f;
template<typename T>IL void debug(T x){cerr<<x;return;}
/* --------------------------------------------------------------------------------------------------------- */
template<typename T>T read(){
char ch;T u=0,f=1;
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){u=(u<<1)+(u<<3)+ch-48;ch=getchar();}
return u*f;
}
namespace Rho{
const int pri[]={2,3,5,7,11,13,17,19,23,29,31,37};
IL bool Miller_Rabin(ll n){
if((nn%6)!=1 && (nn%6)!=5) return false;
mod=n;
rep(i,0,8)if(n%pri[i]==0)return n==pri[i];
ll r,t;
for(r=n-1,t=0;~r&1;r>>=1,++t);
rep(i,0,8){
ll x=fpw(pri[i],r);
for(int j=0;j<t&&x>1;++j){
ll y=mul(x,x);
if(y==1&&x!=n-1)return false;
x=y;
}
if(x!=1)return false;
}
return true;
}
IL ll gcd(ll x,ll y){return !y?x:gcd(y,x%y);}
IL ll func(ll x,ll a){return pls(mul(x,x),a);}
IL ll Find(ll n,ll c){
ll x=rand()%n+1, y=x, k=2;
for(int i=1;;i++) {
x=(mul(x,x)+c)%n;
ll p=gcd(abs(y-x),n);
if(p!=1) return p;
if(i==k) k<<=1, y=x;
}
}
IL void Pollard_Rho(ll n,vector<ll>&D){
if(n==1||Miller_Rabin(n)){if(n!=1)D.pb(n);return;}
ll d=n;while(d==n)d=Find(n,rand()%n);
Pollard_Rho(n/d,D);Pollard_Rho(d,D);
}
}
const int MOD=998244353998244353LL;
ll MUL(ll x,ll y){return (__int128)x*y%MOD;}
map<ll,int>num,rev,vis;
ll Fpw(ll x,ll y,ll r=1ll){for(;y;y>>=1,x=MUL(x,x))if(y&1)r=MUL(r,x);return r;}
int main(){
srand(time(NULL));
int n=gi();
rep(i,1,n){
ll ai=read<ll>();
if(ai==1){rev[1]=1;num[1]++;continue;}
vector<ll>D;
Rho::Pollard_Rho(ai,D);
sort(D.begin(),D.end());
int l=1,val=D[0];ll X=1,Y=1;
for(int i=1;i<D.size();++i){
if(D[i]==val){l++;continue;}
else {
X=MUL(X,Fpw(val,l%3));
Y=MUL(Y,Fpw(val,(3-l%3)%3));
val=D[i];l=1;
}
}if(l){
X=MUL(X,Fpw(val,l%3));
Y=MUL(Y,Fpw(val,(3-l%3)%3));
}rev[X]=Y;rev[Y]=X;num[X]++;
}
int ans=0;
for(auto v:num){
if(vis[v.fr])continue;
if(v.fr==1)ans++;
else ans+=max(v.se,num[rev[v.fr]]),vis[v.fr]=vis[rev[v.fr]]=1;
}
cout<<ans<<endl;
return 0;
}
|
a.cc: In function 'bool Rho::Miller_Rabin(long long int)':
a.cc:45:21: error: 'nn' was not declared in this scope; did you mean 'n'?
45 | if((nn%6)!=1 && (nn%6)!=5) return false;
| ^~
| n
a.cc: At global scope:
a.cc:78:15: warning: overflow in conversion from 'long long int' to 'int' changes value from '998244353998244353' to '1998244353' [-Woverflow]
78 | const int MOD=998244353998244353LL;
| ^~~~~~~~~~~~~~~~~~~~
|
s475831515
|
p04022
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(mp(a,b),c)
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pbc(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof x)
#define SIZE(x) (int)(x.size())
int mod;
IL int pls(int x,int y){x+=y;return x>=mod?x-mod:x;}
IL int dec(int x,int y){x-=y;return x<0?x+mod:x;}
IL ll mul(ll x,ll y){return (__int128)*x*y%mod;}
IL ll mul(ll x,ll y,ll z){return mul(mul(x,y),z);}
IL ll mul(ll x,ll y,ll z,ll p){return mul(mul(x,y),mul(z,p));}
IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;}
IL ll fpw(ll x,ll y,ll r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;}
IL int inv(int x){return fpw(x,mod-2);}
IL int gi(){int x;int _w=scanf("%d",&x);return x;}
IL void gi(int &x){int _w=scanf("%d",&x);}
IL void write(int x){printf("%d\n",x);}
void chkmax(int &x,int y){x=(x>y)?x:y;}
void chkmin(int &x,int y){x=(x<y)?x:y;}
const int INF=0x3f3f3f3f;
template<typename T>IL void debug(T x){cerr<<x;return;}
/* --------------------------------------------------------------------------------------------------------- */
template<typename T>T read(){
char ch;T u=0,f=1;
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){u=(u<<1)+(u<<3)+ch-48;ch=getchar();}
return u*f;
}
namespace Rho{
const int pri[]={2,3,5,7,11,13,17,19,23,29,31,37};
IL bool Miller_Rabin(ll n){
mod=n;
rep(i,0,11)if(n%pri[i]==0)return n==pri[i];
int r,t;
for(r=n-1,t=0;~r&1;r>>=1,++t);
rep(i,0,11){
ll x=fpw(pri[i],r);
for(int j=0;j<t&&x>1;++j){
ll y=mul(x,x);
if(y==1&&x!=n-1)return false;
x=y;
}
if(x!=1)return false;
}
return true;
}
IL ll gcd(ll x, ll y){return !y?x:gcd(y,x%y);}
IL ll func(ll x, ll a){return pls(mul(x,x),a);}
IL ll Find(ll n){
rep(i,0,11)if(n%pri[i]==0)return pri[i];
ll a=rand();
ll x=func(rand(),a),y=x;
do{
ll g=gcd(dec(x,y),n);
if(g!=1&&g!=n)return g;
x=func(x,a);y=func(func(y,a),a);
}while(x!=y);
return -1;
}
IL void Pollard_Rho(ll n,vector<ll>&D){
if(n==1||Miller_Rabin(n)){if(n!=1)D.pb(n);return;}
ll d=-1;while(d==-1)d=Find(n);
Pollard_Rho(d,D);Pollard_Rho(n/d,D);
}
}
map<ll,int>num,rev,vis;
ll Fpw(ll x,ll y,ll r=1ll){for(;y;y>>=1,x=x*x)if(y&1)r=r*x;return r;}
int main(){
#ifdef LOCAL
freopen("/home/noilinux/Desktop/input.txt","r",stdin);
#endif
int n=gi();
rep(i,1,n){
ll ai=read<ll>();
if(ai==1){rev[1]=1;num[1]++;continue;}
vector<ll>D;sort(D.begin(),D.end());
Rho::Pollard_Rho(ai,D);
sort(D.begin(),D.end());
int l=1,val=D[0];ll X=1,Y=1;
for(int i=1;i<D.size();++i){
if(D[i]==val){l++;continue;}
else {
X=X*Fpw(val,l%3);
Y=Y*Fpw(val,(3-l%3)%3);
val=D[i];l=1;
}
}if(l){
X=X*Fpw(val,l%3);
Y=Y*Fpw(val,(3-l%3)%3);
}rev[X]=Y;rev[Y]=X;num[X]++;
}
int ans=0;
for(auto v:num){
if(vis[v.fr])continue;
if(v.fr==1)ans++;
else ans+=max(v.se,num[rev[v.fr]]),vis[v.fr]=vis[rev[v.fr]]=1;
}
cout<<ans<<endl;
return 0;
}
|
a.cc: In function 'long long int mul(long long int, long long int)':
a.cc:22:39: error: invalid type argument of unary '*' (have 'long long int')
22 | IL ll mul(ll x,ll y){return (__int128)*x*y%mod;}
| ^~
|
s056709423
|
p04022
|
C++
|
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define N (200005)
#define MOD (1000000000ll + 7ll)
#define OO (1050000000)
#define OOL (1100000000000000000)
//global
ll a[N];
map<ll,int> act;
map<ll,int> ful;
int main(){
//fold
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cout << setprecision(10);
//endfold
int n;
cin >> n;
rep(i,0,n){
cin >> a[i];
}
rep(i,0,n){
vector<pair<int,int>> bs;
vector<pair<int,int>> rs;
ll j = 2;
while(j*j <= a[i]){
int k = 0;
while(a[i]%j == 0){
k++;
a[i] /= j;
}
if(k%3 != 0) bs.push_back({j,k%3});
j++;
}
if(a[i] > 100000) continue;
if(a[i] > 1) bs.push_back({a[i],1});
ll bsn = 1;
ll rsn = 1;
for(pair<int,int> w:bs){
if(w.second == 1){
bsn *= w.first;
rsn *= w.first;
rsn *= w.first;
}
if(w.second == 2){
bsn *= w.first;
bsn *= w.first;
rsn *= w.first;
}
}
if(bsn <= rsn) act[bsn]++;
ful[min(bsn,rsn)]++;
}
int ans = 0;
for(auto el:act){
i = el.first;
ans += max(act[i],ful[i]-act[i]);
}
cout << ans+(act[1]>0);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:89:17: error: 'i' was not declared in this scope
89 | i = el.first;
| ^
|
s974609851
|
p04022
|
C++
|
#include <map>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
map <ll ,int > ma;
const int M=3005,N=100005;
int p[M],tot=0;bool notp[M];
ll a[N];ll c1[N],c2[N];
int cnt[N];
map <ll,bool > used;
inline void getp(){
for (int i=2;i<=3000;i++){
if (!notp[i]) p[++tot]=i;
for (int j=1;i*p[j]<=3000&&j<=tot;j++){
notp[i*p[j]]=true;
if (i%p[j]==0) break;
}
}
}
int main (){
int n;scanf ("%d",&n);
getp();bool flag=false;
for (int i=1;i<=n;i++) scanf ("%lld",&a[i]);
for (int i=1;i<=n;i++){
for (int j=1;j<=tot;j++) cnt[j]=0;
ll hash=1,hash2=1;
for (int j=1;j<=tot;j++)
while (a[i]%p[j]==0) a[i]/=p[j],cnt[j]++;
for (int j=1;j<=tot;j++) {
cnt[j]%=3;
for (int k=1;k<=cnt[j];k++) hash*=p[j];
if (cnt[j]) for (int k=2;k>=cnt[j];k--) hash2*=p[j];
}
if (a[i]==1) c1[i]=hash,c2[i]=hash2;
else {
ll t=(ll)sqrt(a[i]);
if (t*t==a[i]) hash*=t,hash*=t,hash2*=t;
else hash*=a[i],hash2*=a[i],hash2*=a[i];
c1[i]=hash,c2[i]=hash2;
}
}
int ans=0;
for (int i=1;i<=n;i++) ma[c1[i]]++;
for (int i=1;i<=n;i++){
ll x=c1[i],y=c2[i];
if (used[x]||used[y]) continue;
ll t=ma[x]>ma[y]?x:y;used[t]=1;
ans+=(t==1)?1:ma[t];
}
printf ("%d",ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:39:34: error: 'sqrt' was not declared in this scope
39 | ll t=(ll)sqrt(a[i]);
| ^~~~
|
s098875097
|
p04022
|
C++
|
#include <map>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
map <ll ,int > ma;
const int M=3005,N=100005;
int p[M],tot=0;bool notp[M];
ll a[N];ll c1[N],c2[N];
int cnt[N];
inline void getp(){
for (int i=2;i<=3000;i++){
if (!notp[i]) p[++tot]=i;
for (int j=1;i*p[j]<=3000&&j<=tot;j++){
notp[i*p[j]]=true;
if (i%p[j]==0) break;
}
}
}
int main (){
int n;scanf ("%d",&n);
getp();bool flag=false;
for (int i=1;i<=n;i++) scanf ("%lld",&a[i]);
for (int i=1;i<=n;i++){
for (int j=1;j<=tot;j++) cnt[j]=0;
ll hash=1,hash2=1;
for (int j=1;j<=tot;j++)
while (a[i]%p[j]==0) a[i]/=p[j],cnt[j]++;
for (int j=1;j<=tot;j++) {
cnt[j]%=3;
for (int k=1;k<=cnt[j];k++) hash*=p[j];
if (cnt[j]) for (int k=2;k>=cnt[j];k--) hash2*=p[j];
}
if (a[i]==1) c1[i]=hash,c2[i]=hash2;
else {
int t=(int)sqrt(a[i]);
if (t*t==a[i]) hash*=t,hash*=t,hash2*=t;
else hash*=a[i],hash2*=a[i],hash2*=a[i];
c1[i]=hash,c2[i]=hash2;
}
}
int ans=0;
for (int i=1;i<=n;i++) if (c1[i]!=1) ma[c1[i]]++;else flag=true;
ans+=flag;
for (int i=1;i<=n;i++)
if (ma[c1[i]]>ma[c2[i]]) ans++;
else if (ma[c1[i]]&&ma[c1[i]]==ma[c2[i]]) ans+=ma[c1[i]],ma[c1[i]]=ma[c2[i]]=0;
printf ("%d",ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:38:36: error: 'sqrt' was not declared in this scope
38 | int t=(int)sqrt(a[i]);
| ^~~~
|
s010840097
|
p04022
|
C++
|
#include <map>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
map <ll ,int > ma;
const int M=3005,N=100005;
int p[M],tot=0;bool notp[M];
ll a[N];ll c1[N],c2[N];
int cnt[N];
inline void getp(){
for (int i=2;i<=3000;i++){
if (!notp[i]) p[++tot]=i;
for (int j=1;i*p[j]<=3000&&j<=tot;j++){
notp[i*p[j]]=true;
if (i%p[j]==0) break;
}
}
}
int main (){
int n;scanf ("%d",&n);
getp();bool flag=false;
for (int i=1;i<=n;i++) scanf ("%lld",&a[i]);
for (int i=1;i<=n;i++){
for (int j=1;j<=tot;j++) cnt[j]=0;
ll hash=1,hash2=1;
for (int j=1;j<=tot;j++)
while (a[i]%p[j]==0) a[i]/=p[j],cnt[j]++;
for (int j=1;j<=tot;j++) {
cnt[j]%=3;
for (int k=1;k<=cnt[j];k++) hash*=p[j];
if (cnt[j]) for (int k=2;k>=cnt[j];k--) hash2*=p[j];
}
if (a[i]==1) c1[i]=hash,c2[i]=hash2;
else {
int t=(int)sqrt(a[i]);
if (t*t==a[i]) hash*=t,hash*=t,hash2*=t;
else hash*=a[i],hash2*=a[i],hash2*=a[i];
c1[i]=hash,c2[i]=hash2;
}
}
int ans=0;
for (int i=1;i<=n;i++) if (c1[i]!=1) ma[c1[i]]++;else flag=true;
ans+=flag;
for (int i=1;i<=n;i++)
if (ma[c1[i]]>ma[c2[i]]) ans++;
else if (ma[c1[i]]&&ma[c1[i]]==ma[c2[i]]) ans+=ma[c1[i]],ma[c1[i]]=ma[c2[i]]=0;
printf ("%d",ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:38:36: error: 'sqrt' was not declared in this scope
38 | int t=(int)sqrt(a[i]);
| ^~~~
|
s353486149
|
p04022
|
C++
|
// warm heart, wagging tail,and a smile just for you!
// ███████████
// ███╬╬╬╬╬╬╬╬╬╬███
// ███╬╬╬╬╬████╬╬╬╬╬╬███
// ███████████ ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
// █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
// ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
// ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
// ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
// ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
// █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
// ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ██████████████ ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
// ███████ █████ ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
vec pri;
void p_calc(){
int n = 1e5;
for(int i=2;i<n;i+=2){
bool flag = true;
for(int j=3; j<=sqrt(i);j+=2){
if(i%j == 0){
flag = false;
break;
}
}
if(flag || i == 2) pri.push_back(i);
if(i == 2) i--;
}
}
int calc(int x){
int id = 0;
int tmp = 8;
while(tmp <= x){
while(x%tmp == 0) x /= tmp;
id++;
if(id == pri.size()) break;
tmp = pri[id]*pri[id]*pri[id];
}
return x;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
p_calc();
vec a(n);
REP(i,n){
cin >> a[i];
a[i] = calc(a[i]);
}
int cb = 0;
map<int,int> mp1,mp2;
REP(i,n){
if(a[i] == 1){
cb++;
continue;
}
int id = 0;
int tmp = 4;
int pos = 1;
int cur = a[i];
while(a[i] >= tmp){
while(a[i]%tmp == 0) a[i] /= tmp, pos *= pri[id];
id++;
if(id == tmp.size()) break;
tmp = pri[id]*pri[id];
}
//debug(a[i]);
if(a[i] == 1) mp2[pos]++;
else mp1[cur]++;
}
int ans = 0;
if(cb) ans++;
ITR(itr,mp1) ans += max(itr->sc,mp2[itr->fs]);
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:103:20: error: request for member 'size' in 'tmp', which is of non-class type 'long long int'
103 | if(id == tmp.size()) break;
| ^~~~
|
s891892373
|
p04022
|
C++
|
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll p[10000],a[100005],k[100005];
int cnt=0;
map<ll,int>x;
map<ll,bool>vis;
ll M(ll t,ll h)
{
ll ans1=1,ans2=1;
for(int i=0;i<cnt&&p[i]*p[i]<=t;i++)
{
int cot=0;
while(t%p[i]==0) cot++,t/=p[i];
cot%=3;
if(cot==0) continue;
if(cot==1)
{
ans1*=p[i],ans2*=p[i];
if(ans2>1e10) ans2=0;
ans2*=p[i];
if(ans2>1e10) ans2=0;
}
else
{
ans1*=p[i]*p[i],ans2*=p[i];
if(ans2>1e10) ans2=0;
}
}
if(t>1)
{
ans1*=t,ans2*=t
if(ans>1e10) ans2=0;
ans2=*t;
if(ans2>1e10) ans2=0;
}
x[ans1]++;
if(ans2!=0)
k[h]=ans2;
else k[h]=ans1;
return ans1;
}
int main()
{
for(int i=2;i<=100000;i++)
{
bool flag=true;
for(int j=2;j*j<=i;j++)
if(i%j==0) {flag=false;break;}
if(flag) p[cnt++]=i;
}
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
ll m;
scanf("%lld",&m);
a[i]=M(m,i);
}
int ans=0;
vis[1]=true;
for(int i=1;i<=n;i++)
if(!vis[a[i]]) ans+=max(x[a[i]],x[k[i]]),vis[a[i]]=vis[k[i]]=true;
if(x[1]>=1) ans++;
printf("%d\n",ans);
}
|
a.cc: In function 'long long int M(long long int, long long int)':
a.cc:32:24: error: expected ';' before 'if'
32 | ans1*=t,ans2*=t
| ^
| ;
33 | if(ans>1e10) ans2=0;
| ~~
a.cc:34:14: error: invalid type argument of unary '*' (have 'long long int')
34 | ans2=*t;
| ^~
|
s083027409
|
p04022
|
C++
|
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<map>
#define ll long long
using namespace std;
inline ll read(){
ll re=0,flag=1;char ch=getchar();
while(!isdigit(ch)){
if(ch=='-') flag=-1;
ch=getchar();
}
while(isdigit(ch)) re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
return re*flag;
}
ll n,vis[200010],pri[100010],cntp,mark;
map<ll,ll>big;
void init(){
ll i,j,k;vis[1]=1;
for(i=2;i<=100000;i++){
if(!vis[i]){pri[++cntp]=i;big[(ll)i*(ll)i]=i;}
for(j=1;j<=cntp;j++){
k=i*pri[j];if(k>100000) break;
vis[k]=1;
if(i%pri[j]==0) break;
}
if(i==3000) mark=cntp;
}
}
vector<ll>f1,f2;bool cb=0;
ll cur[100010],inv[100010];
map<ll,ll>s;
void F(ll x,ll num){
if(x==1){cur[num]=inv[num]=1e15;cb=1;return;}
ll i,cnt,flag=0;
f1.clear();f2.clear();
for(i=1;i<=mark;i++){
if(x%pri[i]) continue;
cnt=0;
while(x%pri[i]==0) cnt++,x/=pri[i];
if(cnt%3==1) f1.push_back(pri[i]),flag=1;
if(cnt%3==2) f2.push_back(pri[i]),flag=1;
}
// cout<<"mid "<<x<<' '<<num<<'\n';
if(x!=1){
flag=1;
if(big.count(x)) f2.push_back(big[x]);
else f1.push_back(x);
}
// cout<<"kkk "<<flag<<' '<<f1.size()<<' '<<f2.size()<<'\n';
if(!flag){cur[num]=inv[num]=1e15;cb=1;return;}
ll rer=1,rel=1;
for(auto i:f1) rer*=(i*i),rel*=i;
for(auto i:f2) rer*=i,rel*=(i*i);
if(s.count(rel)) s[rel]++;
else s[rel]=1;
cur[num]=rel;inv[num]=rer;
// cout<<"final "<<num<<' '<<cur[num]<<' '<<inv[num]<<'\n';
}
ll rk[100010];
inline bool cmp(ll l,ll r){
return cur[l]<cur[r];
}
int main(){
init();
n=read();ll i,tmp,j,de=0,tot=0;
for(i=1;i<=n;i++){
tmp=read();
F(tmp,i);rk[i]=i;
}
sort(rk+1,rk+n+1,cmp);
for(j=1;j<=n;j++){
// cout<<j<<' '<<rk[j]<<' '<<cur[rk[j]]<<' '<<inv[rk[j]]<<'\n';
if(cur[rk[j]]==1e15) continue;
tot++;
if(cur[rk[j]]==cur[rk[j-1]]) continue;
if(inv[rk[j]]>=cur[rk[j]]&&s.count(inv[rk[j]])){
// cout<<"add de "<<'\n';
de+=min(s[cur[rk[j]]],s[inv[rk[j]]]);
}
}
cout<<tot-de+(cb!=0)<<'\n';
}
|
a.cc:32:1: error: 'vector' does not name a type
32 | vector<ll>f1,f2;bool cb=0;
| ^~~~~~
a.cc: In function 'void F(long long int, long long int)':
a.cc:38:9: error: 'f1' was not declared in this scope
38 | f1.clear();f2.clear();
| ^~
a.cc:38:20: error: 'f2' was not declared in this scope
38 | f1.clear();f2.clear();
| ^~
|
s688987408
|
p04022
|
C++
|
#include <cstdio>
#include <algorithm>
#include <map>
const int N=1e5+5,P=2200+5;
int n,tot,p[P];
long long a[N],s[N],t[N];
bool flg[P];
std::map<long long,int> mp;
void init() {
for(int i=2;i<P;++i) {
if(!flg[i]) p[++tot]=i;
for(int j=1;j<=tot&&i*p[j]<P;++j) {
flg[i*p[j]]=1;
if(i%p[j]==0) break;
}
}
}
void solve() {
scanf("%d",&n);
for(int k=1;k<=n;++k) {
long long x;
scanf("%lld",&x);
t[k]=1;
for(int i=1;1LL*p[i]*p[i]*p[i]<=x;++i) {
long long c=1LL*p[i]*p[i]*p[i];
while(x%c==0) x/=c;
}
++mp[s[k]=x];
for(int i=1;1LL*p[i]*p[i]*p[i]<=x;++i) {
int cnt=0;
while(x%p[i]==0) x/=p[i],++cnt;
if(cnt==1) t[k]*=1LL*p[i]*p[i];
if(cnt==2) t[k]*=p[i];
}
long long rt=std::sqrt(x);
rt*rt==x?t[k]*=rt:t[k]*=x*x;
}
int ans=0;
if(mp[1]) ++ans,mp[1]=0;
for(int i=1;i<=n;++i) {
ans+=std::max(mp[s[i]],mp[t[i]]);
mp[s[i]]=mp[t[i]]=0;
}
printf("%d\n",ans);
}
int main() {
init();
solve();
return 0;
}
|
a.cc: In function 'void solve()':
a.cc:36:35: error: 'sqrt' is not a member of 'std'; did you mean 'sort'?
36 | long long rt=std::sqrt(x);
| ^~~~
| sort
|
s731423821
|
p04022
|
C++
|
#include <bits/stdc++.h>
using namespace std;
namespace IO
{
const int __S=(1<<20)+5;char __buf[__S],*__H,*__T;
inline char getc()
{
if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
if(__H==__T) return -1;return *__H++;
}
template <class __I>inline void read(__I &__x)
{
__x=0;int __fg=1;char __c=getc();
while(!isdigit(__c)&&__c!='-') __c=getc();
if(__c=='-') __fg=-1,__c=getc();
while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
__x*=__fg;
}
inline void readd(double &__x)
{
__x=0;double __fg=1.0;char __c=getc();
while(!isdigit(__c)&&__c!='-') __c=getc();
if(__c=='-') __fg=-1.0,__c=getc();
while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
if(__c!='.'){__x=__x*__fg;return;}else while(!isdigit(__c)) __c=getc();
double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
__x=__x*__fg;
}
inline void reads(char *__s,int __x)
{
char __c=getc();int __tot=__x-1;
while(__c<'!'||__c>'~') __c=getc();
while(__c>='!'&&__c<='~') __s[++__tot]=__c,__c=getc();
__s[++__tot]='\0';
}
char __obuf[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
template <class __I>inline void print(__I __x)
{
if(!__x) putc('0');
if(__x<0) putc('-'),__x=-__x;
while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
while(__qr) putc(__qu[__qr--]);
}
inline void prints(const char *__s,const int __x)
{
int __len=strlen(__s+__x);
for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
}
inline void printd(double __x,int __d)
{
long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
while(__d--)
{
double __y=__x*10.0;__x*=10.0;
int __c=(int)floor(__y);
putc(__c+'0');__x-=floor(__y);
}
}
inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
#define ll long long
unordered_map<ll,ll>iv,cnt;ll a,p[100005];int n,vis[100005],tot,ans,gg;
int main()
{
for(int i=2;i<=100000;i++)
{
if(!vis[i]) p[++tot]=i;
for(int j=1;j<=tot&&i*p[j]<=100000;j++){vis[i*p[j]]=1;if(i%p[j]==0) break;}
}
read(n);for(int i=1;i<=n;i++)
{
read(a);ll t=a,val=1,inv=1;
for(int j=1;j<=tot&&1ll*p[j]*p[j]*p[j]<=a;j++) if(t%p[j]==0)
{
int mi=0;while(t%p[j]==0) t/=p[j],mi++;mi%=3;
for(int i=1;i<=mi;i++) val*=p[j];for(int i=1;i<=(3-mi)%3;i++) inv*=p[j];
}
if(t>1){val*=t;ll sq=sqrt(t);if(sq*sq==t) inv*=sq;else inv*=t*t;}
if(val==1) gg=1;else cnt[val]++,iv[inv]=val,iv[val]=inv;
}
for(map<ll,ll>::iterator it=cnt.begin();it!=cnt.end();++it)
{
if(cnt.find(iv[it->first])==cnt.end()) ans+=it->second;
else ans+=max(it->second,cnt[iv[it->first]]),it->second=0,cnt[iv[it->first]]=0;
}
printf("%d\n",ans+gg);
}
|
a.cc: In function 'int main()':
a.cc:83:42: error: conversion from 'std::unordered_map<long long int, long long int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, long long int>, std::allocator<std::pair<const long long int, long long int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} to non-scalar type 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} requested
83 | for(map<ll,ll>::iterator it=cnt.begin();it!=cnt.end();++it)
| ~~~~~~~~~^~
a.cc:83:47: error: no match for 'operator!=' (operand types are 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} and 'std::unordered_map<long long int, long long int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, long long int>, std::allocator<std::pair<const long long int, long long int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'})
83 | for(map<ll,ll>::iterator it=cnt.begin();it!=cnt.end();++it)
| ~~^~~~~~~~~~~
| | |
| | std::unordered_map<long long int, long long int>::iterator {aka std::__detail::_Insert_base<long long int, std::pair<const long long int, long long int>, std::allocator<std::pair<const long long int, long long int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator}
| std::map<long long int, long long int>::iterator {aka std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator}
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1132:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1132 | operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1132:5: note: template argument deduction/substitution failed:
a.cc:83:57: note: 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
83 | for(map<ll,ll>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:1212:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1212 | operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1212:5: note: template argument deduction/substitution failed:
a.cc:83:57: note: 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
83 | for(map<ll,ll>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:1305:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1305 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1305:5: note: template argument deduction/substitution failed:
a.cc:83:57: note: 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
83 | for(map<ll,ll>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:1379:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1379 | operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1379:5: note: template argument deduction/substitution failed:
a.cc:83:57: note: 'std::unordered_map<long long int, long long int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, long long int>, std::allocator<std::pair<const long long int, long long int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
83 | for(map<ll,ll>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:1473:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1473 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1473:5: note: template argument deduction/substitution failed:
a.cc:83:57: note: 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
83 | for(map<ll,ll>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:1547:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1547 | operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1547:5: note: template argument deduction/substitution failed:
a.cc:83:57: note: 'std::unordered_map<long long int, long long int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, long long int>, std::allocator<std::pair<const long long int, long long int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
83 | for(map<ll,ll>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:1647:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1647 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1647:5: note: template argument deduction/substitution failed:
a.cc:83:57: note: 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
83 | for(map<ll,ll>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:2213:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator!=(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
2213 | operator!=(const match_results<_Bi_iter, _Alloc>& __m1,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2213:5: n
|
s762827716
|
p04022
|
C++
|
#include <bits/stdc++.h>
using namespace std;
namespace IO
{
const int __S=(1<<20)+5;char __buf[__S],*__H,*__T;
inline char getc()
{
if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
if(__H==__T) return -1;return *__H++;
}
template <class __I>inline void read(__I &__x)
{
__x=0;int __fg=1;char __c=getc();
while(!isdigit(__c)&&__c!='-') __c=getc();
if(__c=='-') __fg=-1,__c=getc();
while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
__x*=__fg;
}
inline void readd(double &__x)
{
__x=0;double __fg=1.0;char __c=getc();
while(!isdigit(__c)&&__c!='-') __c=getc();
if(__c=='-') __fg=-1.0,__c=getc();
while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
if(__c!='.'){__x=__x*__fg;return;}else while(!isdigit(__c)) __c=getc();
double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
__x=__x*__fg;
}
inline void reads(char *__s,int __x)
{
char __c=getc();int __tot=__x-1;
while(__c<'!'||__c>'~') __c=getc();
while(__c>='!'&&__c<='~') __s[++__tot]=__c,__c=getc();
__s[++__tot]='\0';
}
char __obuf[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
template <class __I>inline void print(__I __x)
{
if(!__x) putc('0');
if(__x<0) putc('-'),__x=-__x;
while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
while(__qr) putc(__qu[__qr--]);
}
inline void prints(const char *__s,const int __x)
{
int __len=strlen(__s+__x);
for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
}
inline void printd(double __x,int __d)
{
long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
while(__d--)
{
double __y=__x*10.0;__x*=10.0;
int __c=(int)floor(__y);
putc(__c+'0');__x-=floor(__y);
}
}
inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
#define ll long long
map<ll,ll>iv,cnt;ll a,p[100005];int n,vis[100005],tot,ans,gg;
int main()
{
for(int i=2;i<=100000;i++)
{
if(!vis[i]) p[++tot]=i;
for(int j=1;j<=tot&&i*p[j]<=100000;j++){vis[i*p[j]]=1;if(i%p[j]==0) break;}
}
read(n);for(int i=1;i<=n;i++)
{
read(a);ll t=a,val=1,inv=1;
for(int j=1;j<=tot&&1ll*p[j]*p[j]*p[j]<=a;j++) if(t%p[j]==0)
{
int mi=0;while(t%p[j]==0) t/=p[j],mi++;mi%=3;
for(int i=1;i<=mi;i++) val*=p[j];for(int i=1;i<=(3-mi)%3;i++) inv*=p[j];
}
if(t>1){val*=t;ll sq=sqrt(t);if(sq*sq==t) inv*=sq;else inv*=t*t;}
if(val==1) gg=1;else cnt[val]++,iv[inv]=val,iv[val]=inv;
}
for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
{
if(cnt.find(iv[it->first])==cnt.end()) ans+=it->second;
else ans+=max(it->second,cnt[iv[it->first]]),it->second=0,cnt[iv[it->first]]=0;
}
printf("%d\n",ans+gg);
}
|
a.cc: In function 'int main()':
a.cc:83:43: error: conversion from '_Rb_tree_iterator<pair<[...],long long int>>' to non-scalar type '_Rb_tree_iterator<pair<[...],int>>' requested
83 | for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
| ~~~~~~~~~^~
a.cc:83:48: error: no match for 'operator!=' (operand types are 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} and 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'})
83 | for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
| ~~^~~~~~~~~~~
| | |
| | _Rb_tree_iterator<pair<[...],long long int>>
| _Rb_tree_iterator<pair<[...],int>>
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1132:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1132 | operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1132:5: note: template argument deduction/substitution failed:
a.cc:83:58: note: 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
83 | for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:1212:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1212 | operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1212:5: note: template argument deduction/substitution failed:
a.cc:83:58: note: 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
83 | for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:1305:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1305 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1305:5: note: template argument deduction/substitution failed:
a.cc:83:58: note: 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
83 | for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:1379:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1379 | operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1379:5: note: template argument deduction/substitution failed:
a.cc:83:58: note: 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
83 | for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:1473:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1473 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1473:5: note: template argument deduction/substitution failed:
a.cc:83:58: note: 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
83 | for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:1547:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1547 | operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1547:5: note: template argument deduction/substitution failed:
a.cc:83:58: note: 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
83 | for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:1647:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1647 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1647:5: note: template argument deduction/substitution failed:
a.cc:83:58: note: 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
83 | for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
/usr/include/c++/14/bits/regex.h:2213:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator!=(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
2213 | operator!=(const match_results<_Bi_iter, _Alloc>& __m1,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2213:5: note: template argument deduction/substitution failed:
a.cc:83:58: note: 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
83 | for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed:
a.cc:83:58: note: 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::pair<_T1, _T2>'
83 | for(map<ll,int>::iterator it=cnt.begin();it!=cnt.end();++it)
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
455 | operator!=(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed:
a.cc:83:58: note: 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<con
|
s068297128
|
p04022
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG_MODE
#define DBG(n) n;
#else
#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define EPS 1e-6
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
bool noPrime[100011];
int main(){
vector<int> primeList;
set<ll> primeSet;
for(int i = 2;i < 100011;i++){
if(!noPrime[i]){
primeList.PB(i);
primeSet.insert(i);
for(int j = i;j < 100011;j += i)noPrime[j] = true;
}
}
int n;cin >> n;
ll ans = 0;
vector<pair<ll,ll>> v;
REP(i,n){
ll s;cin >> s;
ll now = 1;
ll ref = 1;
for(int i = 0;primeList[i] <= 11111;i++){
int cou = 0;
while(s % primeList[i] == 0){
cou = (cou + 1) % 3;
s /= primeList[i];
}
if(cou){
REP(j,cou)now *= primeList[i];
REP(j,3-cou)ref *= primeList[i];
}
if(ref > 1e11)break;
}
if(ref * s * S > 1e11){
ans++;
}
else {
ll sq = sqrt(s);
if(sq*sq != s)v.PB(MP(now*s,ref*s*s));
else v.PB(MP(now*s,ref*sq));
}
}
set<ll> s;
REP(i,v.size()){
if(s.count(v[i].FI))continue;
s.insert(v[i].SE);
ans++;
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:62:30: error: 'S' was not declared in this scope
62 | if(ref * s * S > 1e11){
| ^
|
s385588793
|
p04022
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100005];
bool ex = false;
multiset<long long> s, ss;
map<long long, int> f;
int spf[100005];
const int MAXN = 100001;
void sieve() {
spf[1] = 1;
for (int i=2; i<=100000; i++)
spf[i] = i;
for (int i=4; i<MAXN; i+=2)
spf[i] = 2;
for (int i=3; i*i<MAXN; i++)
{
if (spf[i] == i)
{
for (int j=i*i; j<MAXN; j+=i)
if (spf[j]==j)
spf[j] = i;
}
}
}
long long get(long long x) {
long long ou = 1;
while (x != 1) {
ou *= spf[x];
x /= spf[x];
}
return ou;
}
long long p(long long n, long long k) {
return n*n*n;
}
signed main() {
sieve();
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%lld", &a[i]);
s.insert(a[i]);
}
for (int i = 1; 1ll*i*i*i <= 10000000000; i ++) {
if (s.find(1ll*i*i*i) != s.end()) {
ex = true;
s.erase(1ll*i*i*i);
ss.insert(1ll*i*i*i);
}
}
//cout << s.size() << endl;
int res = 0;
if (ex) res++;
for (int i = 1; i <= n; i++) {
if (ss.find(a[i]) != ss.end()) continue;
for (int j = 2154; j >= 1; j--) {
if (a[i] % (1ll*j*j*j) == 0) {
a[i] /= 1ll*j*j*j;
}
}
f[a[i]]++;
}
for (int i = 1; i <= n; i++) {
if (ss.find(a[i]) != ss.end()) continue;
//cout << a[i] << endl;
if (a[i] > 100000) {res += f[a[i]]; f[a[i]] = 0;};
else {
long long op = p(get(a[i]), 3)/a[i];
res += max(f[a[i]], f[op]);
f[op] = 0;
f[a[i]] = 0;
}
}
cout << res;
}
|
a.cc: In function 'int main()':
a.cc:76:17: error: 'else' without a previous 'if'
76 | else {
| ^~~~
|
s512800516
|
p04022
|
C++
|
#include<bits/stdc++.h>
const int N = 1e5 + 5;
using namespace std;
int n, ans;
long long a[N];
long long cal(long long x){
long long ans = 1;
for (long long i = 2; i * i <= x; i++){
if (x % i != 0) continue;
if (x % (i * i) == 0) ans *= i, x /= i * i;
else ans *= i * i, x /= i;
}
if (x != 1) ans *= x * x;
return ans;
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++){
for (long long j = 2; j * j * j <= a[i]; j++){
long long x = j * j * j;
while (a[i] % x == 0) a[i] /= x;
}
mymap[a[i]]++;
}
for (int i = 1; i <= n; i++){
if (mymap[a[i]] == 0) continue;
if (a[i] == 1) {ans++; mymap[1] = 0; continue;}
long long x = cal(a[i]);
ans += max(mymap[a[i]], mymap[x]), mymap[a[i]] = mymap[x] = 0;
}
cout << ans;
}
|
a.cc: In function 'int main()':
a.cc:28:9: error: 'mymap' was not declared in this scope
28 | mymap[a[i]]++;
| ^~~~~
a.cc:31:13: error: 'mymap' was not declared in this scope
31 | if (mymap[a[i]] == 0) continue;
| ^~~~~
a.cc:32:32: error: 'mymap' was not declared in this scope
32 | if (a[i] == 1) {ans++; mymap[1] = 0; continue;}
| ^~~~~
a.cc:34:20: error: 'mymap' was not declared in this scope
34 | ans += max(mymap[a[i]], mymap[x]), mymap[a[i]] = mymap[x] = 0;
| ^~~~~
|
s618412229
|
p04022
|
Java
|
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
class Main{
static void solve(){
int n = ni();
long[] s = nla(n);
boolean[] isPrime = new boolean[100001];
Arrays.fill(isPrime, true);
for(int i=2;i<=100000;++i){
if(!isPrime[i])continue;
for(int j=i*2;j<=100000;j+=i)isPrime[j]=false;
}
List<Integer> primes = new ArrayList<>();
for(int i=2;i<=100000;++i)if(isPrime[i])primes.add(i);
Set<Long> under1e5 = new HashSet<>();
for(int p: primes)under1e5.add((long)p);
under1e5.add(1L);
List<Long> cubep = new ArrayList<>();
for(int p : primes){
if((long)p*p*p>(long)1e10)break;
cubep.add((long)p);
}
Map<Long, Long> sqrMap = new HashMap<>();
for(long i=2;i*i<=10000000000L;++i)sqrMap.put(i*i, i);
Map<Long, Long> reve = new HashMap<>();
Map<Long , Integer> cnt = new HashMap<>();
int ans = 0;
boolean zero=true;
for(int i=0;i<n;++i){
long ss = s[i];
long rev = 1;
for(int k=0;k<cubep.size();++k){
long p= cubep.get(k);
while(s[i]%(p*p*p)==0)s[i]/=(p*p*p);
if(s[i]%p==0){
if(s[i]%(p*p)==0)rev*=p;
else rev*=p*p;
}
while(s[i]%p==0)s[i]/=p;
}
if(sqrSet.containsKey(s[i]))rev*=sqrMap.get(s[i]);
else rev*=(s[i]*s[i]);
if(rev==1){
if(zero)++ans;
zero=false;continue;
}
reve.put(ss, rev);
cnt.put(ss, cnt.getOrDefault(ss, 0)+1);
}
int ans2 = 0;
Set<Long> used = new HashSet<>();
for(Map.Entry<Long , Integer> entry: cnt.entrySet()){
if(used.contains(entry.getKey()))continue;
ans2 += Math.max(entry.getValue(), cnt.getOrDefault(reve.get(entry.getKey()), 0));
used.add(reve.get(entry.getKey()));
}
// out.println(ans+" "+ans2);
out.println(ans+ans2);
}
public static void main(String[] args){
solve();
out.flush();
}
private static InputStream in = System.in;
private static PrintWriter out = new PrintWriter(System.out);
private static final byte[] buffer = new byte[1<<15];
private static int ptr = 0;
private static int buflen = 0;
private static boolean hasNextByte(){
if(ptr<buflen)return true;
ptr = 0;
try{
buflen = in.read(buffer);
} catch (IOException e){
e.printStackTrace();
}
return buflen>0;
}
private static int readByte(){ if(hasNextByte()) return buffer[ptr++]; else return -1;}
private static boolean isSpaceChar(int c){ return !(33<=c && c<=126);}
private static int skip(){int res; while((res=readByte())!=-1 && isSpaceChar(res)); return res;}
private static double nd(){ return Double.parseDouble(ns()); }
private static char nc(){ return (char)skip(); }
private static String ns(){
StringBuilder sb = new StringBuilder();
for(int b=skip();!isSpaceChar(b);b=readByte())sb.append((char)b);
return sb.toString();
}
private static int[] nia(int n){
int[] res = new int[n];
for(int i=0;i<n;++i)res[i]=ni();
return res;
}
private static long[] nla(int n){
long[] res = new long[n];
for(int i=0;i<n;++i)res[i]=nl();
return res;
}
private static int ni(){
int res=0,b;
boolean minus=false;
while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-'));
if(b=='-'){
minus=true;
b=readByte();
}
for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0');
return minus ? -res:res;
}
private static long nl(){
long res=0,b;
boolean minus=false;
while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-'));
if(b=='-'){
minus=true;
b=readByte();
}
for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0');
return minus ? -res:res;
}
}
|
Main.java:46: error: cannot find symbol
if(sqrSet.containsKey(s[i]))rev*=sqrMap.get(s[i]);
^
symbol: variable sqrSet
location: class Main
1 error
|
s437307522
|
p04022
|
C++
|
#include <stdio.h>
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)
#define int ll
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;
ll need[N], waste[N];
ll a[N];
int n;
vector<int> pr;
bool is_prime(int x) {
for(int i = 2; 1ll * i * i <= x; i ++)
if(x % i == 0)
return 0;
return 1;
}
map<ll, int> square;
map<ll, set<int> > ne, wa;
set<ll> st;
main() {
cin >> n;
for(int i = 1; i <= n; i ++)
cin >> a[i];
for(int i = 1; i <= n; i ++) {
for(ll x = (int)3e3; x >= 1; x --) {
if(a[i] % (x * x * x) == 0) {
waste[i] = a[i] / (x * x * x);
break;
}
}
}
for(int x = 2; x <= (int)3e3; x ++) {
if(is_prime(x)) {
pr.pb(x);
}
}
for(int x = 1; x <= (int)1e5; x ++)
square[1ll * x * x] = x;
for(int i = 1; i <= n; i ++) {
ll tmp = a[i], tmp_need = 1;
for(int it = 0; it < sz(pr); it ++) {
int cnt = 0;
while(tmp % pr[it] == 0)
cnt ++, tmp /= pr[it];
cnt %= 3;
if(cnt == 1) tmp_need *= pr[it] * pr[it];
if(cnt == 2) tmp_need *= pr[it];
}
if(!square.count(tmp))
tmp_need *= tmp;
else
tmp_need *= square[tmp];
need[i] = tmp_need;
}
for(int i = 1; i <= n; i ++) {
ne[need[i]].insert(i), wa[waste[i]].insert(i);
st.insert(need[i]);
st.insert(waste[i]);
}
int res = 0;
for(auto x : st) {
if(x == 1) continue;
if(sz(ne[x]) > sz(wa[x])) res += sz(ne[x]);
else res += sz(wa[x]);
for(auto ind : ne[x])
if(waste[ind] != x)
wa[waste[ind]].erase(ind);
for(auto ind : wa[x])
if(ne[ind] != x)
ne[need[ind]].erase(ind);
}
if(sz(ne[1]) || sz(wa[1]))
res ++;
cout << res;
return 0;
}
|
a.cc:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
50 | main() {
| ^~~~
a.cc: In function 'int main()':
a.cc:103:28: error: no match for 'operator!=' (operand types are 'std::map<long long int, std::set<long long int> >::mapped_type' {aka 'std::set<long long int>'} and 'long long int')
103 | if(ne[ind] != x)
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:2:
/usr/include/c++/14/bits/regex.h:1132:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1132 | operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1132:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: 'std::map<long long int, std::set<long long int> >::mapped_type' {aka 'std::set<long long int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
103 | if(ne[ind] != x)
| ^
/usr/include/c++/14/bits/regex.h:1212:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1212 | operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1212:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: 'std::map<long long int, std::set<long long int> >::mapped_type' {aka 'std::set<long long int>'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
103 | if(ne[ind] != x)
| ^
/usr/include/c++/14/bits/regex.h:1305:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1305 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1305:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: 'std::map<long long int, std::set<long long int> >::mapped_type' {aka 'std::set<long long int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
103 | if(ne[ind] != x)
| ^
/usr/include/c++/14/bits/regex.h:1379:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1379 | operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1379:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int'
103 | if(ne[ind] != x)
| ^
/usr/include/c++/14/bits/regex.h:1473:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1473 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1473:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: 'std::map<long long int, std::set<long long int> >::mapped_type' {aka 'std::set<long long int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
103 | if(ne[ind] != x)
| ^
/usr/include/c++/14/bits/regex.h:1547:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1547 | operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1547:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int'
103 | if(ne[ind] != x)
| ^
/usr/include/c++/14/bits/regex.h:1647:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1647 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1647:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: 'std::map<long long int, std::set<long long int> >::mapped_type' {aka 'std::set<long long int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
103 | if(ne[ind] != x)
| ^
/usr/include/c++/14/bits/regex.h:2213:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator!=(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
2213 | operator!=(const match_results<_Bi_iter, _Alloc>& __m1,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2213:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: 'std::map<long long int, std::set<long long int> >::mapped_type' {aka 'std::set<long long int>'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
103 | if(ne[ind] != x)
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: 'std::map<long long int, std::set<long long int> >::mapped_type' {aka 'std::set<long long int>'} is not derived from 'const std::pair<_T1, _T2>'
103 | if(ne[ind] != x)
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
455 | operator!=(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: 'std::map<long long int, std::set<long long int> >::mapped_type' {aka 'std::set<long long int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
103 | if(ne[ind] != x)
| ^
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
500 | operator!=(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: 'std::map<long long int, std::set<long long int> >::mapped_type' {aka 'std::set<long long int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
103 | if(ne[ind] != x)
| ^
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1686 | operator!=(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: 'std::map<long long int, std::set<long long int> >::mapped_type' {aka 'std::set<long long int>'} is not derived from 'const std::move_iterator<_IteratorL>'
103 | if(ne[ind] != x)
| ^
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1753 | operator!=(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: 'std::map<long long int, std::set<long long int> >::mapped_type' {aka 'std::set<long long int>'} is not derived from 'const std::move_iterator<_IteratorL>'
103 | if(ne[ind] != x)
| ^
In file included from /usr/include/c++/14/bits/char_traits.h:42,
from /usr/include/c++/14/string:42,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)'
197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed:
a.cc:103:31: note: 'std::map<long long int, std::set<long long int> >::mapped_type' {aka 'std::set<long long int>'} is not derived from 'const std::fpos<_StateT>'
103 | if(ne[ind] != x)
| ^
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)'
243 | operator!=(const allocat
|
s559531146
|
p04022
|
C++
|
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <queue>
#include <map>
#include <ctime>
#include <unordered_map>
using namespace std;
typedef long long ll;
const int maxn=150000;
const ll MOD=1e9+7;
ll prime[maxn],tot;
bool isprime[maxn];
void get_prime(){
memset(isprime,true,sizeof isprime);
isprime[0]=isprime[1]=false;
for (ll i = 2; i < maxn; ++i)
{
if(!isprime[i]) continue;
prime[tot++]=i;
for (ll j = i*i; j < maxn; j+=i)
{
isprime[j]=false;
}
}
}
int n;
unordered_map<ll,int> mp;
unordered_map<ll,ll> rvs;
unordered_map<ll,bool> rvs;
ll L[maxn],R[maxn];
int main(int argc, char const *argv[])
{
get_prime();
scanf("%d", &n);
for (int i = 0; i < n; ++i)
{
ll x,y=1,z=1;
scanf("%lld", &x);
for (int j = 0; prime[j]*prime[j] <= x; ++j)
{
ll k=prime[j];
if(x%k==0){
int cnt=0;
while(x%k==0){
x/=k;
cnt++;
}
cnt%=3;
int tmp=(3-cnt)%3;
while(cnt--) y*=k;
while(tmp--){
z*=k;
if(z>1e10) z=0;
}
}
}
if(x>1){
y=y*x;
if(z*x>1e10 || z*x*x> 1e10) z=0;
z=z*x*x;
}
mp[y]++;
L[i]=y;
R[i]=z;
// rvs[y]=z;
// rvs[z]=y;
}
int ans=0;
for (int i = 0; i < n; ++i)
{
if(L[i]==1){
ans+=int(mp[1]>0);
mp[1]=0;
}
else if(vis.count(L[i])==0){
ans+=max(mp[L[i]],mp[R[i]]);
// mp[L[i]]=mp[R[i]]=0;
vis[L[i]]=vis[R[i]]=true;
}
}
printf("%d\n", ans);
return 0;
}
|
a.cc:32:24: error: conflicting declaration 'std::unordered_map<long long int, bool> rvs'
32 | unordered_map<ll,bool> rvs;
| ^~~
a.cc:31:22: note: previous declaration as 'std::unordered_map<long long int, long long int> rvs'
31 | unordered_map<ll,ll> rvs;
| ^~~
a.cc: In function 'int main(int, const char**)':
a.cc:79:17: error: 'vis' was not declared in this scope
79 | else if(vis.count(L[i])==0){
| ^~~
|
s100419812
|
p04022
|
C++
|
#include<bits/stdc++.h>
#define debug puts("&&&&&&&&")
#define read(x) scanf("%lld",&x)
using namespace std;
typedef long long LL;
const int maxn=1e5+5;
const int maxx=1e10+2;
LL a[maxn];
LL b[maxn];
LL n;
map<LL,int>ma;
LL sqr(LL a) {
return a*a;
}
int main() {
while(read(n) != EOF) {
ma.clear();
for(LL i=1;i<=n;i++) {
read(a[i]);
LL t=a[i];
for(LL j=2;j*j*j<=t;j++) {
while(t%(j*j*j)==0) {
t/=(j*j*j);
}
}
ma[t]++,a[i]=t;
LL ans=1;
for(LL j=2;j*j*j<=t;j++) {
if(t%j==0) {
if(t%j*j==0) {
ans*=j;
}
else {
ans*=j*j;
}
while(t%j==0) {
t/=j;
}
}
}
LL d=sqrt(t);
if (sqr((LL)sqrt(t))==t) y*=(LL)sqrt(t);
else ans*=t*t;
b[i]=ans;
}
LL ans=0;
if(ma[1]){ans++;
ma[1]=0;}
for(int i=1;i<=n;i++) {
ans+=max(ma[a[i]],ma[b[i]]);
ma[a[i]]=ma[b[i]]=0;
}
cout<<ans<<endl;
}
return 0;
}
|
a.cc:7:20: warning: overflow in conversion from 'double' to 'int' changes value from '1.0000000002e+10' to '2147483647' [-Woverflow]
7 | const int maxx=1e10+2;
| ~~~~^~
a.cc: In function 'int main()':
a.cc:42:38: error: 'y' was not declared in this scope
42 | if (sqr((LL)sqrt(t))==t) y*=(LL)sqrt(t);
| ^
|
s387517654
|
p04022
|
C++
|
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
long long n;
long long a[(1<<20)], f[(1<<20)];
vector < long long > prs;
pair < long long, long long > vals[(1<<20)];
map < long long, long long > cnt;
pair< long long, long long > gg ( long long x ) {
long long a = 1, b = 1;
for ( int i = 0 ; prs[i]*prs[i] <= x ; i ++ ) {
if ( x%prs[i] == 0 ) {
int cnt = 0;
for ( ; x%prs[i] == 0 ; cnt ++ ) {
x /= prs[i];
}
cnt %= 3;
for ( int c = 0 ; c < cnt ; c ++ ) { a *= prs[i]; }
cnt = (3-cnt)%3;
for ( int c = 0 ; c < cnt ; c ++ ) { b *= prs[i]; }
}
}
if ( x != 1 ) {
a *= x;
b *= x*x;
}
return make_pair( a, b );
}
int main () {
for( long long i = 2 ; i*i < (10000000000LL) ; i ++ ) {
if ( f[i] == 0 ) {
prs.push_back( i );
for ( long long j = 1; i*i*j*j < (10000000000LL) ; j ++ ) {
f[i*j] = 1;
}
}
}
cin >> n;
for ( long long i = 0 ; i < n ; i ++ ) {
cin >> a[i];
vals[i] = gg( a[i] );
cnt[ vals[i].first ] ++;
}
sort ( vals, vals+n );
long long ans = 0;
for ( long long i = 0 ; i < n ; ) {
long long j = i;
for ( ; j < n && vals[i].first == vals[j].first ; j ++ ) {}
long long ccnt = j-i, revcnt = cnt[ vals[i].second ];
if ( vals[i].first == 1 ) { ans ++; }
else {
if ( ccnt > revcnt ) {
ans += ccnt;
}else if ( ccnt < revcnt ) {
//ans += revcnt;
}else {
if ( vals[i].first < vals[i].second ) {
ans += ccnt;
}
}
}
i = j;
}
cout << ans << "\n";
return 0;
}
|
a.cc:8:1: error: 'vector' does not name a type
8 | vector < long long > prs;
| ^~~~~~
a.cc: In function 'std::pair<long long int, long long int> gg(long long int)':
a.cc:16:23: error: 'prs' was not declared in this scope
16 | for ( int i = 0 ; prs[i]*prs[i] <= x ; i ++ ) {
| ^~~
a.cc: In function 'int main()':
a.cc:42:13: error: 'prs' was not declared in this scope
42 | prs.push_back( i );
| ^~~
|
s462103071
|
p04022
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int n;
vector<__int128_t> s, t;
void init() {
map<__int128_t, __int128_t> mp;
vector<int> prime;
bool f[101010];
memset(f, true, sizeof f);
f[0] = f[1] = false;
for (int i = 2; i <= 100000; ++i) {
if (f[i]) {
if (i < 2200) prime.push_back(i);
mp[i * i] = i;
for (int j = 2 * i; j <= 100000; j += i) {
f[j] = false;
}
}
}
for (int i = 0; i < n; ++i) {
__int128_t m;
cin >> m;
__int128_t a, b;
a = b = 1;
for (auto &p : prime) {
int cnt = 0;
while (m % p == 0) {
++cnt;
m /= p;
}
cnt %= 3;
for (int j = 0; j < cnt; ++j) a *= p;
for (int j = (3 - cnt) % 3; j > 0; --j) b *= p;
}
if (mp.count(m)) {
a *= mp[m];
b *= m;
} else {
a *= m * m;
b *= m;
}
s.push_back(a);
t.push_back(b);
}
}
int main() {
cin >> n;
init();
map<__int128_t, int> mp;
map<__int128_t, __int128_t> po;
for (int i = 0; i < n; ++i) {
mp[s[i]]++;
po[s[i]] = t[i];
}
int ans = n;
for (auto &i : mp) {
if (i.first == 1) {
ans -= i.second - 1;
continue;
}
__int128_t uku = po[i.first];
if (mp.count(uku) && uku < i.first) {
ans -= min(mp[uku], i.second);
}
}
cout << ans << endl;
}
|
a.cc: In function 'void init()':
a.cc:26:9: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__int128')
26 | cin >> m;
| ~~~ ^~ ~
| | |
| | __int128
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type '__int128'
26 | cin >> m;
| ^
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type '__int128'
26 | cin >> m;
| ^
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type '__int128'
26 | cin >> m;
| ^
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: cannot bind non-const lvalue reference of type 'int&' to a value of type '__int128'
26 | cin >> m;
| ^
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type '__int128'
26 | cin >> m;
| ^
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type '__int128'
26 | cin >> m;
| ^
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type '__int128'
26 | cin >> m;
| ^
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type '__int128'
26 | cin >> m;
| ^
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type '__int128'
26 | cin >> m;
| ^
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: cannot bind non-const lvalue reference of type 'float&' to a value of type '__int128'
26 | cin >> m;
| ^
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: cannot bind non-const lvalue reference of type 'double&' to a value of type '__int128'
26 | cin >> m;
| ^
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type '__int128'
26 | cin >> m;
| ^
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: invalid conversion from '__int128' to 'void*' [-fpermissive]
26 | cin >> m;
| ^
| |
| __int128
a.cc:26:12: error: cannot bind rvalue '(void*)((long int)m)' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: invalid conversion from '__int128' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
26 | cin >> m;
| ^
| |
| __int128
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match)
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:7: note: conversion of argument 1 would be ill-formed:
a.cc:26:12: error: invalid conversion from '__int128' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} [-fpermissive]
26 | cin >> m;
| ^
| |
| __int128
/usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
133 | operator>>(ios_base& (*__pf)(ios_base&))
| ^~~~~~~~
/usr/include/c++/14/istream:133:7: note: conversion of argument 1 would be ill-formed:
|
s100939553
|
p04022
|
C++
|
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}
template<class T> using V = vector<T>;
ll gcd(ll _a, ll _b) {
ull a = abs(_a), b = abs(_b);
while (b) {
swap(a, b);
b %= a;
}
return a;
}
/// g:gcd(a, b), ax+by=g
struct EG { ll g, x, y; };
EG ext_gcd(ll a, ll b) {
if (b==0) {
if (a >= 0) return EG{a, 1, 0};
else return EG{-a, -1, 0};
} else {
auto e = ext_gcd(b, a%b);
return EG{e.g, e.y, e.x-a/b*e.y};
}
}
ll inv_mod(ll x, ll md) {
auto z = ext_gcd(x, md).x;
return (z % md + md) % md;
}
template<class T, class U>
T pow_mod(T x, U n, T md) {
T r = 1 % md;
x %= md;
while (n) {
if (n & 1) r = (r * x) % md;
x = (x * x) % md;
n >>= 1;
}
return r;
}
bool is_prime(ll n) {
if (n <= 1) return false;
if (n == 2) return true;
if (n % 2 == 0) return false;
ll d = n-1;
while (d % 2 == 0) d /= 2;
vector<ll> alist{2,3,5,7,11,13,17,19,23,29,31,37}; // n < 2^64
for (ll a: alist) {
if (n <= a) break;
ll t = d;
ll y = pow_mod<__int128_t>(a, t, n); //over
while (t != n-1 && y != 1 && y != n-1) {
y = __int128_t(y)*y % n; //flow
t <<= 1;
}
if (y != n-1 && t % 2 == 0) {
return false;
}
}
return true;
}
ll pollard_single(ll n){
auto f = [](ll x){ return (__int128_t(x)*x + 1) % n; };
if (is_prime(n)) return n;
if (n % 2 == 0) return 2;
ll st = 0;
while (true) {
st++;
ll x = st, y = st;
while (true) {
x = f(x);
y = f(f(y));
ll p = gcd((y-x+n), n);
if (p == 0 || p == n) break;
if (p != 1) return p;
}
}
}
V<ll> pollard(ll n) {
if (n == 1) return {};
ll x = pollard_single(n);
if (x == n) return {x};
V<ll> le = pollard(x);
V<ll> ri = pollard(n/x);
le.insert(end(le), begin(ri), end(ri));
return le;
}
ll mul(ll a, ll b) {
if (TEN(12)/a < b) return TEN(12);
return a*b;
}
int main() {
using P = pair<ll, ll>;
map<ll, P> g;
int n;
scanf("%d", &n);
bool one = false;
for (int i = 0; i < n; i++) {
ll s;
scanf("%lld", &s);
auto facv = pollard(s);
map<ll, int> fac;
for (auto d: facv) fac[d]++;
// map<ll, int> fac = pr.fact(s);
ll d0 = 1, d1 = 1;
for (auto p: fac) {
p.second %= 3;
if (p.second == 1) {
d0 = mul(d0, p.first);
d1 = mul(d1, p.first);
d1 = mul(d1, p.first);
} else if (p.second == 2) {
d0 = mul(d0, p.first);
d0 = mul(d0, p.first);
d1 = mul(d1, p.first);
}
}
if (d0 == 1) {
one = true;
continue;
}
if (d0 < d1) {
g[d0].first++;
} else {
g[d1].second++;
}
}
int ans = 0;
for (auto p: g) {
ans += max(p.second.first, p.second.second);
}
cout << ans + (one ? 1 : 0) << endl;
return 0;
}
|
a.cc: In lambda function:
a.cc:85:55: error: 'n' is not captured
85 | auto f = [](ll x){ return (__int128_t(x)*x + 1) % n; };
| ^
a.cc:85:15: note: the lambda has no capture-default
85 | auto f = [](ll x){ return (__int128_t(x)*x + 1) % n; };
| ^
a.cc:84:22: note: 'll n' declared here
84 | ll pollard_single(ll n){
| ~~~^
|
s708166434
|
p04022
|
C++
|
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}
template<class T> using V = vector<T>;
struct Prime {
int n;
vector<bool> used;
vector<int> pr;
vector<ull> bpr;
Prime(int n) : n(n) {
used = vector<bool>(n+1, false);
for (int i = 2; i <= n; i++) {
if (used[i]) continue;
pr.push_back(i);
bpr.push_back(((__int128(1)<<64)+i-1) / i);
for (int j = 2*i; j <= n; j += i) {
used[j] = true;
}
}
}
map<ll, int> fact(ll x) {
assert(x <= (ll)n*n);
int pc = (int)pr.size();
map<ll, int> mp;
for (int i = 0; i < pc; i++) {
ll d = pr[i]; ull rd = bpr[i];
// if (x < d*d) break; 枝刈り
while (true) {
ll xd = __int128(x)*rd >> 64;
if (xd * d != x) break;
x = xd;
mp[d]++;
}
}
if (x > 1) mp[x]++;
return mp;
}
};
template<class T>
T gcd(T a, T b) {
// a = abs(a); b = abs(b);
if (b == 0) return a;
return gcd(b, a%b);
}
template<class T, class U>
T pow_mod(T x, U n, T md) {
assert(n>=0);
x %= md;
T r = 1 % md;
while (n) {
if (n & 1) r = (r * x) % md;
x = (x * x) % md;
n >>= 1;
}
return r;
}
/// g:gcd(a, b), ax+by=g
template<class T> struct EG { T g, x, y; };
template<class T>
EG<T> ext_gcd(T a, T b) {
if (b==0) {
if (a >= 0) return EG<T>{a, 1, 0};
else return EG<T>{-a, -1, 0};
} else {
auto e = ext_gcd<T>(b, a%b);
return EG<T>{e.g, e.y, e.x-a/b*e.y};
}
}
template<class T>
T inv_mod(T x, T md) {
auto r = ext_gcd(x, md);
auto z = r.x;
return (z % md + md) % md;
}
bool isPrime(ll n) {
if (n <= 1) return false;
if (n == 2) return true;
if (n % 2 == 0) return false;
ll d = n-1;
while (d % 2 == 0) d /= 2;
vector<ll> alist{2,3,5,7,11,13,17,19,23,29,31,37}; // n < 2^64
for (ll a: alist) {
if (n <= a) break;
ll t = d;
ll y = pow_mod<__int128>(a, t, n); //over
while (t != n-1 && y != 1 && y != n-1) {
y = __int128(y)*y % n; //flow
t <<= 1;
}
if (y != n-1 && t % 2 == 0) {
return false;
}
}
return true;
}
ll f(ll x, ll n) { return __int128_t(x)*x % n + 1 % n; }
ll pollard_single(ll n){
ll i,x,y,p;
if(isPrime(n)) return n;
if(!(n&1)) return 2;
for(i=1;i<40;i++){
x=i; y=f(x,n); p=gcd(y-x,n);
while(p==1) {x=f(x,n); y=f(f(y,n),n); p=gcd((y-x+n)%n,n)%n;}
if(p==0||p==n) continue;
return p;
}
assert(false);
}
#include <inttypes.h>
#define nelems(x) (sizeof(x) / sizeof((x)[0]))
const int multiplier[] = {1, 3, 5, 7, 11, 3*5, 3*7, 3*11, 5*7, 5*11, 7*11, 3*5*7, 3*5*11, 3*7*11, 5*7*11, 3*5*7*11};
uint64_t SQUFOF( uint64_t N )
{
if (isPrime(N)) return N;
if (N % 2 == 0) return 2;
if (N % 3 == 0) return 3;
if (N % 5 == 0) return 5;
if (N % 7 == 0) return 7;
if (N % 11 == 0) return 11;
uint64_t D, Po, P, Pprev, Q, Qprev, q, b, r, s;
uint32_t L, B, i;
s = (uint64_t)(sqrtl(N)+0.5);
if (s*s == N) return s;
for (int k = 0; k < nelems(multiplier) && N <= UINT64_MAX/multiplier[k]; k++) {
D = multiplier[k]*N;
Po = Pprev = P = sqrtl(D);
Qprev = 1;
Q = D - Po*Po;
L = 2 * sqrtl( 2*s );
B = 3 * L;
for (i = 2 ; i < B ; i++) {
b = (uint64_t)((Po + P)/Q);
P = b*Q - P;
q = Q;
Q = Qprev + b*(Pprev - P);
r = (uint64_t)(sqrtl(Q)+0.5);
if (!(i & 1) && r*r == Q) break;
Qprev = q;
Pprev = P;
};
if (i >= B) continue;
b = (uint64_t)((Po - P)/r);
Pprev = P = b*r + P;
Qprev = r;
Q = (D - Pprev*Pprev)/Qprev;
i = 0;
do {
b = (uint64_t)((Po + P)/Q);
Pprev = P;
P = b*Q - P;
q = Q;
Q = Qprev + b*(Pprev - P);
Qprev = q;
i++;
} while (P != Pprev);
r = gcd(N, Qprev);
if (r != 1 && r != N) return r;
}
return pollard_single(n);
// cout << "UNTI-KONG" << endl;
// exit(0);
// return 0;
}
V<ll> pollard(ll n) {
if (n == 1) return {};
ll x;
// x = pollard_single(n);
x = SQUFOF(n);
if (x == n) return {x};
V<ll> le = pollard(x);
V<ll> ri = pollard(n/x);
for (ll d: ri) le.push_back(d);
return le;
}
const int MP = 100100;
ll mul(ll a, ll b) {
if (TEN(12)/a < b) return TEN(12);
return a*b;
}
int main() {
Prime pr(MP);
using P = pair<ll, ll>;
map<ll, P> g;
int n;
scanf("%d", &n);
bool one = false;
for (int i = 0; i < n; i++) {
ll s;
scanf("%lld", &s);
auto facv = pollard(s);
map<ll, int> fac;
for (auto d: facv) fac[d]++;
// map<ll, int> fac = pr.fact(s);
ll d0 = 1, d1 = 1;
for (auto p: fac) {
p.second %= 3;
if (p.second == 1) {
d0 = mul(d0, p.first);
d1 = mul(d1, p.first);
d1 = mul(d1, p.first);
} else if (p.second == 2) {
d0 = mul(d0, p.first);
d0 = mul(d0, p.first);
d1 = mul(d1, p.first);
}
}
if (d0 == 1) {
one = true;
continue;
}
if (d0 < d1) {
g[d0].first++;
} else {
g[d1].second++;
}
}
int ans = 0;
for (auto p: g) {
ans += max(p.second.first, p.second.second);
}
cout << ans + (one ? 1 : 0) << endl;
return 0;
}
|
a.cc: In function 'uint64_t SQUFOF(uint64_t)':
a.cc:190:27: error: 'n' was not declared in this scope
190 | return pollard_single(n);
| ^
|
s198932609
|
p04022
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int lint;
map <lint, int> Map;
int main()
{
ios_base :: sync_with_stdio(false);
int N;
cin >> N;
while (N --) {
lint nr;
cin >> nr;
for (int i = 2200; i; -- i) {
const lint cube = (1LL * i * i * i);
if (nr % cube == 0) {
nr /= cube;
break;
}
}
++ Map[nr];
}
int ans = 0;
for (const auto it: Map) {
lint nr = it.first;
lint minimum = 1E9 + 15;
for (int i = 1; i <= 2200; ++ i) {
const lint cube = (1LL * i * i * i);
if (cube % nr == 0)
minimum = min(minimum, cube / nr);
}
if (minimum == nr && Map[nr])
++ ans, Map[nr] = 0;
else if (minimum < 1E9 + 10) {
ans += max(Map[nr], Map[minimum]);
Map[nr] = 0;
if (Map.count(minim))
Map[minimum] = 0;
}
else
ans += Map[nr];
}
cout << ans << '\n';
return 0;
}
|
a.cc: In function 'int main()':
a.cc:42:27: error: 'minim' was not declared in this scope; did you mean 'minimum'?
42 | if (Map.count(minim))
| ^~~~~
| minimum
|
s112708782
|
p04022
|
C++
|
#include <cstdio>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define iter(i, n) for (int i = 1; i <= n; ++i)
#define forw(i, a, b) for (int i = a; i <= b; ++i)
typedef long long i64;
unordered_map<i64, int> mp;
unordered_map<i64, i64> inv;
#define fi first
#define se second
const int N = 2200;
bool vp[N + 10];
int p[N / 5], psz, n;
void sieve(int N) {
forw(i, 2, N) {
if (!vp[i]) p[++psz] = i;
for (int j = 1; j <= psz && i * p[j] <= N; ++j) {
vp[i * p[j]] = true;
if (i % p[j] == 0) break;
}
}
}
int main() {
//freopen("3D.in", "r", stdin);
scanf("%d", &n);
sieve(N);
iter(i, n) {
i64 a;
scanf("%lld", &a);
i64 s = 1, v = 1;
for (int j = 1; j <= psz && a >= p[j]; ++j) if (a % p[j] == 0) {
int c = 0;
for (; a % p[j] == 0; a /= p[j]) ++c;
c %= 3;
if (c == 1) s *= p[j], v *= p[j] * p[j];
else if (c == 2) s *= p[j] * p[j], v *= p[j];
}
if (a != 1) {
i64 q = sqrt(a);
if (q * q == a) s *= q * q, v *= q;
else {
if (log(v) + log(a) + log(a) > 11) s *= a, v = -1;
else s *= a, v *= a * a;
}
}
//printf("%lld %lld\n", s, v);
++mp[s]; inv[s] = v;
}
int ans = 0;
for (auto p : mp) {
i64 v = inv[p.fi];
if (p.fi == 1) {
++ans;
} else {
if (mp.find(v) == mp.end()) ans += p.se;
else if (p.fi < v) ans += max(p.se, mp[v]);
}
}
printf("%d\n", ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:48:33: error: 'sqrt' was not declared in this scope
48 | i64 q = sqrt(a);
| ^~~~
a.cc:51:37: error: 'log' was not declared in this scope; did you mean 'long'?
51 | if (log(v) + log(a) + log(a) > 11) s *= a, v = -1;
| ^~~
| long
|
s566830032
|
p04022
|
C++
|
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int maxn=2160;
bool flag[maxn];
int pri[maxn],t;
void pre()
{
memset(flag,0,sizeof(flag));
t=0;
for(int i=2;i<maxn;i++)
{
if(!flag[i]){
pri[t++]=i;
}
for(int j=0;j<t&&i*pri[j]<maxn;j++)
{
flag[i*pri[j]]=1;
if(i%pri[j]==0) break;
}
}
}
long long shit[100005];
bool vis[100005];
map<long long,int> mp;
long long q[100005];
long long now[100005];
bool deal(long long num,int id)
{
now[id]=1;
q[id]=1;
for(int i=0;i<t;i++)
{
if(num%pri[i]==0){
int cnt=0;
while(num%pri[i]==0){
num=num/pri[i];
cnt++;
}
cnt=cnt%3;
if(cnt){
for(int j=1;j<=cnt;j++)
now[id]=now[id]*pri[i];
for(int j=1;j<=3-cnt;j++)
q[id]=q[id]*pri[i];
}
}
if(num==1) break;
}
if(num==1) {
mp[now[id]]++;return 0;
}
long long t=(long long)sqrtl(1.0*num);
if(t*t==num){
q[id]=q[id]*t;
now[id]=now[id]*t*t;
mp[now[id]]++;return 0;
}
else if((t-1)*(t-1)==num){
q[id]=q[id]*(t-1);
now[id]=now[id]*(t-1)*(t-1);
mp[now[id]]++;return 0;
}
else if((t+1)*(t+1)==num){
q[id]=q[id]*(t+1);
now[id]=now[id]*(t+1)*(t+1);
mp[now[id]]++;return 0;
}
else if(num<1000000){
now[id]=now[id]*num;
q[id]=q[id]*num*num;
mp[now[id]]++;return 0;
}
else{
return 1;
}
}
int main()
{
pre();
int n;
scanf("%d",&n);
int ans=0;
memset(vis,0,sizeof(vis));
for(int i=1;i<=n;i++)
{
scanf("%d",shit+i);
vis[i]=deal(shit[i],i);
ans=ans+vis[i];
// printf("%d %d-----\n",shit[i],vis[i]);
// printf("%lld %lld\n",now[i],q[i]);
}
bool ss=0;
for(int i=1;i<=n;i++)
{
if(vis[i]) continue;
int num=mp[now[i]];
//printf("%d %dkk %d %d\n",i,ans,num,q[i]);
if(num==0) continue;
mp[now[i]]=0;
if(now[i]==1){
ans++;
}
else{
map<long long, int>::iterator iter = mp.find(q[i]);
if (iter == M.end())
{
ans += num;
continue;
}
num=max(num,iter->second);
ans+=num;
iter->second=0;
}
}
printf("%d\n",ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:106:25: error: 'M' was not declared in this scope
106 | if (iter == M.end())
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.