submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s106388008
p03682
C++
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <stack> #include <queue> #include <cstdlib> #include <cstdio> #include <string> #include <cstring> using namespace std; static const long long INF = 200000; #define N 100000 struct POINT { int x; int y; }; int n; POINT p[N]; long long cost[N + 1][N + 1]; int d[N + 1][N + 1]; int main() { cin >> n; for ( int i = 0; i < n; i++ ) { cin >> p[i].x >> p[i].y; } for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { cost[i][j] = INF; } } for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { if ( i == j ) continue; cost[i][j] = min(abs(p[i].x - p[j].x), abs(p[i].y - p[j].y)); } } for ( int k = 0; k < n; k++ ) { for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } long long ans = 0; int minc = INF; for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { int tmp = d[i][j]; minc = min(tmp, minc); } ans += minc; } cout << ans << endl; return 0; }
/tmp/ccU1HuA2.o: in function `main': a.cc:(.text+0x22e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccU1HuA2.o a.cc:(.text+0x255): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccU1HuA2.o a.cc:(.text+0x281): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccU1HuA2.o a.cc:(.text+0x2ba): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccU1HuA2.o a.cc:(.text+0x33b): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccU1HuA2.o collect2: error: ld returned 1 exit status
s495059666
p03682
C++
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <stack> #include <queue> #include <cstdlib> #include <cstdio> #include <string> #include <cstring> using namespace std; static const long long INF = 200000; #define N 100000 struct POINT { int x; int y; }; int n; POINT p[N]; long long cost[N + 1][N + 1]; int d[N + 1][N + 1]; int main() { cin >> n; for ( int i = 0; i < n; i++ ) { cin >> p[i].x >> p[i].y; } for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { cost[i][j] = INF; } } for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { if ( i == j ) continue; cost[i][j] = min(abs(p[i].x - p[j].x), abs(p[i].y - p[j].y)); } } for ( int k = 0; k < n; k++ ) { for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } long long ans = 0; int minc = INF; for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { int tmp = d[i][j]; minc = min(tmp, minc); } ans += minc; } cout << ans << endl; return 0; }
/tmp/ccvnl5A8.o: in function `main': a.cc:(.text+0x22e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvnl5A8.o a.cc:(.text+0x255): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvnl5A8.o a.cc:(.text+0x281): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvnl5A8.o a.cc:(.text+0x2ba): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvnl5A8.o a.cc:(.text+0x33b): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccvnl5A8.o collect2: error: ld returned 1 exit status
s276855421
p03682
C++
#include <bits/stdc++.h> using namespace std; #define REP(i, s, n) for (int i = s; i < n; ++i) #define rep(i, n) REP(i, 0, n) #define SORT(c) sort((c).begin(), (c).end()) #define IINF INT_MAX #define LLINF LLONG_MAX #define DEBUG false #define MAX_V 100 #define INF INT_MAX struct city { int x, y, num; }; int cost[100000][100000]; int mincost[100000]; bool used[100000]; int V; int prim(){ for(int i=0;i<V;i++){ mincost[i]=INF; used[i]=false; } mincost[0]=0; int res=0; while(true){ int v=-1; for(int u=0;u<V;u++){ if(!used[u] && (v==-1 || mincost[u] <mincost[v] )) v=u; } if(v==-1) break; used[v]=true; res+=mincost[v]; for(int u=0;u<V;u++){ mincost[u]=min(mincost[u],cost[v][u]); } } return res; } bool sortfirst(const city &left, const city &right) { if (left.x == right.x) { if (left.y == right.y) { return left.num < right.num; } else { return left.y < right.y; } } else { return left.x < right.x; } } bool sortsecond(const city &left, const city &right) { if (left.y == right.y) { if (left.x == right.x) { return left.num < right.num; } else { return left.x < right.x; } } else { return left.y < right.y; } } int main() { int n; cin >> n; V=n; vector<city> v(n); rep(i, n) { cin >> v[i].x >> v[i].y ; v[i].num=i; } sort(v.begin(), v.end(), sortfirst); rep(i,n-1){ cost[v[i].x][v[i].y]=min(v[i+1].x-v[1].x,v[i+1].y-v[1].y); cost[v[i].y][v[i].x]=cost[v[i].x][v[i].y]; } sort(v.begin(), v.end(), sortsecond); rep(i,n-1){ cost[v[i].x][v[i].y]=min(v[i+1].x-v[1].x,v[i+1].y-v[1].y); cost[v[i].y][v[i].x]=cost[v[i].x][v[i].y]; } cout<<prim()<<endl; }
/tmp/ccBbkTzU.o: in function `prim()': a.cc:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccBbkTzU.o a.cc:(.text+0x34): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccBbkTzU.o a.cc:(.text+0x42): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccBbkTzU.o a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccBbkTzU.o a.cc:(.text+0x74): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccBbkTzU.o a.cc:(.text+0x99): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccBbkTzU.o a.cc:(.text+0xb0): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccBbkTzU.o a.cc:(.text+0xc7): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccBbkTzU.o a.cc:(.text+0xe2): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccBbkTzU.o a.cc:(.text+0xfa): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccBbkTzU.o a.cc:(.text+0x144): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s248109022
p03682
C
#include <iostream> using namespace std; #define FOR(i, j, k) for(int i = j; i < k; ++i) #define rep(i, j) FOR(i, 0, j) #define FORr(i, j, k) for(int i = j; i >= k; --i) #define repr(i, j) FOR(i, j, 0) #define INF (1 << 30) #define ft first #define sd second typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; typedef pair<P, int> Pi; const int MOD = 1e9 + 7; const int dy[]={0, 0, 1, -1}; const int dx[]={1, -1, 0, 0}; template <class T> void chmin(T& a, const T& b) { a = min(a, b); } template <class T> void chmax(T& a, const T& b) { a = max(a, b); } P p[100000]; bool went[100000]; int main() { int N; scanf("%d", &N); int i, j; ll ans = 0; for(i = 0; i < N; ++i) scanf("%lld %lld", &p[i].ft, &p[i].sd); for(i = 0; i < N - 1; ++i) { int latte = INF; for(j = 0; j < N; ++j) { if(i == j || went[i]) continue; int tmp = min(abs(p[i].ft - p[j].ft), abs(p[i].sd - p[j].sd)); if(tmp < latte) { latte = tmp; } } went[i] = true; ans += latte; } printf("%lld\n", ans); return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s377960674
p03682
C++
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <numeric> #include <utility> #include <sys/time.h> #include <cmath> using namespace std; struct UnionFind { vector<int> par; vector<int> sizes; UnionFind(int n) : par(n), sizes(n, 1) { for (int i = 0; i < n; i++) { par[i] = i; } } int find(int x) { if (x == par[x]) return x; return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (sizes[x] < sizes[y]) swap(x, y); par[y] = x; sizes[x] += sizes[y]; } bool same(int x, int y) { return find(x) == find(y); } int size(int x) { return sizes[find(x)]; } }; bool xord(pair< int, pair<int, int> > v1, pair< int, pair<int, int> >v2) { return v1.second.first < v2.second.first; } bool yord(pair< int, pair<int, int> > v1, pair< int, pair<int, int> >v2) { return v1.second.second < v2.second.second; } void solve(int n, vector< pair< int, pair<int, int> > > V) { vector< pair<int, pair <int, int> > > E; vector< pair<int, pair<int, int> > > V1(n) = V; vector< pair<int, pair<int, int> > > V2(n) = V; sort(V1.begin, V1.end, xord) sort(V2.begin, V2.end, yord) for (int i = 0; i < n-1; i++) { pair<int, pair <int, int> > = tmp; tmp.first = V1[i+1].second.first - V1[i].second.first; tmp.second.first = V1[i].first; tmp.second.second = V1[i+1].first; E.push_back(tmp); } for (int i = 0; i < n-1; i++) { pair<int, pair <int, int> > = tmp; tmp.first = V2[i+1].second.first - V2[i].second.first; tmp.second.first = V2[i].first; tmp.second.second = V2[i+1].first; E.push_back(tmp); } sort(E.begin(), E.end()); int min_cost = 0; UnionFind uf(n); for (int i = 0; i < E.size(); i++) { if (!uf.same(E.second.first, E.second.second)) { min_cost += e.cost; uf.unite(E.second.first, E.second.second); } } std::cout << min_cost << std::endl; } int main() { struct timeval start,end; long long span; int n; gettimeofday(&start,NULL); std::cin >> n; vector< pair<int, pair<int, int> > > V(n); for (int i = 0; i < n; i++) { V[i].first = i; std::cin >> V[i].second.first >> V[i].second.second; } solve(n, V); gettimeofday(&end,NULL); span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec); std::cerr << "--Total Time: " << span/1000 << "ms" << endl; return 0; }
a.cc: In function 'void solve(int, std::vector<std::pair<int, std::pair<int, int> > >)': a.cc:54:48: error: expected ',' or ';' before '=' token 54 | vector< pair<int, pair<int, int> > > V1(n) = V; | ^ a.cc:55:48: error: expected ',' or ';' before '=' token 55 | vector< pair<int, pair<int, int> > > V2(n) = V; | ^ a.cc:56:9: error: no matching function for call to 'sort(<unresolved overloaded function type>, <unresolved overloaded function type>, bool (&)(std::pair<int, std::pair<int, int> >, std::pair<int, std::pair<int, int> >))' 56 | sort(V1.begin, V1.end, xord) | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)' 4762 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last) | ^~~~ /usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate expects 2 arguments, 3 provided /usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)' 4793 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:4793:5: note: template argument deduction/substitution failed: a.cc:56:9: note: couldn't deduce template parameter '_RAIter' 56 | sort(V1.begin, V1.end, xord) | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)' 292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate expects 4 arguments, 3 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)' 296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: template argument deduction/substitution failed: a.cc:56:9: note: couldn't deduce template parameter '_ExecutionPolicy' 56 | sort(V1.begin, V1.end, xord) | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~ a.cc:58:21: error: 'i' was not declared in this scope 58 | for (int i = 0; i < n-1; i++) { | ^ a.cc:66:37: error: expected unqualified-id before '=' token 66 | pair<int, pair <int, int> > = tmp; | ^ a.cc:67:9: error: 'tmp' was not declared in this scope; did you mean 'tm'? 67 | tmp.first = V2[i+1].second.first - V2[i].second.first; | ^~~ | tm a.cc:76:24: error: 'class std::vector<std::pair<int, std::pair<int, int> > >' has no member named 'second' 76 | if (!uf.same(E.second.first, E.second.second)) { | ^~~~~~ a.cc:76:40: error: 'class std::vector<std::pair<int, std::pair<int, int> > >' has no member named 'second' 76 | if (!uf.same(E.second.first, E.second.second)) { | ^~~~~~ a.cc:77:25: error: 'e' was not declared in this scope 77 | min_cost += e.cost; | ^ a.cc:78:24: error: 'class std::vector<std::pair<int, std::pair<int, int> > >' has no member named 'second' 78 | uf.unite(E.second.first, E.second.second); | ^~~~~~ a.cc:78:40: error: 'class std::vector<std::pair<int, std::pair<int, int> > >' has no member named 'second' 78 | uf.unite(E.second.first, E.second.second); | ^~~~~~
s431845294
p03682
C++
#include<iostream> #include<algorithm> #include<cmath> using namespace std; #define min(a,b)(a>b ? b:a) void Swap(int*a,int*b){ long long int temp=*a; *a=*b; *b=temp; } int main(){ int n=0; cin>>n; int data[100000][2]; for(int i=0;i<n;i++){ cin>>data[i][0]>>data[i][1]; } for(int i=0;i<n;i++){ int k=i; for(int j=i+1;j<n;j++){ if(data[k][0]>data[j][0]){ k=j; } } Swap(&data[k][0],&data[i][0]); Swap(&data[k][1],&data[i][1]); } for(int i=0;i<n;i++){ int k=i; for(int j=i+1;j<n;j++){ if(data[k][0]==data[j][0]){ if(data[k][1]>data[j][1]){ k=j; } }else if(data[k][0]<data[j][0]{ continue; }else{ break; } } Swap(&data[k][0],&data[i][0]); Swap(&data[k][1],&data[i][1]); } int prevX=data[0][0]; int prevY=data[0][1]; int value=0; for(int i=0;i<n;i++){ value=min(abs(prevX-data[i][0]),abs(prevY-data[i][1])); } cout<<value<<endl; return 0; }
a.cc: In function 'int main()': a.cc:35:55: error: expected ')' before '{' token 35 | }else if(data[k][0]<data[j][0]{ | ~ ^ | ) a.cc:40:17: error: expected primary-expression before '}' token 40 | } | ^
s494192275
p03682
C
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define int64 long long int #define uint64 unsigned long long int using namespace std; const int N = 100005; int n, DS[N], SZ[N]; int64 ans, cnt; vector <pair<int,int>> vx, vy; vector <struct Edge> D; struct Edge { int64 c; int x; int y; }; int root (int i) { while (DS[DS[i]] != i) i = DS[DS[i]]; return i; } int merge (int x, int y) { int r = root (x); int rr = root (y); if (r == rr) return 0; if (SZ[r] < SZ[rr]) { DS[rr] = r; SZ[r] += SZ[rr]; } else { DS[r] = rr; SZ[rr] += SZ[r]; } return 1; } bool cmp (struct Edge A, struct Edge B) { return A.c < B.c; } int main () { scanf ("%d", &n); for (int i = 0; i <= n; i++) DS[i] = i, SZ[i] = 0; for (int i = 0; i < n; i++) { int x, y; scanf ("%d %d", &x, &y); vx.pb ({x, i + 1}); vy.pb ({y, i + 1}); } sort (vx.begin (), vx.end ()); sort (vy.begin (), vy.end ()); for (int i = 0; i < vx.size () - 1; i++) { struct Edge E; E.c = vx[i + 1].first - vx[i].first; E.x = vx[i].second; E.y = vx[i + 1].second; D.pb (E); } for (int i = 0; i < vy.size () - 1; i++) { struct Edge E; E.c = vy[i + 1].first - vy[i].first; E.x = vy[i].second; E.y = vy[i + 1].second; D.pb (E); } sort (D.begin (), D.end (), cmp); for (auto p : D) { int64 c = p.c; int x = p.x, y = p.y; if (merge (x, y)) { cnt++; ans += c; } if (cnt == n - 1) break; } printf ("%lld\n", ans); return 0; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s751390518
p03682
C++
#include<stdio.h> #include<iostream> #include<algorithm> using namespace std; long long int n, a[100005], val[100005],set[100005]; int findSet(int x) { if (set[x] == x) return x; return set[x] = findSet(set[x]); } void unionSet(int x, int y) { int fx = findSet(x); int fy = findSet(y); if(fx!=fy) set[fx] = fy; } struct road { long long int len,turn1,turn2; }; struct road rx[100005],ry[100005]; struct retuint { long long int x,y,turn; }; struct retuint retu[100005],retu2[100005]; bool cmp(struct retuint p1, struct retuint p2) { if(p1.x<p2.x) return true; if(p1.x>=p2.x) return false; } bool cmp2(struct retuint p1, struct retuint p2) { if(p1.y<p2.y) return true; if(p1.y>=p2.y) return false; } long long int fact(long long int val) { long long int te = 1; for (long long int i = 1; i <= val; i++) { te = (te*i); te = te; } return te; } bool cmprx(struct road r1, struct road r2) { if(r1.len<r2.len) return true; if(r1.len>=r2.len) return false; } bool cmpry(struct road r1, struct road r2) { if(r1.len<r2.len) return true; if(r1.len>=r2.len) return false; } int main() { int i,j; cin>>n; for(int i=0; i<=n; i++) set[i] =i; for(i=0; i<n; i++) { cin>>retu[i].x>>retu[i].y; retu2[i].x = retu[i].x; retu2[i].y = retu[i].y; retu[i].turn = i+1; retu2[i].turn = i+1; } sort(retu,retu+n,cmp); sort(retu2,retu2+n,cmp2); for(i=1; i<n; i++) { rx[i-1].turn1 = retu[i-1].turn; rx[i-1].turn2 = retu[i].turn; rx[i-1].len = fabs(retu[i-1].x - retu[i].x); } for(i=1; i<n; i++) { ry[i-1].turn1 = retu2[i-1].turn; ry[i-1].turn2 = retu2[i].turn; ry[i-1].len = fabs(retu2[i-1].y - retu2[i].y); } long long int ans = 0; sort(rx,rx+n-1,cmprx); sort(ry,ry+n-1,cmpry); int fc1=0,fc2=0; int tt = 0; int xx = 100000; for(; tt<n-1; ) { if (xx<10000000){ long long int r1 = rx[fc1].len, r2 = ry[fc2].len; if(r1<r2) { if(findSet(rx[fc1].turn1)!=findSet(rx[fc1].turn2)) { ans+=rx[fc1].len; unionSet(rx[fc1].turn1,rx[fc1].turn2); tt++; xx--; } fc1++; xx++; } else { if(findSet(ry[fc2].turn1)!=findSet(ry[fc2].turn2)) { ans+=ry[fc2].len; unionSet(ry[fc2].turn1,ry[fc2].turn2); tt++; xx--; } fc2++; xx++; } } } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:73:31: error: 'fabs' was not declared in this scope; did you mean 'labs'? 73 | rx[i-1].len = fabs(retu[i-1].x - retu[i].x); | ^~~~ | labs a.cc:78:31: error: 'fabs' was not declared in this scope; did you mean 'labs'? 78 | ry[i-1].len = fabs(retu2[i-1].y - retu2[i].y); | ^~~~ | labs a.cc: In function 'bool cmp(retuint, retuint)': a.cc:29:1: warning: control reaches end of non-void function [-Wreturn-type] 29 | } | ^ a.cc: In function 'bool cmp2(retuint, retuint)': a.cc:33:1: warning: control reaches end of non-void function [-Wreturn-type] 33 | } | ^ a.cc: In function 'bool cmprx(road, road)': a.cc:51:1: warning: control reaches end of non-void function [-Wreturn-type] 51 | } | ^ a.cc: In function 'bool cmpry(road, road)': a.cc:55:1: warning: control reaches end of non-void function [-Wreturn-type] 55 | } | ^
s304122980
p03682
C++
#include<stdio.h> #include<iostream> #include<algorithm> using namespace std; long long int n, a[100005], val[100005],set[100005]; int findSet(int x) { if (set[x] == x) return x; return set[x] = findSet(set[x]); } void unionSet(int x, int y) { int fx = findSet(x); int fy = findSet(y); if(fx!=fy) set[fx] = fy; } struct road { long long int len,turn1,turn2; }; struct road rx[100005],ry[100005]; struct retuint { long long int x,y,turn; }; struct retuint retu[100005],retu2[100005]; bool cmp(struct retuint p1, struct retuint p2) { if(p1.x<p2.x) return true; if(p1.x>=p2.x) return false; } bool cmp2(struct retuint p1, struct retuint p2) { if(p1.y<p2.y) return true; if(p1.y>=p2.y) return false; } long long int fact(long long int val) { long long int te = 1; for (long long int i = 1; i <= val; i++) { te = (te*i); te = te%MOD; } return te; } bool cmprx(struct road r1, struct road r2) { if(r1.len<r2.len) return true; if(r1.len>=r2.len) return false; } bool cmpry(struct road r1, struct road r2) { if(r1.len<r2.len) return true; if(r1.len>=r2.len) return false; } int main() { int i,j; cin>>n; for(int i=0; i<=n; i++) set[i] =i; for(i=0; i<n; i++) { cin>>retu[i].x>>retu[i].y; retu2[i].x = retu[i].x; retu2[i].y = retu[i].y; retu[i].turn = i+1; retu2[i].turn = i+1; } sort(retu,retu+n,cmp); sort(retu2,retu2+n,cmp2); for(i=1; i<n; i++) { rx[i-1].turn1 = retu[i-1].turn; rx[i-1].turn2 = retu[i].turn; rx[i-1].len = fabs(retu[i-1].x - retu[i].x); } for(i=1; i<n; i++) { ry[i-1].turn1 = retu2[i-1].turn; ry[i-1].turn2 = retu2[i].turn; ry[i-1].len = fabs(retu2[i-1].y - retu2[i].y); } long long int ans = 0; sort(rx,rx+n-1,cmprx); sort(ry,ry+n-1,cmpry); int fc1=0,fc2=0; int tt = 0; int xx = 100000; for(; tt<n-1; ) { if (xx<10000000){ long long int r1 = rx[fc1].len, r2 = ry[fc2].len; if(r1<r2) { if(findSet(rx[fc1].turn1)!=findSet(rx[fc1].turn2)) { ans+=rx[fc1].len; unionSet(rx[fc1].turn1,rx[fc1].turn2); tt++; xx--; } fc1++; xx++; } else { if(findSet(ry[fc2].turn1)!=findSet(ry[fc2].turn2)) { ans+=ry[fc2].len; unionSet(ry[fc2].turn1,ry[fc2].turn2); tt++; xx--; } fc2++; xx++; } } } cout<<ans; return 0; }
a.cc: In function 'long long int fact(long long int)': a.cc:42:17: error: 'MOD' was not declared in this scope 42 | te = te%MOD; | ^~~ a.cc: In function 'int main()': a.cc:73:31: error: 'fabs' was not declared in this scope; did you mean 'labs'? 73 | rx[i-1].len = fabs(retu[i-1].x - retu[i].x); | ^~~~ | labs a.cc:78:31: error: 'fabs' was not declared in this scope; did you mean 'labs'? 78 | ry[i-1].len = fabs(retu2[i-1].y - retu2[i].y); | ^~~~ | labs a.cc: In function 'bool cmp(retuint, retuint)': a.cc:29:1: warning: control reaches end of non-void function [-Wreturn-type] 29 | } | ^ a.cc: In function 'bool cmp2(retuint, retuint)': a.cc:33:1: warning: control reaches end of non-void function [-Wreturn-type] 33 | } | ^ a.cc: In function 'bool cmprx(road, road)': a.cc:51:1: warning: control reaches end of non-void function [-Wreturn-type] 51 | } | ^ a.cc: In function 'bool cmpry(road, road)': a.cc:55:1: warning: control reaches end of non-void function [-Wreturn-type] 55 | } | ^
s163526170
p03682
C++
#include<iostream> #include<cmath> #include<queue> #include<cstdio> using namespace std; priority_queue<pair<int,pair<int,int> > > q; pair<int,int> pos[111111]; int pa[111111],n,ans,cnt; int root(int x) { if (pa[x]!=x) pa[x]=root(pa[x]); return pa[x]; } bool Union(int x,int y) { int rx=root(x); int ry=root(y); if (rx==ry) return 0; pa[rx]=ry; return 1; } int dis(int i,int j) { return min(abs(pos[i].first-pos[j].first),abs(pos[i].second-pos[j].second)); } int main() { scanf("%d",&n); for (int i=1;i<=n;i++) { scanf("%d%d",&pos[i].first,&pos[i].second); } for (int i=1;i<=n;i++) { for (int j=i+1;j<=n;j++) { q.push(make_pair(-dis(i,j),make_pair(i,j))); } } for (int i=1;i<=n;i++) pa[i]=i; while(cnt<n-1) { int x=q.top().second.first,y=q.top().second.second,z=-q.top().first; q.pop(); if (Union(x,y)) { ans+=z; cnt++; } } cout<<ans<<endl; return 0;
a.cc: In function 'int main()': a.cc:52:18: error: expected '}' at end of input 52 | return 0; | ^ a.cc:27:1: note: to match this '{' 27 | { | ^
s596399329
p03683
Java
import java.math.BigInteger; import java.util.*; public class B { public static void main(String[] args) { Scanner sc=new Scanner(System.in); fact=new long[100001]; fact[0]=1; for(int i=1;i<100001;i++) { fact[i]=(fact[i-1]%mod*i%mod+mod)%mod; } int n=sc.nextInt(); int m=sc.nextInt(); if((n==1&&m>1)||(m==1&&n>1)) { System.out.println(0); }else { if(n%2==0&&m%2==0) System.out.println(fact[n]*fact[m]*2%mod); else System.out.println(fact[n]*fact[m]%mod); } } static long modInverse(long fac, int p) { return pow(fac, p - 2); } static long nCr(int n, int r, int p) { if (r == 0) return 1; long [] fac = new long [n + 1]; fac[0] = 1; for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p; return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; } public static long[] fact; public static long[] invfact; public static long ncr(int n, int r){ if(r > n) return 0; return ((((fact[n]) * (invfact[r])) % mod)* invfact[n-r]) % mod; } static int mod=(int)1e9+7; static long pow(long x,long y) { long res=1l; while(y!=0) { if(y%2==1) { res=x*res%mod; } y/=2; x=x*x%mod; } return res; } }
Main.java:4: error: class B is public, should be declared in a file named B.java public class B { ^ 1 error
s124575403
p03683
C++
#include<cstdio.h> #include<cmaths> using namespace std; const int M=1000000007; int n,m; long long ans=1; int main(){ scanf("%d%d",&n,&m); if(abs(n-m)>1){ printf("-1\n"); return 0; } for(int i=1;i<=n;++i)ans=ans*i%M; for(int i=1;i<=m;++i)ans=ans*i%M; if(n!=m)printf("%lld\n",ans); else printf("%lld\n",2*ans%M); return 0; }
a.cc:1:9: fatal error: cstdio.h: No such file or directory 1 | #include<cstdio.h> | ^~~~~~~~~~ compilation terminated.
s183730720
p03683
C++
#include <bits/stdc++.h> using namespace std; int r,c; int sd(pair<int,int> a){ int x,y; tie(x,y) = a; if(x==0) return 0; if(y==c) return 1; if(x==r) return 2; if(y==0) return 3; return -1; } bool bcmp(pair<pair<int,int>,int> a, pair<pair<int,int>,int> b){ if(sd(a.first)!=sd(b.first)) return sd(a.first)<sd(b.first); if(sd(a.first)<2) return a.first<b.first; return a.first>b.first; } int main(){ scanf("%d%d",&r,&c); int n; scanf("%d",&n); vector<pair<pair<int,int>,int>> xvec; for(int i = 0; i<n; i++){ int x1,y1,x2,y2; scanf("%d%d%d%d",&x1,&y1,&x2,&y2); if(sd({x1,y1})!=-1&&sd({x2,y2})!=-1){ xvec.push_back({{x1,y1},i}); xvec.push_back({{x2,y2},i}); } } sort(xvec.begin(),xvec.end(),bcmp); int xsz = xvec.size(); for(int i = 0; i<xsz; i++) xvec.push_back(xvec[i]); xsz+=xsz; stack<int> ist; vector<int> xc(n,0); bool failed = false; for(int i = 0;i<xsz; i++){ if(!ist.empty()&&ist.top()==xvec[i].second){ xc[xvec[i].second]--; ist.pop(); }else if(!xc[xvec[i].second]){ xc[xvec[i].second]++; ist.push(xvec[i].second); }else{ failed = true; break; } } if(failed) printf("NO\n"); else printf("YES\n"); return 0; }
a.cc: In function 'int main()': a.cc:42:9: error: no matching function for call to 'sort(std::vector<std::pair<std::pair<int, int>, int> >::iterator, std::vector<std::pair<std::pair<int, int>, int> >::iterator, <unresolved overloaded function type>)' 42 | sort(xvec.begin(),xvec.end(),bcmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)' 4762 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last) | ^~~~ /usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate expects 2 arguments, 3 provided /usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)' 4793 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:4793:5: note: template argument deduction/substitution failed: a.cc:42:9: note: couldn't deduce template parameter '_Compare' 42 | sort(xvec.begin(),xvec.end(),bcmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)' 292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate expects 4 arguments, 3 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)' 296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: template argument deduction/substitution failed: In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15: /usr/include/c++/14/pstl/execution_defs.h: In substitution of 'template<class _ExecPolicy, class _Tp> using __pstl::__internal::__enable_if_execution_policy = typename std::enable_if<__pstl::execution::v1::is_execution_policy<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::value, _Tp>::type [with _ExecPolicy = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _Tp = void]': /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: required by substitution of 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator) [with _ExecutionPolicy = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >; _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<std::pair<int, int>, int>*, std::vector<std::pair<std::pair<int, int>, int> > >]' a.cc:42:9: required from here 42 | sort(xvec.begin(),xvec.end(),bcmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/pstl/execution_defs.h:82:7: error: no type named 'type' in 'struct std::enable_if<false, void>' 82 | using __enable_if_execution_policy = | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
s136858283
p03683
C++
#include<bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; const mod=1000000007; int main() { ll n,m; cin>>n>>m; ll aa=1; if(abs(n-m)>=2){ cout<<0<<endl;} else{ for(ll i=1; i<=n; i++){ aa=(aa*i)%mod;} for(ll i=1; i<=m; i++){ aa=(aa*i)%mod;} cout<<aa<<endl;}}
a.cc:5:7: error: 'mod' does not name a type 5 | const mod=1000000007; | ^~~ a.cc: In function 'int main()': a.cc:14:11: error: 'mod' was not declared in this scope; did you mean 'modf'? 14 | aa=(aa*i)%mod;} | ^~~ | modf a.cc:16:11: error: 'mod' was not declared in this scope; did you mean 'modf'? 16 | aa=(aa*i)%mod;} | ^~~ | modf
s945447604
p03683
C++
#include <bits/stdc++.h> using namespace std; // #define int long long #define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i) #define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps(i, n) for (int i = ((int)(n)); i > 0; i--) #define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i) #define SORT(v, n) sort(v, v + n); #define vsort(v) sort(v.begin(), v.end()); #define all(v) v.begin(), v.end() #define mp(n, m) make_pair(n, m); #define cout(d) cout<<d<<endl; #define coutd(d) cout<<std::setprecision(10)<<d<<endl; #define cinline(n) getline(cin,n); #define replace_all(s, b, a) replace(s.begin(),s.end(), b, a); #define PI (acos(-1)) #define FILL(v, n, x) fill(v, v + n, x); #define sz(x) int(x.size()) #define pqasc priority_queue<long long, vector<long long>, greater<long long>> using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using pii = pair<int, int>; using pll = pair<ll, ll>; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } class UnionFind{ private: vector<int> Parent; public: UnionFind(int N){ Parent = vector<int>(N, -1); } int root(int A){ if(Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } int size(int A){ return -Parent[root(A)]; } bool connect(int A, int B){ A = root(A); B = root(B); if(A == B){ return false; } if(size(A) < size(B)) swap(A, B); Parent[A] += Parent[B]; Parent[B] = A; return true; } bool isSame(int A, int B){ return root(A) == root(B); } }; long long gcd(long long a, long long b) { return b ? gcd(b, a%b) : a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } long long ngcd(vector<long long> a) { long long res = a[0]; for(int i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res); return res; } long long nlcm(vector<long long> a){ long long res = a[0]; for(int i=1; i<a.size(); i++) res = lcm(a[i], res); return res; } bool is_prime(long long n) { if(n < 2) return false; for (long long i = 2; i * i <= n; i++) if (n % i == 0) return false; return true; } int digsum(int n) { int res=0; while(n) res += n%10, n /= 10; return res; } int digcnt(int n){ int res=0; while(n) res++, n /= 10; return res; } vector<int> divisor(int n) { vector<int> res; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (i != n / i) res.push_back(n / i); } } return res; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; (a *= a) %= mod; n >>= 1; } return res; } long long comb(long long a, long long b, long long mod){ long long res = 1; for (long long i = a; i > a - b; i--) res = res * i % mod; for (long long i = 1; i <= b; i++) res = (res * modpow(i, mod-2, mod)) % mod; return res; } long long fact(int a){ long long res=1; for(int i=1; i<=a; i++) (res *= i) %= MOD; return res; } const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1}; const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; inline bool inside(int y, int x, int H, int W) { return (y >= 0 && x >= 0 && y < H && x < W); } const int INF = 1e9; const int MOD = 1e9+7; const ll LINF = 1e18; signed main() { cin.tie( 0 ); ios::sync_with_stdio( false ); ll n,m; cin>>n>>m; if(abs(n-m)>1){ cout<<0<<endl; return 0; } ll ans; if(n==m){ ans=fact(n); ans=(((ans*ans)%MOD)*2)%MOD; }else{ ans=fact(n)*fact(m)%MOD; } cout<<ans<<endl; }
a.cc: In function 'long long int fact(int)': a.cc:132:41: error: 'MOD' was not declared in this scope 132 | for(int i=1; i<=a; i++) (res *= i) %= MOD; | ^~~
s161372003
p03683
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N=sc.nextLong(); long M=sc.nextLong(); long sum_N = 1; long sum_M = 1; long ans = 0; long n_m = Math.abs(N-M); long l = (Long)Math.pow(10, 9) + 7; if(n_m < 2){ for(long i = N;i <= 0;i--){ sum_N *= i; } for(long j = M;j <= 0;j--){ sum_M *= j; } if(n_m == 0){ ans =sum_N * sum_M * 2; }else{ ans =sum_N * sum_M; } } System.out.println(ans % l); } }
Main.java:12: error: incompatible types: double cannot be converted to Long long l = (Long)Math.pow(10, 9) + 7; ^ 1 error
s157279858
p03683
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N=sc.nextLong(); long M=sc.nextLong(); long sum_N = 1; long sum_M = 1; long ans = 0; long n_m = Math.abs(N-M); long l = Math.pow(10, 9) + 7; if(n_m < 2){ for(long i = N;i <= 0;i--){ sum_N *= i; } for(long j = M;j <= 0;j--){ sum_M *= j; } if(n_m == 0){ ans =sum_N * sum_M * 2; }else{ ans =sum_N * sum_M; } } System.out.println(ans % l); } }
Main.java:12: error: incompatible types: possible lossy conversion from double to long long l = Math.pow(10, 9) + 7; ^ 1 error
s158909141
p03683
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N=sc.nextLong(); long M=sc.nextLong(); long sum_N = 1; long sum_M = 1; long ans = 0; int n_m = Math.abs(N-M); if(n_m < 2){ for(long i = N;i <= 0;i--){ sum_N *= i; } for(long j = M;j <= 0;j--){ sum_M *= j; } if(n_m == 0){ ans =sum_N * sum_M * 2; }else{ ans =sum_N * sum_M; } } System.out.println(ans); } }
Main.java:11: error: incompatible types: possible lossy conversion from long to int int n_m = Math.abs(N-M); ^ 1 error
s061982739
p03683
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N=sc.nextLong(); long M=sc.nextLong(); long sum_N = 1; long sum_M = 1; long ans = 0; int n_m = Math.abs(N-M); if(n_m < 2){ for(long i = N;i <= 0;i--){ sum_N *= i; } for(long j = M;j <= 0;j--){ sum_M *= j; } if(n_m = 0){ ans =sum_N * sum_M * 2; }else{ ans =sum_N * sum_M; } } System.out.println(ans); } }
Main.java:11: error: incompatible types: possible lossy conversion from long to int int n_m = Math.abs(N-M); ^ Main.java:20: error: incompatible types: int cannot be converted to boolean if(n_m = 0){ ^ 2 errors
s717297548
p03683
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N=sc.nextLong(); long M=sc.nextLong(); long sum_N = 0; long sum_M = 0; if(Math.abs(N-M) < 2){ for(long i = N;i = 0;i--){ sum_N *= i; } for(long j = M;j = 0;j--){ sum_M *= j; } } System.out.println(sum_N * sum_M); } }
Main.java:12: error: incompatible types: long cannot be converted to boolean for(long i = N;i = 0;i--){ ^ Main.java:15: error: incompatible types: long cannot be converted to boolean for(long j = M;j = 0;j--){ ^ 2 errors
s528199154
p03683
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N=sc.nextLong(); long M=sc.nextLong(); long sum_N = 0; long sum_M = 0; if(ABS(N-M) < 2){ for(i = N;i = 0;i--){ sum_N *= i; } for(j = M;j = 0;j--){ sum_M *= j; } } System.out.println(sum_N * sum_M); } }
Main.java:11: error: cannot find symbol if(ABS(N-M) < 2){ ^ symbol: method ABS(long) location: class Main Main.java:12: error: cannot find symbol for(i = N;i = 0;i--){ ^ symbol: variable i location: class Main Main.java:12: error: cannot find symbol for(i = N;i = 0;i--){ ^ symbol: variable i location: class Main Main.java:12: error: cannot find symbol for(i = N;i = 0;i--){ ^ symbol: variable i location: class Main Main.java:13: error: cannot find symbol sum_N *= i; ^ symbol: variable i location: class Main Main.java:15: error: cannot find symbol for(j = M;j = 0;j--){ ^ symbol: variable j location: class Main Main.java:15: error: cannot find symbol for(j = M;j = 0;j--){ ^ symbol: variable j location: class Main Main.java:15: error: cannot find symbol for(j = M;j = 0;j--){ ^ symbol: variable j location: class Main Main.java:16: error: cannot find symbol sum_M *= j; ^ symbol: variable j location: class Main 9 errors
s738950076
p03683
C++
#include <iostream> #include <vector> #include <algorithm> #include <bits/stdc++.h> using namespace std; long long int a,b,c[110],d[100010],ans =1,ant=1; int main(){ cin >> a >>b; if(abs(a-b) >1){ cout << "0" <<endl; } else{ if(abs(a-b) =1){ for(int i=1;i<=a;i++){ ans *= i; ans %=1000000007; } for(int i=1;i<=b;i++){ ans *=i; ans %1000000007; } cout << ans << endl; } else{ for(int i=1;i<=a;i++){ ans *= i; ans %=1000000007; } for(int i=1;i<=b;i++){ ans *=i; ans %1000000007; } ans *= 2; cout << ans << endl; } } }
a.cc: In function 'int main()': a.cc:20:11: error: lvalue required as left operand of assignment 20 | if(abs(a-b) =1){ | ~~~^~~~~
s563752338
p03683
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a,b; unsigned long long int c=1,d,e; cin>>a>>b; for(int i=1;i<=a;i++){ c*=i; c=c%1000000007; } for(int =1;i<=b;i++){ e*=i; e=c%1000000007; } if(abs(a-b)>1) cout<<0<<endl; else if(a==b){ d=2*c*c%1000000007; cout<<d<<endl; } else{ d=c*e%1000000007; cout<<d<<endl; } }
a.cc: In function 'int main()': a.cc:12:11: error: expected unqualified-id before '=' token 12 | for(int =1;i<=b;i++){ | ^ a.cc:12:10: error: expected ';' before '=' token 12 | for(int =1;i<=b;i++){ | ^~ | ; a.cc:12:11: error: expected primary-expression before '=' token 12 | for(int =1;i<=b;i++){ | ^ a.cc:12:14: error: 'i' was not declared in this scope 12 | for(int =1;i<=b;i++){ | ^ a.cc:12:18: error: expected ')' before ';' token 12 | for(int =1;i<=b;i++){ | ~ ^ | ) a.cc:12:19: error: 'i' was not declared in this scope 12 | for(int =1;i<=b;i++){ | ^
s203138808
p03683
C++
#include <bits/stdc++.h> using namespace std; int main() { const wa=1000000007; int N,M; cin >> N >> M; if(abs(N-M)>1)cout << 0; else{ long mat=1; for(long i=1;i<N+1;i++){ mat*=i; mat=mat%wa; } for(long i=1;i<M+1;i++){ mat*=i; mat=mat%wa; } if(N==M)mat*=2; cout << mat; } }
a.cc: In function 'int main()': a.cc:5:9: error: 'wa' does not name a type 5 | const wa=1000000007; | ^~ a.cc:13:15: error: 'wa' was not declared in this scope 13 | mat=mat%wa; | ^~ a.cc:17:15: error: 'wa' was not declared in this scope 17 | mat=mat%wa; | ^~
s486128301
p03683
C++
#include <bits/stdc++.h> using namespace std; int main() { const wa=1000000007; int N,M; cin >> N >> M; if(abs(N-M)>1)cout << 0; else{ long mat=1; for(int i=1;i<N+1;i++){ mat*=i; mat=mat%wa; } for(int i=1;i<M+1;i++){ mat*=i; mat=mat%wa; } if(N==M)mat*=2; cout << mat; } }
a.cc: In function 'int main()': a.cc:5:9: error: 'wa' does not name a type 5 | const wa=1000000007; | ^~ a.cc:13:15: error: 'wa' was not declared in this scope 13 | mat=mat%wa; | ^~ a.cc:17:15: error: 'wa' was not declared in this scope 17 | mat=mat%wa; | ^~
s798649531
p03683
C++
#include <bits/stdc++.h> using namespace std; const wa=1000000007; int main() { int N,M; cin >> N >> M; if(abs(N-M)>1)cout << 0; else{ long mat=1; for(int i=1;i<N+1;i++){ mat*=i; mat=mat%wa; } for(int i=1;i<M+1;i++){ mat*=i; mat=mat%wa; } if(N==M)mat*=2; cout << mat; } }
a.cc:3:7: error: 'wa' does not name a type 3 | const wa=1000000007; | ^~ a.cc: In function 'int main()': a.cc:13:15: error: 'wa' was not declared in this scope 13 | mat=mat%wa; | ^~ a.cc:17:15: error: 'wa' was not declared in this scope 17 | mat=mat%wa; | ^~
s830577499
p03683
C++
#include <iostream> #include <stdlib.h> using namespace std; long Factorial(int k); int main() { long n,m,ans=0; cin >> n >> m; if(abs(n-m)>=2){ ans=0; } else if(abs(n-m)==1){ ans=(Factorial(n)%1000000007)*Factorial(m)%1000000007; } else if(n==m){ ans=2*(Factorial(n)%1000000007)Factorial(m)%1000000007; } cout << ans << endl; return 0; } long Factorial(int k){ long sum=1; for (int i=1;i<=k;i++) { sum *= i; sum %= 1000000007; } return sum; }
a.cc: In function 'int main()': a.cc:18:48: error: expected ';' before 'Factorial' 18 | ans=2*(Factorial(n)%1000000007)Factorial(m)%1000000007; | ^~~~~~~~~ | ;
s908886198
p03683
C++
#include <bits/stdc++.h> #define fi first #define se second #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define rng(a) a.begin(),a.end() #define maxs(x,y) (x = max(x,y)) #define mins(x,y) (x = min(x,y)) #define limit(x,l,r) max(l,min(x,r)) #define lims(x,l,r) (x = max(l,min(x,r))) #define isin(x,l,r) ((l) <= (x) && (x) < (r)) #define pb push_back #define sz(x) (int)(x).size() #define pcnt __builtin_popcountll #define uni(x) x.erase(unique(rng(x)),x.end()) #define snuke srand((unsigned)clock()+(unsigned)time(NULL)); #define show(x) cout<<#x<<" = "<<x<<endl; #define PQ(T) priority_queue<T,v(T),greater<T> > #define bn(x) ((1<<x)-1) #define dup(x,y) (((x)+(y)-1)/(y)) #define newline puts("") #define v(T) vector<T> #define vv(T) v(v(T)) using namespace std; typedef long long int ll; typedef unsigned uint; typedef unsigned long long ull; typedef pair<int,int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; inline int in() { int x; scanf("%d",&x); return x;} template<typename T>inline istream& operator>>(istream&i,v(T)&v) {rep(j,sz(v))i>>v[j];return i;} template<typename T>string join(const v(T)&v) {stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);} template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v) {if(sz(v))o<<join(v);return o;} template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v) {return i>>v.fi>>v.se;} template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v) {return o<<v.fi<<","<<v.se;} template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;} const double eps = 1e-10; const ll LINF = 1001002003004005006ll; const int INF = 1001001001; #define dame { puts("-1"); return 0;} #define yn {puts("Yes");}else{puts("No");} const int MX = 200005; #define RET(ans) {cout<<ans<<endl;return 0;} // 二次元ベクターの基本 /* vector<vector<int>> dp; // 宣言 dp.resize(n); // 1次元めの要素数決定 dp[i].push_back(int); // プッシュバック rep(i,n){ sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート } */ // 整数スキャン(複数) /* int x,y,z; scanf("%d%d%d",&x,&y,&z); // n個の整数のスキャン /* ll a[n] = {}; rep(i,n){ scanf("%lld",&a[i]); } */ // 文字列スキャン /* string s; cin >> s; */ // n個の文字列スキャン /* vector<string> slist; rep(i,n){ string s; cin >> s; slist.push_back(s); } */ int main() { ll n,m; scanf("%lld%lld",&n,&m); ll ans = 0; if(n==m){ ans = 2; srep(i,1,n+1){ ans *= i; ans %= 1000000007; ans *= i; ans %= 1000000007; } }else if(abs(n-m)==1){ ans = 1; srep(i,1,n+1){ ans *= i; ans %= 1000000007; } srep(i,,1,m+1){ ans *= i; ans %= 1000000007; } } cout << ans << endl; return 0; }
a.cc:113:22: error: macro "srep" passed 4 arguments, but takes just 3 113 | srep(i,,1,m+1){ | ^ a.cc:7:9: note: macro "srep" defined here 7 | #define srep(i,s,t) for (int i = s; i < t; ++i) | ^~~~ a.cc: In function 'int main()': a.cc:113:9: error: 'srep' was not declared in this scope 113 | srep(i,,1,m+1){ | ^~~~
s119367606
p03683
C++
// Code by ajcxsu // Problem: exhausted #include<bits/stdc++.h> using namespace std; const int N=2e5+10; struct Pos { int x, y; } p[N]; bool cmp(const Pos &a, const Pos &b) { return a.x==b.x?a.x<b.x; } #define ls x<<1 #define rs x<<1|1 int mx[N<<2], sum[N<<2]; void updata(int x, int l, int r, int d, int w) { if(l==r) { mx[x]+=w, sum[x]+=w; return; } int mid=(l+r)>>1; if(d<=mid) updata(ls, l, mid, d, w); else updata(rs, mid+1, r, d, w); mx[x]=max(mx[rs], mx[ls]+sum[rs]); sum[x]=sum[ls]+sum[rs]; } int main() { ios::sync_with_stdio(false), cin.tie(0); int n, m, ans=0; cin>>n>>m; for(int i=1;i<=n;i++) cin>>p[i].x>>p[i].y; sort(p+1, p+1+n, cmp); for(int i=0;i<=m;i++) updata(1, 0, m+1, i, -1); for(int i=1;i<=n;i++) { updata(1, 0, m+1, p[i].y, 1); ans=max(ans, -p[i].x+mx[1]); } cout<<ans<<endl; return 0; }
a.cc: In function 'bool cmp(const Pos&, const Pos&)': a.cc:9:63: error: expected ':' before ';' token 9 | bool cmp(const Pos &a, const Pos &b) { return a.x==b.x?a.x<b.x; } | ^ | : a.cc:9:63: error: expected primary-expression before ';' token
s979222872
p03683
C++
#include <iostream> #include <algorithm> #include <vector> #include <iomanip> #include <map> #include <queue> static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using namespace std; ll perm(ll a) { if(MOD<=a) return 0; ll ans0 = 1, ans1 = 1; for (ll i = 1; i < a/2; ++i) { ans0 = (ans0 * (2*i)) % MOD; ans1 = (ans1 * (2*i+1)) % MOD; } ans0 = (ans0 * a) % MOD; if (a % 2 && a != 1){ ans0 = (ans0 * (1 1a-1)) % MOD; } return (ans0 * ans1) % MOD; } int main() { ll n, m; cin >> n >> m; if(abs(n-m)>1){ cout << 0 << "\n"; return 0; } cout << (perm(n)*perm(m)*(n == m ? 2 : 1))%MOD << "\n"; return 0; }
a.cc: In function 'll perm(ll)': a.cc:22:26: error: expected ')' before numeric constant 22 | ans0 = (ans0 * (1 1a-1)) % MOD; | ~ ^~~ | ) a.cc:22:39: error: expected ')' before ';' token 22 | ans0 = (ans0 * (1 1a-1)) % MOD; | ~ ^ | )
s168833653
p03683
C++
#include <iostream> #include <algorithm> #include <cstring> #include <map> #include <unordered_map> using namespace std; const int mod = 1e9 + 7; using ll = long long; unordered_map<int,ll>hash; ll f(int n) { if(!hash[n]) { ll ans = 1; for (ll i = 1; i <= n; ++i) { ans = (ans * i) % mod; } hash[n] = ans; return ans; } else { return hash[n]; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int m, n; cin >> m >> n; ll ans = abs(m - n) > 1 ? 0 : (m == n ? 2 * f(m) * f(m) : f(m) * f(n)) % mod; cout << ans << endl; }
a.cc: In function 'll f(int)': a.cc:11:9: error: reference to 'hash' is ambiguous 11 | if(!hash[n]) { | ^~~~ 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:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:9:22: note: 'std::unordered_map<int, long long int> hash' 9 | unordered_map<int,ll>hash; | ^~~~ a.cc:16:9: error: reference to 'hash' is ambiguous 16 | hash[n] = ans; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:9:22: note: 'std::unordered_map<int, long long int> hash' 9 | unordered_map<int,ll>hash; | ^~~~ a.cc:20:16: error: reference to 'hash' is ambiguous 20 | return hash[n]; | ^~~~ /usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash' 59 | struct hash; | ^~~~ a.cc:9:22: note: 'std::unordered_map<int, long long int> hash' 9 | unordered_map<int,ll>hash; | ^~~~
s364922058
p03683
C++
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair #define int long long typedef pair<int,int> ii; typedef pair<ii,ii> iiii; iiii x[1000005]; vector<ii> vec[10]; int r,c,n,cnt; stack<int> st; //0 là cột bên trái //1 là hàng ở trên //2 là cột bên phải //3 là hàng ở dưới void qualify(int x1,int y1,int x2,int y2,int num){ int count1=0,count2=0; if(y1==0&&count1==0){ vec[0].pb(mp(x1,num)); count1++; } if(y1==c&&count1==0){ count1++; vec[2].pb(mp(x1,num)); } if(y2==0&&count2==0){ count2++; vec[0].pb(mp(x2,num)); } if(y2==c&&count2==0){ count2++; vec[2].pb(mp(x2,num)); } if(x1==0&&count1==0){ count1++; vec[1].pb(mp(y1,num)); } if(x1==r&&count1==0){ count1++; vec[3].pb(mp(y1,num)); } if(x2==0&&count2==0){ count2++; vec[1].pb(mp(y2,num)); } if(x2==r&&count2==0){ count2++; vec[3].pb(mp(y2,num)); } } bool cmp(const ii &a,const ii &b){ return a.fi<b.fi; } bool cmp1(const ii &a,const ii &b){ return a.fi>b.fi; } int main(){ ios::sync_with_stdio(0); cin>>r>>c>>n; for(int i=1;i<=n;i++) cin>>x[i].fi.fi>>x[i].fi.se>>x[i].se.fi>>x[i].se.se; for(int i=1;i<=n;i++){ int count1=0,count2=0; if(x[i].fi.fi==0||x[i].fi.fi==r) count1++; if(x[i].se.fi==0||x[i].se.fi==r) count2++; if(x[i].fi.se==0||x[i].fi.se==c) count1++; if(x[i].se.se==0||x[i].se.se==c) count2++; if(count1>=1&&count2>=1) qualify(x[i].fi.fi,x[i].fi.se,x[i].se.fi,x[i].se.se,i); } sort(vec[0].begin(),vec[0].end(),cmp1); sort(vec[1].begin(),vec[1].end(),cmp); sort(vec[2].begin(),vec[2].end(),cmp); sort(vec[3].begin(),vec[3].end(),cmp1); for(int i=0;i<=3;i++){ for(int j=0;j<vec[i].size();j++){ if(!st.empty()){ if(vec[i][j].se==st.top()) st.pop(); else st.push(vec[i][j].se); } else st.push(vec[i][j].se); } } if(!st.empty()) cout<<"NO"; else cout<<"YES"; }
cc1plus: error: '::main' must return 'int'
s600562724
p03683
C++
l = map(int, raw_input().split()) n = l[0] m = l[1] mod = 1000000000 + 7 ''' def mod_pow(x,n,mod): ll ret = 1; while n > 0: if n & 1 : (ret *= x) %= mod (x *= x) %= mod n /= 2 return ret def combo(n,k,mod): if n / 2 < k: k = n - k bunshi = 1 for i in range(n - k + 1,n + 1): bunshi *= i; bunshi %= mod; bunbo = 1 for i in range(1,k + 1): bunbo *= i; bunbo *= mod; (bunshi *= mod_pow(bunbo(bunshi,mod - 2,mod)) %= mod) ''' def f(n): ret = 1 for i in range(1,n + 1) : ret *= i ret %= mod return ret if m < n : l = n n = m m = l if n == m : print (2 * f(n) * f(n) % mod) elif m - n < 2 : print (f(n) * f(m) % mod) else: print (0)
a.cc:6:1: error: empty character constant 6 | ''' | ^~ a.cc:6:3: warning: missing terminating ' character 6 | ''' | ^ a.cc:6:3: error: missing terminating ' character a.cc:29:1: error: empty character constant 29 | ''' | ^~ a.cc:29:3: warning: missing terminating ' character 29 | ''' | ^ a.cc:29:3: error: missing terminating ' character a.cc:1:1: error: 'l' does not name a type 1 | l = map(int, raw_input().split()) | ^ a.cc:9:5: error: expected unqualified-id before 'while' 9 | while n > 0: | ^~~~~ a.cc:22:9: error: 'bunshi' does not name a type 22 | bunshi %= mod; | ^~~~~~ a.cc:23:5: error: 'bunbo' does not name a type 23 | bunbo = 1 | ^~~~~ a.cc:26:9: error: 'bunbo' does not name a type 26 | bunbo *= mod; | ^~~~~ a.cc:28:12: error: expected ')' before '*=' token 28 | (bunshi *= mod_pow(bunbo(bunshi,mod - 2,mod)) %= mod) | ~ ^~~ | )
s956793695
p03683
Java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = scan.nextInt(); long frac[] = new long[100020]; int a = 1000000007; if (Math.abs(x - y) > 1) { System.out.println('0'); return; } frac[0] = 1; for (int i = 1; i <= 100000; i++)frac[i] = frac[i - 1] * i % a; long ans = frac[x] * frac[y] % a; if (x == y) ans = ans * 2 % a; System.out.println(ans); return; }}
Main.java:6: error: cannot find symbol int y = scan.nextInt(); ^ symbol: variable scan location: class Main 1 error
s670929463
p03683
C++
2 2
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 2 2 | ^
s841123779
p03683
C++
#include <iostream> #include <cstdio> using namespace std; typedef long long ll; ll n, m; ll M = 1e9 + 7; ll f(ll p) { ll re; for (re = 1; p > 0; re = re * p-- % M); return re; } ll abs(ll p) {return p > 0 ? p : -p;} int main() { cin >> n >> m; cout << f(n) * f(m) * max(0LL, 2 - abs(n - m)) % M << endl; return 0; }
a.cc: In function 'int main()': a.cc:20:43: error: call of overloaded 'abs(ll)' is ambiguous 20 | cout << f(n) * f(m) * max(0LL, 2 - abs(n - m)) % M << endl; | ~~~^~~~~~~ In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/ext/string_conversions.h:43, from /usr/include/c++/14/bits/basic_string.h:4154, 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/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:15:4: note: candidate: 'll abs(ll)' 15 | ll abs(ll p) {return p > 0 ? p : -p;} | ^~~ In file included from /usr/include/c++/14/cstdlib:81: /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~
s914360751
p03683
C
#include <stdio.h> #include <math.h> int factorial(int n) { if (n > 0) { return n * factorial(n - 1); } else { return 1; } } int main(void){ int mode = pow(10,9) + 7; int N,M; int ans; scanf_s("%d", &N); scanf_s("%d", &M); if(N == M){ ans = factorial(N) * factorial(M) * 2; printf("%d\n",ans % mode); } else if((N + 1) == M || N == (M + 1)){ ans = factorial(N) * factorial(M); printf("%d\n",ans % mode); } else{ printf("0\n"); } return 0; }
main.c: In function 'main': main.c:15:5: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration] 15 | scanf_s("%d", &N); | ^~~~~~~ | scanf
s206013901
p03683
C
#include <stdio.h> #include <math.h> int factorial(int n) { if (n > 0) { return n * factorial(n - 1); } else { return 1; } } int main(void){ int mode = pow(10,9) + 7; int N,M; int ans; scanf("%d",&N); scanf("%d",&M); if(N == M){ ans = factorial(N) * factorial(M) * 2; puts("%d",ans % mode); } else if((N + 1) == M || N == (M + 1)){ ans = factorial(N) * factorial(M); puts("%d",ans % mode); } else{ puts("0"); } return 0; }
main.c: In function 'main': main.c:19:9: error: too many arguments to function 'puts' 19 | puts("%d",ans % mode); | ^~~~ In file included from main.c:1: /usr/include/stdio.h:714:12: note: declared here 714 | extern int puts (const char *__s); | ^~~~ main.c:23:9: error: too many arguments to function 'puts' 23 | puts("%d",ans % mode); | ^~~~ /usr/include/stdio.h:714:12: note: declared here 714 | extern int puts (const char *__s); | ^~~~
s008669329
p03683
C
#include <stdio.h> #include <stdlib.h> #define MOD (7+1e9) long long int factorial(long long int n) { long long int fact[100000]; long long int i; fact[1] = 1; for(i = 2; i <= n; i++) { fact[i] = ((fact[i-1] % MOD) * (i % MOD)) % MOD; } return fact[n]; } int main(){ long long int n, m, count; scanf("%lld %lld", &n, &m); if(abs(n-m)>=2){ printf("0\n"); return 0; } if(m == n){ //m!*n!*2 count = ((factorial(m) % MOD) * (factorial(n) % MOD) * 2) % MOD; }else{ //m!*n! count = ((factorial(m) % MOD) * (factorial(n) % MOD)) % MOD; } printf("%lld\n", count); return 0; }
main.c: In function 'factorial': main.c:13:31: error: invalid operands to binary % (have 'long long int' and 'double') 13 | fact[i] = ((fact[i-1] % MOD) * (i % MOD)) % MOD; | ~~~~~~~~~ ^ | | | long long int main.c:13:43: error: invalid operands to binary % (have 'long long int' and 'double') 13 | fact[i] = ((fact[i-1] % MOD) * (i % MOD)) % MOD; | ^ main.c: In function 'main': main.c:31:32: error: invalid operands to binary % (have 'long long int' and 'double') 31 | count = ((factorial(m) % MOD) * (factorial(n) % MOD) * 2) % MOD; | ~~~~~~~~~~~~ ^ | | | long long int main.c:31:55: error: invalid operands to binary % (have 'long long int' and 'double') 31 | count = ((factorial(m) % MOD) * (factorial(n) % MOD) * 2) % MOD; | ~~~~~~~~~~~~ ^ | | | long long int main.c:34:32: error: invalid operands to binary % (have 'long long int' and 'double') 34 | count = ((factorial(m) % MOD) * (factorial(n) % MOD)) % MOD; | ~~~~~~~~~~~~ ^ | | | long long int main.c:34:55: error: invalid operands to binary % (have 'long long int' and 'double') 34 | count = ((factorial(m) % MOD) * (factorial(n) % MOD)) % MOD; | ~~~~~~~~~~~~ ^ | | | long long int
s512507360
p03683
C
#include<bits/stdc++.h> #define ll long long #define mo 1000000007 using namespace std; int x,y; ll fac(int x){ ll s=1; for (int i=1;i<=x;i++) s=s*i%mo; return s; } int main(){ scanf("%d%d",&x,&y); if (x>y) swap(x,y); if (x==y) printf("%lld",fac(x)*fac(x)*2%mo); else if (x+1==y) printf("%lld",fac(x)*fac(y)%mo); else puts("0"); }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s432517155
p03683
C++
dsfdsz
a.cc:1:1: error: 'dsfdsz' does not name a type 1 | dsfdsz | ^~~~~~
s932256638
p03683
C++
#encoding: utf-8 def main(): N,M=map(int,input().split()) if(abs(N-M)<=2): return 0 ret=1 for i in range(1,N+1): ret*=i for i in range(1,M+1): ret*=i return ret if __name__ == '__main__': main()
a.cc:1:2: error: invalid preprocessing directive #encoding 1 | #encoding: utf-8 | ^~~~~~~~ a.cc:15:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 15 | if __name__ == '__main__': | ^~~~~~~~~~ a.cc:3:1: error: 'def' does not name a type 3 | def main(): | ^~~
s647756665
p03683
C
#include <iostream> #include <algorithm> #include <cmath> #define MAX 1000000007 using namespace std; long long int fct(int n) { if(n==1) return 1; return (n*fct(n-1))%MAX; } int main() { int n,m; cin>>n>>m; if(abs(n-m)>1) { cout<<0<<endl; return 0; } if(abs(n-m)==1) { cout<<(fct(n)*fct(m))%MAX<<endl; return 0; } cout<<(2*fct(n)*fct(m))%MAX<<endl; return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s379652857
p03683
C
#include <bits/stdc++.h> #define MAX 1000000007 using namespace std; long long int fct(int n) { if(n==1) return 1; return (n*fct(n-1))%MAX; } int main() { int n,m; cin>>n>>m; if(abs(n-m)>1) { cout<<0<<endl; return 0; } if(abs(n-m)==1) { cout<<(fct(n)*fct(m))%MAX<<endl; return 0; } cout<<(2*fct(n)*fct(m))%MAX<<endl; return 0; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s524217162
p03683
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigDecimal; /** * @author fangda.wang */ public class Reconciled { private final static int MOD = 1_000_000_000 +7; private final static BigDecimal B_MOD = BigDecimal.valueOf(MOD); public static void main (String... args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String[] vals = reader.readLine().split(" "); final int N = Integer.parseInt(vals[0]); final int M = Integer.parseInt(vals[1]); if (Math.abs(N-M) > 1) { System.out.print(0); return; } BigDecimal result; if (N == M) { result = BigDecimal.valueOf(2).multiply(getPermutation(N)).multiply(getPermutation(N)); } else { result = getPermutation(N).multiply(getPermutation(M)); } System.out.print(result.remainder(B_MOD)); } private static BigDecimal getPermutation(final int n) { BigDecimal result = BigDecimal.ONE; for (int i = 1; i <= n; i++) { result = result.multiply(BigDecimal.valueOf(i)); if (result.compareTo(B_MOD) == 1) result = result.remainder(B_MOD); } return result; } }
Main.java:8: error: class Reconciled is public, should be declared in a file named Reconciled.java public class Reconciled { ^ 1 error
s522441269
p03683
C++
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigDecimal; /** * @author fangda.wang */ public class Reconciled { private final static int MOD = 1_000_000_000 +7; private final static BigDecimal B_MOD = BigDecimal.valueOf(MOD); public static void main (String... args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String[] vals = reader.readLine().split(" "); final int N = Integer.parseInt(vals[0]); final int M = Integer.parseInt(vals[1]); if (Math.abs(N-M) > 1) { System.out.print(0); return; } BigDecimal result; if (N == M) { result = BigDecimal.valueOf(2).multiply(getPermutation(N)).multiply(getPermutation(N)); } else { result = getPermutation(N).multiply(getPermutation(M)); } System.out.print(result.remainder(B_MOD)); } private static BigDecimal getPermutation(final int n) { BigDecimal result = BigDecimal.ONE; for (int i = 1; i <= n; i++) { result = result.multiply(BigDecimal.valueOf(i)); if (result.compareTo(B_MOD) == 1) result = result.remainder(B_MOD); } return result; } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.BufferedReader; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.io.InputStreamReader; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.math.BigDecimal; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:8:1: error: expected unqualified-id before 'public' 8 | public class Reconciled { | ^~~~~~
s506411172
p03683
C++
iiiii const search = function (keywords) { return ajaxPost(`/signals/search`, {keywords: keywords}) .then(res => { renderRecent(res.recent); renderClassic(res.cars); }) .catch(err => { console.error(err); }); };
a.cc:2:21: error: stray '`' in program 2 | return ajaxPost(`/signals/search`, {keywords: keywords}) | ^ a.cc:2:37: error: stray '`' in program 2 | return ajaxPost(`/signals/search`, {keywords: keywords}) | ^ a.cc:1:1: error: 'iiiii' does not name a type 1 | iiiii const search = function (keywords) { | ^~~~~
s871674145
p03683
C++
#include <iostream> using namespace std; int main(){ int N, M; long long sum = 1; long long d = (long long)pow(10.0, 9.0) + 7; cin >> N >> M; if(N > M){ int a = N; N = M; M = N; for(int i = 1 ; i <= N; i++){ sum *= i; sum %= d; } sum *= sum; sum %= d; sum *= (N + 1); sum %= d; } else if(N == M){ for(int i = 1 ; i <= N; i++){ sum *= i; sum %= d; } sum *= sum; sum %= d; sum *= 2; sum %= d; } else sum = 0; cout << sum; return 0; }
a.cc: In function 'int main()': a.cc:8:34: error: 'pow' was not declared in this scope 8 | long long d = (long long)pow(10.0, 9.0) + 7; | ^~~
s203406321
p03683
C++
#include <iostream> using namespace std; int main(){ int N, M; long long sum = 1; long long d = (long long)pow(10.0, 9.0) + 7; cin >> N >> M; if(N > M){ int a = N; N = M; M = N; for(int i = 1 ; i <= N; i++){ sum *= i; sum %= d; } sum *= sum; sum %= d; sum *= (N + 1); sum %= d; } else if(N == M){ for(int i = 1 ; i <= N; i++){ sum *= i; sum %= d; } sum *= sum; sum %= d; sum *= 2; sum %= d; } else sum = 0; cout << sum; return 0; }
a.cc: In function 'int main()': a.cc:8:34: error: 'pow' was not declared in this scope 8 | long long d = (long long)pow(10.0, 9.0) + 7; | ^~~
s891117571
p03683
C++
#include<stdio.h> long long int factorial(int N){ int i; int fact; for(i=1;i<=N;i++){ fact*=i; } return fact; } int main(){ int N,M,multi_N,multi_M; scanf("%d %d",&N,&M); if(N-M>=3 || N-M<=-3){ printf("0\n"); }else{ printf("%lld\n",factorial(M)*factorial(N)*2.0%(1000000000.0+7.0)); } return 0; }
a.cc: In function 'int main()': a.cc:18:54: error: invalid operands of types 'double' and 'double' to binary 'operator%' 18 | printf("%lld\n",factorial(M)*factorial(N)*2.0%(1000000000.0+7.0)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ | | | | double double
s308289874
p03683
C++
int b = (a * a) % mod
a.cc:1:14: error: 'a' was not declared in this scope 1 | int b = (a * a) % mod | ^ a.cc:1:18: error: 'a' was not declared in this scope 1 | int b = (a * a) % mod | ^ a.cc:1:23: error: 'mod' was not declared in this scope 1 | int b = (a * a) % mod | ^~~
s820246990
p03683
C++
#include <fstream> #include <iostream> #include <algorithm> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <sstream> #include <map> #include <set> #include <vector> #include <cmath> #include <queue> #include <random> using namespace std; #define min(a,b) ((a)<(b) ? (a):(b)) #define max(a,b) ((a)>(b) ? (a):(b)) //INT_MAX //LONG_LONG_MAX long long maxd(long long a,long long b){ if(a>=b){ return a; } return b; } long long mind(long long a,long long b){ if(a<=b){ return a; } return b; } long long gcd(long long a, long long b){ if(a<b){ swap(a,b); } while(b){ long long r = a%b; a=b; b=r; } return a; } long long lcm(long long a, long long b){ return (a*b)/gcd(a,b); } int isPrim(int a){ if(a==1){ return 0; } for(int i=2;i<=(a+1)/2;i++){ if(a%i==0){ return 0; } } return 1; } long long mod_pow(long long x, long long n, long long mod){ //xのn乗を計算するのにn乗を2進表記にして計算 //x^22 = x^16 + x^4 + x^2 long long ret=1; while(n>0){ if(n%2==1){ ret=(ret*x)%mod;//答えに付加 } x=(x*x)%mod;//2乗 n=n/2; } return ret; } struct XX{ int x; int kx; int y; int ky; int i; int nearx; int neary; }; class xxIntx { public: bool operator()(const XX& riLeft, const XX& riRight) const { //第2条件 if((riLeft.x) == (riRight.x)){ return riLeft.y < riRight.y;//<:昇順(小さいものから順番)、>:降順(大きいものから順番) } //第1条件 return (riLeft.x) < (riRight.x); } }; class xxInty { public: bool operator()(const XX& riLeft, const XX& riRight) const { //第2条件 if((riLeft.y) == (riRight.y)){ return riLeft.x < riRight.x;//<:昇順(小さいものから順番)、>:降順(大きいものから順番) } //第1条件 return (riLeft.y) < (riRight.y); } }; class xxGreater { public: bool operator()(const XX& riLeft, const XX& riRight) const { //第2条件 if((riLeft.x) == (riRight.x)){ return riLeft.i > riRight.i;//<:昇順(小さいものから順番)、>:降順(大きいものから順番) } //第1条件 return (riLeft.x) > (riRight.x); } }; //union-find int ppar[100001]; int rrank[100001]; void init(int n){ for(int i=0;i<n;i++){ ppar[i]=i; rrank[i]=0; } } int find(int x){ if(ppar[x]==x){ return x; }else{ return ppar[x]=find(ppar[x]); } } void unite(int x,int y){ x=find(x); y=find(y); if(x==y){ return; } if(rrank[x]<rrank[y]){ ppar[x]=y; }else{ ppar[y]=x; if(rrank[x]==rrank[y]){ rrank[x]++; } } } bool same(int x,int y){ return find(x)==find(y); } //kruskal struct edge{ int u; int v; int cost; }; bool comp(edge& e1,edge& e2){ return e1.cost < e2.cost; } edge es[100000]; int kruskal(int V,int E){//V:頂点数,E:辺数 sort(es,es+E,comp); init(V); int res = 0; for(int i=0;i<E;i++){ edge e = es[i]; if(!same(e.u,e.v)){ unite(e.u,e.v); res+=e.cost; } } return res; } //dijkstra //struct edge{ // long to; // long cost; //}; //typedef pair<long,long> P;//first:最短距離、second:頂点番号 //long V; //vector<edge>G[1001];//G[各頂点番号] //long d[1001]; // //int dijkstra(long s){ // priority_queue<P,vector<P>> que; // fill(d,d+V+1,-9223372036854775807); // d[s]=0; // que.push(P(0,s)); // // int index=0; // while(!que.empty()){ // P p=que.top(); // que.pop(); // long v=p.second; // if(d[v]<p.first){ // continue; // } // for(int i=0;i<G[v].size();i++){ // edge e=G[v][i]; // if(d[e.to]<d[v]+e.cost){ // d[e.to]=d[v]+e.cost; // que.push(P(d[e.to],e.to)); // } // } // // if(index++>4000000){ // return -1; // } // } // return 0; //} int main(int argc, const char * argv[]) { //std::ios::sync_with_stdio(false); //scanf("%s",S); //scanf("%d",&N); //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]); //getline(cin, target); //cin >> x >> y; //テスト用 //ifstream ifs( "1_06.txt" ); //ifs >> a; //ここから int N; cin >> N; XX a[100000]; //XX a[100]; for(int i=0;i<N;i++){ int tmp1,tmp2; cin >> tmp1 >> tmp2; a[i].x=tmp1; a[i].y=tmp2; a[i].i=i; } for(int i=0;i<N;i++){ es[i].cost=INT_MAX; } sort(a,a+N,xxIntx()); for(int i=0;i<N;i++){ if(i==0){ es[i].u=a[i].i; es[i].v=a[i+1].i; es[i].cost=min(es[i].cost,a[i+1].x-a[i].x); }else if(i==N-1){ es[i].u=a[i].i; es[i].v=a[i-1].i; es[i].cost=min(es[i].cost,a[i].x-a[i-1].x); }else{ if(a[i].x-a[i-1].x>a[i+1].x-a[i].x){ es[i].u=a[i].i; es[i].v=a[i+1].i; es[i].cost=min(es[i].cost,a[i+1].x-a[i].x); }else{ es[i].u=a[i].i; es[i].v=a[i-1].i; es[i].cost=min(es[i].cost,a[i].x-a[i-1].x); } } } sort(a,a+N,xxInty()); for(int i=N;i<2*N;i++){ if(i==0){ es[i].u=a[i].i; es[i].v=a[i+1].i; es[i].cost=min(es[i].cost,a[i+1].y-a[i].y); }else if(i==N-1){ es[i].u=a[i].i; es[i].v=a[i-1].i; es[i].cost=min(es[i].cost,a[i].y-a[i-1].y); }else{ if(a[i].y-a[i-1].y>a[i+1].y-a[i].y){ es[i].u=a[i].i; es[i].v=a[i+1].i; es[i].cost=min(es[i].cost,a[i+1].y-a[i].y); }else{ es[i].u=a[i].i; es[i].v=a[i-1].i; es[i].cost=min(es[i].cost,a[i].y-a[i-1].y); } } } long long ans=kruskal(N,2*N); cout << ans << endl; //cout << ans << endl; //ここまで //cout << "ans" << endl;改行含む //printf("%.0f\n",ans);//小数点以下表示なし //printf("%.7f\n",p); //printf("%f\n",pow(2,ans.size())); return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:261:20: error: 'INT_MAX' was not declared in this scope 261 | es[i].cost=INT_MAX; | ^~~~~~~ a.cc:15:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 14 | #include <random> +++ |+#include <climits> 15 |
s411384895
p03683
C++
#include <stdio.h> #include <stdlib.h> using namespace std; const int nom = 1000000007; int ans = 0, n, m, f[100005]; int main() { scanf("%d%d", &n, &m); if (abs(n - m) > 1) { printf("0"); return 0; } f[0] = 1; for (int i = 1; i <= max(n, m); i++) f[i] = (f[i - 1] * i) % nom; ans = (f[n] * f[m]) % nom; if (n == m) ans = (ans * 2) % nom: printf("%d", ans); }
a.cc: In function 'int main()': a.cc:13:31: error: 'max' was not declared in this scope 13 | for (int i = 1; i <= max(n, m); i++) | ^~~ a.cc:16:43: error: found ':' in nested-name-specifier, expected '::' 16 | if (n == m) ans = (ans * 2) % nom: | ^ | :: a.cc:16:40: error: 'nom' is not a class, namespace, or enumeration 16 | if (n == m) ans = (ans * 2) % nom: | ^~~
s991447794
p03683
Java
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Reconciled { static final long MOD = (long) 1e9 + 7; static final int MAX = (int) 1e5 + 1; public static void main(String[] args) throws IOException { MyScanner sc = new MyScanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(), m = sc.nextInt(); long[] fact = new long[MAX]; fact[0] = fact[1] = 1; for (int i = 2; i < MAX; i++) fact[i] = (i * fact[i - 1]) % MOD; if (n == m) out.println((((fact[n] * fact[m]) % MOD) << 1) % MOD); else if (n + 1 == m || n - 1 == m) out.println((fact[n] * fact[m]) % MOD); else out.println(0); out.flush(); out.close(); } static class MyScanner { StringTokenizer st; BufferedReader br; public MyScanner(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); } public MyScanner(String file) throws IOException { br = new BufferedReader(new FileReader(new File(file))); } public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public String nextLine() throws IOException { return br.readLine(); } public boolean ready() throws IOException { return br.ready(); } } }
Main.java:11: error: class Reconciled is public, should be declared in a file named Reconciled.java public class Reconciled { ^ 1 error
s654129921
p03683
C
g`"#include<stdbool.h> int all(int n) { unsigned long result = 1; for(int i = 1; i <=n; i++) { result = result*i; result = result % 1000000007; } return result; } int main() { int a,b; unsigned long kekka; scanf("%d %d", &a, &b); if (a == b) { kekka = (all(a) * all(b) * 2) % 1000000007; } else if (a == b+1 || a+1 == b) { kekka = (all(a) * all(b)) % 1000000007; } else { kekka = 0; } printf("%lu\n", kekka); return 0; }
main.c:1:2: error: stray '`' in program 1 | g`"#include<stdbool.h> | ^ main.c:1:3: warning: missing terminating " character 1 | g`"#include<stdbool.h> | ^ main.c:1:3: error: missing terminating " character 1 | g`"#include<stdbool.h> | ^~~~~~~~~~~~~~~~~~~~ main.c:1:2: error: expected ';' before 'int' 1 | g`"#include<stdbool.h> | ^ | ; 2 | 3 | int all(int n) { | ~~~ main.c: In function 'main': main.c:15:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 15 | scanf("%d %d", &a, &b); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | g`"#include<stdbool.h> main.c:15:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 15 | scanf("%d %d", &a, &b); | ^~~~~ main.c:15:5: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:23:5: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 23 | printf("%lu\n", kekka); | ^~~~~~ main.c:23:5: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:23:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:23:5: note: include '<stdio.h>' or provide a declaration of 'printf'
s074332443
p03683
C++
#include <bits/stdc++.h> #include <windows.h> #define LEN 100000 using namespace std; class UFS { private: int f[LEN]; int size[LEN]; int len; int block; public: UFS(int n); void Add(); int Union(int a, int b); int IsSameRoot(int a, int b); int GetLength(); int FindRoot(int k); int GetBlocks(); void Debug(); }; UFS::UFS(int n) { memset(f, 0, sizeof(f)); memset(size, 0, sizeof(size)); len = block = n; } void UFS::Add() { len++; } int UFS::Union(int a, int b) { if (a > len && b > len && a < 1 && b < 1) { return -1; } if ((a = FindRoot(a)) == (b = FindRoot(b))) { return 0; } if (size[b] > size[a]) { f[a] = b; size[b] += size[a]; } else { f[b] = a; size[a] += size[b]; } block--; return 1; } int UFS::IsSameRoot(int a, int b) { return FindRoot(a) == FindRoot(b); } int UFS::GetLength() { return len; } int UFS::FindRoot(int k) { if (!f[k]) { return k; } f[k] = FindRoot(f[k]); return f[k]; } int UFS::GetBlocks() { return block; } void UFS::Debug() { puts("===================="); printf("Blocks: %d\n", block); for(int i = 1; i <= len; i++) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FindRoot(i)); printf("%d -> %d\n", i, FindRoot(i)); } SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7); puts("===================="); } priority_queue<int> pq; int main() { UFS u(100005); int n; cin >> n; }
a.cc:2:10: fatal error: windows.h: No such file or directory 2 | #include <windows.h> | ^~~~~~~~~~~ compilation terminated.
s522414801
p03683
C++
#include <iostream> using namespace std; struct { int x,y; }v[100003]; int n,viz[100003],dist,a,b,nod; long long dist; int main() { cin>>n; for(int i=1;i<=n;++i) cin>>v[i].x>>v[i].y; for(int i=1;i<=n;++i) { if(!viz[i]) { viz[i]=true; dist=99999999; for(int j=1;j<=n;++j) { if(i==j) continue; a=v[i].x-v[j].x; if(a<0) a=-a; b=v[i].y-v[j].y; if(b<0) b=-b; if(a<dist) { dist=a; nod=j; } if(b<dist) { dist=b; nod=j; } } viz[nod]=true; sol+=dist; } } cout<<sol; return 0; }
a.cc:9:11: error: conflicting declaration 'long long int dist' 9 | long long dist; | ^~~~ a.cc:8:19: note: previous declaration as 'int dist' 8 | int n,viz[100003],dist,a,b,nod; | ^~~~ a.cc: In function 'int main()': a.cc:39:13: error: 'sol' was not declared in this scope 39 | sol+=dist; | ^~~ a.cc:42:7: error: 'sol' was not declared in this scope 42 | cout<<sol; | ^~~
s249269502
p03683
C++
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <stack> #include <queue> #include <cstdlib> #include <cstdio> #include <string> #include <cstring> using namespace std; static const long long INF = 1000000000; #define N 100000 struct POINT { int x; int y; }; int n; POINT p[N]; int cost[N + 1][N + 1]; long long d[N + 1][N + 1]; int main() { cin >> n; for ( int i = 0; i < n; i++ ) { cin >> p[i].x >> p[i].y; } for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { cost[i][j] = INF; } } for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { if ( i == j ) continue; cost[i][j] = std::min(std::abs(p[i].x - p[j].x), std::abs(p[i].y - p[j].y)); } } for ( int k = 0; k < n; k++ ) { for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]); } } } long long ans = 0; long long minc = INF; for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { long long tmp = d[i][j]; minc = std::min(tmp, minc); } ans = ans + minc; } cout << ans << endl; return 0; }
/tmp/ccWVy1Zw.o: in function `main': a.cc:(.text+0x22a): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccWVy1Zw.o a.cc:(.text+0x252): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccWVy1Zw.o a.cc:(.text+0x281): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccWVy1Zw.o a.cc:(.text+0x2bb): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccWVy1Zw.o a.cc:(.text+0x33e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccWVy1Zw.o collect2: error: ld returned 1 exit status
s289137700
p03683
C++
#include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #include<map> #include<set> #include<algorithm> #include<queue> #include<time.h> #define fo(i,a,b) for(int i=a;i<=b;i++) #define fd(i,a,b) for(int i=a;i>=b;i--) #define fe(x) for(int ii=be[x];ii;ii=e[ii].ne) using namespace std; int r,c,n,m,xx,yy,zz,ww,tot; int random(){ return rand()*32768+rand(); } bool bor(int a,int b){ if (a==0||a==r) return 1; if (b==0||b==c) return 1; return 0; } struct nod{ int x1,y1,x2,y2; }; nod a[110000]; double cj(double ax,double ay,double bx,double by){ return ax*by-ay*bx; } inline bool cro(int c,int d){ return ((cj(a[d].x1-a[c].x1,a[d].y1-a[c].y1,a[c].x2-a[c].x1,a[c].y2-a[c].y1)*cj(a[d].x2-a[c].x1,a[d].y2-a[c].y1,a[c].x2-a[c].x1,a[c].y2-a[c].y1))<0); } int main(){ scanf("%d%d%d",&r,&c,&n); fo(i,1,n){ scanf("%d%d%d%d",&xx,&yy,&zz,&ww); if (bor(xx,yy)&&bor(zz,ww)){ ++m; a[m].x1=xx; a[m].y1=yy; a[m].x2=zz; a[m].y2=ww; } } fo(i,1,4*m){ int xx=random()%m+1,yy=random()%m+1; swap(a[xx],a[yy]); } fo(i,1,m-1) fo(j,i+1,m){ if (cro(i,j)){ printf("NO\n"); return 0; } tot++; if (tot>=6000000){ printf("YES\n"); return 0; } } printf("YES\n"); return 0; }
a.cc:15:5: error: ambiguating new declaration of 'int random()' 15 | int random(){ | ^~~~~~ In file included from /usr/include/c++/14/bits/std_abs.h:38, from /usr/include/c++/14/cmath:49, from /usr/include/c++/14/math.h:36, from a.cc:2: /usr/include/stdlib.h:521:17: note: old declaration 'long int random()' 521 | extern long int random (void) __THROW; | ^~~~~~
s118816491
p03683
C++
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <stack> #include <queue> #include <cstdlib> #include <cstdio> #include <string> #include <cstring> using namespace std; #define N 100000 #define INF (1 << 21) struct POINT { int x; int y; }; int n; POINT p[N]; int cost[N + 1][N + 1]; long long d[N + 1][N + 1]; int main() { cin >> n; for ( int i = 0; i < n; i++ ) { cin >> p[i].x >> p[i].y; } for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { cost[i][j] = INF; } } for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { if ( i == j ) continue; cost[i][j] = std::min(std::abs(p[i].x - p[j].x), std::abs(p[i].y - p[j].y)); } } for ( int k = 0; k < n; k++ ) { for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]); } } } long long ans = 0; long long minc = INF; for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { long long tmp = d[i][j]; minc = std::min(tmp, minc); } ans = ans + minc; } cout << ans << endl; return 0; }
/tmp/cc0QajjK.o: in function `main': a.cc:(.text+0x22a): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cc0QajjK.o a.cc:(.text+0x252): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cc0QajjK.o a.cc:(.text+0x281): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cc0QajjK.o a.cc:(.text+0x2bb): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cc0QajjK.o a.cc:(.text+0x33e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cc0QajjK.o collect2: error: ld returned 1 exit status
s393367673
p03683
C++
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <stack> #include <queue> #include <cstdlib> #include <cstdio> #include <string> #include <cstring> using namespace std; #define N 100000 #define INF (1 << 21) struct POINT { int x; int y; }; int n; POINT p[N]; int cost[N + 1][N + 1]; long long d[N + 1][N + 1]; int main() { cin >> n; for ( int i = 0; i < n; i++ ) { cin >> p[i].x >> p[i].y; } for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { cost[i][j] = INF; } } for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { if ( i == j ) continue; cost[i][j] = std::min(std::abs(p[i].x - p[j].x), std::abs(p[i].y - p[j].y)); } } for ( int k = 0; k < n; k++ ) { for ( int i = 0; i < n; i++ ) { if ( d[i][k] == INF ) continue; for ( int j = 0; j < n; j++ ) { if ( d[k][j] == INF ) continue; d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]); } } } long long ans = 0; long long minc = INF; for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { long long tmp = d[i][j]; minc = std::min(tmp, minc); } ans += minc; } cout << ans << endl; return 0; }
/tmp/ccjHn4lZ.o: in function `main': a.cc:(.text+0x21e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccjHn4lZ.o a.cc:(.text+0x25e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccjHn4lZ.o a.cc:(.text+0x292): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccjHn4lZ.o a.cc:(.text+0x2ba): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccjHn4lZ.o a.cc:(.text+0x2e9): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccjHn4lZ.o a.cc:(.text+0x323): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccjHn4lZ.o a.cc:(.text+0x3ac): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccjHn4lZ.o collect2: error: ld returned 1 exit status
s300630525
p03683
C++
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <stack> #include <queue> #include <cstdlib> #include <cstdio> #include <string> #include <cstring> using namespace std; #define N 100000 #define INF (1 << 21) struct POINT { int x; int y; }; int n; POINT p[N]; int cost[N + 1][N + 1]; long long d[N + 1][N + 1]; int main() { cin >> n; for ( int i = 0; i < n; i++ ) { cin >> p[i].x >> p[i].y; } for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { cost[i][j] = INF; } } for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { if ( i == j ) continue; cost[i][j] = min(abs(p[i].x - p[j].x), abs(p[i].y - p[j].y)); } } for ( int k = 0; k < n; k++ ) { for ( int i = 0; i < n; i++ ) { if ( d[i][k] == INF ) continue; for ( int j = 0; j < n; j++ ) { if ( d[k][j] == INF ) continue; d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } long long ans = 0; long long minc = INF; for ( int i = 0; i < n; i++ ) { for ( int j = 0; j < n; j++ ) { long long tmp = d[i][j]; minc = min(tmp, minc); } ans += minc; } cout << ans << endl; return 0; }
/tmp/ccDJJrwA.o: in function `main': a.cc:(.text+0x21e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o a.cc:(.text+0x25e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o a.cc:(.text+0x292): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o a.cc:(.text+0x2ba): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o a.cc:(.text+0x2e9): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o a.cc:(.text+0x323): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o a.cc:(.text+0x3ac): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDJJrwA.o collect2: error: ld returned 1 exit status
s470802962
p03683
C++
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author HossamDoma */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskC solver = new TaskC(); solver.solve(1, in, out); out.close(); } static class TaskC { public void solve(int testNumber, InputReader in, PrintWriter out) { int n = in.nextInt(); int m = in.nextInt(); long ans = 0; int mod = ((int) 1e9) + 7; if (Math.abs(n - m) > 1) { ans = 0; out.println(ans); return; } ans = n; int tmp = n - 1; int tmp2 = m; for (int i = 1; i < (n + m); ++i) { if (i % 2 == 1) ans = (ans * tmp2--) % mod; else ans = (ans * tmp--) % mod; } tmp = n; tmp2 = m - 1; long ans2 = m; for (int i = 1; i < (n + m); ++i) { if (i % 2 == 1) ans2 = (ans2 * tmp--) % mod; else ans2 = (ans2 * tmp2--) % mod; } out.println((ans + ans2) % mod); } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.OutputStream; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.io.InputStream; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.io.PrintWriter; | ^~~~~~ 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.util.StringTokenizer; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: 'import' does not name a type 6 | import java.io.IOException; | ^~~~~~ a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:7:1: error: 'import' does not name a type 7 | import java.io.BufferedReader; | ^~~~~~ a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:8:1: error: 'import' does not name a type 8 | import java.io.InputStreamReader; | ^~~~~~ a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:9:1: error: 'import' does not name a type 9 | import java.io.InputStream; | ^~~~~~ a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:17:1: error: expected unqualified-id before 'public' 17 | public class Main { | ^~~~~~
s887840852
p03683
C++
#include <iostream> using namespace std; long long int kaizyou(long long int n){ return n*kaizyou(n-1)%1000000007 } main(){ long long int n,m,ans; cin >> n >> m; if(n>m+1 || m>n+1){ cout << "0" <<endl; }else{ ans=kaizyou(n); ans*=kaizyou(m); if(n!=m){ ans*=2; } ans%=1000000007; cout << ans << endl; } }
a.cc: In function 'long long int kaizyou(long long int)': a.cc:5:35: error: expected ';' before '}' token 5 | return n*kaizyou(n-1)%1000000007 | ^ | ; 6 | } | ~ a.cc: At global scope: a.cc:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 8 | main(){ | ^~~~
s228282865
p03683
C++
#include <assert.h> #include <ctype.h> #include <errno.h> #include <float.h> #include <fstream> #include <iomanip> #include <iostream> #include <limits> #include <locale> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <wchar.h> #include <wctype.h> #include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <exception> #include <functional> #include <map> #include <ios> #include <iosfwd> #include <istream> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <utility> #include <vector> #include <cwchar> #include <cwctype> #include <complex.h> #include <fenv.h> #include <inttypes.h> #include <stdbool.h> #include <stdint.h> #include <tgmath.h> #include <conio.h> #include <numeric> #include <list> #include <windows.h> #include <cfloat> #include <climits> using namespace std; const long long Mod=1e9+7; inline long long All(int x) { long long res=1; for(int i=2;i<=x;i++) res=res*i%Mod; return res; } int main() { ios_base::sync_with_stdio(0);cin.tie(0); int n,m; cin>>n>>m; if(abs(n-m)>1) {cout<<0;return 0;} long long ans=All(n)*All(m); if(n==m) ans*=2; ans%=Mod; cout<<ans; return 0; }
a.cc:53:10: fatal error: conio.h: No such file or directory 53 | #include <conio.h> | ^~~~~~~~~ compilation terminated.
s722878053
p03683
C++
#include <bits/stdc++.h> using namespace std; int main() { int n, m; long long res = 1; cin >> n >> m; int base = 1e9 + 7; if ( abs (n - m) > 1) { cout << 0 << '\n; } else { if (n == m) { res = 2; } for (int i = 1; i <= n; ++i) { res *= i; res = res % base; } for (int j = 1; j <= m; ++j) { res *= j; res = res % base; } cout << res << '\n'; } return 0; }
a.cc:13:26: warning: missing terminating ' character 13 | cout << 0 << '\n; | ^ a.cc:13:26: error: missing terminating ' character 13 | cout << 0 << '\n; | ^~~~ a.cc: In function 'int main()': a.cc:14:5: error: expected primary-expression before '}' token 14 | } | ^
s720787274
p03683
C++
#include <bits/stdc++.h> using namespace std; int main() { int n, m; long long res = 1; cin >> n >> m; int base = 1e9 + 7; if ( abs (n - m) > 1) { cout << 0; else { if (n == m) { res = 2; } for (int i = 1; i <= n; ++i) { res *= i; res = res % base; } for (int j = 1; j <= m; ++j) { res *= j; res = res % base; } cout << res << '\n'; } return 0; }
a.cc: In function 'int main()': a.cc:14:9: error: expected '}' before 'else' 14 | else | ^~~~ a.cc:12:27: note: to match this '{' 12 | if ( abs (n - m) > 1) { | ^
s524656135
p03683
C++
#include <bits/stdc++.h> using namespace std; int main() { int n, m; long long res = 1; cin >> n >> m; int base = 1e9 + 7; if ( abs (n - m) > 1) { cout << 0; else { if (n == m) { res = 2; } for (int i = 1; i <= n; ++i) { res *= i; res = res % base; } for (int j = 1; j <= m; ++j) { res *= j; res = res % base; } cout << res << '\n'; } return 0; }
a.cc: In function 'int main()': a.cc:14:9: error: expected '}' before 'else' 14 | else | ^~~~ a.cc:12:27: note: to match this '{' 12 | if ( abs (n - m) > 1) { | ^
s712162843
p03683
C++
#include <iostream> #include <algorithm> #define _ %1000000007 typedef long long LL; using namespace std; int compute(int M, int D) { if (abs(M-D) > 1) return 0; int tiny = min(M, D); LL ret = 1; for (LL item = tiny; item >= 2; item--) { ret = (item*ret)_; } ret = (ret*ret)_; if(M == D) { ret = (ret<<1)_; } else { int big = max(M, D); ret = (ret*big)_; } return ret; } int main() { int m,d; cin >> m >> d; int ret = compute(m, d); cout << ret << endl;100000 100000 return 0; }
a.cc: In function 'int main()': a.cc:32:31: error: expected ';' before numeric constant 32 | cout << ret << endl;100000 100000 | ^~~~~~~ | ;
s087038216
p03683
Java
/** * @author Finn Lidbetter */ import java.util.*; import java.io.*; import java.awt.geom.*; public class TaskC { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); long MOD = 1_000_000_007; String[] s = br.readLine().split(" "); long n = Long.parseLong(s[0]); long m = Long.parseLong(s[1]); if (m>n+1 || m<n-1) { System.out.println(0); System.exit(0); } long fact1 = 1; long fact2 = 1; for (int i=0; i<m; i++) { fact1*=(i+1); fact1%=MOD; } for (int i=0; i<n; i++) { fact2*=(i+1); fact2%=MOD; } long ans = (fact1*fact2)%MOD; if (m==n) ans*=2; ans%=MOD; System.out.println(ans); } }
Main.java:8: error: class TaskC is public, should be declared in a file named TaskC.java public class TaskC { ^ 1 error
s438128784
p03683
C++
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, ans = 1; cin >> n >> m; if (n > m) swap(n,m); if (n + 1 < m) cout << 0; else { rep(i,1,n+1) ans = ans * i % MOD * i % MOD; if (n == m) cout << ans * 2 % MOD; else cout << ans * m % MOD; } }
a.cc: In function 'int main()': a.cc:10:13: error: 'i' was not declared in this scope 10 | rep(i,1,n+1) ans = ans * i % MOD * i % MOD; | ^ a.cc:10:9: error: 'rep' was not declared in this scope 10 | rep(i,1,n+1) ans = ans * i % MOD * i % MOD; | ^~~ a.cc:11:39: error: 'MOD' was not declared in this scope 11 | if (n == m) cout << ans * 2 % MOD; | ^~~ a.cc:12:32: error: 'MOD' was not declared in this scope 12 | else cout << ans * m % MOD; | ^~~
s667119193
p03684
C++
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; /*----------------------------------ここからマクロ----------------------------------*/ #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define vecin(a) rep(i,a.size())cin >> a[i] #define overload4(_1,_2,_3,_4,name,...) name /*#define rep1(n) for(int i=0;i<(int)n;++i) #define rep2(i,n) for(int i=0;i<(int)n;++i) #define rep3(i,a,b) for(int i=(int)a;i<(int)b;++i) #define rep4(i,a,b,c) for(int i=(int)a;i<(int)b;i+=(int)c)*/ #define rep1(n) for(ll i=0;i<(ll)n;++i) #define rep2(i,n) for(ll i=0;i<(ll)n;++i) #define rep3(i,a,b) for(ll i=(ll)a;i<(ll)b;++i) #define rep4(i,a,b,c) for(int i=(ll)a;i<(ll)b;i+=(ll)c) #define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__) #ifdef _DEBUG #define debug1(a) cerr << #a << ": " << a << "\n" #define debug2(a,b) cerr << #a << ": " << a << ", " << #b << ": " << b << "\n" #define debug3(a,b,c) cerr << #a << ": " << a << ", " << #b << ": " << b << ", " << #c << ": " << c << "\n" #define debug4(a,b,c,d) cerr << #a << ": " << a << ", " << #b << ": " << b << ", " << #c << ": " << c << ", " << #d << ": " << d << "\n" #define debug(...) overload4(__VA_ARGS__,debug4,debug3,debug2,debug1)(__VA_ARGS__) #define vecout(a) cerr << #a << ": [";rep(i,a.size()){cerr << a[i];cerr << (i == a.size() - 1 ? "":",");}cerr << "]\n" #else #define debug(...) #define vecout(a) #endif #define mp make_pair //struct doset{doset(int n){cout << fixed << setprecision(n);cerr << fixed << setprecision(n);}}; //struct myset{myset(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}}; void myset(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);} void doset(int n){cout << fixed << setprecision(n);} using ll = long long; using ld = long double; using dou = double; const int inf = 1 << 30; const ll INF = 1LL << 60; const ld pi = 3.14159265358; const ll mod1 = 1000000007LL; const ll mod2 = 998244353LL; typedef pair<ll,ll> P; template<class T, class U> inline bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; } template<class T, class U> inline bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; } template<class T, class U> inline bool change(T& a,U& b){if(a > b){swap(a,b);return 1;}return 0;} //nのm乗をMODで割ったあまりO(logm) ll modpow(ll n,ll m,ll MOD){ if(m == 0)return 1; if(m < 0)return -1; ll res = 1; while(m){ if(m & 1)res = (res * n) % MOD; m >>= 1; n *= n; n %= MOD; } return res; } ll mypow(ll n,ll m){ if(m == 0)return 1; if(m < 0)return -1; ll res = 1; while(m){ if(m & 1)res = (res * n); m >>= 1; n *= n; } return res; } //素数判定O(sqrt(N)) template<class T> inline bool isp(T n){ bool res = true; if(n == 1 || n == 0)return false; else{ for(ll i = 2;i * i <= n;i++){ if(n % i == 0){ res = false; break; } } return res; } } template<class T = int> T in(){T x;cin >> x;return x;} inline bool Yes(bool b){cout << (b ? "Yes\n":"No\n");return b;} inline bool YES(bool b){cout << (b ? "YES\n":"NO\n");return b;} /*----------------------------------マクロここまで----------------------------------*/ ll __lcm(ll a,ll b){ return a / __gcd(a,b) * b; } template<class T> struct UnionFind{ vector<T> par; vector<T> ran; vector<T> siz; T tree_num; UnionFind(T n) : par(n),ran(n,0),siz(n,1),tree_num(n){ rep(i,n){ par[i] = i; } } T find(T x){ if(x == par[x])return x; else return par[x] = find(par[x]); } void unite(T x,T y){ x = find(x); y = find(y); if(x == y)return; tree_num--; if(ran[x] < ran[y]){ siz[y] += siz[x]; par[x] = y; } else{ siz[x] += siz[y]; par[y] = x; if(ran[x] == ran[y])ran[x]++; } } bool same(T x,T y){ return find(x) == find(y); } T get_size(T x){ return siz[find(x)]; } T renketsu_seibun(){ return tree_num; } }; typedef pair<ll,pair<ll,ll>> pii; int main(){ myset(); ll N; cin >> N; UnionFind<ll> UF(N); vector<pii> vec(N); rep(i,N){ cin >> vec[i].first >> vec[i].second.first; vec[i].second.second = i; } if(N == 2){ cout << min(abs(vec[0].first - vec[1].first),abs(vec[0].second.first,vec[1].second.first)) << "\n"; } vector<pii> edge; sort(all(vec)); rep(i,1,N - 1){ edge.push_back(mp(min(abs(vec[i].first - vec[i - 1].first),abs(vec[i].second.first - vec[i - 1].second.first)) ,mp(vec[i].second.second,vec[i - 1].second.second))); edge.push_back(mp(min(abs(vec[i].first - vec[i + 1].first),abs(vec[i].second.first - vec[i + 1].second.first)) ,mp(vec[i].second.second,vec[i + 1].second.second))); } rep(i,N){ swap(vec[i].first,vec[i].second.first); } sort(all(vec)); rep(i,1,N - 1){ edge.push_back(mp(min(abs(vec[i].first - vec[i - 1].first),abs(vec[i].second.first - vec[i - 1].second.first)) ,mp(vec[i].second.second,vec[i - 1].second.second))); edge.push_back(mp(min(abs(vec[i].first - vec[i + 1].first),abs(vec[i].second.first - vec[i + 1].second.first)) ,mp(vec[i].second.second,vec[i + 1].second.second))); } sort(all(edge)); for(auto x : edge){ cout << x.second.second << "," << x.second.first << ":" << x.first << "\n"; } ll ans = 0; for(auto x : edge){ if(!UF.same(x.second.first,x.second.second)){ UF.unite(x.second.second,x.second.first); ans += x.first; } } cout << ans << "\n"; }
a.cc: In function 'int main()': a.cc:157:57: error: no matching function for call to 'abs(long long int&, long long int&)' 157 | cout << min(abs(vec[0].first - vec[1].first),abs(vec[0].second.first,vec[1].second.first)) << "\n"; | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166, from a.cc:1: /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_ValArray, _Tp>, _Tp> std::abs(const valarray<_Tp>&)' 445 | _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_Expr, _Dom>, typename _Dom::value_type> std::abs(const _Expr<_Dom1, typename _Dom1::value_type>&)' 445 | _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:892:5: note: candidate: 'template<class _Tp> _Tp std::abs(const complex<_Tp>&)' 892 | abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); } | ^~~ /usr/include/c++/14/complex:892:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42: /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ /usr/include/stdlib.h:980:12: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/cstdlib:81: /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate expects 1 argument, 2 provided
s152539265
p03684
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll INF = 1e18+7; ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ii,ll> #define f(i,a,b) for(ll i = a;i < b;i++) #define rf(i,a,b) for(long long i=a;i>=b;i--) #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define w(t) while(t--) #define c(n); cin>>n; #define p(n) cout<<n; #define pl(n) cout<<n<<"\n"; #define ps(n); cout<<n<<" "; #define F first #define S second #define pb(a) push_back(a) #define all(x) (x).begin(), (x).end() #define ull unsigned long long #define vll vector<ll> #define vii vector<ii> #define mkp make_pair #define ld long double #define arrin(a,n) f(i,0,n){cin>>a[i];} #define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";} #define printclock cerr<<"Time : "<<*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n"; #define PI (2*acos(0)) #define EPS 1e-18 const long long N = 2e5+5; const long long M = 1e6+5; vll visit,dist,taken; vector<vll> adj; vector<vii> adj2; priority_queue<ii,vector<ii>, greater<ii> > pq; ll bit[N]={0}; ll an[N][35]; ll depth[N]={0}; ll siz; ll res = 0; ll mycbrt(ll num){ll l = 1,r = 1000000;ll ans = 0;while(l <= r){ll mid = (l+r)/2;if(mid * mid * mid <= num){l = mid + 1;ans = max(ans,mid);}else{r = mid - 1;}}return ans;} ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);} ll gcd(ll a,ll b){return __gcd(a,b);} ll power(ll a,ll b,ll MOD){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2,MOD) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;} ll inverse(ll x){x%=MOD;return power(x,MOD-2,MOD);} void BITup(ll k, ll x){while(k <= siz){bit[k]+=x;k += k & -k;}} ll BITq(ll k){ll s=0;while(k>=1){s+=bit[k];k -= k &-k;}return s;} struct point{ll x,y,idx;}; void dfs(ll v){visit[v] = 1;for(auto x:adj[v]){if(!visit[x])dfs(x);}} void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}} void dijkstra(ll s){pq.push(ii(0,s));dist[s] = 0;while(!pq.empty()){ii f = pq.top();pq.pop();ll w = f.F;ll u = f.S;if(w > dist[u]){continue;}for(auto v:adj2[u]){if(dist[u] + v.S < dist[v.F]){dist[v.F] = dist[u] + v.S;pq.push(ii(dist[v.F],v.F));}}}} void prim(ll edge) {taken[edge] = 1;for(auto v:adj2[edge]) {if (taken[v.first]==0)pq.push(ii(v.second, v.first));}} ll mst(ll s){taken.assign(N, 0);prim(s);ll cost = 0;while(!pq.empty()){ii front = pq.top();pq.pop();ll w = front.first;ll u = front.second;if(taken[u]==0)cost += w;prim(u);}return cost;} void bfs01(ll s){deque<ll>q;dist[s] = 0;q.push_back(s);while(!q.empty()){ll v = q.front();q.pop_front();for(auto x:adj2[v]){if(dist[x.F] > dist[v] + x.S){dist[x.F] = dist[v] + x.S;if(x.S == 0){q.push_front(x.F);}else{q.push_back(x.F);}}}}} void build(ll s,ll p){an[s][0] = p;f(i,1,35){an[s][i] = an[an[s][i-1]][i-1];}for(auto x:adj[s]){if(x != p){depth[x] = depth[s] + 1;build(x,s);}}} ll kth(ll x,ll k){ll ans = x;if(depth[x] < k){return -1;}ll pos = 0;while(k > 0){if(k % 2){ans = an[ans][pos];}pos++;k /= 2;}return ans;} ll lca(ll a,ll b){if(depth[a] > depth[b]){swap(a,b);}b = kth(b,abs(depth[a] - depth[b]));if(a == b){return a;}for(ll i = 34;i >= 0;i--){if(an[a][i] == an[b][i]){continue;}a = an[a][i];b = an[b][i];}return an[a][0];} void YESNO(ll a){if(!!a){pl("YES");}else{pl("NO");}} void filesin(void){freopen("tracing.in","r",stdin);} void filesout(void){freopen("tracing.out","w",stdout);} ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Training bool cmp(point a,point b){ return a.x < b.x; } bool cmp2(point a,point b){ return a.y < b.y; } int main(void){ fastio; ll n; cin>>n; point arr[n]; f(i,0,n){ cin>>arr[i].x>>arr[i].y; arr[i].idx = i; } sort(arr,arr+n,cmp); adj2.assign(n+5,vii()); f(i,1,n){ ll a = arr[i].idx,b = arr[i-1].idx; adj2[a].pb(ii(b,arr[i].x - arr[i-1].x)); adj2[b].pb(ii(a,arr[i].x - arr[i-1].x)); } sort(arr,arr+n,cmp2); f(i,1,n){ ll a = arr[i].idx,b = arr[i-1].idx; adj2[a].pb(ii(b,arr[i].y - arr[i-1].y)); adj2[b].pb(ii(a,arr[i].y - arr[i-1].y)); } cout<<mst(0)<<endl; }
a.cc: In function 'void dfs(ll)': a.cc:49:16: error: reference to 'visit' is ambiguous 49 | void dfs(ll v){visit[v] = 1;for(auto x:adj[v]){if(!visit[x])dfs(x);}} | ^~~~~ 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:32:5: note: 'std::vector<long long int> visit' 32 | vll visit,dist,taken; | ^~~~~ a.cc:49:52: error: reference to 'visit' is ambiguous 49 | void dfs(ll v){visit[v] = 1;for(auto x:adj[v]){if(!visit[x])dfs(x);}} | ^~~~~ /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:32:5: note: 'std::vector<long long int> visit' 32 | vll visit,dist,taken; | ^~~~~ a.cc: In function 'void bfs(ll)': a.cc:50:16: error: reference to 'visit' is ambiguous 50 | void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}} | ^~~~~ /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:32:5: note: 'std::vector<long long int> visit' 32 | vll visit,dist,taken; | ^~~~~ a.cc:50:122: error: reference to 'visit' is ambiguous 50 | void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}} | ^~~~~ /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:32:5: note: 'std::vector<long long int> visit' 32 | vll visit,dist,taken; | ^~~~~ a.cc:50:132: error: reference to 'visit' is ambiguous 50 | void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}} | ^~~~~ /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:32:5: note: 'std::vector<long long int> visit' 32 | vll visit,dist,taken; | ^~~~~
s961781593
p03684
C++
#include <iostream> #include <fstream> #include <vector> #include <algorithm> #include <cmath> #include <limits> #include <queue> #include <iomanip> #include <set> //#include <bits/stdc++.h> template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;} template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;} using namespace std; #define ALL(X) X.begin(),X.end() using ll = long long int; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<vvll> vvvll; const int MOD=1000000007; //const int MOD=998244353; const int INTMAX=2147483647; const ll LLMAX=9223372036854775807; bool comp(vll a,vll b){ return a[0]<b[0]; } int main(){ ios::sync_with_stdio(false); cin.tie(0); ll N; cin>>N; vvll x(N,vll(2)),y(N,vll(2)); for(ll i=0;i<N;i++){ cin>>x[i][0]>>y[i][0]; x[i][1]=i;y[i][1]=i; } sort(ALL(x),comp);sort(ALL(y),comp); vvll cost(N,vll(N,LLMAX)); for(ll i=0;i<N-1;i++){ cost[x[i][1]][x[i+1][1]]=x[i+1][0]-x[i][0]; cost[x[i+1][1]][x[i][1]]=x[i+1][0]-x[i][0]; } for(ll i=0;i<N-1;i++){ cost[y[i][1]][y[i+1][1]]=y[i+1][0]-y[i][0]; cost[y[i+1][1]][y[i][1]]=y[i+1][0]-y[i][0]; } vll s(2*N-2),t(2*N-2),c(2*N-2); for(ll i=0;i<N-1;i++){ s[i]=x[i][1]; t[i]=x[i+1][1]; c[i]=x[i+1][0]-x[i][0]; } for(ll i=0;i<N-1;i++){ s[i+N-1]=y[i][1]; t[i+N-1]=y[i+1][1]; c[i+N-1]=y[i+1][0]-y[i][0]; } cout<<kruskal(s,t,c,N)<<endl; return 0; }
a.cc: In function 'int main()': a.cc:68:11: error: 'kruskal' was not declared in this scope 68 | cout<<kruskal(s,t,c,N)<<endl; | ^~~~~~~
s705997866
p03684
C++
#include<iostream> #include<algorithm> using namespace std; struct edge { int x,y,cost; }; struct pct { int x,y,ind; }; bool cmp1(pct a, pct b) { return a.x<b.x; } bool cmp2(pct a, pct b) { return a.y<b.y; } bool cmp(edge a, edge b) { return a.cost<b.cost; } pct P[100005]; vector<edge> Edg; int Pa[100005],Sz[100005]; int parent(int x) { int cx=x; while(Pa[x]!=0) x=Pa[x]; while(Pa[cx]!=0) { int aux=Pa[cx]; Pa[cx]=x; cx=aux; } return x; } bool unite(int x, int y) { x=parent(x); y=parent(y); if(x==y) return 0; if(Sz[x]>=Sz[y]) { Sz[x]+=Sz[y]; Pa[y]=x; } else { Sz[y]+=Sz[x]; Pa[x]=y; } return 1; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin>>n; for(int i=1; i<=n; i++) { cin>>P[i].x>>P[i].y; P[i].ind=i; Sz[i]=1; } sort(P+1,P+n+1,cmp1); for(int i=2; i<=n; i++) Edg.push_back({P[i].ind,P[i-1].ind,P[i].x-P[i-1].x}); sort(P+1,P+n+1,cmp2); for(int i=2; i<=n; i++) Edg.push_back({P[i].ind,P[i-1].ind,P[i].y-P[i-1].y}); sort(Edg.begin(),Edg.end(),cmp); long long rez=0; for(auto edg:Edg) { if(unite(edg.x,edg.y)) rez+=edg.cost; } cout<<rez<<"\n"; return 0; }
a.cc:32:1: error: 'vector' does not name a type 32 | vector<edge> Edg; | ^~~~~~ a.cc: In function 'int main()': a.cc:89:9: error: 'Edg' was not declared in this scope 89 | Edg.push_back({P[i].ind,P[i-1].ind,P[i].x-P[i-1].x}); | ^~~ a.cc:93:9: error: 'Edg' was not declared in this scope 93 | Edg.push_back({P[i].ind,P[i-1].ind,P[i].y-P[i-1].y}); | ^~~ a.cc:95:10: error: 'Edg' was not declared in this scope 95 | sort(Edg.begin(),Edg.end(),cmp); | ^~~
s501421843
p03684
C++
//#include "pch.h" //#include "stdafx.h" #include <iostream> #include <set> #include <queue> #include <vector> #include <algorithm> #include <math.h> #include <cmath> #include <string> #include <cstring> #include <functional> #include <climits> #include <sstream> #include <iomanip> #include <map> #include <stack> using namespace std; /*-----------------------------------------------------------------------------  ライブラリ -------------------------------------------------------------------------------*/ #if 0 // 3次元 vector<vector<vector<SDWORD>>> XXX(AAA, vector<vector<SDWORD>>(BBBB, vector<SDWORD>(CCC, -1))); #endif #if 0 // 2分探索 auto position = lower_bound(getValue.begin(), getValue.end(), 0); // 0以上の要素位置を探す int idx_lower = distance(getValue.begin(), position); // 0以上の要素インデックス int eraseNum = MIN(idx_lower, delCnt); // 要素位置が個数になる #endif #if 0 // プライオリティーキュー、優先度 auto pqCmp = [](P a, P b) { return a.second > b.second; }; std::priority_queue<int, std::vector<int>, decltype(pqCmp)> que; #endif /*-----------------------------------------------------------------------------  定義 -------------------------------------------------------------------------------*/ #define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i)) #define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i)) #define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i)) #define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i)) #define INF 2e9 #define MOD (1000 * 1000 * 1000 + 7) #define MIN(a, b) ((a) < (b) ? a : b) #define MAX(a, b) ((a) > (b) ? a : b) #define CeilN(x, n) (((((DWORD)(x))+((n)-1))/n)*n) /* Nの倍数に切り上げ */ #define FloorN(x, n) ((x)-(x)%(n)) /* Nの倍数に切り下げ */ #define IsOdd(x) (((x)&0x01UL) == 0x01UL) #define IsEven(x) (!IsOdd((x))) #define ArrayLength(x) ( sizeof( x ) / sizeof( x[ 0 ] ) ) #define ArrayEnd(a) (&(a)[ArrayLength(a)]) #define ArrayLast(a) (&(a)[ArrayLength(a) - 1]) #define MAX_DWORD (0xFFFFFFFF) #define MAX_SDWORD ((SDWORD)0x7FFFFFFF) #define MIN_SDWORD ((SDWORD)0x80000000) #define MAX_QWORD ((QWORD)0xFFFFFFFFFFFFFFFF) #define MIN_QWORD ((QWORD)0x0000000000000000) #define MAX_SQWORD ((SQWORD)0x7FFFFFFFFFFFFFFF) #define MIN_SQWORD ((SQWORD)0x8000000000000000) #define M_PI 3.14159265358979 #define deg_to_rad(deg) (((deg)/360)*2*M_PI) #define rad_to_deg(rad) (((rad)/2/M_PI)*360) #define BitSetV(Val,Bit) ((Val) |= (Bit)) #define BitTstV(Val,Bit) ((Val) & (Bit)) typedef short SWORD; typedef long SDWORD; typedef long long SQWORD; typedef unsigned short WORD; typedef unsigned long DWORD; typedef unsigned long long int QWORD; typedef pair<int, int> P; /*-----------------------------------------------------------------------------  パラメータ定義 -------------------------------------------------------------------------------*/ #define N_MAX (100) #define K_MAX (10) #define M_MAX (1000) #define H_MAX (1000) #define W_MAX (1000) /*-----------------------------------------------------------------------------  処理 -------------------------------------------------------------------------------*/ struct edge { edge(int a, int b) { to = a; cost = b; } int to; int cost; }; struct queInfo { queInfo(int a, int b) { idx = a; cost = b; } int idx; int cost; }; bool cmpZahyou(P &a, P &b) { return a.second < b.second; } // メイン int main() { int N; vector<P> zahyouX; vector<P> zahyouY; // 入力 cin >> N; REP(i, N) { int x, y; cin >> x >> y; zahyouX.push_back(make_pair(i, x)); zahyouY.push_back(make_pair(i, y)); } // X方向のリスト static vector<edge> G[N_MAX]; sort(zahyouX.begin(), zahyouX.end(), cmpZahyou); REP(i, N - 1) { int prevIdx = zahyouX[i].first; int nextIdx = zahyouX[i + 1].first; int kyori = zahyouX[i + 1].second - zahyouX[i].second; G[prevIdx].push_back(edge(nextIdx, kyori)); G[nextIdx].push_back(edge(prevIdx, kyori)); } // Y方向のリスト sort(zahyouY.begin(), zahyouY.end(), cmpZahyou); REP(i, N - 1) { int prevIdx = zahyouY[i].first; int nextIdx = zahyouY[i + 1].first; int kyori = zahyouY[i + 1].second - zahyouY[i].second; G[prevIdx].push_back(edge(nextIdx, kyori)); G[nextIdx].push_back(edge(prevIdx, kyori)); } // プライオリティーキュー(昇順、0,0から) auto pqCmp = [](queInfo a, queInfo b) { return a.cost > b.cost; }; // greaterがないので代わり priority_queue<queInfo, vector<queInfo>, decltype(pqCmp)> que; que.push(queInfo(0, 0)); // プリム法 QWORD ans = 0; vector<bool> isUsed(N, false); vector<DWORD> minCost(N, MAX_DWORD); while (!que.empty()) { // 一番小さいのからとれる queInfo point = que.top(); que.pop(); if (isUsed[point.idx]) { // すでに使用済み continue; } if (minCost[point.idx] < point.cost) { // もっと小さいのが入ってる continue; } // 頂点採用 ans += point.cost; isUsed[point.idx] = true; for (auto egdeOne : G[point.idx]) { int nextCost = egdeOne.cost; if (minCost[egdeOne.to] > nextCost) { minCost[egdeOne.to] = nextCost; que.push(queInfo(egdeOne.to, nextCost)); } } } cout << ans; cout << endl; return 0; }
a.cc:70:9: warning: "M_PI" redefined 70 | #define M_PI 3.14159265358979 | ^~~~ In file included from /usr/include/c++/14/cmath:47, from /usr/include/c++/14/math.h:36, from a.cc:8: /usr/include/math.h:1121:10: note: this is the location of the previous definition 1121 | # define M_PI 3.14159265358979323846 /* pi */ | ^~~~ a.cc: In function 'int main()': a.cc:157:67: error: no matching function for call to 'std::priority_queue<queInfo, std::vector<queInfo>, main()::<lambda(queInfo, queInfo)> >::priority_queue()' 157 | priority_queue<queInfo, vector<queInfo>, decltype(pqCmp)> que; | ^~~ In file included from /usr/include/c++/14/queue:66, from a.cc:5: /usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate: 'template<class _InputIterator, class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&, const _Alloc&) [with _Alloc = _InputIterator; _Requires = _Alloc; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 691 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate expects 5 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 679 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate expects 5 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 671 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate expects 4 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 663 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&) [with <template-parameter-2-2> = _InputIterator; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 649 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate expects 4 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&) [with <template-parameter-2-2> = _InputIterator; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 638 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate expects 4 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&) [with <template-parameter-2-2> = _InputIterator; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 629 | priority_queue(_InputIterator __first, _InputIterator __last, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>&&, const _Alloc&) [with _Requires = _Alloc; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 594 | priority_queue(priority_queue&& __q, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const std::priority_queue<_Tp, _Sequence, _Compare>&, const _Alloc&) [with _Requires = _Alloc; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 590 | priority_queue(const priority_queue& __q, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&, const _Alloc&) [with _Requires = _Alloc; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 585 | priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&, const _Alloc&) [with _Requires = _Alloc; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 579 | priority_queue(const _Compare& __x, const _Sequence& __c, | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Alloc&) [with _Requires = _Alloc; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 573 | priority_queue(const _Compare& __x, const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Alloc&) [with _Requires = _Alloc; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 569 | priority_queue(const _Alloc& __a) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_queue.h:554:9: note: candidate: 'template<class _Seq, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue() [with _Requires = _Seq; _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 554 | priority_queue() | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:554:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_queue.h:551:43: error: no type named 'type' in 'struct std::enable_if<false, void>' 551 | template<typename _Seq = _Sequence, typename _Requires = typename | ^~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&) [with _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 563 | priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence()) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:558:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&) [with _Tp = queInfo; _Sequence = std::vector<queInfo>; _Compare = main()::<lambda(queInfo, queInfo)>]' 558 | priority_queue(const _Compare& __x, const _Sequence& __s) | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:558:7: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_queue.h:496:11: note: candidate: 'std::priority_queue<queInfo, std::vector<queInfo>, main()::<lambda(queInfo, queInfo)> >::priority_queue(const std::priority_queue<queInfo, std::vector<queInfo>, main()::<lambda(queInfo, queInfo)> >&)'
s733049455
p03684
C++
#include <bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; typedef long double ld; // typedef complex<double> point; ll mod = 1e9 + 7; #define EPS 1e-1 #define PI 3.141592653589 #define point complex<ld> #define dot(a, b) (conj(a) * b).real() #define cross(a, b) (conj(a) * b).imag() #define line tuple<ll, ll, ll> #define X real() #define Y imag() #define MAXN 100001 int spf[MAXN]; // int dx[] = { 0, 0, 1, -1 }; // int dy[] = { 1, -1, 0, 0 }; #define iofile \ freopen("input.txt", "r", stdin); \ freopen("output.txt", "w", stdout); #define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); using namespace std; void primeFactors(ll n, vector<ll> &vec) { while (n % 2 == 0) { vec.push_back(2); n = n / 2; } for (ll i = 3; i <= sqrt(n); i = i + 2) { while (n % i == 0) { vec.push_back(i); n = n / i; } } if (n > 2) { vec.push_back(n); } } ll gcd(ll a, ll b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } ll Lcm(ll a, ll b) { return ((a * b) / gcd(a, b)); } line getL(point p1, point p2) { ll a, b, c; a = p2.Y - p1.Y; b = p1.X - p2.X; c = -a * p1.X - b * p1.Y; ll gcdres = abs(gcd(a, gcd(b, c))); if (a < 0 || a == 0 && b < 0) { gcdres *= -1; } a /= gcdres; b /= gcdres; c /= gcdres; return line(a, b, c); } ll fastpow(ll base, ll pow) { if (!base) return 0; if (!pow) return 1; if (pow == 1) return base; ll x = fastpow(base, pow / 2) % mod; x *= x; x %= mod; if (pow % 2) x *= base; return x % mod; } ll inverse(ll x) { return fastpow(x, mod - 2) % mod; } ld disty(pair<double, double> a, pair<double, double> b) { return sqrt(pow(b.second - a.second, 2.0) + pow(b.first - a.first, 2.0)); } /*ll fact[(int)1e6 + 5], inv[(int)1e6 + 5]; void init() { fact[0] = inv[0] = 1; for (int i = 1; i <= 1e6; i++) { fact[i] = (i * fact[i - 1]) % mod; inv[i] = inverse(fact[i]); } }*/ void factorize(ll x, set<ll> &ss) { while (x % 2 == 0) ss.insert(2), x /= 2; for (int i = 3; i <= sqrt(x); i += 2) while (x % i == 0) ss.insert(i), x /= i; if (x > 2) ss.insert(x); } /*ll ncr(ll n, ll r) { return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod; }*/ void SieveOfEratosthenes(ll n, bool prime[]) { for (int p = 2; p * p <= n; p++) { if (prime[p] == true) { for (int i = p * p; i <= n; i += p) prime[i] = false; } } } void divisors(ll n, vector<ll> &vec) { // vec.push_back(1); for (ll i = 2; i <= sqrt(n); ++i) { if (n % i == 0 && i != sqrt(n)) { vec.push_back(i); vec.push_back(n / i); } else if (n % i == 0) { vec.push_back(i); } } //if(n!=1){vec.push_back(n);} } bool isprime(ll n) { if (n == 1) { return false; } for (int i = 2; i <= sqrt(n); ++i) { if (n % i == 0) { return false; } } return true; } point rot(point p, ld angle) { return (p * polar((ld)1.0, angle)); } point rotA(point p, point A, ld angle) { return (((p - A) * polar((ld)1, angle)) + A); } ld distance(point a, point b) { ld x1 = a.X, y1 = a.Y, x2 = b.X, y2 = b.Y; return pow(y2 - y1, 2) + pow(x2 - x1, 2); } int distSq(pair<ll, ll> p, pair<ll, ll> q) { return (p.first - q.first) * (p.first - q.first) + (p.second - q.second) * (p.second - q.second); } bool isSquare(pair<ll, ll> p1, pair<ll, ll> p2, pair<ll, ll> p3, pair<ll, ll> p4) { ll d2 = distSq(p1, p2); ll d3 = distSq(p1, p3); ll d4 = distSq(p1, p4); if (d2 == d3 && 2 * d2 == d4 && 2 * d2 == distSq(p2, p3)) { int d = distSq(p2, p4); return (d == distSq(p3, p4) && d == d2); } // The below two cases are similar to above case if (d3 == d4 && 2 * d3 == d2 && 2 * d3 == distSq(p3, p4)) { int d = distSq(p2, p3); return (d == distSq(p2, p4) && d == d3); } if (d2 == d4 && 2 * d2 == d3 && 2 * d2 == distSq(p2, p4)) { int d = distSq(p2, p3); return (d == distSq(p3, p4) && d == d2); } return false; } ll FP(ll base, ll power, ll m) { if (power == 0) { return 1; } else if (power % 2 == 0) { ll res = FP(base, power / 2, m); return (res % m * res % m) % m; } else { ll res = FP(base, power / 2, m); return ((((base % m * (res % m)) % m) * (res % m) % m) % m); } } ll EGCD(ll a, ll b, ll &x, ll &y) { if (b == 0) { x = 0; y = 1; return a; } else { ll ans = EGCD(b, a % b, x, y); ll tmp = x; x = y - (a / b) * x; y = tmp; return ans; } } // ll f[(int)1e7+7],in[(int)1e7+7]; /*void prec(ull n){ f[0]=1; in[0]=1; for(int i=1;i<=n;++i){ f[i]=(f[i-1]*i)%mod; in[i]=FP(f[i],mod-2,mod); } } ll npr(ll n,ll r){ return (f[n]*in[n-r])%mod; } ll NCR(ll n,ll r){ return (((f[n]*in[n-r])%mod)*in[r])%mod; }*/ void sieve() { spf[1] = 1; for (int i=2; i<MAXN; 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; } } } set<int> getFactorization(int x) { set<int> ret; while (x != 1) { ret.insert(spf[x]); x = x / spf[x]; } return ret; } void helper(int* a,int s,int e) { int mid=(s+e)/2; int i=s; int j=mid+1; int k=s; int temp[10]; while(i<=mid && j<=e) { if(a[i]<a[j]) { temp[k++]=a[i++]; } else { temp[k++]=a[j++]; } } while(i<=mid) { temp[k++]=a[i++]; } while(j<=e) { temp[k++]=a[j++]; } for(int h=s; h<=e; ++h) { a[h]=temp[h]; } } void mergesort(int* arr,int s,int e) { if(s>=e) { return; } int mid=(s+e)/2; mergesort(arr,s,mid); mergesort(arr,mid+1,e); helper(arr,s,e); } ll newfastpow(ll base,ll pow){ if(pow==0){return 1;} else if(pow%2==0){ ll x=newfastpow(base,pow/2); return x*x; } else{ ll x=newfastpow(base,pow/2); return x*x*base; } } /*ll saved[500][500]; vector<ll>arr; ll coins(ll wanted,ll idx){ if(wanted==0){return saved[wanted][idx]=1;} if(idx==arr.size()){return saved[wanted][idx]=0;} if(saved[wanted][idx]!=0){return saved[wanted][idx];} else if(arr[idx]<=wanted){ return saved[wanted][idx]=coins(wanted-arr[idx],idx)+coins(wanted,idx+1); } else{ return saved[wanted][idx]=coins(wanted,idx+1); } }*/ ll fact(ll n){ if(n==0){return 1;} else{return n*fact(n-1);} } int pivot(int start,int ending,int arr[],int N) { int mid; double before, after; while (start <= ending) { mid = (start + ending) / 2; if (mid == 0) { before = arr[N - 1]; } else { before = arr[mid - 1]; } if (mid == N - 1) { after = arr[0]; } else { after = arr[mid + 1]; } if(arr[mid]>after && arr[mid] > before) { break; } else if (after > before) { return pivot(mid + 1, ending, arr, N); } else { return pivot(start, mid - 1, arr, N); } } return arr[mid]; } int fib(int n,int arr[]){ if(n<=1){return arr[n]=1;} if(arr[n-1]==-1){arr[n-1]=fib(n-1,arr);} if(arr[n-2]==-1){arr[n-2]=fib(n-2,arr);} return arr[n-1]+arr[n-2]; } ll calcdec(string s){ ll power=s.size()-1; ll num=0; for(int i=0;i<s.size();++i){ ll val=s[i]-'0'; if(val==1){num+=(newfastpow(2,power)*val);} power--; } return num; } /*ll dijekstra() { priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq; for(int i=2; i<=n; ++i) { costs[i]=1e15; parent[i]=-1; } costs[1]=0; pq.push({costs[1],1}); while(!pq.empty()) { ll currnode=pq.top().second; ll currcst=pq.top().first; pq.pop(); if(currnode==n) { break; } if(costs[currnode]<currcst) { continue; } for(int i=0; i<graph[currnode].size(); ++i) { ll nextnode=graph[currnode][i].first; ll nextnodeweight=graph[currnode][i].second; if(costs[nextnode]>currcst+nextnodeweight) { costs[nextnode]=currcst+nextnodeweight; parent[nextnode]=currnode; pq.push({costs[nextnode],nextnode}); } } } return costs[n]; }*/ //vector<vector<ll> >graph; //bool visited[1000005]; /*void TS(int node){ if(visited[node]){return;} visited[node]=true; for(int i=0;i<graph[node].size();++i){ int child=graph[node][i]; if(!visited[child]){TS(child);} } cout<<node<<"\n"; }*/ string toString(ll num){ string s=""; if(num==0){return "0";} while(num>0){ char x=(num%10)+'0'; s=x+s; num/=10; } return s; } ll nc; ll rep[100005]; ll sz[100005]; ll maxx=1; void StartDSU(ll n){ for(int i=0;i<=n;++i){ rep[i]=i; sz[i]=1; } nc=n; } ll findu(ll u){ if(rep[u]==u){return u;} else{return rep[u]=findu(rep[u]);} } void Join(ll a,ll b){ a=findu(rep[a]); b=findu(rep[b]); if(a==b){return;} if(sz[a]<sz[b]){swap(a,b);} rep[b]=a; sz[a]+=sz[b]; nc-=1; maxx=max(maxx,sz[a]); } vector<pair<ll,pair<ll,ll> > >edges; ll kruskal(ll n){ ll cost=0; StartDSU(n); for(int i=0;i<edges.size();++i){ ll from=edges[i].second.first; ll to=edges[i].second.second; ll w=edges[i].first; if(findu(from)==findu(to)){continue;} else{ Join(from,to); cost+=w; } } return cost; } struct wasla{ ll fromx,fromy,tox,toy; }; int main() { //fastio //freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout); ll n; cin>>n; ll num=0; vector<pair<ll,ll> >xx,yy; map<pair<ll,ll>,ll>id; for(ll i=0;i<n;++i){ ll a,b; cin>>a>>b; pair<ll,ll>p(a,b),pp(b,a); xx.push_back(p); yy.push_back(pp); id[{a,b}]=num; num++; } sort(xx.begin(),xx.end()); sort(yy.begin(),yy.end()); map<ll,vector<wasla> >mp; map<ll,vector<wasla> >::iterator it; for(ll i=0;i<xx.size()-1;++i){ ll val1=abs(xx[i].first-xx[i+1].first); ll val2=abs(yy[i].first-yy[i+1].first); wasla w1,w2; w1.fromx=xx[i].first; w1.fromy=xx[i].second; w1.tox=xx[i+1].first; w1.toy=xx[i+1].second; w2.fromx=yy[i].second; w2.fromy=yy[i].first; w2.tox=yy[i+1].second; w2.toy=yy[i+1].first; mp[val1].push_back(w1); mp[val2].push_back(w2); } StartDSU(n); ll finalcost=0; for(it=mp.begin();it!=mp.end();++it){ ll pay=it->first; for(l i=0;i<mp[pay].size();++i){ pair<ll,ll>from(mp[pay][i].fromx,mp[pay][i].fromy),to(mp[pay][i].tox,mp[pay][i].toy); if(findu(id[from])==findu(id[to])){continue;} else{ Join(id[from],id[to]); finalcost+=pay; } } } cout<<finalcost<<"\n"; return 0; }
a.cc: In function 'int main()': a.cc:585:13: error: 'l' was not declared in this scope 585 | for(l i=0;i<mp[pay].size();++i){ | ^ a.cc:585:19: error: 'i' was not declared in this scope; did you mean 'it'? 585 | for(l i=0;i<mp[pay].size();++i){ | ^ | it
s748750495
p03684
C++
#include <algorithm> #include <bits/stdc++.h> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X)) #define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X)) #define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++) #define all(X) (X).begin(), (X).end() #define pb push_back #define mp make_pair #define fi first #define sc second #define print(x) cout << x << endl typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<bool> vb; typedef priority_queue<ll, vl> decendingQueue; //降順 typedef priority_queue<ll, vl, greater<ll>> ascendingQueue; //昇順 const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const ll INF = 9 * 1e18; const ll MOD = 1e9 + 7; class UnionFindTree { private: vector<int> par; vector<int> rnk; vector<int> siz; public: UnionFindTree(int n) { par.assign(n, -1); rnk.assign(n, -1); siz.assign(n, -1); for (int i = 0; i < n; ++i) { par[i] = i; rnk[i] = 0; siz[i] = 1; } } int find(int x) { if (par[x] == x) return x; else return par[x] = find(par[x]); } bool same(int x, int y) { return find(x) == find(y); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rnk[x] < rnk[y]) { par[x] = y; siz[y] += siz[x]; } else { par[y] = x; siz[x] += siz[y]; if (rnk[x] == rnk[y]) ++rnk[x]; } } int size(int x) { x = find(x); return siz[x]; } }; class Edge { public: ll from; ll to; ll cost; Edge() {} Edge(ll from, ll to, ll cost) { this->from = from; this->to = to; this->cost = cost; } bool operator<(const Edge &edge) const { return cost < edge.cost; //昇順 } bool operator>(const Edge &edge) const { return cost > edge.cost; //降順(std::greater) } }; class Graph { public: ll nodes; // ノード数 vector<Edge> edges; Graph() {} Graph(ll nodes) { this->nodes = nodes; } void addEdge(ll from, ll to, ll cost) { this->edges.push_back(Edge(from, to, cost)); } }; class Kruskal { private: Graph graph; vector<Edge> MinimumSpanningTree; ll minimumCost; void Kruskal::searchMinimumSpanningTree() { UnionFindTree uf(graph.nodes); sort(all(graph.edges)); itrep(edge, graph.edges) { if (!uf.same(edge->from, edge->to)) { uf.unite(edge->from, edge->to); MinimumSpanningTree.push_back(*edge); } } } public: Kruskal::Kruskal(Graph graph) { this->graph = graph; } ll Kruskal::getMinimumSpanningTreeCost() { searchMinimumSpanningTree(); ll cost = 0; itrep(it, MinimumSpanningTree) { cost += it->cost; } return cost; } }; // ベルマンフォード O(|V||E|) class BellmanFord { private: Graph graph; // 閉路が含まれるかは個々のノードごとに管理する必要あり vector<bool> hasNegativeCycles; vector<ll> distances; public: BellmanFord(Graph graph) { this->graph = graph; this->distances = vector<ll>(this->graph.nodes + 1, INF); this->hasNegativeCycles = vector<bool>(this->graph.nodes, false); } void searchMinimumPath(ll src) { this->distances[src] = 0; vector<pair<ll, pair<ll, ll>>>::iterator it; for (ll i = 0; i < graph.nodes - 1; i++) { itrep(edge, graph.edges) { ll u = edge->from; ll v = edge->to; ll w = edge->cost; if (this->distances[u] + w < this->distances[v]) { this->distances[v] = this->distances[u] + w; } } } itrep(edge, graph.edges) { ll u = edge->from; ll v = edge->to; ll w = edge->cost; if (this->distances[u] + w < this->distances[v]) { this->hasNegativeCycles[v] = true; } if (this->hasNegativeCycles[u] == true) { this->hasNegativeCycles[v] = true; } } } ll getDistance(ll n) { return this->distances[n]; } bool hasNegativeCycle(ll n) { return this->hasNegativeCycles[n]; } }; void solve(long long N, std::vector<long long> x, std::vector<long long> y) { vector<pll> xi; vector<pll> yi; rep(i, 0, N) { xi.push_back(mp(x[i], i)); yi.push_back(mp(y[i], i)); } sort(all(xi)); sort(all(yi)); Graph g(N); rep(i, 0, N - 1) { ll xi1 = xi[i].sc; ll xi2 = xi[i + 1].sc; ll cost = min(abs(x[xi1] - x[xi2]), abs(y[xi1] - y[xi2])); g.addEdge(xi1, xi2, cost); ll yi1 = yi[i].sc; ll yi2 = yi[i + 1].sc; cost = min(abs(x[yi1] - x[yi2]), abs(y[yi1] - y[yi2])); g.addEdge(yi1, yi2, cost); } // 最小全域木(クラスカル法) Kruskal kruskal(g); print(kruskal.getMinimumSpanningTreeCost()); } int main() { long long N; scanf("%lld", &N); std::vector<long long> x(N); std::vector<long long> y(N); for (int i = 0; i < N; i++) { scanf("%lld", &x[i]); scanf("%lld", &y[i]); } solve(N, std::move(x), std::move(y)); return 0; }
a.cc:132:8: error: extra qualification 'Kruskal::' on member 'searchMinimumSpanningTree' [-fpermissive] 132 | void Kruskal::searchMinimumSpanningTree() { | ^~~~~~~ a.cc:144:3: error: extra qualification 'Kruskal::' on member 'Kruskal' [-fpermissive] 144 | Kruskal::Kruskal(Graph graph) { this->graph = graph; } | ^~~~~~~ a.cc:145:6: error: extra qualification 'Kruskal::' on member 'getMinimumSpanningTreeCost' [-fpermissive] 145 | ll Kruskal::getMinimumSpanningTreeCost() { | ^~~~~~~
s620510686
p03684
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0;i<(n);i++) struct city{ int x,y,i; city(int x_,int y_,int i_){ x=x_,y=y_,i=i_; }; }; struct edge{ int cst,e1,e2; edge(int cst_,int e1_,int e2_){ cst=cst_,e1=e1_,e2=e2_; }; bool operator<(const edge& o)const{cst>o.cst;} }; struct unionFind{ size_t n; vector<int> pr; unionFind(size_t n_){ n=n_; pr.resize(n,-1); }; int root(int a){ if(pr[a]==-1)return a; else return pr[a]=root(pr[a]); } void unify(int a,int b){ a=root(a);b=root(b); if(a==b)return; pr[b]=a; } bool same(int a,int b){return root(a)==root(b);} }; signed main(){ size_t n;cin>>n; vector<city>c(n); rep(i,n){cin>>c[i].x>>c[i].y;c[i].i=i;} priority_queue<edge> pq; sort(begin(c),end(c),[&](city a,city b){return a.x<b.x;}); rep(i,n-1)pq.push(edge(c[i+1].x-c[i].x,c[i].i,c[i+1].i)); sort(begin(c),end(c),[&](city a,city b){return a.y<b.y;}); rep(i,n-1)pq.push(edge(c[i+1].y-c[i].y,c[i].i,c[i+1].i)); unionFind uf(n); int cnt=0,sm=0; while(!pq.empty()){ edge x=pq.top();pq.pop(); if(uf.same(x.e1,x.e2))continue; uf.unify(x.e1,x.e2); cnt++;sm+=x.cst; if(cnt==n-1)break; } cout<<sm<<endl; }
a.cc: In member function 'bool edge::operator<(const edge&) const': a.cc:19:62: warning: no return statement in function returning non-void [-Wreturn-type] 19 | bool operator<(const edge& o)const{cst>o.cst;} | ^ In file included from /usr/include/c++/14/bits/stl_tempbuf.h:61, from /usr/include/c++/14/bits/stl_algo.h:69, from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_construct.h: In instantiation of 'void std::_Construct(_Tp*, _Args&& ...) [with _Tp = city; _Args = {}]': /usr/include/c++/14/bits/stl_uninitialized.h:643:18: required from 'static _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = city*; _Size = long unsigned int; bool _TrivialValueType = false]' 643 | std::_Construct(std::__addressof(*__cur)); | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_uninitialized.h:712:20: required from '_ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = city*; _Size = long unsigned int]' 710 | return __uninitialized_default_n_1<__is_trivial(_ValueType) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 711 | && __can_fill>:: | ~~~~~~~~~~~~~~~~ 712 | __uninit_default_n(__first, __n); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_uninitialized.h:779:44: required from '_ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = city*; _Size = long unsigned int; _Tp = city]' 779 | { return std::__uninitialized_default_n(__first, __n); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1720:36: required from 'void std::vector<_Tp, _Alloc>::_M_default_initialize(size_type) [with _Tp = city; _Alloc = std::allocator<city>; size_type = long unsigned int]' 1720 | std::__uninitialized_default_n_a(this->_M_impl._M_start, __n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1721 | _M_get_Tp_allocator()); | ~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:558:9: required from 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = city; _Alloc = std::allocator<city>; size_type = long unsigned int; allocator_type = std::allocator<city>]' 558 | { _M_default_initialize(__n); } | ^~~~~~~~~~~~~~~~~~~~~ a.cc:44:17: required from here 44 | vector<city>c(n); | ^ /usr/include/c++/14/bits/stl_construct.h:119:7: error: no matching function for call to 'city::city()' 119 | ::new((void*)__p) _Tp(std::forward<_Args>(__args)...); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:8:17: note: candidate: 'city::city(long long int, long long int, long long int)' 8 | city(int x_,int y_,int i_){ | ^~~~ a.cc:8:17: note: candidate expects 3 arguments, 0 provided a.cc:6:8: note: candidate: 'constexpr city::city(const city&)' 6 | struct city{ | ^~~~ a.cc:6:8: note: candidate expects 1 argument, 0 provided a.cc:6:8: note: candidate: 'constexpr city::city(city&&)' a.cc:6:8: note: candidate expects 1 argument, 0 provided
s049004710
p03684
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0;i<(n);i++) struct city{ int x,y,i; city(int x_,int y_,int i_){ x=x_,y=y_,i=i_; }; }; struct edge{ int cst,e1,e2; edge(int cst_,int e1_,int e2_){ cst=cst_,e1=e1_,e2=e2_; }; bool operator<(const edge& o)const{cst>o.cst;} }; struct unionFind{ int n; vector<int> pr; unionFind(size_t n_){ n=n_; pr.resize(n,-1); }; int root(int a){ if(pr[a]==-1)return a; else return pr[a]=root(pr[a]); } void unify(int a,int b){ a=root(a);b=root(b); if(a==b)return; pr[b]=a; } bool same(int a,int b){return root(a)==root(b);} }; signed main(){ size_t n;cin>>n; vector<city>c(n); rep(i,n){cin>>c[i].x>>c[i].y;c[i].i=i;} priority_queue<edge> pq; sort(begin(c),end(c),[&](city a,city b){return a.x<b.x;}); rep(i,n-1)pq.push(edge(c[i+1].x-c[i].x,c[i].i,c[i+1].i)); sort(begin(c),end(c),[&](city a,city b){return a.y<b.y;}); rep(i,n-1)pq.push(edge(c[i+1].y-c[i].y,c[i].i,c[i+1].i)); unionFind uf(n); int cnt=0,sm=0; while(!pq.empty()){ edge x=pq.top();pq.pop(); if(uf.same(x.e1,x.e2))continue; uf.unify(x.e1,x.e2); cnt++;sm+=x.cst; if(cnt==n-1)break; } cout<<sm<<endl; }
a.cc: In member function 'bool edge::operator<(const edge&) const': a.cc:19:62: warning: no return statement in function returning non-void [-Wreturn-type] 19 | bool operator<(const edge& o)const{cst>o.cst;} | ^ In file included from /usr/include/c++/14/bits/stl_tempbuf.h:61, from /usr/include/c++/14/bits/stl_algo.h:69, from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_construct.h: In instantiation of 'void std::_Construct(_Tp*, _Args&& ...) [with _Tp = city; _Args = {}]': /usr/include/c++/14/bits/stl_uninitialized.h:643:18: required from 'static _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = city*; _Size = long unsigned int; bool _TrivialValueType = false]' 643 | std::_Construct(std::__addressof(*__cur)); | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_uninitialized.h:712:20: required from '_ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = city*; _Size = long unsigned int]' 710 | return __uninitialized_default_n_1<__is_trivial(_ValueType) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 711 | && __can_fill>:: | ~~~~~~~~~~~~~~~~ 712 | __uninit_default_n(__first, __n); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_uninitialized.h:779:44: required from '_ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = city*; _Size = long unsigned int; _Tp = city]' 779 | { return std::__uninitialized_default_n(__first, __n); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1720:36: required from 'void std::vector<_Tp, _Alloc>::_M_default_initialize(size_type) [with _Tp = city; _Alloc = std::allocator<city>; size_type = long unsigned int]' 1720 | std::__uninitialized_default_n_a(this->_M_impl._M_start, __n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1721 | _M_get_Tp_allocator()); | ~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:558:9: required from 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = city; _Alloc = std::allocator<city>; size_type = long unsigned int; allocator_type = std::allocator<city>]' 558 | { _M_default_initialize(__n); } | ^~~~~~~~~~~~~~~~~~~~~ a.cc:44:17: required from here 44 | vector<city>c(n); | ^ /usr/include/c++/14/bits/stl_construct.h:119:7: error: no matching function for call to 'city::city()' 119 | ::new((void*)__p) _Tp(std::forward<_Args>(__args)...); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:8:17: note: candidate: 'city::city(long long int, long long int, long long int)' 8 | city(int x_,int y_,int i_){ | ^~~~ a.cc:8:17: note: candidate expects 3 arguments, 0 provided a.cc:6:8: note: candidate: 'constexpr city::city(const city&)' 6 | struct city{ | ^~~~ a.cc:6:8: note: candidate expects 1 argument, 0 provided a.cc:6:8: note: candidate: 'constexpr city::city(city&&)' a.cc:6:8: note: candidate expects 1 argument, 0 provided
s880842789
p03684
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0;i<(n);i++) struct city{ int x,y,i; city(int x_,int y_,int i_){ x=x_,y=y_,i=i_; }; }; struct edge{ int cst,e1,e2; edge(int cst_,int e1_,int e2_){ cst=cst_,e1=e1_,e2=e2_; }; bool operator<(const edge& o)const{cst>o.cst;} }; struct unionFind{ int n; vector<int> pr; unionFind(int n_){ n=n_; pr.resize(n,-1); }; int root(int a){ if(pr[a]==-1)return a; else return pr[a]=root(pr[a]); } void unify(int a,int b){ a=root(a);b=root(b); if(a==b)return; pr[b]=a; } bool same(int a,int b){return root(a)==root(b);} }; signed main(){ int n;cin>>n; vector<city>c(n); rep(i,n){cin>>c[i].x>>c[i].y;c[i].i=i;} priority_queue<edge> pq; sort(begin(c),end(c),[&](city a,city b){return a.x<b.x;}); rep(i,n-1)pq.push(edge(c[i+1].x-c[i].x,c[i].i,c[i+1].i)); sort(begin(c),end(c),[&](city a,city b){return a.y<b.y;}); rep(i,n-1)pq.push(edge(c[i+1].y-c[i].y,c[i].i,c[i+1].i)); unionFind uf(n); int cnt=0,sm=0; while(!pq.empty()){ edge x=pq.top();pq.pop(); if(uf.same(x.e1,x.e2))continue; uf.unify(x.e1,x.e2); cnt++;sm+=x.cst; if(cnt==n-1)break; } cout<<sm<<endl; }
a.cc: In member function 'bool edge::operator<(const edge&) const': a.cc:19:62: warning: no return statement in function returning non-void [-Wreturn-type] 19 | bool operator<(const edge& o)const{cst>o.cst;} | ^ In file included from /usr/include/c++/14/bits/stl_tempbuf.h:61, from /usr/include/c++/14/bits/stl_algo.h:69, from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_construct.h: In instantiation of 'void std::_Construct(_Tp*, _Args&& ...) [with _Tp = city; _Args = {}]': /usr/include/c++/14/bits/stl_uninitialized.h:643:18: required from 'static _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = city*; _Size = long unsigned int; bool _TrivialValueType = false]' 643 | std::_Construct(std::__addressof(*__cur)); | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_uninitialized.h:712:20: required from '_ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = city*; _Size = long unsigned int]' 710 | return __uninitialized_default_n_1<__is_trivial(_ValueType) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 711 | && __can_fill>:: | ~~~~~~~~~~~~~~~~ 712 | __uninit_default_n(__first, __n); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_uninitialized.h:779:44: required from '_ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = city*; _Size = long unsigned int; _Tp = city]' 779 | { return std::__uninitialized_default_n(__first, __n); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1720:36: required from 'void std::vector<_Tp, _Alloc>::_M_default_initialize(size_type) [with _Tp = city; _Alloc = std::allocator<city>; size_type = long unsigned int]' 1720 | std::__uninitialized_default_n_a(this->_M_impl._M_start, __n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1721 | _M_get_Tp_allocator()); | ~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:558:9: required from 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = city; _Alloc = std::allocator<city>; size_type = long unsigned int; allocator_type = std::allocator<city>]' 558 | { _M_default_initialize(__n); } | ^~~~~~~~~~~~~~~~~~~~~ a.cc:44:17: required from here 44 | vector<city>c(n); | ^ /usr/include/c++/14/bits/stl_construct.h:119:7: error: no matching function for call to 'city::city()' 119 | ::new((void*)__p) _Tp(std::forward<_Args>(__args)...); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:8:17: note: candidate: 'city::city(long long int, long long int, long long int)' 8 | city(int x_,int y_,int i_){ | ^~~~ a.cc:8:17: note: candidate expects 3 arguments, 0 provided a.cc:6:8: note: candidate: 'constexpr city::city(const city&)' 6 | struct city{ | ^~~~ a.cc:6:8: note: candidate expects 1 argument, 0 provided a.cc:6:8: note: candidate: 'constexpr city::city(city&&)' a.cc:6:8: note: candidate expects 1 argument, 0 provided
s960874038
p03684
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second const int oo = 1e9 + 7; typedef pair<int, int> ii; typedef pair<ii, int> iii; int n, par[100001], sz[100001]; vector<iii> point, edg; int dist(int a, int b, int c, int d){ return min(abs(a - c), abs(b - d)); } int anc(int x){ if(par[x] == -1) return x; else return (par[x] = root(par[x])); } bool issameset(int x, int y){ return (anc(x) == anc(y));} void uni(int x, int y){ x = anc(x); y = anc(y); if(sz[x] > sz[y]){ sz[x] += sz[y]; par[y] = x; } else{ sz[y] += sz[x]; par[x] = y; } } bool cmp(iii a, iii b){ return a.se < b.se; } signed main(){ cin >> n; for(int i = 1; i <= n; i++){ iii pt; cin >> pt.fi.fi >> pt.fi.se; pt.second = i; point.push_back(pt); } point.push_back(make_pair(make_pair(-oo, -oo), 0)); point.push_back(make_pair(make_pair(2 * oo, 2 * oo), 0)); sort(point.begin(), point.end()); for(int i = 1; i <= n; i++){ if(abs(point[i].fi.fi - point[i - 1].fi.fi) > abs(point[i].fi.fi - point[i + 1].fi.fi)) edg.push_back({{point[i].se, point[i + 1].se}, dist(point[i].fi.fi, point[i].fi.se, point[i + 1].fi.fi, point[i + 1].fi.se)}); else if(abs(point[i].fi.fi - point[i - 1].fi.fi) < abs(point[i].fi.fi - point[i + 1].fi.fi)) edg.push_back({{point[i].se, point[i - 1].se}, dist(point[i].fi.fi, point[i].fi.se, point[i - 1].fi.fi, point[i - 1].fi.se)}); else{ if(abs(point[i].fi.se - point[i - 1].fi.se) > abs(point[i].fi.se - point[i + 1].fi.se)) edg.push_back({{point[i].se, point[i + 1].se}, dist(point[i].fi.fi, point[i].fi.se, point[i + 1].fi.fi, point[i + 1].fi.se)}); else edg.push_back({{point[i].se, point[i - 1].se}, dist(point[i].fi.fi, point[i].fi.se, point[i - 1].fi.fi, point[i - 1].fi.se)}); } } for(int i = 1; i <= n; i++) swap(point[i].fi.fi, point[i].fi.se); sort(point.begin(), point.end()); for(int i = 1; i <= n; i++){ if(abs(point[i].fi.fi - point[i - 1].fi.fi) > abs(point[i].fi.fi - point[i + 1].fi.fi)) edg.push_back({{point[i].se, point[i + 1].se}, dist(point[i].fi.fi, point[i].fi.se, point[i + 1].fi.fi, point[i + 1].fi.se)}); else if(abs(point[i].fi.fi - point[i - 1].fi.fi) < abs(point[i].fi.fi - point[i + 1].fi.fi)) edg.push_back({{point[i].se, point[i - 1].se}, dist(point[i].fi.fi, point[i].fi.se, point[i - 1].fi.fi, point[i - 1].fi.se)}); else{ if(abs(point[i].fi.se - point[i - 1].fi.se) > abs(point[i].fi.se - point[i + 1].fi.se)) edg.push_back({{point[i].se, point[i + 1].se}, dist(point[i].fi.fi, point[i].fi.se, point[i + 1].fi.fi, point[i + 1].fi.se)}); else edg.push_back({{point[i].se, point[i - 1].se}, dist(point[i].fi.fi, point[i].fi.se, point[i - 1].fi.fi, point[i - 1].fi.se)}); } } for(int i = 1; i <= n; i++) par[i] = -1; sort(edg.begin(), edg.end(), cmp); int ans = 0; for(int i = 0; i < edg.size(); i++){ //cout << edg[i].fi.fi << " " << edg[i].fi.se << " " << edg[i].se << endl; if(!issameset(edg[i].fi.fi, edg[i].fi.se)){ ans += edg[i].se; uni(edg[i].fi.fi, edg[i].fi.se); } } cout << ans; }
a.cc: In function 'long long int anc(long long int)': a.cc:20:31: error: 'root' was not declared in this scope 20 | else return (par[x] = root(par[x])); | ^~~~
s378777495
p03684
C++
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; struct point { int x, y, id; } a[N]; bool cmp1(const point& a, const point& b) { if (a.x != b.x) { return a.x < b.x; } return a.y < b.y; } bool cmp2(const point& a, const point& b) { if (a.y != b.y) { return a.y < b.y; } return a.x < b.x; } int n; bool visited[N]; vector<pair<long long, int> > g[N]; long long prim(int x) { priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > pq; long long ans = 0; pq.push({0, x}); while(!pq.empty()) { pair<long long, int> p = pq.top(); pq.pop(); x = p.second; if (visited[x]) { continue; } ans += p.first; visited[x] = true; for(int i = 0; i < g[x].size(); i++) { int y = g[x][i].second; if (!visited[y]) { pq.push(g[x][i]); } } } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i = 0; i < n; i++) { cin >> a[i].x >> a[i].y; a[i].id = i + 1; } sort(p, p + n, cmp1); for (int i = 1; i < n; i++) { g[a[i].id].push_back({abs(a[i].x - a[i - 1].x), a[i - 1].id}); g[a[i - 1].id].push_back({abs(a[i].x - a[i - 1].x), a[i].id}); } sort(p, p + n, cmp2); for (int i = 1; i < n; i++) { g[a[i].id].push_back({abs(a[i].y - a[i - 1].y), a[i - 1].id}); g[a[i - 1].id].push_back({abs(a[i].y - a[i - 1].y), a[i].id}); } cout << prim(1) << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:60:14: error: 'p' was not declared in this scope 60 | sort(p, p + n, cmp1); | ^
s764604370
p03684
C++
typedef long long ll; int N; void _main() { cin >> N; vector<pair<int, int>> va, vb; rep(i, 0, N) { int x, y; cin >> x >> y; va.push_back({ x, i }); vb.push_back({ y, i }); } vector<tuple<int, int, int>> edges; sort(va.begin(), va.end()); sort(vb.begin(), vb.end()); rep(i, 0, N - 1) { edges.push_back(make_tuple( va[i + 1].first - va[i].first, va[i].second, va[i + 1].second )); edges.push_back(make_tuple( vb[i + 1].first - vb[i].first, vb[i].second, vb[i + 1].second)); } sort(edges.begin(), edges.end()); UnionFind uf(N); ll ans = 0; for (auto p : edges) { int x, y, c; tie(c, x, y) = p; if (uf[x] != uf[y]) { uf(x, y); ans += c; } } cout << ans << endl; }
a.cc: In function 'void _main()': a.cc:5:5: error: 'cin' was not declared in this scope 5 | cin >> N; | ^~~ a.cc:6:5: error: 'vector' was not declared in this scope 6 | vector<pair<int, int>> va, vb; | ^~~~~~ a.cc:6:12: error: 'pair' was not declared in this scope 6 | vector<pair<int, int>> va, vb; | ^~~~ a.cc:6:17: error: expected primary-expression before 'int' 6 | vector<pair<int, int>> va, vb; | ^~~ a.cc:7:9: error: 'i' was not declared in this scope 7 | rep(i, 0, N) { | ^ a.cc:7:5: error: 'rep' was not declared in this scope 7 | rep(i, 0, N) { | ^~~ a.cc:13:12: error: 'tuple' was not declared in this scope 13 | vector<tuple<int, int, int>> edges; | ^~~~~ a.cc:13:18: error: expected primary-expression before 'int' 13 | vector<tuple<int, int, int>> edges; | ^~~ a.cc:14:10: error: 'va' was not declared in this scope 14 | sort(va.begin(), va.end()); | ^~ a.cc:14:5: error: 'sort' was not declared in this scope; did you mean 'short'? 14 | sort(va.begin(), va.end()); | ^~~~ | short a.cc:15:10: error: 'vb' was not declared in this scope 15 | sort(vb.begin(), vb.end()); | ^~ a.cc:20:10: error: 'edges' was not declared in this scope 20 | sort(edges.begin(), edges.end()); | ^~~~~ a.cc:22:5: error: 'UnionFind' was not declared in this scope 22 | UnionFind uf(N); | ^~~~~~~~~ a.cc:26:9: error: 'tie' was not declared in this scope 26 | tie(c, x, y) = p; | ^~~ a.cc:28:13: error: 'uf' was not declared in this scope 28 | if (uf[x] != uf[y]) { | ^~ a.cc:33:5: error: 'cout' was not declared in this scope 33 | cout << ans << endl; | ^~~~ a.cc:33:20: error: 'endl' was not declared in this scope 33 | cout << ans << endl; | ^~~~
s802946844
p03684
C++
#include <stdio.h> #include <stdlib.h> #include <algorithm> // 全局变量 const int N = 100010 , M = N + N; int x[N],y[N],id[N],n; typedef struct ufset *UFset; struct ufset { int *parent; int *root; }; UFset UFinit(int size) { int e; UFset U=(UFset)malloc(sizeof *U); U->parent=(int*)malloc((size+1)*sizeof(int)); U->root=(int*)malloc((size+1)*sizeof(int)); for(e=1; e<=size; e++) { U->parent[e]=1; U->root[e]=1; } return U; } int UFfind(int e,UFset U) { int i,j = e; while(!U->root[j]) j = U->parent[j]; while(j!=e){ i = U->parent[e]; U->parent[e]=j; e=i; } return j; } int UFunion(int i,int j,UFset U) { if(U->parent[i]<U->parent[j]) { U->parent[j]+=U->parent[i]; U->root[i]=0; U->parent[i]=j; return j; } else { U->parent[i]+=U->parent[j]; U->root[j]=0; U->parent[j]=i; return i; } } // 记录优化后的边集数 struct Edge { int u, v, cost; bool operator <(const Edge&b) const { return cost < b.cost; } } edge[M]; int tot; // 按照X轴排序 bool cmpX(int a, int b) { return x[a] < x[b]; } // 按照Y轴排序 bool cmpY(int a, int b) { return y[a] < y[b]; } void add(int c, int a, int b) { edge[tot].cost = c; edge[tot].u = a; edge[tot++].v = b; } int main() { scanf("%d", &n); int i for (i = 1; i <= n; ++i) { scanf("%d%d", x + i, y + i); id[i] = i; } std::sort(id + 1 , id + n + 1, cmpX); for (i = 2; i <= n; ++i) add(x[id[i]] - x[id[i - 1]], id[i], id[i - 1]); std::sort(id + 1 , id + n + 1, cmpY); for (i = 2; i <= n; ++i) add(y[id[i]] - y[id[i - 1]], id[i], id[i - 1]); UFset UFS = UFinit(n); // 按照花费排序 std::sort(edge, edge + tot); long long totcost = 0; for (i = 0; i < tot; ++i) { int u = edge[i].u, v = edge[i].v; u = UFfind(u,UFS), v = UFfind(v,UFS); if (u != v) { UFunion(u,v,UFS); totcost += edge[i].cost; } } printf("%lld\n", totcost); return 0; }
a.cc: In function 'int main()': a.cc:87:3: error: expected initializer before 'for' 87 | for (i = 1; i <= n; ++i) | ^~~ a.cc:87:15: error: 'i' was not declared in this scope 87 | for (i = 1; i <= n; ++i) | ^ a.cc:106:24: error: 'v' was not declared in this scope 106 | u = UFfind(u,UFS), v = UFfind(v,UFS); | ^
s756153049
p03684
Java
import sys import heapq def getn(): return int(sys.stdin.readline()) def getnums(): return list(map(int,(sys.stdin.readline().split()))) INF=10000000000 n = getn() pos = [] edge = [[] for i in range(n)] for i in range(n): x,y = getnums() pos.append([x,y,i]) pos.sort(key=lambda x:x[0]) for i,j in zip(pos, pos[1:]): x1,y1,i1 = i x2,y2,i2 = j cost = min(abs(x1-x2), abs(y1-y2)) edge[i1].append([cost,i2]) edge[i2].append([cost,i1]) pos.sort(key=lambda x:x[1]) for i,j in zip(pos, pos[1:]): x1,y1,i1 = i x2,y2,i2 = j cost = min(abs(x1-x2), abs(y1-y2)) edge[i1].append([cost,i2]) edge[i2].append([cost,i1]) def prim(start, n): ans = 0 n_set = 1 group = set([start]) q = edge[start] heapq.heapify(q) while(q): next_e = heapq.heappop(q) if next_e[1] in group: pass else: ans += next_e[0] group.add(next_e[1]) for ne in edge[next_e[1]]: heapq.heappush(q, ne) n_set += 1 #print("union: ", next_e[1], group) #print(q) if n_set == n: return ans ans = prim(0, n) print(ans) #print(edge)
Main.java:1: error: '.' expected import sys ^ Main.java:2: error: '.' expected import heapq ^ Main.java:3: error: ';' expected def getn(): ^ Main.java:48: error: illegal character: '#' #print("union: ", next_e[1], group) ^ Main.java:49: error: illegal character: '#' #print(q) ^ Main.java:55: error: illegal character: '#' #print(edge) ^ 6 errors
s913298631
p03684
C++
/* _____ .'|||||'. / > < \ | ^ | | \ / | \ '---' / '._____.' ||||| */ #include<iostream> #include<string> #include<algorithm> #include<cstdlib> #include<cstdio> #include<set> #include<map> #include<vector> #include<cstring> #include<stack> #include<cmath> #include<queue> using namespace std; #define CL(x,v); memset(x,v,sizeof(x)); #define INF 0x3f3f3f3f #define LL long long #define REP(i,r,n) for(int i=r;i<=n;i++) #define RREP(i,n,r) for(int i=n;i>=r;i--) struct part{ LL v; int id; }; struct part1{ int x,y; LL v; }; bool cmp(struct part a, struct part b) { return(a.v<b.v); } int f[100010]; int find1(int x) { if (f[x]==x) return(x); else f[x]=find1(f[x]); retufn(f[x]); } bool cmp1(struct part1 a, struct part1 b) { return(a.v<b.v); } struct part x[100010],y[100010]; struct part1 a[200010]; int n; int main() { scanf("%d",&n); for (int i=1;i<=n;i++) { LL xx,yy; scanf("%lld%lld",&xx,&yy); x[i].v=xx; x[i].id=i; y[i].v=yy; y[i].id=i; } sort(x+1,x+1+n,cmp); sort(y+1,y+1+n,cmp); int o=0; for (int i=1;i<=n-1;i++) { o++; a[o].x=x[i].id; a[o].y=x[i+1].id; a[o].v=x[i+1].v-x[i].v; } for (int i=1;i<=n-1;i++) { o++; a[o].x=y[i].id; a[o].y=y[i+1].id; a[o].v=y[i+1].v-y[i].v; } sort(a+1,a+1+o,cmp1); for (int i=1;i<=n;i++) f[i]=i; int k=0; LL ans=0; for (int i=1;i<=o;i++) { int fa=find1(a[i].x); int fb=find1(a[i].y); if (fa!=fb) { f[fa]=fb; ans+=a[i].v; k++; } if (k==n-1) break; } printf("%lld\n",ans); return(0); }
a.cc: In function 'int find1(int)': a.cc:46:5: error: 'retufn' was not declared in this scope 46 | retufn(f[x]); | ^~~~~~ a.cc:45:38: warning: control reaches end of non-void function [-Wreturn-type] 45 | if (f[x]==x) return(x); else f[x]=find1(f[x]); | ~~~~^~~~~~~~~~~~
s812556272
p03684
C++
#include<bits/stdc++.h> #define mp make_pair #define pb push_back using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int > vi; typedef pair<int ,int > pii; typedef vector<pii> vii; const int inf=0x3f3f3f3f, maxn=100007, mod=1e9+7; const ll linf=0x3f3f3f3f3f3f3f3fLL; const ll P=19260817; int fa[100007]; int n; register int find(int x){ return x==fa[x]? x: fa[x]=find(fa[x]); } struct node{ int x,y,id; }a[100007]; inline bool cmp1(const node& a,const node& b){ return a.x<b.x; } inline bool cmp2(const node& a,const node& b){ return a.y<b.y; } struct edge{ int x,y,val; }e[100005<<2]; inline bool cmp3(const edge& a,const edge &b){ return a.val<b.val; } int cnt; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++)fa[i]=i; for(int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y),a[i].id=i; sort(a+1,a+n+1,cmp1); for(int i=1;i<n;i++){ e[++cnt].x=a[i].id; e[cnt].y=a[i+1].id; e[cnt].val=abs(a[i].x-a[i+1].x); } sort(a+1,a+n+1,cmp2); for(int i=1;i<n;i++){ e[++cnt].x=a[i].id; e[cnt].y=a[i+1].id; e[cnt].val=abs(a[i].y-a[i+1].y); } sort(e+1,e+cnt+1,cmp3); int p=0; ll ans=0; for(int i=1;i<=cnt;i++){ int fx=find(e[i].x); int fy=find(e[i].y); if(fx==fy)continue; fa[fx]=fy; ans+=e[i].val; p++; if(p==n-1)break; } printf("%lld",ans); return 0; }
a.cc:15:1: error: storage class 'register' invalid for function 'find' 15 | register int find(int x){ | ^~~~~~~~
s288718176
p03684
C++
#include <bits/stdc++.h> using namespace std; #define countof(a) (sizeof(a)/sizeof(*a)) #define vi vector<int> #define vvi vector<vector<int> > #define vpi vector<pi > #define pi pair<int,int> #define mp make_pair #define fi first #define se second #define all(n) n.begin(), n.end() #define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++) #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) #define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--) #define FOR(var, to) UPTO(var, 0, (to)-1) #define DOWN(var, from) DOWNTO(var, (from)-1, 0) #define INIT(var, val) FOR(i,countof(var)) var[i] = val #define INPUT(var) FOR(i,countof(var)) cin >> var[i] #define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]-- #define SORT(v) qsort(v,countof(v),sizeof(*v),int_less) #define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater) #define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b) #define MOD 1000000007 #define INF ((1 << 30)-1) #define LINF ((1LL << 62)-1) typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef int8_t s8; typedef int16_t s16; typedef int32_t s32; typedef int64_t s64; struct Comb { vector<vector<s64> > data; Comb(int n) { // O(n^2) data = vector<vector<s64> >(n+1,vector<s64>(n+1,1)); UPTO(i,1,n) { FOR(j,i+1) { if (!j || j == i) data[i][j] = 1; else data[i][j] = data[i-1][j-1] + data[i-1][j]; } } } s64 ncr(int n, int r) { return data[n][r]; } }; static inline int ri() { int a; scanf("%d", &a); return a; } int int_less(const void *a, const void *b) { return (*((const int*)a) - *((const int*)b)); } int int_greater(const void *a, const void *b) { return (*((const int*)b) - *((const int*)a)); } struct UnionFind{ vi data; UnionFind(int size):data(size,-1){} bool unite(int x,int y) { x=root(x);y=root(y); if(x!=y){ if(data[y]<data[x])swap(x,y); data[x]+=data[y];data[y]=x; } return x!=y; } bool find(int x,int y) { return root(x)==root(y); } int root(int x) { return data[x]<0?x:data[x]=root(data[x]); } int size(int x) { return -data[root(x)]; } // added by QCFium bool united() { int comroot = -1; FOR(i,data.size()) { if (comroot != -1 && root(i) != comroot) return false; comroot = root(i); } return true; } }; using cost_type = s64; #define COST_INF (LINF) typedef struct Edge { int from; int to; cost_type cost; size_t next; bool operator<(const struct Edge& a) const { return cost < a.cost; } } Edge; struct Graph { int n; vector<Edge> hen; vector<size_t> head; multiset<Edge> hen_all; // result of Warshall–Floyd vector<vector<cost_type> > WF; bool wf_completed = false; // result of dijkstra and Bellman-Ford/SPFA vector<vector<cost_type> > SSSP; set<int> sssp_completed; // result of dfs(reachable check) vector<vector<bool> > DFS; set<int> dfs_completed; Graph(int n) { // O(N) head.resize(n); SSSP.resize(n); DFS.resize(n); this->n = n; } cost_type kruskal() { int num = 0; UnionFind uni(n); cost_type res = 0; for (auto& i : hen_all) { if (!uni.find(i.from, i.to)) { res += i.cost; uni.unite(i.from, i.to); if (++num >= n-1) return res; } } return res; } int spfa(int k) { vector<bool> inque(n,false); vector<int> updated(n,0); sssp_completed.insert(k); SSSP[k].assign(n,COST_INF); SSSP[k][k] = 0; queue<int> que; inque[k] = true; que.push(k); while (que.size()) { int i = que.front(); que.pop(); for (size_t j = head[i]; ~j; j=hen[j].next) { if (SSSP[k][hen[j].to] > SSSP[k][i] + hen[j].cost) { SSSP[k][hen[j].to] = SSSP[k][i] + hen[j].cost; if (++updated[hen[j].to] > n) return hen[j].to; if (!inque[hen[j].to]) { inque[hen[j].to] = true; que.push(hen[j].to); } } } inque[i] = false; } return -1; } void dij(int k) { // O(n+mlogm) sssp_completed.insert(k); SSSP[k].assign(n,COST_INF); SSSP[k][k] = 0; using State = pair<cost_type, int>; priority_queue<State, vector<State>, greater<State> > que; que.push({0,k}); while(que.size()) { auto i = que.top(); que.pop(); for (size_t j = head[i.se]; ~j; j=hen[j].next) { if (SSSP[k][hen[j].to] > i.fi + hen[j].cost) { SSSP[k][hen[j].to] = i.fi + hen[j].cost; que.push({SSSP[k][hen[j].to], hen[j].to}); } } } } void wf() { // O(n^3) WF.assign(n,vector<cost_type>(n,COST_INF)); FOR(i,n) { WF[i][i] = 0; for (size_t j = head[i]; ~j; j=hen[j].next) WF[i][hen[j].to] = hen[j].cost; } FOR(k,n) { FOR(i,n) { FOR(j,n) { if (WF[i][k] != COST_INF && WF[k][j] != COST_INF) { WF[i][j] = min(WF[i][j], WF[i][k] + WF[k][j]); } } } } wf_completed = true; } void dfs(int from) { // O(N+M) DFS[from].assign(n,false); DFS[from][from] = true; queue<int> que; que.push(from); while(que.size()) { int i = que.front(); que.pop(); for (size_t j = head[i]; ~j; j=hen[j].next) { if (!DFS[from][hen[j].to]) { DFS[from][hen[j].to] = true; que.push(hen[j].to); } } } dfs_completed.insert(from); } inline bool reachable(int from, int to) { assert(dfs_completed.count(from)); return DFS[from][to]; } inline pair<bool,cost_type> shortest(int from, int to) { assert(wf_completed || sssp_completed.count(from)); if (wf_completed) return mp(WF[from][to] != COST_INF, WF[from][to]); else if (sssp_completed.count(from)) return mp(SSSP[from][to] != COST_INF, SSSP[from][to]); else return {}; // should not reached } inline void add_hen(int from, int to, cost_type cost, bool muki) { insert_hen(from,to,cost); if (!muki) insert_hen(to, from, cost); } private:inline void insert_hen(int from, int to, cost_type cost) { /* Edge new_edge = {from, to, cost, (size_t)-1}; size_t id = hen.size(); hen.push_back(new_edge); hen[head[from]].next = id; head[from] = id;*/ hen_all.insert(new_edge); } }; // Graph.dfs : O(N) // Graph.dij : O(N+MlogM) // Graph.bf : O(NM) // Graph.spfa: O(NM) faster // Graph.wf : O(N^3) // Graph.reachable // Graph.shortest typedef struct { int x; int y; int id; } Dot; int dot_less_x(const void *a, const void *b) { return (((const Dot*)b)->x - ((const Dot*)a)->x); } int dot_less_y(const void *a, const void *b) { return (((const Dot*)b)->y - ((const Dot*)a)->y); } int main() { int n = ri(); Dot a[n]; FOR(i,n) { int t = ri(); a[i] = {t, ri(), i}; } Graph graph(n); QSORT(a,dot_less_x); FOR(i,n-1) { graph.add_hen(a[i].id, a[i+1].id, abs(a[i].x-a[i+1].x), false); } QSORT(a,dot_less_y); FOR(i,n-1) { graph.add_hen(a[i].id, a[i+1].id, abs(a[i].y-a[i+1].y), false); } cost_type res = graph.kruskal(); cout << res << endl; return 0; }
a.cc: In constructor 'Comb::Comb(int)': a.cc:47:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 47 | UPTO(i,1,n) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:48:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 48 | FOR(j,i+1) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:48:13: note: in expansion of macro 'FOR' 48 | FOR(j,i+1) { | ^~~ a.cc: In member function 'bool UnionFind::united()': a.cc:97:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 97 | FOR(i,data.size()) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:97:9: note: in expansion of macro 'FOR' 97 | FOR(i,data.size()) { | ^~~ a.cc: In member function 'void Graph::wf()': a.cc:192:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 192 | FOR(i,n) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:192:17: note: in expansion of macro 'FOR' 192 | FOR(i,n) { | ^~~ a.cc:197:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 197 | FOR(k,n) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:197:17: note: in expansion of macro 'FOR' 197 | FOR(k,n) { | ^~~ a.cc:198:29: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 198 | FOR(i,n) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:198:25: note: in expansion of macro 'FOR' 198 | FOR(i,n) { | ^~~ a.cc:199:37: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 199 | FOR(j,n) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:199:33: note: in expansion of macro 'FOR' 199 | FOR(j,n) { | ^~~ a.cc: In member function 'void Graph::insert_hen(int, int, cost_type)': a.cc:247:32: error: 'new_edge' was not declared in this scope 247 | hen_all.insert(new_edge); | ^~~~~~~~ a.cc: In function 'int main()': a.cc:274:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 274 | FOR(i,n) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:274:9: note: in expansion of macro 'FOR' 274 | FOR(i,n) { | ^~~ a.cc:281:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 281 | FOR(i,n-1) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:281:9: note: in expansion of macro 'FOR' 281 | FOR(i,n-1) { | ^~~ a.cc:285:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 285 | FOR(i,n-1) { | ^ a.cc:17:49: note: in definition of macro 'UPTO' 17 | #define UPTO(var, from, to) for (register int var = (from); var <= ((int)to); var++) | ^~~ a.cc:285:9: note: in expansion of macro 'FOR' 285 | FOR(i,n-1) { | ^~~
s440251623
p03684
C++
#include<iostream> #include<vector> #include<algorithm> #include<queue> struct ver{ int key; int x; int y; }; struct edge{ int cost; int v1; int v2; }; int main(){ int n; int answer=0; std::vector<ver> verList; std::vector<std::vector<edge>> edgeList; std::priority_queue<edge, std::vector<edge>, std::function<bool(edge, edge)>> qList( [](edge a, edge b){return a.cost > b.cost;}); std::cin>>n; verList.resize(n); edgeList.resize(n); for(int i=0; i<n; i++){ std::cin>>verList[i].x>>verList[i].y; verList[i].key= i; } std::sort(verList.begin(), verList.end(), [](const ver& a, const ver& b){return a.x<b.x;}); for(int i=1; i<n; i++){ edgeList[verList[i-1].key].push_back({verList[i].x - verList[i-1].x ,verList[i-1].key, verList[i].key}); edgeList[verList[i].key].push_back({verList[i].x - verList[i-1].x ,verList[i-1].key, verList[i].key}); } std::sort(verList.begin(), verList.end(), [](const ver& a, const ver& b){return a.y<b.y;}); for(int i=1; i<n; i++){ edgeList[verList[i-1].key].push_back({verList[i].y - verList[i-1].y ,verList[i-1].key, verList[i].key}); edgeList[verList[i].key].push_back({verList[i].y - verList[i-1].y ,verList[i-1].key, verList[i].key}); } int edgeCount= 0; std::vector<int> isSelected(n, -1); isSelected[0]= 1; for(int i=0; i< edgeList[0].size(); i++) qList.push(edgeList[0][i]); while(1){ if(edgeCount>= n-1) break; edge e= qList.top(); qList.pop(); if(isSelected[e.v1] * isSelected[e.v2] >0) continue; if(isSelected[e.v1]<0){ isSelected[e.v1]= 1; answer+=e.cost; for(int i=0; i< edgeList[e.v1].size(); i++) qList.push(edgeList[e.v1][i]); edgeCount++; }else if(isSelected[e.v2]<0){ isSelected[e.v2]= 1; answer+=e.cost; for(int i=0; i< edgeList[e.v2].size(); i++) qList.push(edgeList[e.v2][i]); edgeCount++; } } /*------------------------------*/ // for(int i=0; i< edgeList.size(); i++) // std::cout<< edgeList[i].cost<<","<<edgeList[i].v1<<","<<edgeList[i].v2<<std::endl; std::cout<<answer<<std::endl; return 0; }
a.cc: In function 'int main()': a.cc:23:59: error: 'function' is not a member of 'std' 23 | std::priority_queue<edge, std::vector<edge>, std::function<bool(edge, edge)>> qList( | ^~~~~~~~ a.cc:5:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>' 4 | #include<queue> +++ |+#include <functional> 5 | a.cc:23:83: error: expression list treated as compound expression in functional cast [-fpermissive] 23 | std::priority_queue<edge, std::vector<edge>, std::function<bool(edge, edge)>> qList( | ^ a.cc:23:84: error: template argument 3 is invalid 23 | std::priority_queue<edge, std::vector<edge>, std::function<bool(edge, edge)>> qList( | ^~ a.cc:24:17: error: invalid user-defined conversion from 'main()::<lambda(edge, edge)>' to 'int' [-fpermissive] 24 | [](edge a, edge b){return a.cost > b.cost;}); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:24:17: note: candidate is: 'constexpr main()::<lambda(edge, edge)>::operator bool (*)(edge, edge)() const' (near match) 24 | [](edge a, edge b){return a.cost > b.cost;}); | ^ a.cc:24:17: note: no known conversion from 'bool (*)(edge, edge)' to 'int' a.cc:56:23: error: request for member 'push' in 'qList', which is of non-class type 'int' 56 | qList.push(edgeList[0][i]); | ^~~~ a.cc:62:31: error: request for member 'top' in 'qList', which is of non-class type 'int' 62 | edge e= qList.top(); | ^~~ a.cc:63:23: error: request for member 'pop' in 'qList', which is of non-class type 'int' 63 | qList.pop(); | ^~~ a.cc:72:39: error: request for member 'push' in 'qList', which is of non-class type 'int' 72 | qList.push(edgeList[e.v1][i]); | ^~~~ a.cc:78:39: error: request for member 'push' in 'qList', which is of non-class type 'int' 78 | qList.push(edgeList[e.v2][i]); | ^~~~
s553838635
p03684
C++
#include<map> #include<iostream> #include<deque> #include<algorithm> #include<string> #include<cctype> #include<iomanip> #include<vector> #include<queue> using namespace std; #define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++) #define rep0(i,n) REP(i,0ll,n) #define rep1(i,n) REP(i,1ll,n+1) #define shosu setprecision(10) typedef long long ll; typedef pair<ll,ll> P; typedef pair<ll,P> Q; ll longinf=1ll<<60; int inf=1<<29; int dx[4]={1,-1,0,0}; int dy[4]={0,0,1,-1}; int dh[4]={0,1,0,-1}; int dw[4]={1,0,-1,0}; int main (){ int N; cin>>N; P p[N]; rep0(i,N){ cin>>p[i].first>>p[i].second; } sort(p,p+N); map<P,vector<Q>> v; rep0(i,N){ if(i!=(N-1)){ ll d = abs(p[i+1].first-p[i].first); v[p[i]].push_back({d,p[i+1]}); } if(i!=0){ ll d=abs(p[i].first-p[i-1].first); v[p[i]].push_back({d,p[i-1]}); } } swap(p.first,p.second); sort(p,p+N); swap(p.first,p.second); rep0(i,N){ if(i!=(N-1)){ ll d=abs(p[i+1].second-p[i].second); v[p[i]].push_back({d,p[i+1]}); } if(i!=0){ ll d=abs(p[i].second-p[i-1].second); v[p[i]].push_back({d,p[i-1]}); } sort(v[p[i]].begin(), v[p[i]].end()); v[p[i]].erase(std::unique(v[p[i]].begin(), v[p[i]].end()), v[p[i]].end()); } /*rep0(i,N){ cout<<i<<" "; rep0(j,v[p[i]].size()){ cout<<v[p[i]][j].first<<" "<<v[p[i]][j].second.first<<" "<<v[p[i]][j].second.second<<" "; } cout<<endl; }*/ map<P,ll> d; map<P,bool> merged; rep0(i,N){ d[p[i]]=longinf; merged[p[i]]=false; } d[p[0]]=0; priority_queue<Q,vector<Q>,greater<Q>> q; q.push({d[p[0]],p[0]}); ll ans=0; while(q.size()){ Q hoge = q.top(); q.pop(); ll di = hoge.first; P node = hoge.second; if(merged[node]) continue; ans+=di; merged[node]=true; for(int i=0;i<v[node].size();i++){ ll nd = v[node][i].first; P np =v[node][i].second; d[np]=min(d[np],nd); q.push({d[np],np}); } } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:47:14: error: request for member 'first' in 'p', which is of non-class type 'P [N]' {aka 'std::pair<long long int, long long int> [N]'} 47 | swap(p.first,p.second); | ^~~~~ a.cc:47:22: error: request for member 'second' in 'p', which is of non-class type 'P [N]' {aka 'std::pair<long long int, long long int> [N]'} 47 | swap(p.first,p.second); | ^~~~~~ a.cc:49:14: error: request for member 'first' in 'p', which is of non-class type 'P [N]' {aka 'std::pair<long long int, long long int> [N]'} 49 | swap(p.first,p.second); | ^~~~~ a.cc:49:22: error: request for member 'second' in 'p', which is of non-class type 'P [N]' {aka 'std::pair<long long int, long long int> [N]'} 49 | swap(p.first,p.second); | ^~~~~~
s527079372
p03684
C++
#include<map> #include<iostream> #include<deque> #include<algorithm> #include<string> #include<cctype> #include<iomanip> #include<vector> #include<queue> using namespace std; #define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++) #define rep0(i,n) REP(i,0ll,n) #define rep1(i,n) REP(i,1ll,n+1) #define shosu setprecision(10) typedef long long ll; typedef pair<ll,ll> P; typedef pair<ll,P> Q; ll longinf=1ll<<60; int inf=1<<29; int dx[4]={1,-1,0,0}; int dy[4]={0,0,1,-1}; int dh[4]={0,1,0,-1}; int dw[4]={1,0,-1,0}; int main (){ int N; cin>>N; P p[N]; rep0(i,N){ cin>>p[i].first>>p[i].second; } sort(p,p+N); map<P,vector<Q>> v; rep0(i,N){ if(i!=(N-1)){ ll d = abs(p[i+1].first-p[i].first); v[p[i]].push_back({d,p[i+1]}); } if(i!=0){ ll d=abs(p[i].first-p[i-1].first); v[p[i]].push_back({d,p[i-1]}); } } swap(p); sort(p,p+N); swap(p); rep0(i,N){ if(i!=(N-1)){ ll d=abs(p[i+1].second-p[i].second); v[p[i]].push_back({d,p[i+1]}); } if(i!=0){ ll d=abs(p[i].second-p[i-1].second); v[p[i]].push_back({d,p[i-1]}); } sort(v[p[i]].begin(), v[p[i]].end()); v[p[i]].erase(std::unique(v[p[i]].begin(), v[p[i]].end()), v[p[i]].end()); } /*rep0(i,N){ cout<<i<<" "; rep0(j,v[p[i]].size()){ cout<<v[p[i]][j].first<<" "<<v[p[i]][j].second.first<<" "<<v[p[i]][j].second.second<<" "; } cout<<endl; }*/ map<P,ll> d; map<P,bool> merged; rep0(i,N){ d[p[i]]=longinf; merged[p[i]]=false; } d[p[0]]=0; priority_queue<Q,vector<Q>,greater<Q>> q; q.push({d[p[0]],p[0]}); ll ans=0; while(q.size()){ Q hoge = q.top(); q.pop(); ll di = hoge.first; P node = hoge.second; if(merged[node]) continue; ans+=di; merged[node]=true; for(int i=0;i<v[node].size();i++){ ll nd = v[node][i].first; P np =v[node][i].second; d[np]=min(d[np],nd); q.push({d[np],np}); } } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:47:11: error: no matching function for call to 'swap(P [N])' 47 | swap(p); | ~~~~^~~ In file included from /usr/include/c++/14/bits/quoted_string.h:38, from /usr/include/c++/14/iomanip:50, from a.cc:7: /usr/include/c++/14/sstream:1204:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_stringbuf<_CharT, _Traits, _Alloc>&, basic_stringbuf<_CharT, _Traits, _Alloc>&)' 1204 | swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1204:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/sstream:1212:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_istringstream<_CharT, _Traits, _Allocator>&, basic_istringstream<_CharT, _Traits, _Allocator>&)' 1212 | swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1212:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/sstream:1219:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_ostringstream<_CharT, _Traits, _Allocator>&, basic_ostringstream<_CharT, _Traits, _Allocator>&)' 1219 | swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1219:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/sstream:1226:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_stringstream<_CharT, _Traits, _Allocator>&, basic_stringstream<_CharT, _Traits, _Allocator>&)' 1226 | swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1226:5: note: candidate expects 2 arguments, 1 provided In file included from /usr/include/c++/14/bits/stl_pair.h:61, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/bits/stl_tree.h:63, from /usr/include/c++/14/map:62, from a.cc:1: /usr/include/c++/14/bits/move.h:226:5: note: candidate: 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)' 226 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/14/bits/move.h:226:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])' 250 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) | ^~~~ /usr/include/c++/14/bits/move.h:250:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' 1089 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted) 1106 | swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_tree.h:1675:5: note: candidate: 'template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> void std::swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)' 1675 | swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, | ^~~~ /usr/include/c++/14/bits/stl_tree.h:1675:5: note: candidate expects 2 arguments, 1 provided In file included from /usr/include/c++/14/bits/stl_map.h:63, from /usr/include/c++/14/map:63: /usr/include/c++/14/tuple:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_Args1 ...>&, tuple<_Args1 ...>&)' 2805 | swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y) | ^~~~ /usr/include/c++/14/tuple:2805:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_Args1 ...>&, tuple<_Args1 ...>&)' (deleted) 2823 | swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete; | ^~~~ /usr/include/c++/14/tuple:2823:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:1586:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> void std::swap(map<_Key, _Tp, _Compare, _Allocator>&, map<_Key, _Tp, _Compare, _Allocator>&)' 1586 | swap(map<_Key, _Tp, _Compare, _Alloc>& __x, | ^~~~ /usr/include/c++/14/bits/stl_map.h:1586:5: note: candidate expects 2 arguments, 1 provided In file included from /usr/include/c++/14/map:64: /usr/include/c++/14/bits/stl_multimap.h:1208:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> void std::swap(multimap<_Key, _Tp, _Compare, _Allocator>&, multimap<_Key, _Tp, _Compare, _Allocator>&)' 1208 | swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x, | ^~~~ /usr/include/c++/14/bits/stl_multimap.h:1208:5: note: candidate expects 2 arguments, 1 provided 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:2: /usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4039 | swap(basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~ /usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate expects 2 arguments, 1 provided In file included from /usr/include/c++/14/deque:66, from a.cc:3: /usr/include/c++/14/bits/stl_deque.h:2370:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(deque<_Tp, _Alloc>&, deque<_Tp, _Alloc>&)' 2370 | swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) | ^~~~ /usr/include/c++/14/bits/stl_deque.h:2370:5: note: candidate expects 2 arguments, 1 provided In file included from /usr/include/c++/14/vector:66, from a.cc:8: /usr/include/c++/14/bits/stl_vector.h:2122:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(vector<_Tp, _Alloc>&, vector<_Tp, _Alloc>&)' 2122 | swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y) | ^~~~ /usr/include/c++/14/bits/stl_vector.h:2122:5: note: candidate expects 2 arguments, 1 provided In file included from /usr/include/c++/14/queue:66, from a.cc:9: /usr/include/c++/14/bits/stl_queue.h:445:5: note: candidate: 'template<class _Tp, class _Seq> typename std::enable_if<std::__is_swappable<_T2>::value>::type std::swap(queue<_Tp, _Seq>&, queue<_Tp, _Seq>&)' 445 | swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:445:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_queue.h:834:5: note: candidate: 'template<class _Tp, class _Sequence, class _Compare> typename std::enable_if<std::__and_<std::__is_swappable<_T2>, std::__is_swappable<_Compare> >::value>::type std::swap(priority_queue<_Tp, _Sequence, _Compare>&, priority_queue<_Tp, _Sequence, _Compare>&)' 834 | swap(priority_queue<_Tp, _Sequence, _Compare>& __x, | ^~~~ /usr/include/c++/14/bits/stl_queue.h:834:5: note: candidate expects 2 arguments, 1 provided In file included from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41: /usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ^~~~ /usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate expects 2 arguments, 1 provided a.cc:49:11: error: no matching function for call to 'swap(P [N])' 49 | swap(p); | ~~~~^~~ /usr/include/c++/14/sstream:1204:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_stringbuf<_CharT, _Traits, _Alloc>&, basic_stringbuf<_CharT, _Traits, _Alloc>&)' 1204 | swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1204:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/sstream:1212:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_istringstream<_CharT, _Traits, _Allocator>&, basic_istringstream<_CharT, _Traits, _Allocator>&)' 1212 | swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1212:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/sstream:1219:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_ostringstream<_CharT, _Traits, _Allocator>&, basic_ostringstream<_CharT, _Traits, _Allocator>&)' 1219 | swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1219:5: note: candidate expec
s404854357
p03684
C++
6 8 3 4 9 12 19 18 1 13 5 7 6
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 6 | ^
s691415225
p03684
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+10; int pre[N]; struct Node{ int x,y,ind; }v1[N],v[4*N]; int cmp1(Node a,Node b) { if(a.x==b.x) return a.y<b.y; return a.x<b.x; } int cmp2(Node a,Node b) { if(a.y==b.y) return a.x<b.x; return a.y<b.y; } int cmp(Node a,Node b) { return a.ind<b.ind; } int find(int x){ return pre[x]==x?x:find(pre[x]);} int vind=0; int main() { int n,x,y; vind=0; scanf("%d",&n); for(int i=0;i<n;i++) { pre[i]=i; scanf("%d%d",&v1[i].x,&v1[i].y); v1[i].ind=i; } sort(v1,v1+v1ind,cmp1); for(int i=0;i<n-1;i++) { v[vind].x=v1[i].ind;v[vind].y=v1[i+1].ind;v[vind++].ind=min(abs(v1[i].x-v1[i+1].x),abs(v1[i].y-v1[i+1].y)); } sort(v1,v1+v1ind,cmp2); for(int i=0;i<v1ind-1;i++) { v[vind].x=v1[i].ind;v[vind].y=v1[i+1].ind;v[vind++].ind=min(abs(v1[i].x-v1[i+1].x),abs(v1[i].y-v1[i+1].y)); } sort(v,v+vind,cmp); int m=n-1,i=0; ll ans=0; while(i<vind) { if(m==0) break; int prex=find(v[i].x),prey=find(v[i].y); if(prex!=prey) { pre[prex]=prey; m--; ans+=(ll)v[i].ind; } i++; } printf("%lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:41:16: error: 'v1ind' was not declared in this scope; did you mean 'vind'? 41 | sort(v1,v1+v1ind,cmp1); | ^~~~~ | vind
s086854044
p03684
Java
import java.io.*; import java.util.*; class XComparator implements Comparator<Point>{ @Override public int compare(Point p1, Point p2){ return p1.x < p2.x ? -1 : 1; } } class YComparator implements Comparator<Point>{ @Override public int compare(Point p1, Point p2){ return p1.y < p2.y ? -1 : 1; } } class MyComparator implements Comparator<Next>{ @Override public int compare(Next p1, Next p2){ return p1.cost < p2.cost ? -1 : 1; } } class Unionfind{ int[] number; Unionfind(int n){ number = new int[n]; for(int i=0;i<n;i++){ number[i] = i; } } int find(int x){ if(number[x] == x){ return x; } return number[x] = find(number[x]); } void unite(int x, int y){ if(number[x] == number[y]){ } else{ number[find(x)] = number[find(y)]; } } boolean same(int x, int y){ if(number[find(x)] == number[find(y)]){ return true; } return false; } } class Main{ public static void main(String[] args){ solve(); } public static void solve(){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] x = new int[n]; int[] y = new int[n]; Unionfind union = new Unionfind(n); for(int i=0;i<n;i++){ x[i] = sc.nextInt(); y[i] = sc.nextInt(); } ArrayList<Point> xlist = new ArrayList<Point>(); ArrayList<Point> ylist = new ArrayList<Point>(); for(int i=0;i<n;i++){ Point p = new Point(x[i], y[i], i); xlist.add(p); ylist.add(p); } Collections.sort(xlist, new XComparator()); Collections.sort(ylist, new YComparator()); ArrayList<Next> list = new ArrayList<Next>(); for(int i=0;i<n-1;i++){ Point p1 = xlist.get(i); Point p2 = xlist.get(i+1); list.add(new Next(p1.now, p2.now, (int)Math.abs(p1.x-p2.x))); p1 = ylist.get(i); p2 = ylist.get(i+1); list.add(new Next(p1.now, p2.now, (int)Math.abs(p1.y-p2.y))); } Collections.sort(list, new MyComparator()); long ans = 0; for(int i=0;i<list.size();i++){ Next p = list.get(i); if(union.same(p.a, p.b)){ } else{ union.unite(p.a, p.b); ans += (long)p.cost; } } System.out.println(ans); } } class Point{ int x; int y; int now; Point(int x, int y, int now){ this.x = x; this.y = y; this.now = now; } } class Next{ int a; int b; int cost; Next(int a, int b, int cost){ this.a = a; this.b = b; this.cost = cost; } } import java.io.*; import java.util.*; class XComparator implements Comparator<Point>{ @Override public int compare(Point p1, Point p2){ return p1.x < p2.x ? -1 : 1; } } class YComparator implements Comparator<Point>{ @Override public int compare(Point p1, Point p2){ return p1.y < p2.y ? -1 : 1; } } class MyComparator implements Comparator<Next>{ @Override public int compare(Next p1, Next p2){ return p1.cost < p2.cost ? -1 : 1; } } class Unionfind{ int[] number; Unionfind(int n){ number = new int[n]; for(int i=0;i<n;i++){ number[i] = i; } } int find(int x){ if(number[x] == x){ return x; } return number[x] = find(number[x]); } void unite(int x, int y){ if(number[x] == number[y]){ } else{ number[find(x)] = number[find(y)]; } } boolean same(int x, int y){ if(number[find(x)] == number[find(y)]){ return true; } return false; } } class Main{ public static void main(String[] args){ solve(); } public static void solve(){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] x = new int[n]; int[] y = new int[n]; Unionfind union = new Unionfind(n); for(int i=0;i<n;i++){ x[i] = sc.nextInt(); y[i] = sc.nextInt(); } ArrayList<Point> xlist = new ArrayList<Point>(); ArrayList<Point> ylist = new ArrayList<Point>(); for(int i=0;i<n;i++){ Point p = new Point(x[i], y[i], i); xlist.add(p); ylist.add(p); } Collections.sort(xlist, new XComparator()); Collections.sort(ylist, new YComparator()); ArrayList<Next> list = new ArrayList<Next>(); for(int i=0;i<n-1;i++){ Point p1 = xlist.get(i); Point p2 = xlist.get(i+1); list.add(new Next(p1.now, p2.now, (int)Math.abs(p1.x-p2.x))); p1 = ylist.get(i); p2 = ylist.get(i+1); list.add(new Next(p1.now, p2.now, (int)Math.abs(p1.y-p2.y))); } Collections.sort(list, new MyComparator()); long ans = 0; for(int i=0;i<list.size();i++){ Next p = list.get(i); if(union.same(p.a, p.b)){ } else{ union.unite(p.a, p.b); ans += (long)p.cost; } } System.out.println(ans); } } class Point{ int x; int y; int now; Point(int x, int y, int now){ this.x = x; this.y = y; this.now = now; } } class Next{ int a; int b; int cost; Next(int a, int b, int cost){ this.a = a; this.b = b; this.cost = cost; } }
Main.java:134: error: class, interface, enum, or record expected import java.io.*; ^ Main.java:135: error: class, interface, enum, or record expected import java.util.*; ^ 2 errors
s486464597
p03684
C++
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair typedef pair<long long,long long> ii; vector<pair<long long,ii>> edge; long long n,up[100005],sz[100005]; pair<ii,long long> x[100005]; bool cmp(const pair<ii,long long> &a,const pair<ii,long long> &b){ return a.fi.fi<b.fi.fi; } bool cmp1(const pair<ii,long long> &a,const pair<ii,long long> &b){ return a.fi.se<b.fi.se; } int findSet(int x){ if(x==up[x]) return x; else return findSet(up[x]); } void unionSet(int x,int y){ long long x1=findSet(x),y1=findSet(y); if(sz[x1]<sz[y1]) swap(x1,y1); up[y1]=x1; sz[x1]+=sz[y1]; } bool checkSet(int x,int y){ long long x1=findSet(x),x2=findSet(y); if(x1==x2) return 1; else return 0; } int main(){ cin.tie(0),cout.tie(0),ios::sync_with_stdio(0); cin>>n; for(int i=1;i<=n;i++){ cin>>x[i].fi.fi>>x[i].fi.se; x[i].se=i; } sort(x+1,x+1+n,cmp); for(int i=1;i<=n;i++){ up[i]=i; sz[i]=1; } for(int i=1;i<n;i++){ long long x1=x[i].se,x2=x[i+1].se; long long val=abs(x[i].fi.fi-x[i+1].fi.fi),val1=abs(x[i].fi.se-x[i+1].fi.se); edge.pb(mp(min(val,INT_MAX),mp(x1,x2))); } sort(x+1,x+1+n,cmp1); for(int i=1;i<n;i++){ long long x1=x[i].se,x2=x[i+1].se; long long val=abs(x[i].fi.fi-x[i+1].fi.fi),val1=abs(x[i].fi.se-x[i+1].fi.se); edge.pb(mp(min(val,INT_MAX),mp(x1,x2))); } long long sum=0; sort(edge.begin(),edge.end()); for(int i=0;i<edge.size();i++){ long long x1=edge[i].se.fi,x2=edge[i].se.se; if(checkSet(x1,x2)==0){ unionSet(x1,x2); sum+=edge[i].fi; } } cout<<sum; }
a.cc: In function 'int main()': a.cc:53:23: error: no matching function for call to 'min(long long int&, int)' 53 | edge.pb(mp(min(val,INT_MAX),mp(x1,x2))); | ~~~^~~~~~~~~~~~~ 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:53:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 53 | edge.pb(mp(min(val,INT_MAX),mp(x1,x2))); | ~~~^~~~~~~~~~~~~ /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:53:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 53 | edge.pb(mp(min(val,INT_MAX),mp(x1,x2))); | ~~~^~~~~~~~~~~~~ a.cc:59:23: error: no matching function for call to 'min(long long int&, int)' 59 | edge.pb(mp(min(val,INT_MAX),mp(x1,x2))); | ~~~^~~~~~~~~~~~~ /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:59:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 59 | edge.pb(mp(min(val,INT_MAX),mp(x1,x2))); | ~~~^~~~~~~~~~~~~ /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 /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:59:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 59 | edge.pb(mp(min(val,INT_MAX),mp(x1,x2))); | ~~~^~~~~~~~~~~~~
s486870161
p03684
C++
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <string> #include <sstream> #include <complex> #include <vector> #include <list> #include <queue> #include <deque> #include <stack> #include <map> #include <set> using namespace std; typedef long long unsigned int ll; int par[100010]; int rank[100010]; void init(int n) { for(int i = 0; i < n; i++){ par[i] = i; rank[i] = 0; } } int find(int x) { if(par[x] == x){ return x; } else { return par[x] = find(par[x]); } } void unite(int x, int y) { x = find(x); y = find(y); if(x == y){ return ; } if(rank[x] , rank[y]){ par[x] = y; } else { par[y] = x; if(rank[x] == rank[y]){ rank[x]++; } } } bool same(int x, int y) { return find(x) == find(y); } #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) int main() { //cout.precision(10); int n; cin >> n; init(n); vector<pair<int, int> > y(n); vector<pair<int, int> > x(n); for(int i = 1; i <= n; i++){ cin >> x[i - 1].first; cin >> y[i - 1].first; x[i - 1].second = i; y[i - 1].second = i; } sort(x.begin(), x.end()); sort(y.begin(), y.end()); vector<pair<int, pair<int, int> > > distance; for(int i = 0; i < n - 1; i++){ pair<int, pair<int, int> > in; in.second.first = x[i].second; in.second.second = x[i + 1].second; in.first = x[i + 1].first - x[i].first; distance.push_back(in); in.second.first = y[i].second; in.second.second = y[i + 1].second; in.first = y[i + 1].first - y[i].first; distance.push_back(in); } long long ans = 0; sort(distance.begin(), distance.end()); for(int i = 1; i < n; i++){ while(same(distance[0].second.first, distance[0].second.second)){ distance.erase(distance.begin(), distance.begin() + 1); } ans += (long long)distance[0].first; unite(distance[0].second.first, distance[0].second.second); distance.erase(distance.begin(), distance.begin() + 1); } cout << ans << endl; return 0; }
a.cc: In function 'void init(int)': a.cc:25:9: error: reference to 'rank' is ambiguous 25 | rank[i] = 0; | ^~~~ In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:19:5: note: 'int rank [100010]' 19 | int rank[100010]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:45:8: error: reference to 'rank' is ambiguous 45 | if(rank[x] , rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:19:5: note: 'int rank [100010]' 19 | int rank[100010]; | ^~~~ a.cc:45:18: error: reference to 'rank' is ambiguous 45 | if(rank[x] , rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:19:5: note: 'int rank [100010]' 19 | int rank[100010]; | ^~~~ a.cc:49:12: error: reference to 'rank' is ambiguous 49 | if(rank[x] == rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:19:5: note: 'int rank [100010]' 19 | int rank[100010]; | ^~~~ a.cc:49:23: error: reference to 'rank' is ambiguous 49 | if(rank[x] == rank[y]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:19:5: note: 'int rank [100010]' 19 | int rank[100010]; | ^~~~ a.cc:50:13: error: reference to 'rank' is ambiguous 50 | rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:19:5: note: 'int rank [100010]' 19 | int rank[100010]; | ^~~~
s506786599
p03684
C++
/* sort points by x (1st time) by y (2nd time) each time => push back the weight bw 2 points => MST (kruskal) => DONE! */ #include<bits/stdc++.h> using namespace std; #define int long long const int N=1e5+5; struct data{ int x,y,id; } c[N]; int n,pset[N],ans; vector< pair< int,pair<int,int> > > edge; bool cmpx(data _a,data _b){ if(_a.x!=_b.x) return _a.x<_b.x; else return _a.y<_b.y; } bool cmpy(data _a,data _b){ if(_a.y!=_b.y) return _a.y<_b.y; else return _a.x<_b.x; } int findset(int pos){ return ( pos==pset[pos]?pos:pset[pos]=findset(pset[pos]) ); } bool sameset(int i,int j){ return findset(i)==findset(j); } void unionset(int i,int j){ pset[findset(i)]=findset(j); } signed main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n; for(int i = 1; i <= n; ++i){ cin >> c[i].x >> c[i].y; c[i].id = i; } sort(c + 1 , c + n + 1 ,cmpx); for(int i = 1; i < n; ++i) edge.push_back(make_pair(c[i+1].x-c[i].x,make_pair(c[i+1].id,c[i].id))); sort(c + 1, c + n + 1, cmpy); for(int i = 1; i < n; ++i) edge.push_back(make_pair(c[i+1].y-c[i].y,make_pair(c[i+1].id,c[i].id))); sort(edge.begin(),edge.end()); for(int i = 1; i <= n; ++i) pset[i]=i; for(int i = 0; i < edge.size(); ++i){ int w = edge[i].first, u = edge[i].second.first, v = edge[i].second.second; if(!sameset(u,v)){ ans += w; unionset(u,v); } } cout << ans; return 0; }
a.cc:21:11: error: reference to 'data' is ambiguous 21 | bool cmpx(data _a,data _b){ | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:8: /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:15:8: note: 'struct data' 15 | struct data{ | ^~~~ a.cc:21:19: error: reference to 'data' is ambiguous 21 | bool cmpx(data _a,data _b){ | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:15:8: note: 'struct data' 15 | struct data{ | ^~~~ a.cc:21:26: error: expression list treated as compound expression in initializer [-fpermissive] 21 | bool cmpx(data _a,data _b){ | ^ a.cc:25:11: error: reference to 'data' is ambiguous 25 | bool cmpy(data _a,data _b){ | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:15:8: note: 'struct data' 15 | struct data{ | ^~~~ a.cc:25:19: error: reference to 'data' is ambiguous 25 | bool cmpy(data _a,data _b){ | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:15:8: note: 'struct data' 15 | struct data{ | ^~~~ a.cc:25:26: error: expression list treated as compound expression in initializer [-fpermissive] 25 | bool cmpy(data _a,data _b){ | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:71, 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/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = data*; _Iterator2 = data*; _Compare = bool]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:49:9: required from here 49 | sort(c + 1 , c + n + 1 ,cmpx); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:158:30: error: expression cannot be used as a function 158 | { return bool(_M_comp(*__it1, *__it2)); } | ~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = data; _Iterator = data*; _Compare = bool]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Val_comp_iter<bool>]' 1757 | while (__comp(__val, __next)) | ~~~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1785 | std::__unguarded_linear_insert(__i, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 1786 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:49:9: required from here 49 | sort(c + 1 , c + n + 1 ,cmpx); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:240:30: error: expression cannot be used as a function 240 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = data*; _Value = data; _Compare = bool]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_val<bool>]' 140 | while (__holeIndex > __topIndex && __comp(_
s508867066
p03684
C++
#include<bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> iPair; struct Graph { int V, E; vector< pair<int, iPair> > edges; Graph(int V, int E) { this->V = V; this->E = E; } void addEdge(int u, int v, int w) { edges.push_back({w, {u, v}}); } int kruskalMST(); }; struct data{ int first, second; }edges2[100001]; bool cmp1(int a, int b){ if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; else return false; } bool cmp2(int a, int b){ if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; else return false; } struct DisjointSets { int *parent, *rnk; int n; DisjointSets(int n) { this->n = n; parent = new int[n+1]; rnk = new int[n+1]; for (int i = 0; i <= n; i++) { rnk[i] = 0; parent[i] = i; } } int find(int u) { if (u != parent[u]) parent[u] = find(parent[u]); return parent[u]; } void merge(int x, int y) { x = find(x), y = find(y); if (rnk[x] > rnk[y]) parent[y] = x; else parent[x] = y; if (rnk[x] == rnk[y]) rnk[y]++; } }; int Graph::kruskalMST() { int mst_wt = 0; sort(edges.begin(), edges.end()); DisjointSets ds(V); vector< pair<int, iPair> >::iterator it; for (it=edges.begin(); it!=edges.end(); it++) { int u = it->second.first; int v = it->second.second; int set_u = ds.find(u); int set_v = ds.find(v); if (set_u != set_v) { cout << u << " - " << v << endl; mst_wt += it->first; ds.merge(set_u, set_v); } } return mst_wt; } signed main() { int n, x, y; cin >> n; for(int i = 0; i < n; i++){ cin >> edges2[i].first >> edges2[i].second; } Graph(n, 2*(n-1)); sort(edges2, edges2 + n, cmp1); for(int i = 0; i < n-1; i++) Graph.addEdge(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second))); sort(edges2, edges2 + n, cmp2); for(int i = 0; i < n-1; i++) Graph.addEdge(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second))); int mst_wt = Graph.kruskalMST(); cout << mst_wt; return 0; }
a.cc: In function 'int main()': a.cc:105:39: error: expected unqualified-id before '.' token 105 | for(int i = 0; i < n-1; i++) Graph.addEdge(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second))); | ^ a.cc:107:39: error: expected unqualified-id before '.' token 107 | for(int i = 0; i < n-1; i++) Graph.addEdge(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second))); | ^ a.cc:108:23: error: expected primary-expression before '.' token 108 | int mst_wt = Graph.kruskalMST(); | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:71, 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/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = data*; _Iterator2 = data*; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool (*)(long long int, long long int)]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:104:9: required from here 104 | sort(edges2, edges2 + n, cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:158:30: error: cannot convert 'data' to 'long long int' in argument passing 158 | { return bool(_M_comp(*__it1, *__it2)); } | ~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = data; _Iterator = data*; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Val_comp_iter<bool (*)(long long int, long long int)>]' 1757 | while (__comp(__val, __next)) | ~~~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1785 | std::__unguarded_linear_insert(__i, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 1786 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool (*)(long long int, long long int)]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:104:9: required from here 104 | sort(edges2, edges2 + n, cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:240:30: error: cannot convert 'data' to 'long long int' in argument passing 240 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = data*; _Value = data; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_val<bool (*)(long long int, long long int)>]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:247:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 247 | std::__push_heap(__first, __holeIndex, __topIndex, | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 248 | _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:356:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 356 | std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value), | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 357 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1593:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1593 | std::__make_heap(__first, __middle, __comp); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1868:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1868 | std::__heap_select(__first, __middle, __last, __comp); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1884:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = data*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1884 | std::__partial_sort(__first, __last, __last, __comp); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1905:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1905 | std::__introsort_loop(__first, __last, | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool (*)(long long int, long long int)]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:104:9: required from here 104 | sort(edges2, edges2 + n, cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:196:30: error: cannot convert 'data' to 'long long int' in argument passing 196 | { return bool(_M_comp(*__it, __val)); } | ~~~~~~~^~~~~~~~~~~~~~
s195124087
p03684
C++
#include<bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> iPair; struct Graph { int V, E; vector< pair<int, iPair> > edges; Graph(int V, int E) { this->V = V; this->E = E; } void addEdge(int u, int v, int w) { edges.push_back({w, {u, v}}); } int kruskalMST(); }; struct data{ int first, second; }edges2[100001]; bool cmp1(int a, int b){ if(edges2[a].first > edges2[b].first || (edges2[a].second > edges2[b].second && edges2[a].first == edges2[b].first)) return true; else return false; } bool cmp2(int a, int b){ if(edges2[a].second > edges2[b].second || (edges2[a].first > edges2[b].first && edges2[a].second == edges2[b].second)) return true; else return false; } struct DisjointSets { int *parent, *rnk; int n; DisjointSets(int n) { this->n = n; parent = new int[n+1]; rnk = new int[n+1]; for (int i = 0; i <= n; i++) { rnk[i] = 0; parent[i] = i; } } int find(int u) { if (u != parent[u]) parent[u] = find(parent[u]); return parent[u]; } void merge(int x, int y) { x = find(x), y = find(y); if (rnk[x] > rnk[y]) parent[y] = x; else parent[x] = y; if (rnk[x] == rnk[y]) rnk[y]++; } }; int Graph::kruskalMST() { int mst_wt = 0; sort(edges.begin(), edges.end()); DisjointSets ds(V); vector< pair<int, iPair> >::iterator it; for (it=edges.begin(); it!=edges.end(); it++) { int u = it->second.first; int v = it->second.second; int set_u = ds.find(u); int set_v = ds.find(v); if (set_u != set_v) { cout << u << " - " << v << endl; mst_wt += it->first; ds.merge(set_u, set_v); } } return mst_wt; } signed main() { int n, x, y; cin >> n; for(int i = 0; i < n; i++){ cin >> edges2[i].first >> edges2[i].second; } Graph(n, 2*(n-1)); sort(edges2, edges2 + n, cmp1); for(int i = 0; i < n-1; i++) addEdge(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second))); sort(edges2, edges2 + n, cmp2); for(int i = 0; i < n-1; i++) addEdge(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second))); int mst_wt = g.kruskalMST(); cout << mst_wt; return 0; }
a.cc: In function 'int main()': a.cc:105:34: error: 'addEdge' was not declared in this scope 105 | for(int i = 0; i < n-1; i++) addEdge(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second))); | ^~~~~~~ a.cc:107:34: error: 'addEdge' was not declared in this scope 107 | for(int i = 0; i < n-1; i++) addEdge(i, i + 1, min(abs(edges2[i].first-edges2[i+1].first), abs(edges2[i].second-edges2[i+1].second))); | ^~~~~~~ a.cc:108:18: error: 'g' was not declared in this scope 108 | int mst_wt = g.kruskalMST(); | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:71, 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/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = data*; _Iterator2 = data*; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool (*)(long long int, long long int)]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:104:9: required from here 104 | sort(edges2, edges2 + n, cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:158:30: error: cannot convert 'data' to 'long long int' in argument passing 158 | { return bool(_M_comp(*__it1, *__it2)); } | ~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = data; _Iterator = data*; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Val_comp_iter<bool (*)(long long int, long long int)>]' 1757 | while (__comp(__val, __next)) | ~~~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1785 | std::__unguarded_linear_insert(__i, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 1786 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool (*)(long long int, long long int)]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:104:9: required from here 104 | sort(edges2, edges2 + n, cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:240:30: error: cannot convert 'data' to 'long long int' in argument passing 240 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = data*; _Value = data; _Compare = bool (*)(long long int, long long int)]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_val<bool (*)(long long int, long long int)>]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:247:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = data*; _Distance = long int; _Tp = data; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 247 | std::__push_heap(__first, __holeIndex, __topIndex, | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 248 | _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:356:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 356 | std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value), | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 357 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1593:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1593 | std::__make_heap(__first, __middle, __comp); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1868:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1868 | std::__heap_select(__first, __middle, __last, __comp); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1884:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = data*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1884 | std::__partial_sort(__first, __last, __last, __comp); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1905:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = data*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(long long int, long long int)>]' 1905 | std::__introsort_loop(__first, __last, | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = bool (*)(long long int, long long int)]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:104:9: required from here 104 | sort(edges2, edges2 + n, cmp1); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:196:30: error: cannot convert 'data' to 'long long int' in argument passing 196 | { return bool(_M_comp(*__it, __val)); } | ~~~~~~~^~~~~~~~~~~~~~