submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s955239697
p03865
C++
#include<string> #include<iostream> using namespace std; int main(void){ string s; cin >> s; cout << ( (s.size()%2 == 0) ^ (s.front() == s.back()) )?"Second":"First" << endl; return 0; }
a.cc: In function 'int main()': a.cc:6:82: error: invalid operands of types 'const char [6]' and '<unresolved overloaded function type>' to binary 'operator<<' 6 | cout << ( (s.size()%2 == 0) ^ (s.front() == s.back()) )?"Second":"First" << endl; | ~~~~~~~~^~~~~~~
s081358641
p03865
C++
#include <cstdio> #include <cstring> #include <string> #include <cmath> #include <cassert> #include <iostream> #include <algorithm> #include <stack> #include <queue> #include <vector> #include <set> #include <map> #include <bitset> #include <functional> #include <numeric> using namespace std; #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define mp(a,b) make_pair((a),(b)) #define pb(a) push_back((a)) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<((x))<<endl #define fi first #define se second #define INF 123456789987654321 #define long long long int main(){ long n,h; cin>>n>>h; long a,b,c,d,e; cin>>a>>b>>c>>d>>e; b+=e; d+=e; long need = n*e-h; long ans = INF; long i=0; while(i<=n && i*b<=need){ long j = max(0, (need-i*b+d)/d); if(i+j<=n) ans = min(ans, i*a+j*c); i++; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:42:17: error: no matching function for call to 'max(int, long long int)' 42 | long j = max(0, (need-i*b+d)/d); | ~~~^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from a.cc:3: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:42:17: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 42 | long j = max(0, (need-i*b+d)/d); | ~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:7: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:42:17: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 42 | long j = max(0, (need-i*b+d)/d); | ~~~^~~~~~~~~~~~~~~~~~~
s146613038
p03865
C++
#include<iostream> #include<algorithm> #include<vector> #include<string> using namespace std; int const N = 1e5 + 41; char s[N]; int n, rem; int main(){ scanf("%s",&s); n = strlen(s); if(s[0] == s[n-1]){ rem = 1; }else{ rem = 0; } if((n - rem) % 2 == 1){ printf("First\n"); }else{ printf("Second\n"); } return 0; }
a.cc: In function 'int main()': a.cc:14:13: error: 'strlen' was not declared in this scope 14 | n = strlen(s); | ^~~~~~ a.cc:4:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<vector> +++ |+#include <cstring> 4 | #include<string>
s364823227
p03865
Java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // standard input String s = sc.next(); // process boolean isStrLenEvenNumber = (s.length() % 2 == 0); boolean isSameFirstAndLast = (s.charAt(0) == (s.charAt(s.length() - 1)); // standard output System.out.println((isStrLenEvenNumber && isSameFirstAndLast) || (!isStrLenEvenNumber && !isSameFirstAndLast)? "Second": "First"); } }
Main.java:13: error: ')' expected boolean isSameFirstAndLast = (s.charAt(0) == (s.charAt(s.length() - 1)); ^ 1 error
s709499814
p03865
C++
#include<bits/stdc++.h> using namespace std; int main() { string s; cin>>s; int moves=0; int i=1; while(s.size()>2) { int f=0; if((i+1)<s.size()) { if(s[i-1]!=s[i+1]) { r=s; r.erase(i,1); f=1; moves++; } s=r; } if(!f) i++; } if(move%2) printf("First"); else printf("Second"); return 0; }
a.cc: In function 'int main()': a.cc:16:17: error: 'r' was not declared in this scope 16 | r=s; | ^ a.cc:21:15: error: 'r' was not declared in this scope 21 | s=r; | ^ a.cc:27:12: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator%' 27 | if(move%2) | ~~~~^~
s112784010
p03865
C++
#include<bits/stdc++.h> using namespace std; int main() { string s; cin>>s; int moves=0; int i=1; while(s.size()>2) { int f=0; if((i+1)<s.size()) { if(s[i-1]!=s[i+1]) { r=s; r.erase(i,1); f=1; moves++; } s=r; } if(!f) i++; } if(move%2) printf("First"); else printf("Second"); return 0; }
a.cc: In function 'int main()': a.cc:16:17: error: 'r' was not declared in this scope 16 | r=s; | ^ a.cc:21:15: error: 'r' was not declared in this scope 21 | s=r; | ^ a.cc:27:12: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator%' 27 | if(move%2) | ~~~~^~
s394385946
p03865
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair< int, int > pii; typedef vector< int > vi; typedef vector< vi > vvi; typedef vector< ll > vl; typedef vector< vl > vvl; typedef vector< pii > vp; typedef vector< vp > vvp; typedef vector< string > vs; typedef vector< double > vd; typedef vector< vd > vvd; template< class T1, class T2 > int upmin( T1 &x, T2 v ){ if( x > v ){ x = v; return 1; } return 0; } template< class T1, class T2 > int upmax( T1 &x, T2 v ){ if( x < v ){ x = v; return 1; } return 0; } const int INF = 0x3f3f3f3f; const string msg[] = { "Second", "First" }; string S; void solve(){ cin >> S; cout << msg[ ( S.size() % 2 == 0 ) ^ ( S.front == S.back() ) ] << endl; } signed main(){ ios::sync_with_stdio( 0 ); // init(); // preprocess(); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:41:50: error: invalid operands of types '<unresolved overloaded function type>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to binary 'operator==' 41 | cout << msg[ ( S.size() % 2 == 0 ) ^ ( S.front == S.back() ) ] << endl; | ~~~~~~~ ^~ ~~~~~~~~ | | | | | __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char} | <unresolved overloaded function type>
s936200712
p03865
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair< int, int > pii; typedef vector< int > vi; typedef vector< vi > vvi; typedef vector< ll > vl; typedef vector< vl > vvl; typedef vector< pii > vp; typedef vector< vp > vvp; typedef vector< string > vs; typedef vector< double > vd; typedef vector< vd > vvd; template< class T1, class T2 > int upmin( T1 &x, T2 v ){ if( x > v ){ x = v; return 1; } return 0; } template< class T1, class T2 > int upmax( T1 &x, T2 v ){ if( x < v ){ x = v; return 1; } return 0; } const int INF = 0x3f3f3f3f; const string msg[] = { "Second", "First" }; string S; void solve(){ cin >> S; cout << msg[ ( S.size() % 2 == 0 ) ^ ( S.front == S.back() ) ] << endl; } signed main(){ ios::sync_with_stdio( 0 ); init(); preprocess(); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:41:50: error: invalid operands of types '<unresolved overloaded function type>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to binary 'operator==' 41 | cout << msg[ ( S.size() % 2 == 0 ) ^ ( S.front == S.back() ) ] << endl; | ~~~~~~~ ^~ ~~~~~~~~ | | | | | __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char} | <unresolved overloaded function type> a.cc: In function 'int main()': a.cc:46:3: error: 'init' was not declared in this scope; did you mean 'int'? 46 | init(); | ^~~~ | int a.cc:47:3: error: 'preprocess' was not declared in this scope 47 | preprocess(); | ^~~~~~~~~~
s224074538
p03865
C++
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cctype> #include <cmath> #include <iostream> #include <queue> #include <list> #include <stack> #include <map> #include <numeric> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; map<string,bool> memo; bool solve(string& S){ if(S.length()==3){ if(S[0] == S[2]) return false; return true; } if(memo.count(S)>0) return memo[S]; bool flg = true; int cnt = 0; REP(i,1,S.length()-1){ if(S[i-1] == S[i+1]) continue; cnt++; if(solve(S.substr(0,i) + S.substr(i+1))) flg = false; } if(cnt == 0) flg = false; //cerr << S << "\t" << flg << endl; return memo[S] = flg; } int main(){ ios::sync_with_stdio(false); string S; cin >> S; if(solve(S)) cout << "First" << endl; else cout << "Second" << endl; return 0; }
a.cc: In function 'bool solve(std::string&)': a.cc:36:28: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>' 36 | if(solve(S.substr(0,i) + S.substr(i+1))) flg = false; | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ a.cc:25:20: note: initializing argument 1 of 'bool solve(std::string&)' 25 | bool solve(string& S){ | ~~~~~~~~^
s869352114
p03865
C++
#include <cstdio> #include <algorithm> #include <vector> #include <cstring> #include <numeric> #include <cassert> #include <cmath> #include <map> #include <set> using namespace std; typedef unsigned int uint; typedef long long LL; typedef pair<LL, LL> PLL; typedef vector<int> VI; typedef vector<LL> VL; typedef vector<VI> VVI; typedef vector<VL> VVL; typedef pair<int, int> PII; typedef vector<PII > VPII; typedef vector<VPII> VVPII; #define FOR(k,a,b) for(int k(a); k < (b); ++k) #define REP(k,a) for(int k=0; k < (a); ++k) #define ABS(a) ((a)>0?(a):-(a)) int main(int argc, char** argv) { #ifdef HOME freopen("in.txt", "rb", stdin); freopen("out.txt", "wb", stdout); #endif string s; cin >> s; int N = s.length(); vector<int> v(30); REP(i, N) v[s[i] - 'a']++; int mx = 0; REP(i, 30) if (v[i] > mx) { mx = v[i]; } string ans; if (N & 1) { ans = (s[0] == s.back() ? "Second" : "First");//(2 * mx == N + 1 ? "first" : "second"); } else { ans = (s[0]!=s.back()? "Second" : "First"); } cout << ans << endl; return 0; }
a.cc: In function 'int main(int, char**)': a.cc:32:9: error: 'string' was not declared in this scope 32 | string s; | ^~~~~~ a.cc:10:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' 9 | #include <set> +++ |+#include <string> 10 | a.cc:33:9: error: 'cin' was not declared in this scope 33 | cin >> s; | ^~~ a.cc:10:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 9 | #include <set> +++ |+#include <iostream> 10 | a.cc:33:16: error: 's' was not declared in this scope 33 | cin >> s; | ^ a.cc:44:15: error: expected ';' before 'ans' 44 | string ans; | ^~~~ | ; a.cc:47:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 47 | ans = (s[0] == s.back() ? "Second" : "First");//(2 * mx == N + 1 ? "first" : "second"); | ^~~ | abs a.cc:51:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 51 | ans = (s[0]!=s.back()? "Second" : "First"); | ^~~ | abs a.cc:54:9: error: 'cout' was not declared in this scope 54 | cout << ans << endl; | ^~~~ a.cc:54:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:54:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 54 | cout << ans << endl; | ^~~ | abs a.cc:54:24: error: 'endl' was not declared in this scope 54 | cout << ans << endl; | ^~~~ a.cc:10:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 9 | #include <set> +++ |+#include <ostream> 10 |
s007201447
p03865
C++
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; int n=s.size(); int idx; if(s[0]==s[n-1]) idx=1; else idx=0; if(idx){ if(n%2) cout<<Second; else cout<<First; } else { if(n%2) cout<<First; else cout<<Second; } }
a.cc: In function 'int main()': a.cc:11:23: error: 'Second' was not declared in this scope 11 | if(n%2) cout<<Second; | ^~~~~~ a.cc:12:20: error: 'First' was not declared in this scope 12 | else cout<<First; | ^~~~~ a.cc:15:23: error: 'First' was not declared in this scope 15 | if(n%2) cout<<First; | ^~~~~ a.cc:16:20: error: 'Second' was not declared in this scope 16 | else cout<<Second; | ^~~~~~
s315655293
p03865
Java
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; /* _ooOoo_ o8888888o 88" . "88 (| -_- |) O\ = /O ____/`---'\____ .' \\| |// `. / \\||| : |||// \ / _||||| -:- |||||- \ | | \\\ - /// | | | \_| ''\---/'' | | \ .-\__ `-` ___/-. / ___`. .' /--.--\ `. . __ ."" '< `.___\_<|>_/___.' >'"". | | : `- \`.;`\ _ /`;.`/ - ` : | | \ \ `-. \_ __\ /__ _/ .-` / / ======`-.____`-.___\_____/___.-`____.-'====== `=---=' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pass System Test! */ public class D { private static class Task { boolean dfs(String s, boolean first) { for (int i = 1; i < s.length() - 1; i++) { if (s.charAt(i - 1) == s.charAt(i + 1)) continue; boolean result = dfs(s.substring(0, i) + s.substring(i + 1), !first); if (first == result) return first; } return !first; } boolean solve(String s) { int N = s.length(); boolean same = s.charAt(0) == s.charAt(N - 1); if (same) { N--; } return N % 2 != 0; } void solve(FastScanner in, PrintWriter out) throws Exception { String s = in.next(); if (solve(s)) { out.println("First"); } else { out.println("Second"); } // Random random = new Random(); // while (true) { // String s = ""; // int p = -1; // for (int i = 0; i < 10; i++) { // int r = random.nextInt(9); // while (r == p) r = random.nextInt(9); // p = r; // char c = (char) (r + 'a'); // s += c; // } // System.out.println(s); // if (solve(s) != dfs(s, true)) return; // // } } } /** * ここから下はテンプレートです。 */ public static void main(String[] args) throws Exception { OutputStream outputStream = System.out; FastScanner in = new FastScanner(); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(in, out); out.close(); } private static class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int bufferLength = 0; private boolean hasNextByte() { if (ptr < bufferLength) { return true; } else { ptr = 0; try { bufferLength = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (bufferLength <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } boolean hasNext() { skipUnprintable(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } double nextDouble() { return Double.parseDouble(next()); } double[] nextDoubleArray(int n) { double[] array = new double[n]; for (int i = 0; i < n; i++) { array[i] = nextDouble(); } return array; } double[][] nextDoubleMap(int n, int m) { double[][] map = new double[n][]; for (int i = 0; i < n; i++) { map[i] = nextDoubleArray(m); } return map; } public int nextInt() { return (int) nextLong(); } public int[] nextIntArray(int n) { int[] array = new int[n]; for (int i = 0; i < n; i++) array[i] = nextInt(); return array; } public long[] nextLongArray(int n) { long[] array = new long[n]; for (int i = 0; i < n; i++) array[i] = nextLong(); return array; } public String[] nextStringArray(int n) { String[] array = new String[n]; for (int i = 0; i < n; i++) array[i] = next(); return array; } public char[][] nextCharMap(int n) { char[][] array = new char[n][]; for (int i = 0; i < n; i++) array[i] = next().toCharArray(); return array; } public int[][] nextIntMap(int n, int m) { int[][] map = new int[n][]; for (int i = 0; i < n; i++) { map[i] = nextIntArray(m); } return map; } } }
Main.java:30: error: class D is public, should be declared in a file named D.java public class D { ^ 1 error
s713764754
p03865
C++
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> using namespace std; char str[123456]; int main(void) { scanf("%s", str); int n = strlen(str); if (str[0] == str[n - 1]) { if (n % 2 == 0) { printf("First\n"); } else { printf("Second\n"); } } else { if (n % 2 == 0) { printf("Second\n"); } else { printf("First\n"); } } return 0; }
a.cc: In function 'int main()': a.cc:27:17: error: 'strlen' was not declared in this scope 27 | int n = strlen(str); | ^~~~~~ a.cc:20:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 19 | #include <queue> +++ |+#include <cstring> 20 | using namespace std;
s434620953
p03865
C++
//In the Name of God //Ya Ali #include<bits/stdc++.h> #define err(A) cout<<#A<<" = "<<(A)<<endl using namespace std; int main() { ios::sync_with_stdio(0);cin.tie(0); string s; cin>>s; if(s[0]==s[n-1] xor (n&1)) cout<<"Second"<<endl; else cout<<"First"<<endl; return 0; }
a.cc: In function 'int main()': a.cc:17:14: error: 'n' was not declared in this scope 17 | if(s[0]==s[n-1] xor (n&1)) | ^
s790451398
p03865
C++
#include <cstdio> #include <cstring> #include <cmath> #include <queue> #include <cstring> #include <vector> #include <string> #include <stack> #include <set> #include <map> #include <iostream> #include <algorithm> using namespace std; #define MP make_pair #define PB push_back typedef long long LL; typedef pair<int, int> Pii; const int inf = 0x3f3f3f3f; const LL INF = (1uLL << 63) - 1; const LL mod = 1000000007; const int N = 1e5 + 5; const double Pi = acos(-1.0); const int maxn = 1e5 + 5; char s[100005]; int L[100005],R[100005]; int main() { #ifdef local freopen("in", "r", stdin); #endif scanf("%s",s); int n = strlen(s); bool win = 0; for(int i = 0; i < n ;i++){ L[i] = i - 1; R[i] = i+1; } L[0] = -1; R[n-1] = -1; for(int i = 1; i < n ; i++){ if(s[i]!='&'){ int l = L[i]; int r = R[i]; if(l >= 0 && r < n && r >= l & &l < n&&s[l]!=s[r]){ s[i] = '&'; R[i-1] = R[i]; L[i+1] = L[i-1]; win^=1; i = L[i]; } } } if(win)cout<<"First"<<endl; else cout<<"Second"<<endl; }
a.cc: In function 'int main()': a.cc:43:47: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 43 | if(l >= 0 && r < n && r >= l & &l < n&&s[l]!=s[r]){ | ~~~^~~
s029751679
p03865
C++
#include <bits/stdc++.h> using namespace std; typedef long long ull; int main() { string s; cin>>s; char f,l; f=s[0],l=s[s.size()-1]; int rest; if(f==l){ rest=3; }else{ rest=0; char t=l; for(int i=0;i<s.size();i++){ if(t==l){ if(s[i]==f){ rest++; t=f; } }else{ if(s[i]==l){ rest++; t=l; } } } } if(((int)s.size()-rest)%2==0){ cout << "Second" << endl; }else{ cout << "First" << endl; } return 0;
a.cc: In function 'int main()': a.cc:36:18: error: expected '}' at end of input 36 | return 0; | ^ a.cc:5:12: note: to match this '{' 5 | int main() { | ^
s274168847
p03866
C++
#include <bits/stdc++.h> using namespace std; void solve(long long x_s, long long y_s, long long x_t, long long y_t, long long N, std::vector<long long> x, std::vector<long long> y, std::vector<long long> r) {} // Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You // use the default template now. You can remove this line by using your custom // template) int main() { long long x_s; scanf("%lld", &x_s);#include <bits/stdc++.h> #include <stdio.h> #include <iostream> #include <cstdio> #include <bitset> #include <algorithm> #include <vector> #include <list> #include <queue> #include <stack> #include <string> #include <string.h> #include <cmath> #include <utility> #include <functional> #include <map> #include <set> #include <cctype> #include <fstream> #include <numeric> #include <iomanip> #include <cstring> using namespace std; using ll = long long; #define ALL(a) (a).begin(), (a).end() #define FOR(i, a, b) for (long long int i = (a); i <= (b); i++) #define RFOR(i, a, b) for (long long int i = (a); i >= (b); i--) //#define MOD 1000000007 //const int MOD = 1000000007; const int MOD = 998244353; #define LLONG_MAXs 9223372036854775800 / 2 //#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/ #define ALL(a) (a).begin(), (a).end() #include <iostream> #include <cmath> using namespace std; bool isPrimeNum(ll x) { // 素数である場合 true を返す if (x <= 1) { // 1以下である場合は素数でないことがすぐにわかる return false; } // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト int n = (int)sqrt((double)x); for (int i = 2; i <= n; i++) { if (x % i == 0) { // 割り切る整数がある場合、即判定終了 return false; } } return true; // 割り切る整数がない場合、素数である } ll myPow(ll x, ll n, ll m) { if (n == 0) return 1; if (n % 2 == 0) return myPow(x * x % m, n / 2, m); else return x * myPow(x, n - 1, m) % m; } constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); } constexpr ll abs(ll a, ll b) { if (a >= b) return a - b; if (a < b) return b - a; } constexpr double dabs(double a, double b) { if (a >= b) return a - b; if (a < b) return b - a; } constexpr ll min(ll a, ll b) { if (a >= b) return b; if (a < b) return a; } constexpr ll max(ll a, ll b) { if (a >= b) return a; if (a < b) return b; } constexpr double maxd(double a, double b) { if (a >= b) return a; if (a < b) return b; } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int dx8[8] = {1, 0, -1, 0, 1, -1, 1, -1}; int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1}; class UnionFind { public: //親の番号を格納する。親だった場合は-(その集合のサイズ) vector<int> Parent; //作るときはParentの値を全て-1にする //こうすると全てバラバラになる UnionFind(int N) { Parent = vector<int>(N, -1); } //Aがどのグループに属しているか調べる 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 issame(int x, int y) { return root(x) == root(y); } //AとBをくっ付ける bool connect(int A, int B) { //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらひっくり返しちゃう。 if (size(A) < size(B)) swap(A, B); //Aのサイズを更新する Parent[A] += Parent[B]; //Bの親をAに変更する Parent[B] = A; return true; } }; long long fac[510000], finv[510000], inv[510000]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < 510000; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } void yn(bool flag) { if (flag) { cout << "Yes" << endl; } else { cout << "No" << endl; } return; } void YN(bool flag) { if (flag) { cout << "YES" << endl; } else { cout << "NO" << endl; } return; } std::vector<ll> enum_div(ll n) //nの約数を列挙 { std::vector<ll> ret; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (i != 1 && i * i != n) { ret.push_back(n / i); } } } ret.push_back(n); return ret; } // modint: mod 計算を int を扱うように扱える構造体 template <int MOD> struct Fp { long long val; constexpr Fp(long long v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr int getmod() { return MOD; } constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; } constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; } constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; } constexpr Fp &operator+=(const Fp &r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp &operator-=(const Fp &r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp &operator*=(const Fp &r) noexcept { val = val * r.val % MOD; return *this; } constexpr Fp &operator/=(const Fp &r) noexcept { long long a = r.val, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator==(const Fp &r) const noexcept { return this->val == r.val; } constexpr bool operator!=(const Fp &r) const noexcept { return this->val != r.val; } friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept { return os << x.val; } friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept { if (n == 0) return 1; auto t = modpow(a, n / 2); t = t * t; if (n & 1) t = t * a; return t; } }; using mint = Fp<MOD>; // グラフセット struct Edge { ll to; // 辺の行き先 double weight; // 辺の重み Edge(int t, double w) : to(t), weight(w) {} }; //using Graph = vector<vector<Edge>>; #define def 0 template <class V, int NV> struct SegTree { //[l,r) V comp(V &l, V &r) { return max(l, r); }; vector<V> val; SegTree() { val = vector<V>(NV * 2, def); } V get(int x, int y, int l = 0, int r = NV, int k = 1) { if (r <= x || y <= l) return def; if (x <= l && r <= y) return val[k]; auto a = get(x, y, l, (l + r) / 2, k * 2); auto b = get(x, y, (l + r) / 2, r, k * 2 + 1); return comp(a, b); } void update(int i, V v) { i += NV; val[i] = v; while (i > 1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]); } void add(int i, V v) { update(i, val[i + NV] + v); } V operator[](int x) { return get(x, x + 1); } }; typedef vector<vector<long long>> matrix; matrix mul_mod(matrix A, matrix B) { int H = A.size(); int W = B[0].size(); int K = A[0].size(); matrix C(H, vector<ll>(W, 0)); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { for (int k = 0; k < K; k++) { C[i][j] += A[i][k] * B[k][j]; C[i][j] %= MOD; } } } return C; } matrix pow_mod_matrix(matrix A, ll p) { matrix ret = matrix(A.size(), vector<long long>(A.size(), 0)); for (int i = 0; i < A.size(); i++) ret[i][i] = 1; while (p > 0) { if (p & 1) ret = mul_mod(ret, A); A = mul_mod(A, A); p >>= 1; } return ret; } // 区間加算にも対応した BIT template <class Abel> struct BIT { vector<Abel> dat[2]; Abel UNITY_SUM = 0; // to be set /* [1, n] */ BIT(int n) { init(n); } void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); } /* a, b are 1-indexed, [a, b) */ inline void sub_add(int p, int a, Abel x) { for (int i = a; i < (int)dat[p].size(); i += i & -i) dat[p][i] = dat[p][i] + x; } inline void add(int a, int b, Abel x) { sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1)); } /* a is 1-indexed, [a, b) */ inline Abel sub_sum(int p, int a) { Abel res = UNITY_SUM; for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i]; return res; } inline Abel sum(int a, int b) { return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1); } /* debug */ void print() { for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ","; cout << endl; } }; //cout << std::setprecision(30) << ans << endl; using Graph = vector<vector<Edge>>; string solve(string S) { string T = S; string s1, s2, s3; if (S.find("(") != string::npos) { reverse(T.begin(), T.end()); return S + T; } } int main() { cout << std::setprecision(30); ; ll xs, xg, ys, yg; cin >> xs >> ys >> xg >> yg; ll N; cin >> N; Graph G(N + 2); ll x[N], y[N], r[N]; FOR(i, 0, N - 1) { cin >> x[i] >> y[i] >> r[i]; } FOR(i, 0, N - 1) { G[N].push_back(Edge(i, maxd(0, -r[i] + sqrt((xs - x[i]) * (xs - x[i]) + (ys - y[i]) * (ys - y[i]))))); G[i].push_back(Edge(N + 1, maxd(0, -r[i] + sqrt((xg - x[i]) * (xg - x[i]) + (yg - y[i]) * (yg - y[i]))))); //cout << i << endl; //cout << "N-i " << maxd(0, -r[i] + sqrt((xs - x[i]) * (xs - x[i]) + (ys - y[i]) * (ys - y[i]))) << endl; //cout << "i-N+1 " << maxd(0, -r[i] + sqrt((xg - x[i]) * (xg - x[i]) + (yg - y[i]) * (yg - y[i]))) << endl; FOR(j, 0, N - 1) { if (i == j) continue; G[i].push_back(Edge(j, maxd(0, -r[i] - r[j] + sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]))))); //cout << "i-j " << maxd(0, -r[i] - r[j] + sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]))) << endl; } }; using P = pair<double, ll>; vector<double> dis(N + 2); FOR(i, 0, N + 1) { dis[i] = 999999999; } priority_queue<P, vector<P>, greater<P>> pq; // 「仮の最短距離, 頂点」が小さい順に並ぶ dis[N] = 0; pq.emplace(dis[N], N); while (!pq.empty()) { P p = pq.top(); pq.pop(); int v = p.second; //cout << v << dis[v] << p.first << endl; if (dis[v] < p.first) { // 最短距離で無ければ無視 continue; } for (auto &e : G[v]) { cout << "disto " << dis[e.to] << " " << dis[v] << " " << e.weight << endl; if (dis[e.to] > dis[v] + e.weight) { // 最短距離候補なら priority_queue に追加 dis[e.to] = dis[v] + e.weight; pq.emplace(dis[e.to], e.to); } } } cout << dis[N + 1] << endl; return 0; } long long y_s; scanf("%lld", &y_s); long long x_t; scanf("%lld", &x_t); long long y_t; scanf("%lld", &y_t); long long N; scanf("%lld", &N); std::vector<long long> x(N); std::vector<long long> y(N); std::vector<long long> r(N); for (int i = 0; i < N; i++) { scanf("%lld", &x[i]); scanf("%lld", &y[i]); scanf("%lld", &r[i]); } solve(x_s, y_s, x_t, y_t, N, std::move(x), std::move(y), std::move(r)); return 0; }
a.cc:13:23: error: stray '#' in program 13 | scanf("%lld", &x_s);#include <bits/stdc++.h> | ^ a.cc: In function 'int main()': a.cc:13:24: error: 'include' was not declared in this scope 13 | scanf("%lld", &x_s);#include <bits/stdc++.h> | ^~~~~~~ a.cc:13:33: error: 'bits' was not declared in this scope 13 | scanf("%lld", &x_s);#include <bits/stdc++.h> | ^~~~ a.cc:13:38: error: 'stdc' was not declared in this scope; did you mean 'std'? 13 | scanf("%lld", &x_s);#include <bits/stdc++.h> | ^~~~ | std a.cc:35:1: error: expected primary-expression before 'using' 35 | using namespace std; | ^~~~~ a.cc:55:1: error: a function-definition is not allowed here before '{' token 55 | { // 素数である場合 true を返す | ^ a.cc:73:1: error: a function-definition is not allowed here before '{' token 73 | { | ^ a.cc:82:30: error: a function-definition is not allowed here before '{' token 82 | constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } | ^ a.cc:83:30: error: a function-definition is not allowed here before '{' token 83 | constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); } | ^ a.cc:85:1: error: a function-definition is not allowed here before '{' token 85 | { | ^ a.cc:92:1: error: a function-definition is not allowed here before '{' token 92 | { | ^ a.cc:99:1: error: a function-definition is not allowed here before '{' token 99 | { | ^ a.cc:107:1: error: a function-definition is not allowed here before '{' token 107 | { | ^ a.cc:114:1: error: a function-definition is not allowed here before '{' token 114 | { | ^ a.cc:187:1: error: a function-definition is not allowed here before '{' token 187 | { | ^ a.cc:201:1: error: a function-definition is not allowed here before '{' token 201 | { | ^ a.cc:210:1: error: a function-definition is not allowed here before '{' token 210 | { | ^ a.cc:227:1: error: a function-definition is not allowed here before '{' token 227 | { | ^ a.cc:239:1: error: a function-definition is not allowed here before '{' token 239 | { | ^ a.cc:252:1: error: a function-definition is not allowed here before '{' token 252 | { | ^ a.cc:270:1: error: a template declaration cannot appear at block scope 270 | template <int MOD> | ^~~~~~~~ a.cc:347:14: error: 'Fp' does not name a type 347 | using mint = Fp<MOD>; | ^~ a.cc:358:1: error: a template declaration cannot appear at block scope 358 | template <class V, int NV> | ^~~~~~~~ a.cc:388:1: error: a function-definition is not allowed here before '{' token 388 | { | ^ a.cc:408:1: error: a function-definition is not allowed here before '{' token 408 | { | ^ a.cc:423:1: error: a template declaration cannot appear at block scope 423 | template <class Abel> | ^~~~~~~~ a.cc:476:1: error: a function-definition is not allowed here before '{' token 476 | { | ^ a.cc:486:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 486 | int main() | ^~ a.cc:486:9: note: remove parentheses to default-initialize a variable 486 | int main() | ^~ | -- a.cc:486:9: note: or replace parentheses with braces to value-initialize a variable a.cc:487:1: error: a function-definition is not allowed here before '{' token 487 | { | ^
s106307818
p03866
C++
// #pragma GCC optimize("Ofast") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") // #pragma GCC optimize("no-stack-protector") // #pragma GCC optimize("fast-math") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native") #include <bits/stdc++.h> using namespace std; typedef int64_t ll; typedef uint64_t ull; const ll LINF = 9187201950435737471; const ll nLINF = -9187201950435737472; const ll INF = 2139062143; const int nINF = -2139062144; const ull ULINF = numeric_limits<ull>::max(); const ll MAXN = 1000 + 15; const ll MAXE = 1000 + 15; const double PI = acos(-1); const ll MOD = 998244353; const double EPS = 1e-8; auto seed = chrono::high_resolution_clock::now().time_since_epoch().count(); mt19937 rnd(seed); bool isEqual(double a, double b) { return abs(a - b) <= EPS; } #define all(_v) _v.begin(), _v.end() #define rall(v) v.rbegin(), v.rend() #define sz(v) (int)(v.size()) #define sqr(_v) ((_v) * (_v)) #define vpi vector<pair<int, int>> #define eb emplace_back #define pb push_back #define mod(x, m) ((x) % m + ((x) < 0 && ((x % m) != 0) ? m : 0)) #define vi vector<int> #define pi pair<int, int> #define minq(x, y) (x) = min(x, y) #define maxq(x, y) (x) = max(x, y) inline void IO() { #if(DEBUG_LEVEL > 0) freopen("../input.txt", "r", stdin); freopen("../out.txt", "w", stdout); #else ios_base::sync_with_stdio(false); cin.tie(nullptr); #endif } template <typename T> istream& operator >> (istream& in, vector<T>& a) { for (auto& i : a) in >> i; return in; } template <typename T> ostream& operator << (ostream& out, const vector<T>& a) { for (auto& i : a) { out << i << " "; } return out; } template <typename T, typename D> istream& operator >> (istream& in, pair<T, D>& a) { in >> a.first >> a.second; return in; } template <typename T, typename D> ostream& operator << (ostream& out, const pair<T, D>& a) { out << a.first << " " << a.second; return out; } #define int ll #define double long double double dist[MAXN]; bool used[MAXN]; struct circle{ int x, y, r; circle(int xx = 0, int yy = 0, int rr = 0) { x = xx; y = yy; r = rr; } double dist(const circle& p) const { double rast = sqrt(sqr(p.x - x) + sqr(p.y - y)); return max(double(0), rast - p.r - r); } }; inline void solve() { for (int i = 0; i < MAXN; ++i) { dist[i] = INF; } vector <circle> a; int x, y; cin >> x >> y; a.pb({x, y, 0}); cin >> x >> y; int n; cin >> n; for (int i = 0; i < n; ++i) { int xx, yy, rr; cin >> xx >> yy >> rr; a.pb({xx, yy, rr}); } a.pb({x, y, 0}); dist[0] = 0; n += 2; for (int i = 0; i < n; ++i) { int v = -1; for (int j = 0; j < n; ++j) { if (!used[j] && (v == -1 || dist[j] < dist[v])) { v = j; } } if (v == -1) {break;} used[v] = 1; for (int j = 0; j < n; ++j) { if (used[j]) {continue;} dist[j] = min(dist[j], dist[v] + a[v].dist(a[j])); } } cout << setprecision(9) << fixed; cout << dist[n - 1]; } signed main() { IO(); int t = 1; // cin >> t; while (t--) { solve(); } return 0; }
a.cc: In member function 'long double circle::dist(const circle&) const': a.cc:84:16: error: expected primary-expression before 'long' 84 | #define double long double | ^~~~ a.cc:98:20: note: in expansion of macro 'double' 98 | return max(double(0), rast - p.r - r); | ^~~~~~
s161778195
p03866
C++
#include<bits/stdc++.h> using namespace std; using ll = long long; inline int ri() { int n; cin >> n; return n;} //経路復元なしDijkstra法 template<class T> vector<T> dijkstra(int start, const vector<vector<pair<int,T>>>& Hen){ T INF = numeric_limits<T>::max(); int N = Hen.size(); vector<T> dist(N, INF); dist[start] = 0; priority_queue<pair<T,int>, vector<pair<T,int>>, greater<pair<T,int>>> que; que.push(0, start); while(que.size()) { int ver = que.top().second; T cost = que.top().first; que.pop(); if(cost != dist[ver])continue; for(auto i : Hen[ver]) { if(dist[i.first] > cost + i.second) { dist[i.first] = cost + i.second; que.push(dist[i.first], i.first); } } } return dist; } int main() { vector<tuple<double, double, double>> pos; { double xa, ya, xb, yb; cin >> xa >> ya >> xb >> yb; pos.push_back({xa, ya, 0}), pos.push_back({xb, yb, 0}); } int n; cin >> n; for(int i = 0; i < n; i++) { double x, y, r; cin >> x >> y >> r; pos.push_back({x, y, r}); } vector<vector<pair<int,double>>> hen(n + 2); for(int i = 0; i < n + 2; i++) { for(int j = i + 1; j < n + 2; j++) { double xa, ya, ra, xb, yb, rb, dist; tie(xa, ya, ra) = pos[i], tie(xb, yb, rb) = pos[j]; dist = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)) - (ra + rb); dist = max(dist, 0.0); hen[i].push_back({j, dist}); hen[j].push_back({i, dist}); } } cout << fixed <<setprecision(12) << dijkstra(0,hen)[1] << '\n'; }
a.cc: In instantiation of 'std::vector<_Tp> dijkstra(int, const std::vector<std::vector<std::pair<int, T> > >&) [with T = double]': a.cc:57:49: required from here 57 | cout << fixed <<setprecision(12) << dijkstra(0,hen)[1] << '\n'; | ~~~~~~~~^~~~~~~ a.cc:15:17: error: no matching function for call to 'std::priority_queue<std::pair<double, int>, std::vector<std::pair<double, int>, std::allocator<std::pair<double, int> > >, std::greater<std::pair<double, int> > >::push(int, int&)' 15 | que.push(0, start); | ~~~~~~~~^~~~~~~~~~ In file included from /usr/include/c++/14/queue:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157, from a.cc:1: /usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<double, int>; _Sequence = std::vector<std::pair<double, int>, std::allocator<std::pair<double, int> > >; _Compare = std::greater<std::pair<double, int> >; value_type = std::pair<double, int>]' 736 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<double, int>; _Sequence = std::vector<std::pair<double, int>, std::allocator<std::pair<double, int> > >; _Compare = std::greater<std::pair<double, int> >; value_type = std::pair<double, int>]' 744 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate expects 1 argument, 2 provided a.cc:23:41: error: no matching function for call to 'std::priority_queue<std::pair<double, int>, std::vector<std::pair<double, int>, std::allocator<std::pair<double, int> > >, std::greater<std::pair<double, int> > >::push(__gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type&, int&)' 23 | que.push(dist[i.first], i.first); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<double, int>; _Sequence = std::vector<std::pair<double, int>, std::allocator<std::pair<double, int> > >; _Compare = std::greater<std::pair<double, int> >; value_type = std::pair<double, int>]' 736 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<double, int>; _Sequence = std::vector<std::pair<double, int>, std::allocator<std::pair<double, int> > >; _Compare = std::greater<std::pair<double, int> >; value_type = std::pair<double, int>]' 744 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate expects 1 argument, 2 provided
s068677567
p03866
C++
#include <bits/stdc++.h> //#include "bits/stdc++.h" #include <algorithm> #include <array> #ifdef _MSC_VER #include <intrin.h> #endif namespace atcoder { namespace internal { // @param n `0 <= n` // @return minimum non-negative `x` s.t. `n <= 2**x` int ceil_pow2(int n) { int x = 0; while ((1U << x) < (unsigned int)(n)) x++; return x; } // @param n `1 <= n` // @return minimum non-negative `x` s.t. `(n & (1 << x)) != 0` int bsf(unsigned int n) { #ifdef _MSC_VER unsigned long index; _BitScanForward(&index, n); return index; #else return __builtin_ctz(n); #endif } } // namespace internal } // namespace atcoder #include <utility> namespace atcoder { namespace internal { // @param m `1 <= m` // @return x mod m constexpr long long safe_mod(long long x, long long m) { x %= m; if (x < 0) x += m; return x; } // Fast modular multiplication by barrett reduction // Reference: https://en.wikipedia.org/wiki/Barrett_reduction // NOTE: reconsider after Ice Lake struct barrett { unsigned int _m; unsigned long long im; // @param m `1 <= m < 2^31` barrett(unsigned int m) : _m(m), im((unsigned long long)(-1) / m + 1) {} // @return m unsigned int umod() const { return _m; } // @param a `0 <= a < m` // @param b `0 <= b < m` // @return `a * b % m` unsigned int mul(unsigned int a, unsigned int b) const { // [1] m = 1 // a = b = im = 0, so okay // [2] m >= 2 // im = ceil(2^64 / m) // -> im * m = 2^64 + r (0 <= r < m) // let z = a*b = c*m + d (0 <= c, d < m) // a*b * im = (c*m + d) * im = c*(im*m) + d*im = c*2^64 + c*r + d*im // c*r + d*im < m * m + m * im < m * m + 2^64 + m <= 2^64 + m * (m + 1) < 2^64 * 2 // ((ab * im) >> 64) == c or c + 1 unsigned long long z = a; z *= b; #ifdef _MSC_VER unsigned long long x; _umul128(z, im, &x); #else unsigned long long x = (unsigned long long)(((unsigned __int128)(z)*im) >> 64); #endif unsigned int v = (unsigned int)(z - x * _m); if (_m <= v) v += _m; return v; } }; // @param n `0 <= n` // @param m `1 <= m` // @return `(x ** n) % m` constexpr long long pow_mod_constexpr(long long x, long long n, int m) { if (m == 1) return 0; unsigned int _m = (unsigned int)(m); unsigned long long r = 1; unsigned long long y = safe_mod(x, m); while (n) { if (n & 1) r = (r * y) % _m; y = (y * y) % _m; n >>= 1; } return r; } // Reference: // M. Forisek and J. Jancina, // Fast Primality Testing for Integers That Fit into a Machine Word // @param n `0 <= n` constexpr bool is_prime_constexpr(int n) { if (n <= 1) return false; if (n == 2 || n == 7 || n == 61) return true; if (n % 2 == 0) return false; long long d = n - 1; while (d % 2 == 0) d /= 2; constexpr long long bases[3] = {2, 7, 61}; for (long long a : bases) { long long t = d; long long y = pow_mod_constexpr(a, t, n); while (t != n - 1 && y != 1 && y != n - 1) { y = y * y % n; t <<= 1; } if (y != n - 1 && t % 2 == 0) { return false; } } return true; } template <int n> constexpr bool is_prime = is_prime_constexpr(n); // @param b `1 <= b` // @return pair(g, x) s.t. g = gcd(a, b), xa = g (mod b), 0 <= x < b/g constexpr std::pair<long long, long long> inv_gcd(long long a, long long b) { a = safe_mod(a, b); if (a == 0) return {b, 0}; // Contracts: // [1] s - m0 * a = 0 (mod b) // [2] t - m1 * a = 0 (mod b) // [3] s * |m1| + t * |m0| <= b long long s = b, t = a; long long m0 = 0, m1 = 1; while (t) { long long u = s / t; s -= t * u; m0 -= m1 * u; // |m1 * u| <= |m1| * s <= b // [3]: // (s - t * u) * |m1| + t * |m0 - m1 * u| // <= s * |m1| - t * u * |m1| + t * (|m0| + |m1| * u) // = s * |m1| + t * |m0| <= b auto tmp = s; s = t; t = tmp; tmp = m0; m0 = m1; m1 = tmp; } // by [3]: |m0| <= b/g // by g != b: |m0| < b/g if (m0 < 0) m0 += b / s; return {s, m0}; } // Compile time primitive root // @param m must be prime // @return primitive root (and minimum in now) constexpr int primitive_root_constexpr(int m) { if (m == 2) return 1; if (m == 167772161) return 3; if (m == 469762049) return 3; if (m == 754974721) return 11; if (m == 998244353) return 3; int divs[20] = {}; divs[0] = 2; int cnt = 1; int x = (m - 1) / 2; while (x % 2 == 0) x /= 2; for (int i = 3; (long long)(i)*i <= x; i += 2) { if (x % i == 0) { divs[cnt++] = i; while (x % i == 0) { x /= i; } } } if (x > 1) { divs[cnt++] = x; } for (int g = 2;; g++) { bool ok = true; for (int i = 0; i < cnt; i++) { if (pow_mod_constexpr(g, (m - 1) / divs[i], m) == 1) { ok = false; break; } } if (ok) return g; } } template <int m> constexpr int primitive_root = primitive_root_constexpr(m); } // namespace internal } // namespace atcoder #include <cassert> #include <numeric> #include <type_traits> namespace atcoder { namespace internal { #ifndef _MSC_VER template <class T> using is_signed_int128 = typename std::conditional<std::is_same<T, __int128_t>::value || std::is_same<T, __int128>::value, std::true_type, std::false_type>::type; template <class T> using is_unsigned_int128 = typename std::conditional<std::is_same<T, __uint128_t>::value || std::is_same<T, unsigned __int128>::value, std::true_type, std::false_type>::type; template <class T> using make_unsigned_int128 = typename std::conditional<std::is_same<T, __int128_t>::value, __uint128_t, unsigned __int128>; template <class T> using is_integral = typename std::conditional<std::is_integral<T>::value || is_signed_int128<T>::value || is_unsigned_int128<T>::value, std::true_type, std::false_type>::type; template <class T> using is_signed_int = typename std::conditional<(is_integral<T>::value && std::is_signed<T>::value) || is_signed_int128<T>::value, std::true_type, std::false_type>::type; template <class T> using is_unsigned_int = typename std::conditional<(is_integral<T>::value && std::is_unsigned<T>::value) || is_unsigned_int128<T>::value, std::true_type, std::false_type>::type; template <class T> using to_unsigned = typename std::conditional< is_signed_int128<T>::value, make_unsigned_int128<T>, typename std::conditional<std::is_signed<T>::value, std::make_unsigned<T>, std::common_type<T>>::type>::type; #else template <class T> using is_integral = typename std::is_integral<T>; template <class T> using is_signed_int = typename std::conditional<is_integral<T>::value && std::is_signed<T>::value, std::true_type, std::false_type>::type; template <class T> using is_unsigned_int = typename std::conditional<is_integral<T>::value && std::is_unsigned<T>::value, std::true_type, std::false_type>::type; template <class T> using to_unsigned = typename std::conditional<is_signed_int<T>::value, std::make_unsigned<T>, std::common_type<T>>::type; #endif template <class T> using is_signed_int_t = std::enable_if_t<is_signed_int<T>::value>; template <class T> using is_unsigned_int_t = std::enable_if_t<is_unsigned_int<T>::value>; template <class T> using to_unsigned_t = typename to_unsigned<T>::type; } // namespace internal } // namespace atcoder #include <cassert> #include <numeric> #include <type_traits> #ifdef _MSC_VER #include <intrin.h> #endif namespace atcoder { namespace internal { struct modint_base {}; struct static_modint_base : modint_base {}; template <class T> using is_modint = std::is_base_of<modint_base, T>; template <class T> using is_modint_t = std::enable_if_t<is_modint<T>::value>; } // namespace internal template <int m, std::enable_if_t<(1 <= m)>* = nullptr> struct static_modint : internal::static_modint_base { using mint = static_modint; public: static constexpr int mod() { return m; } static mint raw(int v) { mint x; x._v = v; return x; } static_modint() : _v(0) {} template <class T, internal::is_signed_int_t<T>* = nullptr> static_modint(T v) { long long x = (long long)(v % (long long)(umod())); if (x < 0) x += umod(); _v = (unsigned int)(x); } template <class T, internal::is_unsigned_int_t<T>* = nullptr> static_modint(T v) { _v = (unsigned int)(v % umod()); } static_modint(bool v) { _v = ((unsigned int)(v) % umod()); } unsigned int val() const { return _v; } mint& operator++() { _v++; if (_v == umod()) _v = 0; return *this; } mint& operator--() { if (_v == 0) _v = umod(); _v--; return *this; } mint operator++(int) { mint result = *this; ++*this; return result; } mint operator--(int) { mint result = *this; --*this; return result; } mint& operator+=(const mint& rhs) { _v += rhs._v; if (_v >= umod()) _v -= umod(); return *this; } mint& operator-=(const mint& rhs) { _v -= rhs._v; if (_v >= umod()) _v += umod(); return *this; } mint& operator*=(const mint& rhs) { unsigned long long z = _v; z *= rhs._v; _v = (unsigned int)(z % umod()); return *this; } mint& operator/=(const mint& rhs) { return *this = *this * rhs.inv(); } mint operator+() const { return *this; } mint operator-() const { return mint() - *this; } mint pow(long long n) const { assert(0 <= n); mint x = *this, r = 1; while (n) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; } mint inv() const { if (prime) { assert(_v); return pow(umod() - 2); } else { auto eg = internal::inv_gcd(_v, m); assert(eg.first == 1); return eg.second; } } friend mint operator+(const mint& lhs, const mint& rhs) { return mint(lhs) += rhs; } friend mint operator-(const mint& lhs, const mint& rhs) { return mint(lhs) -= rhs; } friend mint operator*(const mint& lhs, const mint& rhs) { return mint(lhs) *= rhs; } friend mint operator/(const mint& lhs, const mint& rhs) { return mint(lhs) /= rhs; } friend bool operator==(const mint& lhs, const mint& rhs) { return lhs._v == rhs._v; } friend bool operator!=(const mint& lhs, const mint& rhs) { return lhs._v != rhs._v; } private: unsigned int _v; static constexpr unsigned int umod() { return m; } static constexpr bool prime = internal::is_prime<m>; }; template <int id> struct dynamic_modint : internal::modint_base { using mint = dynamic_modint; public: static int mod() { return (int)(bt.umod()); } static void set_mod(int m) { assert(1 <= m); bt = internal::barrett(m); } static mint raw(int v) { mint x; x._v = v; return x; } dynamic_modint() : _v(0) {} template <class T, internal::is_signed_int_t<T>* = nullptr> dynamic_modint(T v) { long long x = (long long)(v % (long long)(mod())); if (x < 0) x += mod(); _v = (unsigned int)(x); } template <class T, internal::is_unsigned_int_t<T>* = nullptr> dynamic_modint(T v) { _v = (unsigned int)(v % mod()); } dynamic_modint(bool v) { _v = ((unsigned int)(v) % mod()); } unsigned int val() const { return _v; } mint& operator++() { _v++; if (_v == umod()) _v = 0; return *this; } mint& operator--() { if (_v == 0) _v = umod(); _v--; return *this; } mint operator++(int) { mint result = *this; ++*this; return result; } mint operator--(int) { mint result = *this; --*this; return result; } mint& operator+=(const mint& rhs) { _v += rhs._v; if (_v >= umod()) _v -= umod(); return *this; } mint& operator-=(const mint& rhs) { _v += mod() - rhs._v; if (_v >= umod()) _v -= umod(); return *this; } mint& operator*=(const mint& rhs) { _v = bt.mul(_v, rhs._v); return *this; } mint& operator/=(const mint& rhs) { return *this = *this * rhs.inv(); } mint operator+() const { return *this; } mint operator-() const { return mint() - *this; } mint pow(long long n) const { assert(0 <= n); mint x = *this, r = 1; while (n) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; } mint inv() const { auto eg = internal::inv_gcd(_v, mod()); assert(eg.first == 1); return eg.second; } friend mint operator+(const mint& lhs, const mint& rhs) { return mint(lhs) += rhs; } friend mint operator-(const mint& lhs, const mint& rhs) { return mint(lhs) -= rhs; } friend mint operator*(const mint& lhs, const mint& rhs) { return mint(lhs) *= rhs; } friend mint operator/(const mint& lhs, const mint& rhs) { return mint(lhs) /= rhs; } friend bool operator==(const mint& lhs, const mint& rhs) { return lhs._v == rhs._v; } friend bool operator!=(const mint& lhs, const mint& rhs) { return lhs._v != rhs._v; } private: unsigned int _v; static internal::barrett bt; static unsigned int umod() { return bt.umod(); } }; template <int id> internal::barrett dynamic_modint<id>::bt = 998244353; using modint998244353 = static_modint<998244353>; using modint1000000007 = static_modint<1000000007>; using modint = dynamic_modint<-1>; namespace internal { template <class T> using is_static_modint = std::is_base_of<internal::static_modint_base, T>; template <class T> using is_static_modint_t = std::enable_if_t<is_static_modint<T>::value>; template <class> struct is_dynamic_modint : public std::false_type {}; template <int id> struct is_dynamic_modint<dynamic_modint<id>> : public std::true_type {}; template <class T> using is_dynamic_modint_t = std::enable_if_t<is_dynamic_modint<T>::value>; } // namespace internal } // namespace atcoder #include <cassert> #include <type_traits> #include <vector> namespace atcoder { namespace internal { template <class mint, internal::is_static_modint_t<mint>* = nullptr> void butterfly(std::vector<mint>& a) { static constexpr int g = internal::primitive_root<mint::mod()>; int n = int(a.size()); int h = internal::ceil_pow2(n); static bool first = true; static mint sum_e[30]; // sum_e[i] = ies[0] * ... * ies[i - 1] * es[i] if (first) { first = false; mint es[30], ies[30]; // es[i]^(2^(2+i)) == 1 int cnt2 = bsf(mint::mod() - 1); mint e = mint(g).pow((mint::mod() - 1) >> cnt2), ie = e.inv(); for (int i = cnt2; i >= 2; i--) { // e^(2^i) == 1 es[i - 2] = e; ies[i - 2] = ie; e *= e; ie *= ie; } mint now = 1; for (int i = 0; i <= cnt2 - 2; i++) { sum_e[i] = es[i] * now; now *= ies[i]; } } for (int ph = 1; ph <= h; ph++) { int w = 1 << (ph - 1), p = 1 << (h - ph); mint now = 1; for (int s = 0; s < w; s++) { int offset = s << (h - ph + 1); for (int i = 0; i < p; i++) { auto l = a[i + offset]; auto r = a[i + offset + p] * now; a[i + offset] = l + r; a[i + offset + p] = l - r; } now *= sum_e[bsf(~(unsigned int)(s))]; } } } template <class mint, internal::is_static_modint_t<mint>* = nullptr> void butterfly_inv(std::vector<mint>& a) { static constexpr int g = internal::primitive_root<mint::mod()>; int n = int(a.size()); int h = internal::ceil_pow2(n); static bool first = true; static mint sum_ie[30]; // sum_ie[i] = es[0] * ... * es[i - 1] * ies[i] if (first) { first = false; mint es[30], ies[30]; // es[i]^(2^(2+i)) == 1 int cnt2 = bsf(mint::mod() - 1); mint e = mint(g).pow((mint::mod() - 1) >> cnt2), ie = e.inv(); for (int i = cnt2; i >= 2; i--) { // e^(2^i) == 1 es[i - 2] = e; ies[i - 2] = ie; e *= e; ie *= ie; } mint now = 1; for (int i = 0; i <= cnt2 - 2; i++) { sum_ie[i] = ies[i] * now; now *= es[i]; } } for (int ph = h; ph >= 1; ph--) { int w = 1 << (ph - 1), p = 1 << (h - ph); mint inow = 1; for (int s = 0; s < w; s++) { int offset = s << (h - ph + 1); for (int i = 0; i < p; i++) { auto l = a[i + offset]; auto r = a[i + offset + p]; a[i + offset] = l + r; a[i + offset + p] = (unsigned long long)(mint::mod() + l.val() - r.val()) * inow.val(); } inow *= sum_ie[bsf(~(unsigned int)(s))]; } } } } // namespace internal template <class mint, internal::is_static_modint_t<mint>* = nullptr> std::vector<mint> convolution(std::vector<mint> a, std::vector<mint> b) { int n = int(a.size()), m = int(b.size()); if (!n || !m) return {}; if (std::min(n, m) <= 60) { if (n < m) { std::swap(n, m); std::swap(a, b); } std::vector<mint> ans(n + m - 1); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { ans[i + j] += a[i] * b[j]; } } return ans; } int z = 1 << internal::ceil_pow2(n + m - 1); a.resize(z); internal::butterfly(a); b.resize(z); internal::butterfly(b); for (int i = 0; i < z; i++) { a[i] *= b[i]; } internal::butterfly_inv(a); a.resize(n + m - 1); mint iz = mint(z).inv(); for (int i = 0; i < n + m - 1; i++) a[i] *= iz; return a; } template <unsigned int mod = 998244353, class T, std::enable_if_t<internal::is_integral<T>::value>* = nullptr> std::vector<T> convolution(const std::vector<T>& a, const std::vector<T>& b) { int n = int(a.size()), m = int(b.size()); if (!n || !m) return {}; using mint = static_modint<mod>; std::vector<mint> a2(n), b2(m); for (int i = 0; i < n; i++) { a2[i] = mint(a[i]); } for (int i = 0; i < m; i++) { b2[i] = mint(b[i]); } auto c2 = convolution(move(a2), move(b2)); std::vector<T> c(n + m - 1); for (int i = 0; i < n + m - 1; i++) { c[i] = c2[i].val(); } return c; } std::vector<long long> convolution_ll(const std::vector<long long>& a, const std::vector<long long>& b) { int n = int(a.size()), m = int(b.size()); if (!n || !m) return {}; static constexpr unsigned long long MOD1 = 754974721; // 2^24 static constexpr unsigned long long MOD2 = 167772161; // 2^25 static constexpr unsigned long long MOD3 = 469762049; // 2^26 static constexpr unsigned long long M2M3 = MOD2 * MOD3; static constexpr unsigned long long M1M3 = MOD1 * MOD3; static constexpr unsigned long long M1M2 = MOD1 * MOD2; static constexpr unsigned long long M1M2M3 = MOD1 * MOD2 * MOD3; static constexpr unsigned long long i1 = internal::inv_gcd(MOD2 * MOD3, MOD1).second; static constexpr unsigned long long i2 = internal::inv_gcd(MOD1 * MOD3, MOD2).second; static constexpr unsigned long long i3 = internal::inv_gcd(MOD1 * MOD2, MOD3).second; auto c1 = convolution<MOD1>(a, b); auto c2 = convolution<MOD2>(a, b); auto c3 = convolution<MOD3>(a, b); std::vector<long long> c(n + m - 1); for (int i = 0; i < n + m - 1; i++) { unsigned long long x = 0; x += (c1[i] * i1) % MOD1 * M2M3; x += (c2[i] * i2) % MOD2 * M1M3; x += (c3[i] * i3) % MOD3 * M1M2; // B = 2^63, -B <= x, r(real value) < B // (x, x - M, x - 2M, or x - 3M) = r (mod 2B) // r = c1[i] (mod MOD1) // focus on MOD1 // r = x, x - M', x - 2M', x - 3M' (M' = M % 2^64) (mod 2B) // r = x, // x - M' + (0 or 2B), // x - 2M' + (0, 2B or 4B), // x - 3M' + (0, 2B, 4B or 6B) (without mod!) // (r - x) = 0, (0) // - M' + (0 or 2B), (1) // -2M' + (0 or 2B or 4B), (2) // -3M' + (0 or 2B or 4B or 6B) (3) (mod MOD1) // we checked that // ((1) mod MOD1) mod 5 = 2 // ((2) mod MOD1) mod 5 = 3 // ((3) mod MOD1) mod 5 = 4 long long diff = c1[i] - internal::safe_mod((long long)(x), (long long)(MOD1)); if (diff < 0) diff += MOD1; static constexpr unsigned long long offset[5] = { 0, 0, M1M2M3, 2 * M1M2M3, 3 * M1M2M3}; x -= offset[diff % 5]; c[i] = x; } return c; } } // namespace atcoder #include <algorithm> #include <cassert> #include <vector> namespace atcoder { // Implement (union by size) + (path compression) // Reference: // Zvi Galil and Giuseppe F. Italiano, // Data structures and algorithms for disjoint set union problems struct dsu { public: dsu() : _n(0) {} dsu(int n) : _n(n), parent_or_size(n, -1) {} int merge(int a, int b) { assert(0 <= a && a < _n); assert(0 <= b && b < _n); int x = leader(a), y = leader(b); if (x == y) return x; if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y); parent_or_size[x] += parent_or_size[y]; parent_or_size[y] = x; return x; } bool same(int a, int b) { assert(0 <= a && a < _n); assert(0 <= b && b < _n); return leader(a) == leader(b); } int leader(int a) { assert(0 <= a && a < _n); if (parent_or_size[a] < 0) return a; return parent_or_size[a] = leader(parent_or_size[a]); } int size(int a) { assert(0 <= a && a < _n); return -parent_or_size[leader(a)]; } std::vector<std::vector<int>> groups() { std::vector<int> leader_buf(_n), group_size(_n); for (int i = 0; i < _n; i++) { leader_buf[i] = leader(i); group_size[leader_buf[i]]++; } std::vector<std::vector<int>> result(_n); for (int i = 0; i < _n; i++) { result[i].reserve(group_size[i]); } for (int i = 0; i < _n; i++) { result[leader_buf[i]].push_back(i); } result.erase( std::remove_if(result.begin(), result.end(), [&](const std::vector<int>& v) { return v.empty(); }), result.end()); return result; } private: int _n; // root node: -1 * component size // otherwise: parent std::vector<int> parent_or_size; }; } // namespace atcoder #include <cassert> #include <vector> namespace atcoder { // Reference: https://en.wikipedia.org/wiki/Fenwick_tree template <class T> struct fenwick_tree { using U = internal::to_unsigned_t<T>; public: fenwick_tree() : _n(0) {} fenwick_tree(int n) : _n(n), data(n) {} void add(int p, T x) { assert(0 <= p && p < _n); p++; while (p <= _n) { data[p - 1] += U(x); p += p & -p; } } T sum(int l, int r) { assert(0 <= l && l <= r && r <= _n); return sum(r) - sum(l); } private: int _n; std::vector<U> data; U sum(int r) { U s = 0; while (r > 0) { s += data[r - 1]; r -= r & -r; } return s; } }; } // namespace atcoder #include <algorithm> #include <cassert> #include <iostream> #include <vector> namespace atcoder { template <class S, S (*op)(S, S), S (*e)(), class F, S (*mapping)(F, S), F (*composition)(F, F), F (*id)()> struct lazy_segtree { public: lazy_segtree() : lazy_segtree(0) {} lazy_segtree(int n) : lazy_segtree(std::vector<S>(n, e())) {} lazy_segtree(const std::vector<S>& v) : _n(int(v.size())) { log = internal::ceil_pow2(_n); size = 1 << log; d = std::vector<S>(2 * size, e()); lz = std::vector<F>(size, id()); for (int i = 0; i < _n; i++) d[size + i] = v[i]; for (int i = size - 1; i >= 1; i--) { update(i); } } void set(int p, S x) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); d[p] = x; for (int i = 1; i <= log; i++) update(p >> i); } S get(int p) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); return d[p]; } S prod(int l, int r) { assert(0 <= l && l <= r && r <= _n); if (l == r) return e(); l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push(r >> i); } S sml = e(), smr = e(); while (l < r) { if (l & 1) sml = op(sml, d[l++]); if (r & 1) smr = op(d[--r], smr); l >>= 1; r >>= 1; } return op(sml, smr); } S all_prod() { return d[1]; } void apply(int p, F f) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); d[p] = mapping(f, d[p]); for (int i = 1; i <= log; i++) update(p >> i); } void apply(int l, int r, F f) { assert(0 <= l && l <= r && r <= _n); if (l == r) return; l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push((r - 1) >> i); } { int l2 = l, r2 = r; while (l < r) { if (l & 1) all_apply(l++, f); if (r & 1) all_apply(--r, f); l >>= 1; r >>= 1; } l = l2; r = r2; } for (int i = 1; i <= log; i++) { if (((l >> i) << i) != l) update(l >> i); if (((r >> i) << i) != r) update((r - 1) >> i); } } template <bool (*g)(S)> int max_right(int l) { return max_right(l, [](S x) { return g(x); }); } template <class G> int max_right(int l, G g) { assert(0 <= l && l <= _n); assert(g(e())); if (l == _n) return _n; l += size; for (int i = log; i >= 1; i--) push(l >> i); S sm = e(); do { while (l % 2 == 0) l >>= 1; if (!g(op(sm, d[l]))) { while (l < size) { push(l); l = (2 * l); if (g(op(sm, d[l]))) { sm = op(sm, d[l]); l++; } } return l - size; } sm = op(sm, d[l]); l++; } while ((l & -l) != l); return _n; } template <bool (*g)(S)> int min_left(int r) { return min_left(r, [](S x) { return g(x); }); } template <class G> int min_left(int r, G g) { assert(0 <= r && r <= _n); assert(g(e())); if (r == 0) return 0; r += size; for (int i = log; i >= 1; i--) push((r - 1) >> i); S sm = e(); do { r--; while (r > 1 && (r % 2)) r >>= 1; if (!g(op(d[r], sm))) { while (r < size) { push(r); r = (2 * r + 1); if (g(op(d[r], sm))) { sm = op(d[r], sm); r--; } } return r + 1 - size; } sm = op(d[r], sm); } while ((r & -r) != r); return 0; } private: int _n, size, log; std::vector<S> d; std::vector<F> lz; void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); } void all_apply(int k, F f) { d[k] = mapping(f, d[k]); if (k < size) lz[k] = composition(f, lz[k]); } void push(int k) { all_apply(2 * k, lz[k]); all_apply(2 * k + 1, lz[k]); lz[k] = id(); } }; } // namespace atcoder #include <algorithm> #include <cassert> #include <tuple> #include <vector> namespace atcoder { long long pow_mod(long long x, long long n, int m) { assert(0 <= n && 1 <= m); if (m == 1) return 0; internal::barrett bt((unsigned int)(m)); unsigned int r = 1, y = (unsigned int)(internal::safe_mod(x, m)); while (n) { if (n & 1) r = bt.mul(r, y); y = bt.mul(y, y); n >>= 1; } return r; } long long inv_mod(long long x, long long m) { assert(1 <= m); auto z = internal::inv_gcd(x, m); assert(z.first == 1); return z.second; } // (rem, mod) std::pair<long long, long long> crt(const std::vector<long long>& r, const std::vector<long long>& m) { assert(r.size() == m.size()); int n = int(r.size()); // Contracts: 0 <= r0 < m0 long long r0 = 0, m0 = 1; for (int i = 0; i < n; i++) { assert(1 <= m[i]); long long r1 = internal::safe_mod(r[i], m[i]), m1 = m[i]; if (m0 < m1) { std::swap(r0, r1); std::swap(m0, m1); } if (m0 % m1 == 0) { if (r0 % m1 != r1) return {0, 0}; continue; } // assume: m0 > m1, lcm(m0, m1) >= 2 * max(m0, m1) // (r0, m0), (r1, m1) -> (r2, m2 = lcm(m0, m1)); // r2 % m0 = r0 // r2 % m1 = r1 // -> (r0 + x*m0) % m1 = r1 // -> x*u0*g % (u1*g) = (r1 - r0) (u0*g = m0, u1*g = m1) // -> x = (r1 - r0) / g * inv(u0) (mod u1) // im = inv(u0) (mod u1) (0 <= im < u1) long long g, im; std::tie(g, im) = internal::inv_gcd(m0, m1); long long u1 = (m1 / g); // |r1 - r0| < (m0 + m1) <= lcm(m0, m1) if ((r1 - r0) % g) return {0, 0}; // u1 * u1 <= m1 * m1 / g / g <= m0 * m1 / g = lcm(m0, m1) long long x = (r1 - r0) / g % u1 * im % u1; // |r0| + |m0 * x| // < m0 + m0 * (u1 - 1) // = m0 + m0 * m1 / g - m0 // = lcm(m0, m1) r0 += x * m0; m0 *= u1; // -> lcm(m0, m1) if (r0 < 0) r0 += m0; } return {r0, m0}; } long long floor_sum(long long n, long long m, long long a, long long b) { long long ans = 0; if (a >= m) { ans += (n - 1) * n * (a / m) / 2; a %= m; } if (b >= m) { ans += n * (b / m); b %= m; } long long y_max = (a * n + b) / m, x_max = (y_max * m - b); if (y_max == 0) return ans; ans += (n - (x_max + a - 1) / a) * y_max; ans += floor_sum(y_max, a, m, (a - x_max % a) % a); return ans; } } // namespace atcoder #include <algorithm> #include <vector> namespace atcoder { namespace internal { template <class T> struct simple_queue { std::vector<T> payload; int pos = 0; void reserve(int n) { payload.reserve(n); } int size() const { return int(payload.size()) - pos; } bool empty() const { return pos == int(payload.size()); } void push(const T& t) { payload.push_back(t); } T& front() { return payload[pos]; } void clear() { payload.clear(); pos = 0; } void pop() { pos++; } }; } // namespace internal } // namespace atcoder #include <cassert> #include <limits> #include <queue> #include <vector> namespace atcoder { template <class Cap> struct mf_graph { public: mf_graph() : _n(0) {} mf_graph(int n) : _n(n), g(n) {} int add_edge(int from, int to, Cap cap) { assert(0 <= from && from < _n); assert(0 <= to && to < _n); assert(0 <= cap); int m = int(pos.size()); pos.push_back({from, int(g[from].size())}); int from_id = int(g[from].size()); int to_id = int(g[to].size()); if (from == to) to_id++; g[from].push_back(_edge{to, to_id, cap}); g[to].push_back(_edge{from, from_id, 0}); return m; } struct edge { int from, to; Cap cap, flow; }; edge get_edge(int i) { int m = int(pos.size()); assert(0 <= i && i < m); auto _e = g[pos[i].first][pos[i].second]; auto _re = g[_e.to][_e.rev]; return edge{pos[i].first, _e.to, _e.cap + _re.cap, _re.cap}; } std::vector<edge> edges() { int m = int(pos.size()); std::vector<edge> result; for (int i = 0; i < m; i++) { result.push_back(get_edge(i)); } return result; } void change_edge(int i, Cap new_cap, Cap new_flow) { int m = int(pos.size()); assert(0 <= i && i < m); assert(0 <= new_flow && new_flow <= new_cap); auto& _e = g[pos[i].first][pos[i].second]; auto& _re = g[_e.to][_e.rev]; _e.cap = new_cap - new_flow; _re.cap = new_flow; } Cap flow(int s, int t) { return flow(s, t, std::numeric_limits<Cap>::max()); } Cap flow(int s, int t, Cap flow_limit) { assert(0 <= s && s < _n); assert(0 <= t && t < _n); assert(s != t); std::vector<int> level(_n), iter(_n); internal::simple_queue<int> que; auto bfs = [&]() { std::fill(level.begin(), level.end(), -1); level[s] = 0; que.clear(); que.push(s); while (!que.empty()) { int v = que.front(); que.pop(); for (auto e : g[v]) { if (e.cap == 0 || level[e.to] >= 0) continue; level[e.to] = level[v] + 1; if (e.to == t) return; que.push(e.to); } } }; auto dfs = [&](auto self, int v, Cap up) { if (v == s) return up; Cap res = 0; int level_v = level[v]; for (int& i = iter[v]; i < int(g[v].size()); i++) { _edge& e = g[v][i]; if (level_v <= level[e.to] || g[e.to][e.rev].cap == 0) continue; Cap d = self(self, e.to, std::min(up - res, g[e.to][e.rev].cap)); if (d <= 0) continue; g[v][i].cap += d; g[e.to][e.rev].cap -= d; res += d; if (res == up) break; } return res; }; Cap flow = 0; while (flow < flow_limit) { bfs(); if (level[t] == -1) break; std::fill(iter.begin(), iter.end(), 0); while (flow < flow_limit) { Cap f = dfs(dfs, t, flow_limit - flow); if (!f) break; flow += f; } } return flow; } std::vector<bool> min_cut(int s) { std::vector<bool> visited(_n); internal::simple_queue<int> que; que.push(s); while (!que.empty()) { int p = que.front(); que.pop(); visited[p] = true; for (auto e : g[p]) { if (e.cap && !visited[e.to]) { visited[e.to] = true; que.push(e.to); } } } return visited; } private: int _n; struct _edge { int to, rev; Cap cap; }; std::vector<std::pair<int, int>> pos; std::vector<std::vector<_edge>> g; }; } // namespace atcoder #include <algorithm> #include <cassert> #include <limits> #include <queue> #include <vector> namespace atcoder { template <class Cap, class Cost> struct mcf_graph { public: mcf_graph() {} mcf_graph(int n) : _n(n), g(n) {} int add_edge(int from, int to, Cap cap, Cost cost) { assert(0 <= from && from < _n); assert(0 <= to && to < _n); int m = int(pos.size()); pos.push_back({from, int(g[from].size())}); int from_id = int(g[from].size()); int to_id = int(g[to].size()); if (from == to) to_id++; g[from].push_back(_edge{to, to_id, cap, cost}); g[to].push_back(_edge{from, from_id, 0, -cost}); return m; } struct edge { int from, to; Cap cap, flow; Cost cost; }; edge get_edge(int i) { int m = int(pos.size()); assert(0 <= i && i < m); auto _e = g[pos[i].first][pos[i].second]; auto _re = g[_e.to][_e.rev]; return edge{ pos[i].first, _e.to, _e.cap + _re.cap, _re.cap, _e.cost, }; } std::vector<edge> edges() { int m = int(pos.size()); std::vector<edge> result(m); for (int i = 0; i < m; i++) { result[i] = get_edge(i); } return result; } std::pair<Cap, Cost> flow(int s, int t) { return flow(s, t, std::numeric_limits<Cap>::max()); } std::pair<Cap, Cost> flow(int s, int t, Cap flow_limit) { return slope(s, t, flow_limit).back(); } std::vector<std::pair<Cap, Cost>> slope(int s, int t) { return slope(s, t, std::numeric_limits<Cap>::max()); } std::vector<std::pair<Cap, Cost>> slope(int s, int t, Cap flow_limit) { assert(0 <= s && s < _n); assert(0 <= t && t < _n); assert(s != t); // variants (C = maxcost): // -(n-1)C <= dual[s] <= dual[i] <= dual[t] = 0 // reduced cost (= e.cost + dual[e.from] - dual[e.to]) >= 0 for all edge std::vector<Cost> dual(_n, 0), dist(_n); std::vector<int> pv(_n), pe(_n); std::vector<bool> vis(_n); auto dual_ref = [&]() { std::fill(dist.begin(), dist.end(), std::numeric_limits<Cost>::max()); std::fill(pv.begin(), pv.end(), -1); std::fill(pe.begin(), pe.end(), -1); std::fill(vis.begin(), vis.end(), false); struct Q { Cost key; int to; bool operator<(Q r) const { return key > r.key; } }; std::priority_queue<Q> que; dist[s] = 0; que.push(Q{0, s}); while (!que.empty()) { int v = que.top().to; que.pop(); if (vis[v]) continue; vis[v] = true; if (v == t) break; // dist[v] = shortest(s, v) + dual[s] - dual[v] // dist[v] >= 0 (all reduced cost are positive) // dist[v] <= (n-1)C for (int i = 0; i < int(g[v].size()); i++) { auto e = g[v][i]; if (vis[e.to] || !e.cap) continue; // |-dual[e.to] + dual[v]| <= (n-1)C // cost <= C - -(n-1)C + 0 = nC Cost cost = e.cost - dual[e.to] + dual[v]; if (dist[e.to] - dist[v] > cost) { dist[e.to] = dist[v] + cost; pv[e.to] = v; pe[e.to] = i; que.push(Q{dist[e.to], e.to}); } } } if (!vis[t]) { return false; } for (int v = 0; v < _n; v++) { if (!vis[v]) continue; // dual[v] = dual[v] - dist[t] + dist[v] // = dual[v] - (shortest(s, t) + dual[s] - dual[t]) + (shortest(s, v) + dual[s] - dual[v]) // = - shortest(s, t) + dual[t] + shortest(s, v) // = shortest(s, v) - shortest(s, t) >= 0 - (n-1)C dual[v] -= dist[t] - dist[v]; } return true; }; Cap flow = 0; Cost cost = 0, prev_cost_per_flow = -1; std::vector<std::pair<Cap, Cost>> result; result.push_back({flow, cost}); while (flow < flow_limit) { if (!dual_ref()) break; Cap c = flow_limit - flow; for (int v = t; v != s; v = pv[v]) { c = std::min(c, g[pv[v]][pe[v]].cap); } for (int v = t; v != s; v = pv[v]) { auto& e = g[pv[v]][pe[v]]; e.cap -= c; g[v][e.rev].cap += c; } Cost d = -dual[s]; flow += c; cost += c * d; if (prev_cost_per_flow == d) { result.pop_back(); } result.push_back({flow, cost}); prev_cost_per_flow = d; } return result; } private: int _n; struct _edge { int to, rev; Cap cap; Cost cost; }; std::vector<std::pair<int, int>> pos; std::vector<std::vector<_edge>> g; }; } // namespace atcoder #include <algorithm> #include <algorithm> #include <utility> #include <vector> namespace atcoder { namespace internal { template <class E> struct csr { std::vector<int> start; std::vector<E> elist; csr(int n, const std::vector<std::pair<int, E>>& edges) : start(n + 1), elist(edges.size()) { for (auto e : edges) { start[e.first + 1]++; } for (int i = 1; i <= n; i++) { start[i] += start[i - 1]; } auto counter = start; for (auto e : edges) { elist[counter[e.first]++] = e.second; } } }; // Reference: // R. Tarjan, // Depth-First Search and Linear Graph Algorithms struct scc_graph { public: scc_graph(int n) : _n(n) {} int num_vertices() { return _n; } void add_edge(int from, int to) { edges.push_back({from, {to}}); } // @return pair of (# of scc, scc id) std::pair<int, std::vector<int>> scc_ids() { auto g = csr<edge>(_n, edges); int now_ord = 0, group_num = 0; std::vector<int> visited, low(_n), ord(_n, -1), ids(_n); visited.reserve(_n); auto dfs = [&](auto self, int v) -> void { low[v] = ord[v] = now_ord++; visited.push_back(v); for (int i = g.start[v]; i < g.start[v + 1]; i++) { auto to = g.elist[i].to; if (ord[to] == -1) { self(self, to); low[v] = std::min(low[v], low[to]); } else { low[v] = std::min(low[v], ord[to]); } } if (low[v] == ord[v]) { while (true) { int u = visited.back(); visited.pop_back(); ord[u] = _n; ids[u] = group_num; if (u == v) break; } group_num++; } }; for (int i = 0; i < _n; i++) { if (ord[i] == -1) dfs(dfs, i); } for (auto& x : ids) { x = group_num - 1 - x; } return {group_num, ids}; } std::vector<std::vector<int>> scc() { auto ids = scc_ids(); int group_num = ids.first; std::vector<int> counts(group_num); for (auto x : ids.second) counts[x]++; std::vector<std::vector<int>> groups(ids.first); for (int i = 0; i < group_num; i++) { groups[i].reserve(counts[i]); } for (int i = 0; i < _n; i++) { groups[ids.second[i]].push_back(i); } return groups; } private: int _n; struct edge { int to; }; std::vector<std::pair<int, edge>> edges; }; } // namespace internal } // namespace atcoder #include <cassert> #include <vector> namespace atcoder { struct scc_graph { public: scc_graph() : internal(0) {} scc_graph(int n) : internal(n) {} void add_edge(int from, int to) { int n = internal.num_vertices(); assert(0 <= from && from < n); assert(0 <= to && to < n); internal.add_edge(from, to); } std::vector<std::vector<int>> scc() { return internal.scc(); } private: internal::scc_graph internal; }; } // namespace atcoder #include <algorithm> #include <cassert> #include <vector> namespace atcoder { template <class S, S (*op)(S, S), S (*e)()> struct segtree { public: segtree() : segtree(0) {} segtree(int n) : segtree(std::vector<S>(n, e())) {} segtree(const std::vector<S>& v) : _n(int(v.size())) { log = internal::ceil_pow2(_n); size = 1 << log; d = std::vector<S>(2 * size, e()); for (int i = 0; i < _n; i++) d[size + i] = v[i]; for (int i = size - 1; i >= 1; i--) { update(i); } } void set(int p, S x) { assert(0 <= p && p < _n); p += size; d[p] = x; for (int i = 1; i <= log; i++) update(p >> i); } S get(int p) { assert(0 <= p && p < _n); return d[p + size]; } S prod(int l, int r) { assert(0 <= l && l <= r && r <= _n); S sml = e(), smr = e(); l += size; r += size; while (l < r) { if (l & 1) sml = op(sml, d[l++]); if (r & 1) smr = op(d[--r], smr); l >>= 1; r >>= 1; } return op(sml, smr); } S all_prod() { return d[1]; } template <bool (*f)(S)> int max_right(int l) { return max_right(l, [](S x) { return f(x); }); } template <class F> int max_right(int l, F f) { assert(0 <= l && l <= _n); assert(f(e())); if (l == _n) return _n; l += size; S sm = e(); do { while (l % 2 == 0) l >>= 1; if (!f(op(sm, d[l]))) { while (l < size) { l = (2 * l); if (f(op(sm, d[l]))) { sm = op(sm, d[l]); l++; } } return l - size; } sm = op(sm, d[l]); l++; } while ((l & -l) != l); return _n; } template <bool (*f)(S)> int min_left(int r) { return min_left(r, [](S x) { return f(x); }); } template <class F> int min_left(int r, F f) { assert(0 <= r && r <= _n); assert(f(e())); if (r == 0) return 0; r += size; S sm = e(); do { r--; while (r > 1 && (r % 2)) r >>= 1; if (!f(op(d[r], sm))) { while (r < size) { r = (2 * r + 1); if (f(op(d[r], sm))) { sm = op(d[r], sm); r--; } } return r + 1 - size; } sm = op(d[r], sm); } while ((r & -r) != r); return 0; } private: int _n, size, log; std::vector<S> d; void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); } }; } // namespace atcoder #include <algorithm> #include <cassert> #include <numeric> #include <string> #include <vector> namespace atcoder { namespace internal { std::vector<int> sa_naive(const std::vector<int>& s) { int n = int(s.size()); std::vector<int> sa(n); std::iota(sa.begin(), sa.end(), 0); std::sort(sa.begin(), sa.end(), [&](int l, int r) { if (l == r) return false; while (l < n && r < n) { if (s[l] != s[r]) return s[l] < s[r]; l++; r++; } return l == n; }); return sa; } std::vector<int> sa_doubling(const std::vector<int>& s) { int n = int(s.size()); std::vector<int> sa(n), rnk = s, tmp(n); std::iota(sa.begin(), sa.end(), 0); for (int k = 1; k < n; k *= 2) { auto cmp = [&](int x, int y) { if (rnk[x] != rnk[y]) return rnk[x] < rnk[y]; int rx = x + k < n ? rnk[x + k] : -1; int ry = y + k < n ? rnk[y + k] : -1; return rx < ry; }; std::sort(sa.begin(), sa.end(), cmp); tmp[sa[0]] = 0; for (int i = 1; i < n; i++) { tmp[sa[i]] = tmp[sa[i - 1]] + (cmp(sa[i - 1], sa[i]) ? 1 : 0); } std::swap(tmp, rnk); } return sa; } // SA-IS, linear-time suffix array construction // Reference: // G. Nong, S. Zhang, and W. H. Chan, // Two Efficient Algorithms for Linear Time Suffix Array Construction template <int THRESHOLD_NAIVE = 10, int THRESHOLD_DOUBLING = 40> std::vector<int> sa_is(const std::vector<int>& s, int upper) { int n = int(s.size()); if (n == 0) return {}; if (n == 1) return {0}; if (n == 2) { if (s[0] < s[1]) { return {0, 1}; } else { return {1, 0}; } } if (n < THRESHOLD_NAIVE) { return sa_naive(s); } if (n < THRESHOLD_DOUBLING) { return sa_doubling(s); } std::vector<int> sa(n); std::vector<bool> ls(n); for (int i = n - 2; i >= 0; i--) { ls[i] = (s[i] == s[i + 1]) ? ls[i + 1] : (s[i] < s[i + 1]); } std::vector<int> sum_l(upper + 1), sum_s(upper + 1); for (int i = 0; i < n; i++) { if (!ls[i]) { sum_s[s[i]]++; } else { sum_l[s[i] + 1]++; } } for (int i = 0; i <= upper; i++) { sum_s[i] += sum_l[i]; if (i < upper) sum_l[i + 1] += sum_s[i]; } auto induce = [&](const std::vector<int>& lms) { std::fill(sa.begin(), sa.end(), -1); std::vector<int> buf(upper + 1); std::copy(sum_s.begin(), sum_s.end(), buf.begin()); for (auto d : lms) { if (d == n) continue; sa[buf[s[d]]++] = d; } std::copy(sum_l.begin(), sum_l.end(), buf.begin()); sa[buf[s[n - 1]]++] = n - 1; for (int i = 0; i < n; i++) { int v = sa[i]; if (v >= 1 && !ls[v - 1]) { sa[buf[s[v - 1]]++] = v - 1; } } std::copy(sum_l.begin(), sum_l.end(), buf.begin()); for (int i = n - 1; i >= 0; i--) { int v = sa[i]; if (v >= 1 && ls[v - 1]) { sa[--buf[s[v - 1] + 1]] = v - 1; } } }; std::vector<int> lms_map(n + 1, -1); int m = 0; for (int i = 1; i < n; i++) { if (!ls[i - 1] && ls[i]) { lms_map[i] = m++; } } std::vector<int> lms; lms.reserve(m); for (int i = 1; i < n; i++) { if (!ls[i - 1] && ls[i]) { lms.push_back(i); } } induce(lms); if (m) { std::vector<int> sorted_lms; sorted_lms.reserve(m); for (int v : sa) { if (lms_map[v] != -1) sorted_lms.push_back(v); } std::vector<int> rec_s(m); int rec_upper = 0; rec_s[lms_map[sorted_lms[0]]] = 0; for (int i = 1; i < m; i++) { int l = sorted_lms[i - 1], r = sorted_lms[i]; int end_l = (lms_map[l] + 1 < m) ? lms[lms_map[l] + 1] : n; int end_r = (lms_map[r] + 1 < m) ? lms[lms_map[r] + 1] : n; bool same = true; if (end_l - l != end_r - r) { same = false; } else { while (l < end_l) { if (s[l] != s[r]) { break; } l++; r++; } if (l == n || s[l] != s[r]) same = false; } if (!same) rec_upper++; rec_s[lms_map[sorted_lms[i]]] = rec_upper; } auto rec_sa = sa_is<THRESHOLD_NAIVE, THRESHOLD_DOUBLING>(rec_s, rec_upper); for (int i = 0; i < m; i++) { sorted_lms[i] = lms[rec_sa[i]]; } induce(sorted_lms); } return sa; } } // namespace internal std::vector<int> suffix_array(const std::vector<int>& s, int upper) { assert(0 <= upper); for (int d : s) { assert(0 <= d && d <= upper); } auto sa = internal::sa_is(s, upper); return sa; } template <class T> std::vector<int> suffix_array(const std::vector<T>& s) { int n = int(s.size()); std::vector<int> idx(n); iota(idx.begin(), idx.end(), 0); sort(idx.begin(), idx.end(), [&](int l, int r) { return s[l] < s[r]; }); std::vector<int> s2(n); int now = 0; for (int i = 0; i < n; i++) { if (i && s[idx[i - 1]] != s[idx[i]]) now++; s2[idx[i]] = now; } return internal::sa_is(s2, now); } std::vector<int> suffix_array(const std::string& s) { int n = int(s.size()); std::vector<int> s2(n); for (int i = 0; i < n; i++) { s2[i] = s[i]; } return internal::sa_is(s2, 255); } // Reference: // T. Kasai, G. Lee, H. Arimura, S. Arikawa, and K. Park, // Linear-Time Longest-Common-Prefix Computation in Suffix Arrays and Its // Applications template <class T> std::vector<int> lcp_array(const std::vector<T>& s, const std::vector<int>& sa) { int n = int(s.size()); assert(n >= 1); std::vector<int> rnk(n); for (int i = 0; i < n; i++) { rnk[sa[i]] = i; } std::vector<int> lcp(n - 1); int h = 0; for (int i = 0; i < n; i++) { if (h > 0) h--; if (rnk[i] == 0) continue; int j = sa[rnk[i] - 1]; for (; j + h < n && i + h < n; h++) { if (s[j + h] != s[i + h]) break; } lcp[rnk[i] - 1] = h; } return lcp; } std::vector<int> lcp_array(const std::string& s, const std::vector<int>& sa) { int n = int(s.size()); std::vector<int> s2(n); for (int i = 0; i < n; i++) { s2[i] = s[i]; } return lcp_array(s2, sa); } // Reference: // D. Gusfield, // Algorithms on Strings, Trees, and Sequences: Computer Science and // Computational Biology template <class T> std::vector<int> z_algorithm(const std::vector<T>& s) { int n = int(s.size()); if (n == 0) return {}; std::vector<int> z(n); z[0] = 0; for (int i = 1, j = 0; i < n; i++) { int& k = z[i]; k = (j + z[j] <= i) ? 0 : std::min(j + z[j] - i, z[i - j]); while (i + k < n && s[k] == s[i + k]) k++; if (j + z[j] < i + z[i]) j = i; } z[0] = n; return z; } std::vector<int> z_algorithm(const std::string& s) { int n = int(s.size()); std::vector<int> s2(n); for (int i = 0; i < n; i++) { s2[i] = s[i]; } return z_algorithm(s2); } } // namespace atcoder #include <cassert> #include <vector> namespace atcoder { // Reference: // B. Aspvall, M. Plass, and R. Tarjan, // A Linear-Time Algorithm for Testing the Truth of Certain Quantified Boolean // Formulas struct two_sat { public: two_sat() : _n(0), scc(0) {} two_sat(int n) : _n(n), _answer(n), scc(2 * n) {} void add_clause(int i, bool f, int j, bool g) { assert(0 <= i && i < _n); assert(0 <= j && j < _n); scc.add_edge(2 * i + (f ? 0 : 1), 2 * j + (g ? 1 : 0)); scc.add_edge(2 * j + (g ? 0 : 1), 2 * i + (f ? 1 : 0)); } bool satisfiable() { auto id = scc.scc_ids().second; for (int i = 0; i < _n; i++) { if (id[2 * i] == id[2 * i + 1]) return false; _answer[i] = id[2 * i] < id[2 * i + 1]; } return true; } std::vector<bool> answer() { return _answer; } private: int _n; std::vector<bool> _answer; internal::scc_graph scc; }; } // namespace atcoder using namespace std; using namespace atcoder; typedef long long ll; /* #define i_7 (ll)(1E9+7) //#define i_7 998244353 #define i_5 i_7-2 ll mod(ll a){ ll c=a%i_7; if(c>=0)return c; return c+i_7; } void Add(ll &pos,ll val){pos=mod(pos+val);} void mod_print(ll k){ ll P=50000; rep(y,1,P){ ll x=mod(y*k); if(abs(x)<=P||x+P>=i_7){ if(x+P>=i_7){ x-=i_7; } cout<<x<<"/"<<y<<endl; //cout<<setprecision(5)<<(dd)x/(dd)y; return; } } cout<<"nun"<<endl; } */ /* #include "boost/multiprecision/cpp_int.hpp" #include "boost/multiprecision/cpp_dec_float.hpp" namespace mp = boost::multiprecision; typedef mp::cpp_int LL; typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする) */ typedef long double dd; typedef pair<ll,ll> l_l; typedef pair<dd,dd> d_d; ll inf=(ll)1E16; #define rep(i,l,r) for(ll i=l;i<=r;i++) #define rrep(i,r,l) for(ll i=r;i>=l;i--) #define pb push_back ll max(ll a,ll b){if(a<b)return b;else return a;} ll min(ll a,ll b){if(a>b)return b;else return a;} void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]); void Min(ll &pos,ll val){pos=min(pos,val);} dd EPS=1E-12; #define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define fi first #define se second #define SORT(v) sort(v.begin(),v.end()) #define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end()) #define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin()) #define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin()) template<class T,class S> inline bool chmax(T &a, S b) { if(a < b) { a = b; return true; } return false; } template<class T,class S> inline bool chmin(T &a, S b) { if(a > b) { a = b; return true; } return false; } #define endl "\n" //インタラクティブで消す!!!!!!!!!!!!!!!!!!!!! #define all(c) c.begin(),c.end() //using mint = modint998244353; using mint = modint1000000007; //using mint=modint; //using mint=static_modint<100>; typedef vector<ll> vl; typedef vector<mint>vi; dd PI=acos((dd)-1); ////////////////////////// ///////////////////////////////////////////////////////////////// typedef pair<double,int> i_d; #define MAX_V 1005//調節!!!!!!!!!!!!!!!!!!!!!!!! struct edge{int to;double cost;}; double d[MAX_V];//頂点sからの最短距離 int V;//頂点数!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! vector<edge>G[MAX_V]; void dijkstra(int s){ priority_queue<i_d,vector<i_d>,greater<i_d>> que;//firstは最短距離、secondは頂点の番号 fill(d,d+V+1,inf);//頂点番号は0~V-1でも1~Vでもお好きな方で d[s]=0; que.push(i_d(0,s)); while(!que.empty()){ //greater<i_i>なのでfirstが小さい順に取り出せる! i_d p=que.top();que.pop(); int 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(i_i(d[e.to],e.to)); } } } } //////////////////////////////////////// double dis(double x1,double y1,double x2,double y2){ return sqrt((double)pow(x1-x2,2)+double(pow(y1-y2,2))); } int main(){ int xs,ys,xt,yt;cin>>xs>>ys>>xt>>yt; int n;cin>>n; V=n+2; ll point[n+2][3]; rep(i,1,n){ rep(j,0,2){ cin>>point[i][j]; } } point[0][0]=xs;point[0][1]=ys;point[0][2]=0; point[n+1][0]=xt;point[n+1][1]=yt;point[n+1][2]=0; rep(i,0,n+1){ rep(j,i+1,n+1){ double distance=dis(point[i][0],point[i][1],point[j][0],point[j][1]); distance-=point[i][2]+point[j][2]; distance=max(distance,0.0); edge e; e.to=j;e.cost=distance; G[i].pb(e); e.to=i; G[j].pb(e); } } dijkstra(0); /* rep(i,0,n+1){ cout<<i<<" "<<d[i]<<endl; }*/ printf("%10.10lf\n",d[n+1]); return 0; }
a.cc: In function 'void dijkstra(int)': a.cc:2191:26: error: 'i_i' was not declared in this scope; did you mean 'i_d'? 2191 | que.push(i_i(d[e.to],e.to)); | ^~~ | i_d
s511641497
p03866
C++
#include <bits/stdc++.h> using namespace std; #define f0r(a, b) for (long long a = 0; a < b; a++) #define f1r(a, b, c) for (long long a = b; a < c; a++) #define f0rd(a, b) for (long long a = b; a >= 0; a--) #define f1rd(a, b, c) for (long long a = b; a >= c; a--) #define ms(arr, v) memset(arr, v, sizeof(arr)) #define mp(a, b) make_pair(a, b) #define pb push_back #define f first #define s second #define ao(a, n) {for (int ele = 0; ele < n; ele++) { if (ele) cout << " "; cout << a[ele]; } cout << endl;} typedef long long ll; typedef double ld; typedef long double lld; 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<pii> vpi; typedef vector<pll> vpl; const ll inf = 1e12; const ll mod = 1e9 + 7; double graph[1005][1005]; int main() { ios_base::sync_with_stdio(false); ll xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt; ll n; cin >> n; pair<ll, pair<ll, ll> > pos[n + 2]; pos[0] = mp(0, mp(xs, ys)); for (int i = 0; i < n; i++) { ll x, y, r; cin >> x >> y >> r; pos[i + 1] = mp(r, mp(x, y)); } pos[n + 1] = mp(0, mp(xt, yt)); for (int i = 0; i <= n + 1; i++) { for (int j = i+1; j <= n + 1; j++) { graph[i][j] = max((sqrt((pos[i].s.f - pos[j].s.f) * (pos[i].s.f - pos[j].s.f) + (pos[i].s.s - pos[j].s.s) * (pos[i].s.s - pos[j].s.s)) - pos[i].f - pos[j].f), 0.0); graph[j][i] = graph[i][j]; //cout << graph[i][j] << endl; } } //do dijkstras bool mark[n+1]; double dists[n+1]; dists[0] = 0; mark[0] = 0; for (int i = 1; i <= n + 1; i++) { dists[i] = 1e18; mark[i] = 0; } priority_queue<pair<double, ll>, vector<pair<double, int> >, greater<pair<double, ll> > > pq; pq.push(mp(dists[0], 0)); while (!pq.empty()) { ll u = pq.top().s; // cout << u << endl; pq.pop(); if (mark[u]) continue; mark[u] = true; for (int i = 0; i <= n + 1; i++) { if (i == u) continue; if (dists[i] > dists[u] + graph[i][u]) { dists[i] = dists[u] + graph[i][u]; pq.push(mp(dists[i], i)); } } } std::cout << std::setprecision(10) << endl; cout << fixed; cout << dists[n + 1] << endl; }
In file included from /usr/include/c++/14/queue:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157, from a.cc:1: /usr/include/c++/14/bits/stl_queue.h: In instantiation of 'class std::priority_queue<std::pair<double, long long int>, std::vector<std::pair<double, int> >, std::greater<std::pair<double, long long int> > >': a.cc:81:95: required from here 81 | priority_queue<pair<double, ll>, vector<pair<double, int> >, greater<pair<double, ll> > > pq; | ^~ /usr/include/c++/14/bits/stl_queue.h:520:67: error: static assertion failed: value_type must be the same as the underlying container 520 | static_assert(is_same<_Tp, typename _Sequence::value_type>::value, | ^~~~~ /usr/include/c++/14/bits/stl_queue.h:520:67: note: 'std::integral_constant<bool, false>::value' evaluates to false
s726221600
p03866
C++
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define sz(x) (int)((x).size()) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define endl '\n' #define x first #define y second #define int long long #define double long double #define pii pair<int, int> #define pb push_back #define vec vector #define beg begin #define dbg(x) cout << #x << " = " << x << endl; template<class T> ostream& operator<<(ostream &str, vector<T> &a) { for (auto &i : a) { str << i << " "; } return str; } template<class T> istream& operator>>(istream &str, vector<T> &a) { for (auto &i : a) { str >> i; } return str; } template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) { str << a.first << " " << a.second; return str; } template<class T> istream& operator>>(istream &str, pair<T, T> &a) { str >> a.first >> a.second; return str; } void solve(); signed main() { #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif srand(time(0)); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20); solve(); return 0; } const int MAXN = 1e5 + 10; const double INF = 2e18 + 10; int n; vec<vec<int>> cycl; int xs, ys, xf, yf; vec<pair<double, int>> g[MAXN]; double get_dist(vec<int> &a, vec<int> &b) { int x1 = a[0], y1 = a[1], r1 = a[2]; int x2 = b[0], y2 = b[1], r2 = b[2]; if ((r1 + r2) * (r1 + r2) >= (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) { return (double)0.; } else { return max((double)0., sqrtl((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) - (double)(r1 + r2)); } } void solve() { cin >> xs >> ys >> xf >> yf; cin >> n; cycl.resize(n, vec<int>(3)); for (int i = 0; i < n; ++i) { cin >> cycl[i]; } for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { double wt = get_dist(cycl[i], cycl[j]); g[i].pb({wt, j}); g[j].pb({wt, i}); } } for (int i = 0; i < n; ++i) { vec<int> tmp = {xs, ys, 0}; double wt = get_dist(tmp, cycl[i]); g[n].pb({wt, i}); g[i].pb({wt, n}); } for (int i = 0; i < n; ++i) { vec<int> tmp = {xf, yf, 0}; double wt = get_dist(tmp, cycl[i]); g[n + 1].pb({wt, i}); g[i].pb({wt, n + 1}); } vec<double> dist(MAXN, INF); dist[n] = (double)0.; priority_queue<pair<double, int>> se; se.push({(double)0., n}); while (!se.empty()) { auto it = se.top(); se.pop(); if (dist[it.y] < it.x) continue; for (auto nxt : g[it.y]) { if (dist[nxt.y] > dist[it.y] + nxt.x) { dist[nxt.y] = dist[it.y] + nxt.x; se.emplace({-dist[nxt.y], nxt.y}); } } } cout << dist[n + 1] << endl; }
a.cc: In function 'void solve()': a.cc:111:27: error: no matching function for call to 'std::priority_queue<std::pair<long double, long long int> >::emplace(<brace-enclosed initializer list>)' 111 | se.emplace({-dist[nxt.y], nxt.y}); | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/queue:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157, from a.cc:2: /usr/include/c++/14/bits/stl_queue.h:752:9: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::emplace(_Args&& ...) [with _Args = {}; _Tp = std::pair<long double, long long int>; _Sequence = std::vector<std::pair<long double, long long int> >; _Compare = std::less<std::pair<long double, long long int> >]' 752 | emplace(_Args&&... __args) | ^~~~~~~ /usr/include/c++/14/bits/stl_queue.h:752:9: note: candidate expects 0 arguments, 1 provided
s448655649
p03866
C++
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define sz(x) (int)((x).size()) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define endl '\n' #define x first #define y second #define int long long #define double long double #define pii pair<int, int> #define pb push_back #define vec vector #define beg begin #define dbg(x) cout << #x << " = " << x << endl; template<class T> ostream& operator<<(ostream &str, vector<T> &a) { for (auto &i : a) { str << i << " "; } return str; } template<class T> istream& operator>>(istream &str, vector<T> &a) { for (auto &i : a) { str >> i; } return str; } template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) { str << a.first << " " << a.second; return str; } template<class T> istream& operator>>(istream &str, pair<T, T> &a) { str >> a.first >> a.second; return str; } void solve(); signed main() { #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif srand(time(0)); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20); solve(); return 0; } const double eps = 1e-5; const int MAXN = 1e5 + 10; const double INF = 1e20 + 10; int n; vec<vec<int>> cycl; int xs, ys, xf, yf; vec<pair<double, int>> g[MAXN]; double get_dist(vec<int> &a, vec<int> &b) { int x1 = a[0], y1 = a[1], r1 = a[2]; int x2 = b[0], y2 = b[1], r2 = b[2]; if ((r1 + r2) * (r1 + r2) >= (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) { return 0.; } else { return max(0., sqrtl((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) - (double)(r1 + r2)); } } void solve() { cin >> xs >> ys >> xf >> yf; cin >> n; cycl.resize(n, vec<int>(3)); for (int i = 0; i < n; ++i) { cin >> cycl[i]; } for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { double wt = get_dist(cycl[i], cycl[j]); g[i].pb({wt, j}); g[j].pb({wt, i}); } } for (int i = 0; i < n; ++i) { vec<int> tmp = {xs, ys, 0}; double wt = get_dist(tmp, cycl[i]); g[n].pb({wt, i}); g[i].pb({wt, n}); } for (int i = 0; i < n; ++i) { vec<int> tmp = {xf, yf, 0}; double wt = get_dist(tmp, cycl[i]); g[n + 1].pb({wt, i}); g[i].pb({wt, n + 1}); } vec<double> dist(MAXN, INF); dist[n] = 0.; set<pair<double, int>> se; se.insert({0., n}); while (!se.empty()) { auto it = *se.begin(); se.erase(se.begin()); for (auto nxt : g[it.y]) { if (dist[nxt.y] > dist[it.y] + nxt.x) { se.erase({dist[nxt.y], nxt.y}); dist[nxt.y] = dist[it.y] + nxt.x; se.insert({dist[nxt.y], nxt.y}); } } } cout << dist[n + 1] << endl; }
a.cc: In function 'long double get_dist(std::vector<long long int>&, std::vector<long long int>&)': a.cc:70:19: error: no matching function for call to 'max(double, long double)' 70 | return max(0., sqrtl((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) - (double)(r1 + r2)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:2: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:70:19: note: deduced conflicting types for parameter 'const _Tp' ('double' and 'long double') 70 | return max(0., sqrtl((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) - (double)(r1 + r2)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:70:19: note: mismatched types 'std::initializer_list<_Tp>' and 'double' 70 | return max(0., sqrtl((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) - (double)(r1 + r2)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s354250793
p03866
C
#include <algorithm> //STL ???? #include <bitset> //STL ???? #include <cctype> //???? #include <cerrno> //????? #include <cfloat> //????? #include <ciso646> //????????? #include <climits> //????????????? #include <clocale> //??????? #include <cmath> //?????? #include <complex> //??? #include <csignal> //?????? #include <csetjmp> //?????? #include <cstdarg> //???????? #include <cstddef> //???? #include <cstdio> //????/???? #include <cstdlib> //????????????? #include <cstring> //????? #include <ctime> //????????? #include <cwchar> //????????/?? #include <cwctype> //????? #include <deque> //STL ?????? #include <exception> //????? #include <fstream> //????/?? #include <functional> //STL ??????(?????) #include <limits> //???????????? #include <list> //STL ?????? #include <locale> //??????? #include <map> //STL ???? #include <memory> //STL???????????? #include<new> //?????? #include <numeric> //STL??????? #include <iomanip> //?????/?? #include <ios> //????/???? #include <iosfwd> //??/??????????? #include <iostream> //?????/?? #include <istream> //????? #include <iterator> //STL??? #include <ostream> //????? #include <queue> //STL ???? #include <set> //STL ???? #include <sstream> //??????? #include <stack> //STL ???? #include <stdexcept> //????? #include <streambuf> //????/???? #include <string> //???? #include <typeinfo> //???????? #include <utility> //STL ????? #include <valarray> //?????????? #include <vector> //STL ?????? using namespace std; const double INF=1e18; const int N=1010; int n; struct Edge{ int nxt,to; double dis; }edge[N*N]; int head[N],edge_num; void add(int f,int t,double d){ edge[edge_num].nxt=head[f]; edge[edge_num].dis=d; edge[edge_num].to=t; head[f]=edge_num++; return; } struct node{ int x,y,r; }a[N],s,t; double cale_dis(node a,node b){ return max(0.0,sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))-a.r-b.r); } struct nd{ int id; double d; bool friend operator < (nd a,nd b){ return a.d>b.d; } }nw; priority_queue <nd> q; bool vis[N]; double dist[N]; void dij(int x){ for (int i=1;i<=n+2;i++) dist[i]=INF; dist[x]=nw.d=0.0; nw.id=x; q.push(nw); while(!q.empty()){ nw=q.top(); q.pop(); int u=nw.id; if (vis[u]) continue; vis[u]=1; for (int i=head[u];~i;i=edge[i].nxt){ int v=edge[i].to; if (vis[v]||dist[v]<=dist[u]+edge[i].dis) continue; dist[v]=dist[u]+edge[i].dis; nw.id=v; nw.d=dist[v]; q.push(nw); } } return; } int main(){ memset(head,-1,sizeof(head)); scanf("%d%d%d%d",&s.x,&s.y,&t.x,&t.y); s.r=0.0; t.r=0.0; scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].r); for (int i=1;i<=n;i++){ add(n+1,i,cale_dis(s,a[i])); add(i,n+1,cale_dis(s,a[i])); add(i,n+2,cale_dis(t,a[i])); add(n+2,i,cale_dis(t,a[i])); for (int j=1;j<=n;j++) add(i,j,cale_dis(a[i],a[j])); } dij(n+1); printf("%.10lf",dist[n+2]); return 0; }
main.c:1:10: fatal error: algorithm: No such file or directory 1 | #include <algorithm> //STL ???? | ^~~~~~~~~~~ compilation terminated.
s583389270
p03866
C
#include<bits/stdc++.h> using namespace std; const double INF=1e18; const int N=1010; int n; struct Edge{ int nxt,to; double dis; }edge[N*N]; int head[N],edge_num; void add(int f,int t,double d){ edge[edge_num].nxt=head[f]; edge[edge_num].dis=d; edge[edge_num].to=t; head[f]=edge_num++; return; } struct node{ int x,y,r; }a[N],s,t; double cale_dis(node a,node b){ return max(0.0,sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))-a.r-b.r); } struct nd{ int id; double d; bool friend operator < (nd a,nd b){ return a.d>b.d; } }nw; priority_queue <nd> q; bool vis[N]; double dist[N]; void dij(int x){ for (int i=1;i<=n+2;i++) dist[i]=INF; dist[x]=nw.d=0.0; nw.id=x; q.push(nw); while(!q.empty()){ nw=q.top(); q.pop(); int u=nw.id; if (vis[u]) continue; vis[u]=1; for (int i=head[u];~i;i=edge[i].nxt){ int v=edge[i].to; if (vis[v]||dist[v]<=dist[u]+edge[i].dis) continue; dist[v]=dist[u]+edge[i].dis; nw.id=v; nw.d=dist[v]; q.push(nw); } } return; } int main(){ memset(head,-1,sizeof(head)); scanf("%d%d%d%d",&s.x,&s.y,&t.x,&t.y); s.r=0.0; t.r=0.0; scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].r); for (int i=1;i<=n;i++){ add(n+1,i,cale_dis(s,a[i])); add(i,n+1,cale_dis(s,a[i])); add(i,n+2,cale_dis(t,a[i])); add(n+2,i,cale_dis(t,a[i])); for (int j=1;j<=n;j++) add(i,j,cale_dis(a[i],a[j])); } dij(n+1); printf("%.10lf",dist[n+2]); return 0; }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s662090303
p03866
C++
#include <stdio.h> #include <string.h> #include <algorithm> #include<math.h> using namespace std; #define inf 0x3f3f3f3f #define N 1005 long double maze[N][N], dis[N]; int n; int vis[N]; void Dijkstra() { int i, j, minn, indx; memset(vis, 0, sizeof(vis)); vis[0] = 1; for (i = 0; i <= n + 1; i++) dis[i] = maze[0][i]; for (i = 1; i <= n + 1; i++) { minn = inf; for (j = 1; j <= n + 1; j++) { if (dis[j] < minn && !vis[j]) { indx = j; minn = dis[j]; } } vis[indx] = 1; for (j = 1; j <= n + 1; j++) { if (!vis[j] && dis[indx] + maze[indx][j] < dis[j]) dis[j] = dis[indx] + maze[indx][j]; } } } struct node { int x; int y; int r; } s[N]; int main() { int xx, yy; scanf_s("%d%d%d%d", &s[0].x, &s[0].y, &xx, &yy); s[0].r = 0; scanf_s("%d", &n); for (int i = 0; i <= n + 1; i++)for (int j = 0; j <= n + 1; j++)maze[i][j] = inf; s[n + 1].x = xx; s[n + 1].y = yy; s[n + 1].r = 0; for (int i = 1; i <= n; i++) scanf_s("%d%d%d", &s[i].x, &s[i].y, &s[i].r); for (int i = 0; i <= n + 1; i++) { for (int j = i + 1; j <= n + 1; j++) { maze[i][j] = (long double)sqrt((long double)(s[i].x - s[j].x)*(s[i].x - s[j].x) + (s[i].y - s[j].y)*(s[i].y - s[j].y)); maze[i][j] -= s[i].r + s[j].r; if (maze[i][j] < 0) maze[i][j] = 0; maze[j][i] = maze[i][j]; } } Dijkstra(); printf("%.9Lf\n", dis[n + 1]); return 0; }
a.cc: In function 'int main()': a.cc:46:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 46 | scanf_s("%d%d%d%d", &s[0].x, &s[0].y, &xx, &yy); | ^~~~~~~ | scanf
s963460555
p03866
C++
#include <stdio.h> #include <string.h> #include <algorithm> #include<math.h> using namespace std; #define inf 0x3f3f3f3f #define N 1005 double maze[N][N], dis[N]; int n; int vis[N]; void Dijkstra() { int i, j, minn, indx; memset(vis, 0, sizeof(vis)); vis[0] = 1; for (i = 0; i <= n + 1; i++) dis[i] = maze[0][i]; for (i = 1; i <= n + 1; i++) { minn = inf; for (j = 1; j <= n + 1; j++) { if (dis[j] < minn && !vis[j]) { indx = j; minn = dis[j]; } } vis[indx] = 1; for (j = 1; j <= n + 1; j++) { if (!vis[j] && dis[indx] + maze[indx][j] < dis[j]) dis[j] = dis[indx] + maze[indx][j]; } } } struct node { int x; int y; int r; } s[N]; int main() { int xx, yy; scanf_s("%d%d%d%d", &s[0].x, &s[0].y, &xx, &yy); s[0].r = 0; scanf_s("%d", &n); for (int i = 0; i <= n + 1; i++)for (int j = 0; j <= n + 1; j++)maze[i][j] = inf; s[n + 1].x = xx; s[n + 1].y = yy; s[n + 1].r = 0; for (int i = 1; i <= n; i++) scanf_s("%d%d%d", &s[i].x, &s[i].y, &s[i].r); for (int i = 0; i <= n + 1; i++) { for (int j = i + 1; j <= n + 1; j++) { maze[i][j] = (long double)sqrt((long double)(s[i].x - s[j].x)*(s[i].x - s[j].x) + (s[i].y - s[j].y)*(s[i].y - s[j].y)); maze[i][j] -= s[i].r + s[j].r; if (maze[i][j] < 0) maze[i][j] = 0; maze[j][i] = maze[i][j]; } } Dijkstra(); printf("%.9lf\n", dis[n + 1]); return 0; }
a.cc: In function 'int main()': a.cc:46:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 46 | scanf_s("%d%d%d%d", &s[0].x, &s[0].y, &xx, &yy); | ^~~~~~~ | scanf
s392225646
p03866
C++
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <tuple> #include <queue> #include <deque> #include <map> #include <set> #include <cmath> #include <iomanip> #include <functional> #define rep(i, n) for (int i = 0; i < (n); ++i) #define REP(i, n) for (int i = 1; i < (n); ++i) #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)(x).size() using namespace std; using ll = long long; constexpr int inf = 1000000000; constexpr ll INF = 5000000000000000000; #define double long double #define int ll struct Edge {int to; double cost;}; int main() { int xs, ys, xg, yg; cin >> xs >> ys >> xg >> yg; int N; cin >> N; vector<int> x(N), y(N), r(N); rep(i, N) cin >> x[i] >> y[i] >> r[i]; vector<vector<Edge>> G(N + 2); rep(i, N) { G[0].push_back(Edge{i + 1, max(sqrt((xs - x[i]) * (xs - x[i]) + (ys - y[i]) * (ys - y[i])) - r[i], 0.0)}); G[i + 1].push_back(Edge{0, max(sqrt((xs - x[i]) * (xs - x[i]) + (ys - y[i]) * (ys - y[i])) - r[i], 0.0)}); G[N + 1].push_back(Edge{i + 1, max(sqrt((xg - x[i]) * (xg - x[i]) + (yg - y[i]) * (yg - y[i])) - r[i], 0.0)}); G[i + 1].push_back(Edge{N + 1, max(sqrt((xg - x[i]) * (xg - x[i]) + (yg - y[i]) * (yg - y[i])) - r[i], 0.0)}); } rep(i, N) rep(j, N) { if (i == j) continue; G[i + 1].push_back(Edge{j + 1, max(sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])) - r[i] - r[j], 0.0)}); } G[0].push_back(Edge{N + 1, sqrt((xs - xg) * (xs - xg) + (ys - yg) * (ys - yg))}); G[N + 1].push_back(Edge{N, sqrt((xs - xg) * (xs - xg) + (ys - yg) * (ys - yg))}); vector<double> dist(N + 2, 3000000000000000000.0); dist[0] = 0; vector<int> used(N + 2, 0); priority_queue<pair<double, int>> pq; pq.push(pair<double, int>{0, 0}); while (!pq.empty()) { int v = pq.top().second; pq.pop(); if (used[v]) continue; for (auto e : G[v]) { double alt = dist[v] + e.cost; if (alt < dist[e.to]) { dist[e.to] = alt; pq.push(pair<double, int>{-alt, e.to}); } } used[v] = 1; } cout << fixed << setprecision(15) << dist[N + 1] << "\n"; return 0; }
a.cc:24:13: error: '::main' must return 'int' 24 | #define int ll | ^~ a.cc:28:1: note: in expansion of macro 'int' 28 | int main() { | ^~~
s070274480
p03866
C++
#include <iostream> #include <algorithm> #include <queue> #define flush fflush(stdout) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> Pl; typedef pair<double, int> Pd; const int mod = (int)1e9 + 7, INF = (int)1e9; const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 }; int main(void) { int n, i, pv; double xs, ys, xg, yg, x[1007], y[1007], r[1003], d[1007] = {}, ds, nds, dx, dy; priority_queue<Pd, vector<Pd>, greater<Pd>> pq; scanf("%lf%lf%lf%lf", &xs, &ys, &xg, &yg); scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%lf%lf%lf", &x[i + 1], &y[i + 1], &r[i + 1]); } for (i = 0; i < n + 2; i++) { d[i] = 1000000000.0; } x[0] = xs; y[0] = ys; x[n + 1] = xg; y[n + 1] = yg; r[0] = r[n + 1] = 0.0; d[0] = 0.0; pq.push(Pd(0.0, 0)); while (!pq.empty()) { Pd p = pq.top(); pq.pop(); ds = p.first; pv = p.second; if (d[pv] < ds) { continue; } for (i = 1; i < n + 2; i++) { if (i == pv) { continue; } dx = x[pv] - x[i]; dy = y[pv] - y[i]; nds = max(0.0, sqrt(dx * dx + dy * dy) - r[pv] - r[i]); if (d[i] > ds + nds) { d[i] = ds + nds; pq.push(Pd(d[i], i)); } } } printf("%.12lf\n", d[n + 1]); return 0; }
a.cc: In function 'int main()': a.cc:50:28: error: 'sqrt' was not declared in this scope 50 | nds = max(0.0, sqrt(dx * dx + dy * dy) - r[pv] - r[i]); | ^~~~
s850096676
p03866
C++
#include <iostream> #include <algorithm> #include <queue> #define flush fflush(stdout) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> Pl; typedef pair<double, int> Pd; const int mod = (int)1e9 + 7, INF = (int)1e9; const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 }; int main(void) { int n, i, pv; double xs, ys, xg, yg, x[1007], y[1007], r[1003], d[1007] = {}, ds, nds, dx, dy; priority_queue<Pd, vector<Pd>, greater<Pd>> pq; scanf("%lf%lf%lf%lf", &xs, &ys, &xg, &yg); scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%lf%lf%lf", &x[i + 1], &y[i + 1], &r[i + 1]); } for (i = 0; i < n + 2; i++) { d[i] = 1000000000.0; } x[0] = xs; y[0] = ys; x[n + 1] = xg; y[n + 1] = yg; r[0] = r[n + 1] = 0.0; d[0] = 0.0; pq.push(Pd(0.0, 0)); while (!pq.empty()) { Pd p = pq.top(); pq.pop(); ds = p.first; pv = p.second; if (d[pv] < ds) { continue; } for (i = 1; i < n + 2; i++) { if (i == pv) { continue; } dx = x[pv] - x[i]; dy = y[pv] - y[i]; nds = max(0.0, sqrt(dx * dx + dy * dy) - r[pv] - r[i]); if (d[i] > ds + nds) { d[i] = ds + nds; pq.push(Pd(d[i], i)); } } } printf("%.12lf\n", d[n + 1]); return 0; }
a.cc: In function 'int main()': a.cc:50:28: error: 'sqrt' was not declared in this scope 50 | nds = max(0.0, sqrt(dx * dx + dy * dy) - r[pv] - r[i]); | ^~~~
s147303339
p03866
C++
#include <iostream> #include <algorithm> #include <queue> #define flush fflush(stdout) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> Pl; typedef pair<double, int> Pd; const int mod = (int)1e9 + 7, INF = (int)1e9; const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 }; int main(void) { int n, i, pv; double xs, ys, xg, yg, x[1007], y[1007], r[1003], d[1007] = {}, ds, nds, dx, dy; priority_queue<Pd, vector<Pd>, greater<Pd>> pq; scanf("%lf%lf%lf%lf", &xs, &ys, &xg, &yg); scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%lf%lf%lf", &x[i + 1], &y[i + 1], &r[i + 1]); } for (i = 0; i < n + 2; i++) { d[i] = 1000000000.0; } x[0] = xs; y[0] = ys; x[n + 1] = xg; y[n + 1] = yg; r[0] = r[n + 1] = 0.0; d[0] = 0.0; pq.push(Pd(0.0, 0)); while (!pq.empty()) { Pd p = pq.top(); pq.pop(); ds = p.first; pv = p.second; if (d[pv] < ds) { continue; } for (i = 1; i < n + 2; i++) { if (i == pv) { continue; } dx = abs(x[pv] - x[i]); dy = abs(y[pv] - y[i]); nds = max(0.0, sqrt(dx * dx + dy * dy) - r[pv] - r[i]); if (d[i] > ds + nds) { d[i] = ds + nds; pq.push(Pd(d[i], i)); } } } printf("%.12lf\n", d[n + 1]); return 0; }
a.cc: In function 'int main()': a.cc:50:28: error: 'sqrt' was not declared in this scope 50 | nds = max(0.0, sqrt(dx * dx + dy * dy) - r[pv] - r[i]); | ^~~~
s158972373
p03866
C++
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。 // // AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。 // #define _USE_MATH_DEFINES #include<math.h> //#include<cmath> #include<deque> #include<queue> #include<vector> #include<algorithm> #include<iostream> #include<set> #include<cmath> #include<tuple> #include<string> #include<chrono> #include<functional> #include<iterator> #include<random> #include<unordered_set> #include<array> #include<map> #include<iomanip> #include<assert.h> #include<bitset> #include<stack> #include<memory> //#include "Ants.h" using namespace std; typedef long long ll; #define rad_to_deg(rad) (((rad)/2/M_PI)*360) #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define rep(i,n) for(int i=0;i<n;i++) #define show(s) cout<<s<<endl #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) #define LINF (1LL << 50) #define MOD (1e9+7) #define rep1(i,n) for(int i =1;i<=n;i++) #define rrep(i,n) for(int i=n-1;i>=0;--i) typedef pair < ll, double> P; ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b) if (b == 0) return a; return gcd(b, a % b); } ll lcd(ll a, ll b) {//最小公倍数を求める b=0のときaを返す if (b == 0) return a; return (a / gcd(a, b)) * b; } vector<int> divnum(ll num) { int dig; vector<int>p; while (num) { dig = num % 10; p.push_back(dig); num /= 10; } return p; } int digiter(ll num) { int dig; vector<int>p; while (num) { dig = num % 10; p.push_back(dig); num /= 10; } return p.size(); } vector<int> convertstring(string s) { vector<int> d; ll n = s.size(); rep(i, n) { d.push_back(s[i] - '0'); } return d; } map< ll, int > prime_factor(ll n) { map< ll, int > ret; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { ret[i]++; n /= i; } } if (n != 1) ret[n] = 1; return ret; } vector<ll> divisor(ll n) { vector<ll>res; for (ll i = 1; i * i <= n; i++) { if (n % i != 0)continue; res.push_back(i); if (i * i != n)res.push_back(n / i); } return res; } ll myPow(ll x, ll n, ll m) {//x^n if (n == 0) return 1; if (n % 2 == 0) return myPow(x * x % m, n / 2, m); else return x * myPow(x, n - 1, m) % m; } std::vector<int> Eratosthenes(const int N)//素数列挙 { std::vector<bool> is_prime(N + 1); for (int i = 0; i <= N; i++) { is_prime[i] = true; } std::vector<int> P; for (int i = 2; i <= N; i++) { if (is_prime[i]) { for (int j = 2 * i; j <= N; j += i) { is_prime[j] = false; } P.emplace_back(i); } } return P; } const ll mod = MOD; struct mint { ll x; // typedef long long ll; mint(ll x = 0) :x((x% mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint& operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } //operator long long() const { return x; } }; istream& operator>>(istream& is, const mint& a) { return is >> a.x; } ostream& operator<<(ostream& os, const mint& a) { return os << a.x; } struct combination {//comb(a,b)でよぶaCb vector<mint> fact, ifact; combination(ll n) :fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (ll i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (ll i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(ll n, ll k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }comb(1000005);//comb貯め mint f(ll n, ll k) { if (n < 0) return 0; // nPk = nCk * k! mint res = comb(n, k); res *= comb.fact[k]; return res; } /*int Q; struct SegmentTree { private: int n; vector<int> node; public: SegmentTree(vector<int> v) {//SegmentTree seg(vector<int> v(N,INF))で呼び出し int sz = v.size(); n = 1; while (n < sz) n *= 2; node.resize(2 * n - 1, INF); for (int i = 0; i < sz; i++) node[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; i--) node[i] = min(node[2 * i + 1], node[2 * i + 2]); } void update(int x, int val) { x += (n - 1); node[x] = val; while (x > 0) { x = (x - 1) / 2; node[x] = min(node[2 * x + 1], node[2 * x + 2]); } } int getmin(int a, int b, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; if (r <= a || b <= l) return INF; if (a <= l && r <= b) return node[k]; int vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2); int vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r); return min(vl, vr); } }; // 1-indexedなので注意。 struct BIT { private: vector<int> bit; int N; public: BIT(int size) { N = size; bit.resize(N + 1); } // 一点更新です void add(int a, int w) {//a番目をwに更新 for (int x = a; x <= N; x += x & -x) bit[x] += w; } // 1~Nまでの和を求める。 int sum(int a) { int ret = 0; for (int x = a; x > 0; x -= x & -x) ret += bit[x]; return ret; } };*/ struct edge { int to; double cost; edge(int to, double cost):to(to),cost(cost) {} }; int xs, ys, xt, yt,N; ll x[1005], y[1005],r[1005]; vector<edge>G[10005]; double dist[1005]; void dikstra(int s){ fill(dist, dist + N + 3, LINF); dist[s] = 0; priority_queue<P, vector<P>, greater<P>>que; que.push(P(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); int v = p.second; //cout << v <<"vertex"<<p.first<<" "<<dist[v]<< endl; //cout << x[v - 1] << " " << y[v - 1] << endl; //rep(i, N + 2)printf("%.10f\n", dist[i]); if (p.first > dist[v])continue; for (edge e : G[v]) { const int u = e.to; //cout <<u<<" " <<dist[u] <<" "<< dist[v] + e.cost << endl; if (dist[u] > dist[v] + e.cost) { dist[u] = dist[v] + e.cost; que.push(make_pair(dist[u], u)); } } } } int32_t main() { cin >> xs >> ys >> xt >> yt; cin >> N; rep(i, N) { cin >> x[i] >> y[i]>>r[i]; } rep(i, N) { const int s = i + 1; rep(j, N) { if (i == j)continue; const int t = j + 1; ll dist = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]); double cost = sqrt(dist); cost -= r[i];cost-= r[j]; chmax(cost, double(0)); G[s].push_back(edge(t, cost)); //cout << x[i]<<" "<<y[i]<<" "<<x[j]<<" "<<y[j]<<" "<<cost << endl; } } rep(i, N) { const int s = 0; const int t = i + 1; ll dist = (xs - x[i]) * (xs - x[i]) + (y[i] - ys) * (y[i] - ys); double cost = sqrt(dist); cost -= r[i]; chmax(cost, double(0)); G[s].push_back(edge(t, cost)); //cout << cost <<"work"<< endl; } rep(i, N) { const int t = N+1; const int s = i + 1; ll dist = (xt - x[i]) * (xt - x[i]) + (y[i] - yt) * (y[i] - yt); double cost = sqrt(dist); cost -= r[i]; chmax(cost, double(0)); G[s].push_back(edge(t, cost)); //cout << cost <<"work"<< endl; } ll dist = (xt - xt) * (xt - xt) + (ys - yt) * (ys - yt); double cost = sqrt(dist); cost = max(cost, double(0)); G[0].push_back(edge(0, N + 1)); dikstra(0); //rep(i,N+2)printf("%.10f\n", dist[i]); printf("%.15lf\n", dist[N+1]); }
a.cc: In function 'int32_t main()': a.cc:336:32: error: invalid types 'll {aka long long int}[int]' for array subscript 336 | printf("%.15lf\n", dist[N+1]); | ^
s157920730
p03866
C++
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。 // // AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。 // #define _USE_MATH_DEFINES #include<math.h> //#include<cmath> #include<deque> #include<queue> #include<vector> #include<algorithm> #include<iostream> #include<set> #include<cmath> #include<tuple> #include<string> #include<chrono> #include<functional> #include<iterator> #include<random> #include<unordered_set> #include<array> #include<map> #include<iomanip> #include<assert.h> #include<bitset> #include<stack> #include<memory> //#include "Ants.h" using namespace std; typedef long long ll; #define rad_to_deg(rad) (((rad)/2/M_PI)*360) #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define rep(i,n) for(int i=0;i<n;i++) #define show(s) cout<<s<<endl #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) #define LINF (1LL << 50) #define MOD (1e9+7) #define rep1(i,n) for(int i =1;i<=n;i++) #define rrep(i,n) for(int i=n-1;i>=0;--i) typedef pair < ll, long double> P; ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b) if (b == 0) return a; return gcd(b, a % b); } ll lcd(ll a, ll b) {//最小公倍数を求める b=0のときaを返す if (b == 0) return a; return (a / gcd(a, b)) * b; } vector<int> divnum(ll num) { int dig; vector<int>p; while (num) { dig = num % 10; p.push_back(dig); num /= 10; } return p; } int digiter(ll num) { int dig; vector<int>p; while (num) { dig = num % 10; p.push_back(dig); num /= 10; } return p.size(); } vector<int> convertstring(string s) { vector<int> d; ll n = s.size(); rep(i, n) { d.push_back(s[i] - '0'); } return d; } map< ll, int > prime_factor(ll n) { map< ll, int > ret; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { ret[i]++; n /= i; } } if (n != 1) ret[n] = 1; return ret; } vector<ll> divisor(ll n) { vector<ll>res; for (ll i = 1; i * i <= n; i++) { if (n % i != 0)continue; res.push_back(i); if (i * i != n)res.push_back(n / i); } return res; } ll myPow(ll x, ll n, ll m) {//x^n if (n == 0) return 1; if (n % 2 == 0) return myPow(x * x % m, n / 2, m); else return x * myPow(x, n - 1, m) % m; } std::vector<int> Eratosthenes(const int N)//素数列挙 { std::vector<bool> is_prime(N + 1); for (int i = 0; i <= N; i++) { is_prime[i] = true; } std::vector<int> P; for (int i = 2; i <= N; i++) { if (is_prime[i]) { for (int j = 2 * i; j <= N; j += i) { is_prime[j] = false; } P.emplace_back(i); } } return P; } const ll mod = MOD; struct mint { ll x; // typedef long long ll; mint(ll x = 0) :x((x% mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint& operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } //operator long long() const { return x; } }; istream& operator>>(istream& is, const mint& a) { return is >> a.x; } ostream& operator<<(ostream& os, const mint& a) { return os << a.x; } struct combination {//comb(a,b)でよぶaCb vector<mint> fact, ifact; combination(ll n) :fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (ll i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (ll i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(ll n, ll k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }comb(1000005);//comb貯め mint f(ll n, ll k) { if (n < 0) return 0; // nPk = nCk * k! mint res = comb(n, k); res *= comb.fact[k]; return res; } /*int Q; struct SegmentTree { private: int n; vector<int> node; public: SegmentTree(vector<int> v) {//SegmentTree seg(vector<int> v(N,INF))で呼び出し int sz = v.size(); n = 1; while (n < sz) n *= 2; node.resize(2 * n - 1, INF); for (int i = 0; i < sz; i++) node[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; i--) node[i] = min(node[2 * i + 1], node[2 * i + 2]); } void update(int x, int val) { x += (n - 1); node[x] = val; while (x > 0) { x = (x - 1) / 2; node[x] = min(node[2 * x + 1], node[2 * x + 2]); } } int getmin(int a, int b, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; if (r <= a || b <= l) return INF; if (a <= l && r <= b) return node[k]; int vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2); int vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r); return min(vl, vr); } }; // 1-indexedなので注意。 struct BIT { private: vector<int> bit; int N; public: BIT(int size) { N = size; bit.resize(N + 1); } // 一点更新です void add(int a, int w) {//a番目をwに更新 for (int x = a; x <= N; x += x & -x) bit[x] += w; } // 1~Nまでの和を求める。 int sum(int a) { int ret = 0; for (int x = a; x > 0; x -= x & -x) ret += bit[x]; return ret; } };*/ struct edge { int to; long double cost; edge(int to, long double cost):to(to),cost(cost) {} }; int xs, ys, xt, yt,N; ll x[1005], y[1005],r[1005]; vector<edge>G[10005]; long double dist[1005]; void dikstra(int s){ fill(dist, dist + N + 3, LINF); dist[s] = 0; priority_queue<P, vector<P>, greater<P>>que; que.push(P(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); int v = p.second; //cout << v <<"vertex"<<p.first<<" "<<dist[v]<< endl; //cout << x[v - 1] << " " << y[v - 1] << endl; //rep(i, N + 2)printf("%.10f\n", dist[i]); if (p.first > dist[v])continue; for (edge e : G[v]) { const int u = e.to; //cout <<u<<" " <<dist[u] <<" "<< dist[v] + e.cost << endl; if (dist[u] > dist[v] + e.cost) { dist[u] = dist[v] + e.cost; que.push(make_pair(dist[u], u)); } } } } int32_t main() { cin >> xs >> ys >> xt >> yt; cin >> N; rep(i, N) { cin >> x[i] >> y[i]>>r[i]; } rep(i, N) { const int s = i + 1; rep(j, N) { if (i == j)continue; const int t = j + 1; ll dist = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]); long double cost = sqrt(dist); cost -= r[i];cost-= r[j]; chmax(cost, long double(0)); G[s].push_back(edge(t, cost)); //cout << x[i]<<" "<<y[i]<<" "<<x[j]<<" "<<y[j]<<" "<<cost << endl; } } rep(i, N) { const int s = 0; const int t = i + 1; ll dist = (xs - x[i]) * (xs - x[i]) + (y[i] - ys) * (y[i] - ys); long double cost = sqrt(dist); cost -= r[i]; chmax(cost, long double(0)); G[s].push_back(edge(t, cost)); //cout << cost <<"work"<< endl; } rep(i, N) { const int t = N+1; const int s = i + 1; ll dist = (xt - x[i]) * (xt - x[i]) + (y[i] - yt) * (y[i] - yt); long double cost = sqrt(dist); cost -= r[i]; chmax(cost, long double(0)); G[s].push_back(edge(t, cost)); //cout << cost <<"work"<< endl; } dikstra(0); //rep(i,N+2)printf("%.10f\n", dist[i]); printf("%.10f\n", dist[N+1]); }
a.cc: In function 'int32_t main()': a.cc:305:37: error: expected primary-expression before 'long' 305 | chmax(cost, long double(0)); | ^~~~ a.cc:47:28: note: in definition of macro 'chmax' 47 | #define chmax(x,y) x=max(x,y) | ^ a.cc:315:29: error: expected primary-expression before 'long' 315 | chmax(cost, long double(0)); | ^~~~ a.cc:47:28: note: in definition of macro 'chmax' 47 | #define chmax(x,y) x=max(x,y) | ^ a.cc:324:29: error: expected primary-expression before 'long' 324 | chmax(cost, long double(0)); | ^~~~ a.cc:47:28: note: in definition of macro 'chmax' 47 | #define chmax(x,y) x=max(x,y) | ^
s235238491
p03866
C++
#include <iostream> #include <iomanip> //#include <string> #include <vector> #include <algorithm> //#include <utility> //#include <set> //#include <map> #include <queue> //#include <deque> //#include <bitset> //#include <math.h> using namespace std ; using ll = long long ; using ld = long double ; using vll = vector<ll> ; using vvll = vector<vll> ; //using vc = vector<char> ; //using vvc = vector<vc> ; //using vb = vector<bool> ; //using vvb = vector<vb> ; //using pll = pair<ll,ll> ; //#define all(v) v.begin(),v.end() //ll mod = 1000000007 ; //long double pie = acos(-1) ; //ll INF = 1000000000000 ; //void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;} //void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;} //ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;} //ll lcm(long long a,long long b){return a/gcd(a,b)*b ;} //ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;} void fix_cout(){cout << fixed << setprecision(20) ;} template<class F,class S,class T> struct triple{ F first ; S second ; T third ; triple(F f,S s,T t){ first = f ; second = s ; third = t ; } triple(){} bool operator<(const triple<F,S,T> &right) const{ if(first!=right.first) return first<right.first ; else if(second!=right.second) return second<right.second ; else return third<right.third ; } bool operator>(const triple<F,S,T> &right) const{ return right<*this ; } bool operator<=(const triple<F,S,T> &right) const{ return !(*this>right) ; } bool operator>=(const triple<F,S,T> &right) const{ return !(*this<right) ; } }; int main(){ auto dis = [](ll a,ll b,ll c,ll d){ return sqrt((a-c)*(a-c)+(b-d)*(b-d)) ; } ; fix_cout() ; ll sx,sy,gx,gy ; cin >> sx >> sy >> gx >> gy ; ll n ; cin >> n ; vector<triple<ll,ll,ll>> c(n+2) ; c.at(0).first = sx ; c.at(0).second = sy ; c.at(0).third = 0 ; for(int i=1;i<=n;i++) cin >> c.at(i).first >> c.at(i).second >> c.at(i).third ; c.at(n+1).first = gx ; c.at(n+1).second = gy ; c.at(n+1).third = 0 ; vector<vector<ld>> d(n+2,vector<ld>(n+2)) ; for(int i=0;i<n+2;i++){ for(int j=0;j<n+2;j++){ if(i==j) d.at(i).at(j) = 0 ; else{ d.at(i).at(j) = max(0.0,dis(c.at(i).first,c.at(i).second,c.at(j).first,c.at(j).second)-c.at(i).third-c.at(j).third) ; } } } vector<ld> cnt(n+2,100000000000000.0) ; priority_queue<triple<ld,ll,ll>,vector<triple<ld,ll,ll>>,greater<triple<ld,ll,ll>>> pq ; cnt.at(0) = 0 ; for(int i=1;i<n+2;i++) pq.emplace(d.at(0).at(i),0,i) ; vll use(n+2,0) ; while(!pq.empty()){ triple<ld,ll,ll> e = pq.top() ; pq.pop() ; if(use.at(e.third)) continue ; // cout << e.second << " " << e.third << " " << e.first << endl ; use.at(e.third) = 1 ; cnt.at(e.third) = cnt.at(e.second)+e.first ; for(int i=0;i<n+2;i++) if(i!=e.third) pq.emplace(d.at(e.third).at(i),e.third,i) ; } cout << cnt.at(n+1) << endl ; // for(auto i:cnt) cout << i << endl ; }
a.cc: In lambda function: a.cc:65:24: error: 'sqrt' was not declared in this scope 65 | return sqrt((a-c)*(a-c)+(b-d)*(b-d)) ; | ^~~~
s002391083
p03866
C++
#ifndef DEBUG # define NDEBUG #endif #include <iostream> #include <algorithm> #include <string> #include <iterator> #include <utility> #include <type_traits> #include <limits> #include <cassert> #include <numeric> #include <vector> #include <queue> using namespace std; // template {{{ // misc {{{ using Z = long long; [[maybe_unused]] constexpr Z INF = numeric_limits<Z>::max() / 3; // }}} // debug {{{ template <class T> using enable_if_sequence_t = enable_if_t< is_same< typename iterator_traits< typename remove_cv_t<remove_reference_t<T>>::iterator >::iterator_category, random_access_iterator_tag>{}>; #ifdef NDEBUG # define dump(x) # define debug if (0) template <class T> inline T&& ix(T&& value) { return value; } template <class T, class Index, class... Indices, class = enable_if_sequence_t<T>> inline auto&& ix(T&& container, Index index, Indices... indices) { return ix(container[index], indices...); } #else # define dump(x) do { \ cerr << "\e[33m[dump: " << __LINE__ << "] " << (#x) << " = " << x << "\e[0m" << endl; \ } while (0); # define debug template <class T> inline auto&& ix_impl([[maybe_unused]] int line, [[maybe_unused]] const char* code, T&& value) { return value; } template <class T, class Index, class... Indices, class = enable_if_sequence_t<T>> inline auto&& ix_impl(int line, const char* code, T&& container, Index index, Indices... indices) { if (index < 0) { cerr << "\e[31mix: negative index at line " << line << ", ix(" << code << ")\e[0m" << endl; exit(1); } int size = container.size(); if (index >= size) { cerr << "\e[31mix: index out of range at line " << line << ", ix(" << code << ")\n" << "index = " << index << " whereas size = " << size << "\e[0m" << endl; exit(1); } return ix_impl(line, code, container[index], indices...); } #define ix(...) ix_impl(__LINE__, #__VA_ARGS__, __VA_ARGS__) #endif // }}} // IO {{{ template <class T, class U> ostream& operator<< (ostream& os, pair<T, U> p) { os << '(' << p.first << ", " << p.second << ')'; return os; } template <class T, class U> istream& operator>> (istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; } template <class T> false_type is_container_impl(...); template <class T, class = typename T::iterator> true_type is_container_impl(T); template <class T> struct is_container : decltype(is_container_impl<T>(declval<T>())) {}; template <> struct is_container <string> : std::false_type {}; template <class Container, class = enable_if_t<is_container<Container>{}>> istream& operator>> (istream& is, Container& cont) { for (auto& v : cont) is >> v; return is; } template <class Container, class = enable_if_t<is_container<Container>{}>> ostream& operator<< (ostream& os, Container const& cont) { bool first = true; constexpr char sep = is_container<typename Container::value_type>{} ? '\n' : ' '; for (auto const& v : cont) { if (!first) { os << sep; } first = false; os << v; } return os; } // }}} // }}} struct edge { Z to; double cost; }; using Graph = vector<vector<edge>>; vector<double> dijkstra(Graph const& gr, Z start) { Z N = gr.size(); vector<double> dists(N, 100000000000.0); priority_queue<pair<double, Z>, vector<pair<double, Z>>, greater<pair<double, Z>>> que; que.emplace(0, start); while (!que.empty()) { double d; Z v; tie(d, v) = que.top(); que.pop(); if (d >= ix(dists, v)) continue; ix(dists, v) = d; for (auto&& e : ix(gr, v)) { double nd = e.cost + d; if (nd >= ix(dists, e.to)) continue; que.emplace(nd, e.to); } } return dists; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.precision(10); cout << fixed; Z xs, ys, xt, yt, N; cin >> xs >> ys >> xt >> yt >> N; vector<Z> x(N + 2), y(N + 2), r(N + 2); for (auto i = 0; i < N; i++) cin >> ix(x, i) >> ix(y, i) >> ix(r, i); ix(x, N) = xs; ix(x, N + 1) = xt; ix(y, N) = ys; ix(y, N + 1) = yt; Graph gr(N + 2); for (auto i = 0; i < N + 2; i++) { for (auto j = 0; j < N + 2; j++) { if (i == j) continue; double dist = max(0., hypot(ix(x, i) - ix(x, j), ix(y, i) - ix(y, j)) - ix(r, i) - ix(r, j)); ix(gr, i).push_back({j, dist}); } } debug { for (auto&& row : gr) { for (auto&& e : row) cerr << '(' << e.to << ", " << e.cost << ") "; cerr << endl; } } auto const& ds = dijkstra(gr, N); dump(ds); cout << ix(ds, N + 1) << endl; }
a.cc: In function 'int main()': a.cc:157:29: error: 'hypot' was not declared in this scope 157 | double dist = max(0., hypot(ix(x, i) - ix(x, j), ix(y, i) - ix(y, j)) - ix(r, i) - ix(r, j)); | ^~~~~
s665675342
p03866
C++
#include <iostream> #include <iomanip> #include <string> #include <algorithm> #include <vector> #include <queue> #include <cmath> #include <limits> #define REP(i,n) for(int i=0;i<(n);++i) using namespace std; typedef long long LL; double calc_dist(double Xa, double Ya, double Ra, double Xb, double Yb, double Rb) { double dX = Xa - Xb, dY = Ya - Yb; return max(sqrt(dX * dX + dY * dY) - Ra - Rb, 0.0); } int main() { double Xs, Ys, Xt, Yt; cin >> Xs >> Ys >> Xt >> Yt; int N; cin >> N; vector<double> X(N), Y(N), R(N), dist(N); bool visited(N, false); priority_queue<pair<double,int>> q; REP(i, N) { cin >> X[i] >> Y[i] >> R[i]; double d = calc_dist(Xs, Ys, 0, X[i], Y[i], R[i]); dist[i] = d; q.push(make_pair(d, i)); } while(!q.empty()) { auto item = q.top(); q.pop(); double td = item.first; int idx = item.second; if(td > dist[idx]) continue; visited[idx] = true; REP(i, N) { if(visited[i]) continue; double newdist = td + calc_dist(X[idx], Y[idx], R[idx], X[i], Y[i], R[i]); if(newdist < dist[i]) { dist[i] = newdist; q.push(make_pair(newdist, i)); } } } double ret = calc_dist(Xt, Yt, 0, Xs, Ys, 0); REP(i, N) { double newdist = dist[i] + calc_dist(Xt, Yt, 0, X[i], Y[i], R[i]); ret = min(ret, newdist); } cout << fixed << setprecision(9) << ret << endl; }
a.cc: In function 'int main()': a.cc:24:24: error: expression list treated as compound expression in initializer [-fpermissive] 24 | bool visited(N, false); | ^ a.cc:38:12: error: invalid types 'bool[int]' for array subscript 38 | visited[idx] = true; | ^ a.cc:40:17: error: invalid types 'bool[int]' for array subscript 40 | if(visited[i]) continue; | ^
s763565639
p03866
C++
#include <bits/stdc++.h> #include <boost/range/algorithm.hpp> #include <boost/range/numeric.hpp> #include <boost/range/irange.hpp> #include <boost/range/adaptor/indexed.hpp> #define FOR(i,k,n) for(int i = (k);i < (n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(x) begin(x),end(x) using namespace std; using namespace boost::adaptors; using namespace std::string_literals; using ll = int64_t; using vecint = vector<int>; using vecll = vector<ll>; using boost::irange; using Weight = double; using Data = pair<Weight,int>; // enable reduce struct Heap { shared_ptr<Heap> l,r,p; Data val; Heap(Data v) : val(v) {} Data top() { return val; } }; shared_ptr<Heap> meld( shared_ptr<Heap> a, shared_ptr<Heap> b, shared_ptr<Heap> p = nullptr) { if (!a) { if (b) b->p = p; return b; } if (!b) { if (a) a->p = p; return a; } if (a->val > b->val) swap(a, b); a->p = p; a->r = meld(a->r, b, a); swap(a->l, a->r); return a; } pair<shared_ptr<Heap>, shared_ptr<Heap>> push(shared_ptr<Heap> h, Data v) { auto n = make_shared<Heap>(v); return make_pair(meld(h, n), n); } shared_ptr<Heap> pop(shared_ptr<Heap> h) { if (h->l) h->l->p.reset(); if (h->r) h->r->p.reset(); return meld(h->l, h->r); } shared_ptr<Heap> reduce(shared_ptr<Heap> h, shared_ptr<Heap> root, Data v) { if (v > h->val) return root; h->val = v; if (!h->p) return root; if (h->val < h->p->val) { if (h->p->l && h->p->l == h) { h->p->l.reset(); return meld(h, root); } else { h->p->r.reset(); return meld(h, root); } } else return root; } Weight INF = 1e18; struct Edge{ int src, dest; Weight weight; bool operator < (const Edge &rhs) const {return weight > rhs.weight;} }; using Edges = vector<Edge>; using Graph = vector<Edges>; using Array = vector<Weight>; using Matrix = vector<Array>; void add_edge(Graph &g, int src, int dest, Weight weight) { g[src].push_back((Edge){src, dest, weight}); g[dest].push_back((Edge){dest, src, weight}); } //O(V)-space dijkstra //G: function object template<typename G> void dijkstra(G &g, Array &d, int s) { int n=g.size(); d.assign(n, INF); d[s] = 0; shared_ptr<Heap> que; vector<shared_ptr<Heap>> nodes(n); auto p = push(que, Data(0, s)); que = p.first; nodes[s] = p.second; while (que) { Weight dist = que->top().first; int v = que->top().second; que = pop(que); nodes[v].reset(); if (d[v] < dist) continue; REP(i, g[v].size()) { Edge e = g[v][i]; if (d[e.dest] > d[v] + e.weight) { d[e.dest] = d[v] + e.weight; if (!nodes[e.dest]) { auto p = push(que, Data(d[e.dest], e.dest)); que = p.first; nodes[e.dest] = p.second; } else { que = reduce(nodes[e.dest], que, Data(d[e.dest], e.dest)); } } } } } int main() { ios::sync_with_stdio(false); cin.tie(0); using C = tuple<ll,ll,ll>; vector<C> vc; ll xs,ys,xt,yt; cin>>xs>>ys>>xt>>yt; vc.emplace_back(xs,ys,0); vc.emplace_back(xt,yt,0); int n; cin>>n; REP(i,n) { ll x,y,r; cin>>x>>y>>r; vc.emplace_back(x,y,r); } n += 2; Graph g(n); REP(i,n)REP(j,n) { if (i == j) continue; ll x0,y0,r0,x1,y1,r1; tie(x0,y0,r0) = vc[i]; tie(x1,y1,r1) = vc[j]; double d = max(0., sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1)) - r0 - r1); g[i].push_back(Edge{i,j,d}); } Array dist; dijkstra(g, dist, 0); cout << fixed << setprecision(10) << dist[1] << endl; return 0; }
a.cc:2:10: fatal error: boost/range/algorithm.hpp: No such file or directory 2 | #include <boost/range/algorithm.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s845349896
p03866
Java
import java.util.*; import java.io.*; import java.math.*; public class Main { static boolean DEBUG; public static void main(String[] args) { DEBUG = args.length > 0 && args[0].equals("-DEBUG"); Solver solver = new Solver(); solver.solve(); solver.exit(); } static class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if(ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if(buflen <= 0) { return false; } } return true; } private int readByte() { if(hasNextByte()) return buffer[ptr++]; else return -1;} private boolean isPrintableChar(int c) { return 33 <= c && c <= 126;} private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;} public boolean hasNext() { skipUnprintable(); return hasNextByte();} public String next() { if(!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while(isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if(!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if(b == '-') { minus = true; b = readByte(); } if(b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } } } static class Solver { FastScanner sc = new FastScanner(); public Solver() { } String ns() { return sc.next(); } String[] ns(int n) { String a[] = new String[n]; for(int i = 0; i < n; i ++) { a[i] = ns(); } return a; } String[][] ns(int n, int m) { String a[][] = new String[n][m]; for(int i = 0; i < n; i ++) { a[i] = ns(m); } return a; } char[] nc(int n) { String str = ns(); char a[] = new char[max(n, str.length())]; for(int i = 0; i < str.length(); i ++) { a[i] = str.charAt(i); } return a; } char[][] nc(int n, int m) { char a[][] = new char[n][m]; for(int i = 0; i < n; i ++) { a[i] = nc(m); } return a; } boolean[] nb(int n, char t) { char c[] = nc(-1); if(n < 0) n = c.length; boolean a[] = new boolean[n]; for(int i = 0; i < n; i ++) { a[i] = c[i] == t; } return a; } boolean[][] nb(int n, int m, char t) { boolean a[][] = new boolean[n][m]; for(int i = 0; i < n; i ++) { a[i] = nb(m, t); } return a; } int ni() { return (int)sc.nextLong(); } int[] ni(int n) { int a[] = new int[n]; for(int i = 0; i < n; i ++) { a[i] = ni(); } return a; } int[][] ni(int n, int m) { int a[][] = new int[n][m]; for(int i = 0; i < n; i ++) { a[i] = ni(m); } return a; } long nl() { return sc.nextLong(); } long[] nl(int n) { long a[] = new long[n]; for(int i = 0; i < n; i ++) { a[i] = nl(); } return a; } long[][] nl(int n, int m) { long a[][] = new long[n][m]; for(int i = 0; i < n; i ++) { a[i] = nl(m); } return a; } double nd() { return Double.parseDouble(sc.next()); } double[] nd(int n) { double a[] = new double[n]; for(int i = 0; i < n; i ++) { a[i] = nd(); } return a; } double[][] nd(int n, int m) { double a[][] = new double[n][m]; for(int i = 0; i < n; i ++) { a[i] = nd(m); } return a; } PrintWriter out = new PrintWriter(System.out); PrintWriter err = new PrintWriter(System.err); void prt() { out.print(""); } <T> void prt(T a) { out.print(a); } void prtln() { out.println(""); } <T> void prtln(T a) { out.println(a); } void prtln(int... a) { StringBuilder sb = new StringBuilder(); for(int element : a){ sb.append(element+" "); } prtln(sb.toString().trim()); } void prtln(long... a) { StringBuilder sb = new StringBuilder(); for(long element : a){ sb.append(element+" "); } prtln(sb.toString().trim()); } void prtln(double... a) { StringBuilder sb = new StringBuilder(); for(double element : a){ sb.append(element+" "); } prtln(sb.toString().trim()); } void prtln(String... a) { StringBuilder sb = new StringBuilder(); for(String element : a){ sb.append(element+" "); } prtln(sb.toString().trim()); } void prtln(char... a) { StringBuilder sb = new StringBuilder(); for(char element : a){ sb.append(element); } prtln(sb.toString().trim()); } void prtln(int[][] a) { for(int[] element : a){ prtln(element); } } void prtln(long[][] a) { for(long[] element : a){ prtln(element); } } void prtln(double[][] a) { for(double[] element : a){ prtln(element); } } void prtln(String[][] a) { for(String[] element : a){ prtln(element); } } void prtln(char[][] a) { for(char[] element : a){ prtln(element); } } String errconvert(int a) { return isINF(a) ? "_" : String.valueOf(a); } String errconvert(long a) { return isINF(a) ? "_" : String.valueOf(a); } void errprt(int a) { if(DEBUG) { err.print(errconvert(a)); } } void errprt(long a) { if(DEBUG) { err.print(errconvert(a)); } } void errprt() { if(DEBUG) { err.print(""); } } <T> void errprt(T a) { if(DEBUG) { err.print(a); } } void errprt(boolean a) { if(DEBUG) { errprt(a ? "#" : "."); } } void errprtln() { if(DEBUG) { err.println(""); } } void errprtln(int a) { if(DEBUG) { err.println(errconvert(a)); } } void errprtln(long a) { if(DEBUG) { err.println(errconvert(a)); } } <T> void errprtln(T a) { if(DEBUG) { err.println(a); } } void errprtln(boolean a) { if(DEBUG) { errprtln(a ? "#" : "."); } } void errprtln(int... a) { if(DEBUG) { StringBuilder sb = new StringBuilder(); for(int element : a){ sb.append(errconvert(element)+" "); } errprtln(sb.toString().trim()); } } void errprtln(long... a) { if(DEBUG) { StringBuilder sb = new StringBuilder(); for(long element : a){ sb.append(errconvert(element)+" "); } errprtln(sb.toString().trim()); } } void errprtln(double... a) { if(DEBUG) { StringBuilder sb = new StringBuilder(); for(double element : a){ sb.append(element+" "); } errprtln(sb.toString().trim()); } } void errprtln(String... a) { if(DEBUG) { StringBuilder sb = new StringBuilder(); for(String element : a){ sb.append(element+" "); } errprtln(sb.toString().trim()); } } void errprtln(char... a) { if(DEBUG) { StringBuilder sb = new StringBuilder(); for(char element : a){ sb.append(element); } errprtln(sb.toString().trim()); } } void errprtln(boolean... a) { if(DEBUG) { StringBuilder sb = new StringBuilder(); for(boolean element : a){ sb.append((element ? "#" : ".")+" "); } errprtln(sb.toString().trim()); } } void errprtln(int[][] a) { if(DEBUG) { for(int[] element : a){ errprtln(element); } } } void errprtln(long[][] a) { if(DEBUG) { for(long[] element : a){ errprtln(element); } } } void errprtln(double[][] a) { if(DEBUG) { for(double[] element : a){ errprtln(element); } } } void errprtln(String[][] a) { if(DEBUG) { for(String[] element : a){ errprtln(element); } } } void errprtln(char[][] a) { if(DEBUG) { for(char[] element : a){ errprtln(element); } } } void errprtln(boolean[][] a) { if(DEBUG) { for(boolean[] element : a){ errprtln(element); } } } void reply(boolean b) { prtln(b ? "Yes" : "No"); } void REPLY(boolean b) { prtln(b ? "YES" : "NO"); } void flush() { out.flush(); if(DEBUG) { err.flush(); } } void exit() { flush(); System.exit(0); } void assertion(boolean b) { if(!b) throw new AssertionError(); } int min(int a, int b) { return Math.min(a, b); } long min(long a, long b) { return Math.min(a, b); } double min(double a, double b) { return Math.min(a, b); } int min(int... x) { int min = x[0]; for(int val : x) { min = min(min, val); } return min; } long min(long... x) { long min = x[0]; for(long val : x) { min = min(min, val); } return min; } double min(double... x) { double min = x[0]; for(double val : x) { min = min(min, val); } return min; } int max(int a, int b) { return Math.max(a, b); } long max(long a, long b) { return Math.max(a, b); } double max(double a, double b) { return Math.max(a, b); } int max(int... x) { int max = x[0]; for(int val : x) { max = max(max, val); } return max; } long max(long... x) { long max = x[0]; for(long val : x) { max = max(max, val); } return max; } double max(double... x) { double max = x[0]; for(double val : x) { max = max(max, val); } return max; } long sum(int... a) { long sum = 0; for(int element : a) { sum += element; } return sum; } long sum(long... a) { long sum = 0; for(long element : a) { sum += element; } return sum; } double sum(double... a) { double sum = 0; for(double element : a) { sum += element; } return sum; } long[] sums(int[] a) { long sum[] = new long[a.length + 1]; sum[0] = 0; for(int i = 0; i < a.length; i ++) { sum[i + 1] = sum[i] + a[i]; } return sum; } long[] sums(long[] a) { long sum[] = new long[a.length + 1]; sum[0] = 0; for(int i = 0; i < a.length; i ++) { sum[i + 1] = sum[i] + a[i]; } return sum; } double[] sums(double[] a) { double sum[] = new double[a.length + 1]; sum[0] = 0; for(int i = 0; i < a.length; i ++) { sum[i + 1] = sum[i] + a[i]; } return sum; } int abs(int x) { return x >= 0 ? x : - x; } long abs(long x) { return x >= 0 ? x : - x; } double abs(double x) { return x >= 0 ? x : - x; } int signum(int x) { return x > 0 ? 1 : x < 0 ? -1 : 0; } int signum(long x) { return x > 0 ? 1 : x < 0 ? -1 : 0; } int signum(double x) { return x > 0 ? 1 : x < 0 ? -1 : 0; } long round(double x) { return Math.round(x); } long floor(double x) { return (long)Math.floor(x); } int divfloor(int a, int b) { return signum(a) == signum(b) ? a / b : - divceil(abs(a), abs(b)); } long divfloor(long a, long b) { return signum(a) == signum(b) ? a / b : - divceil(abs(a), abs(b)); } long ceil(double x) { return (long)Math.ceil(x); } int divceil(int a, int b) { return a >= 0 && b > 0 ? (a + b - 1) / b : a < 0 && b < 0 ? divceil(abs(a), abs(b)) : - divfloor(abs(a), abs(b)); } long divceil(long a, long b) { return a >= 0 && b > 0 ? (a + b - 1) / b : a < 0 && b < 0 ? divceil(abs(a), abs(b)) : - divfloor(abs(a), abs(b)); } double sqrt(int x) { return Math.sqrt((double)x); } double sqrt(long x) { return Math.sqrt((double)x); } double sqrt(double x) { return Math.sqrt(x); } double pow(double x, double y) { return Math.pow(x, y); } long pow(long x, long y) { if(y == 0) { return 1; }else { long tmp = pow(x, y / 2); return tmp * tmp * (y % 2 == 0 ? 1 : x); } } int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); } long lcm(long a, long b) { return a / gcd(a, b) * b; } int gcd(int[] array) { int gcd = 0; for(int i = 0; i < array.length; i ++) { gcd = gcd(gcd, array[i]); } return gcd; } long gcd(long[] array) { long gcd = 0; for(int i = 0; i < array.length; i ++) { gcd = gcd(gcd, array[i]); } return gcd; } int upperToInt(char a) { return a - 'A'; } int lowerToInt(char a) { return a - 'a'; } int numToInt(char a) { return a - '0'; } int charToInt(char a) { return a >= 'a' ? lowerToInt(a) : a >= 'A' ? upperToInt(a) : numToInt(a); } char intToUpper(int a) { return (char)(a + 'A'); } char intToLower(int a) { return (char)(a + 'a'); } char intToNum(int a) { return (char)(a + '0'); } int[] charToInt(char[] a) { int array[] = new int[a.length]; for(int i = 0; i < a.length; i ++) { array[i] = charToInt(a[i]); } return array; } long[] div(long a) { List<Long> divList = new ArrayList<Long>(); for(long i = 1; i * i <= a; i ++) { if(a % i == 0) { divList.add(i); if(i * i != a) { divList.add(a / i); }; } } long div[] = new long[divList.size()]; for(int i = 0; i < divList.size(); i ++) { div[i] = divList.get(i); } return div; } long[][] factor(long a) { List<Long> factorList = new ArrayList<Long>(); List<Long> degreeList = new ArrayList<Long>(); for(long i = 2; i * i <= a; i ++) { if(a % i == 0) { long count = 0; while(a % i == 0) { a /= i; count ++; } factorList.add(i); degreeList.add(count); } } if(a > 1) { factorList.add(a); degreeList.add(1L); } long factor[][] = new long[factorList.size()][2]; for(int i = 0; i < factorList.size(); i ++) { factor[i][0] = factorList.get(i); factor[i][1] = degreeList.get(i); } Arrays.sort(factor, (sort1, sort2) -> Long.compare(sort1[0], sort2[0])); return factor; } boolean isPrime(long x) { boolean ok = x > 1; for(long i = 2; i * i <= x; i ++) { ok &= x % i != 0; if(!ok) return ok; } return ok; } boolean[] prime(int num) { boolean prime[] = new boolean[num]; fill(prime, true); prime[0] = false; prime[1] = false; for(int i = 2; i < num; i ++) { if(prime[i]) { for(int j = 2; i * j < num; j ++) { prime[i * j] = false; } } } return prime; } long[][] countElements(long[] a, boolean sort) { int len = a.length; long array[] = new long[len]; for(int i = 0; i < len; i ++) { array[i] = a[i]; } if(sort) { Arrays.sort(array); } List<Long> elem = new ArrayList<Long>(); List<Long> cnt = new ArrayList<Long>(); long tmp = 1; for(int i = 1; i <= len; i ++) { if(i == len || array[i] != array[i - 1]) { elem.add(array[i - 1]); cnt.add(tmp); tmp = 1; }else { tmp ++; } } long counts[][] = new long[elem.size()][2]; for(int i = 0; i < elem.size(); i ++) { counts[i][0] = elem.get(i); counts[i][1] = cnt.get(i); } return counts; } long[][] countElements(String str, boolean sort) { int len = str.length(); char array[] = str.toCharArray(); if(sort) { Arrays.sort(array); } List<Long> elem = new ArrayList<Long>(); List<Long> cnt = new ArrayList<Long>(); long tmp = 1; for(int i = 1; i <= len; i ++) { if(i == len || array[i] != array[i - 1]) { elem.add((long)array[i - 1]); cnt.add(tmp); tmp = 1; }else { tmp ++; } } long counts[][] = new long[elem.size()][2]; for(int i = 0; i < elem.size(); i ++) { counts[i][0] = elem.get(i); counts[i][1] = cnt.get(i); } return counts; } int[] baseConvert(long x, int n) { long tmp = x; int len = 0; while(tmp > 0) { tmp /= n; len ++; } int digit[] = new int[len]; int i = 0; tmp = x; while(tmp > 0) { digit[i ++] = (int)(tmp % n); tmp /= n; } return digit; } int[] baseConvert(int x, int n) { int tmp = x; int len = 0; while(tmp > 0) { tmp /= n; len ++; } int digit[] = new int[len]; int i = 0; tmp = x; while(tmp > 0) { digit[i ++] = (int)(tmp % n); tmp /= n; } return digit; } int numDigits(long a) { return Long.toString(a).length(); } long bitFlag(int a) { return 1L << (long)a; } boolean isFlagged(long x, int a) { return (x & bitFlag(a)) != 0; } long countString(String str, String a) { return (str.length() - str.replace(a, "").length()) / a.length(); } long countStringAll(String str, String a) { return str.length() - str.replaceAll(a, "").length(); } int lowerBound(long[] array, long key) { return BS(array, key, true, true, true); } int lowerBound(long[] array, long key, int ng, int ok) { return BS(array, key, true, true, true, ng, ok); } int upperBound(long[] array, long key) { return BS(array, key, true, true, false); } int upperBound(long[] array, long key, int ng, int ok) { return BS(array, key, true, true, false, ng, ok); } int cntBS(long[] array, long key, boolean ascending, boolean greater, boolean equals) { return BS(array, key, ascending, greater, equals, true); } int cntBS(long[] array, long key, boolean ascending, boolean greater, boolean equals, int ng, int ok) { return BS(array, key, ascending, greater, equals, true, ng, ok); } int BS(long[] array, long key, boolean ascending, boolean greater, boolean equals) { return BS(array, key, ascending, greater, equals, false); } int BS(long[] array, long key, boolean ascending, boolean greater, boolean equals, int ng, int ok) { return BS(array, key, ascending, greater, equals, false, ng, ok); } int BS(long[] array, long key, boolean ascending, boolean greater, boolean equals, boolean count) { int ng = ascending ^ greater ? array.length : -1; int ok = ascending ^ greater ? -1 : array.length; return BS(array, key, ascending, greater, equals, count, ng, ok); } int BS(long[] array, long key, boolean ascending, boolean greater, boolean equals, boolean count, int ng, int ok) { int index = binarySearch(array, key, greater, equals, ng, ok); return count ? (int)abs(ok - index) : index; } int binarySearch(long[] array, long key, boolean greater, boolean equals, int ng, int ok) { while (abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if(isOKforBinarySearch(array, mid, key, greater, equals)) { ok = mid; }else { ng = mid; } } return ok; } boolean isOKforBinarySearch(long[] array, int index, long key, boolean greater, boolean equals) { return (array[index] > key && greater) || (array[index] < key && !greater) || (array[index] == key && equals); } void reverse(String[] array) { String reversed[] = new String[array.length]; for(int i = 0; i < array.length; i ++) { reversed[array.length - i - 1] = array[i]; } for(int i = 0; i < array.length; i ++) { array[i] = reversed[i]; } } void reverse(int[] array) { int reversed[] = new int[array.length]; for(int i = 0; i < array.length; i ++) { reversed[array.length - i - 1] = array[i]; } for(int i = 0; i < array.length; i ++) { array[i] = reversed[i]; } } void reverse(long[] array) { long reversed[] = new long[array.length]; for(int i = 0; i < array.length; i ++) { reversed[array.length - i - 1] = array[i]; } for(int i = 0; i < array.length; i ++) { array[i] = reversed[i]; } } void reverse(double[] array) { double reversed[] = new double[array.length]; for(int i = 0; i < array.length; i ++) { reversed[array.length - i - 1] = array[i]; } for(int i = 0; i < array.length; i ++) { array[i] = reversed[i]; } } void reverse(boolean[] array) { boolean reversed[] = new boolean[array.length]; for(int i = 0; i < array.length; i ++) { reversed[array.length - i - 1] = array[i]; } for(int i = 0; i < array.length; i ++) { array[i] = reversed[i]; } } void reverse(Object[] array) { Object reversed[] = new Object[array.length]; for(int i = 0; i < array.length; i ++) { reversed[array.length - i - 1] = array[i]; } for(int i = 0; i < array.length; i ++) { array[i] = reversed[i]; } } void fill(int[] array, int x) { Arrays.fill(array, x); } void fill(long[] array, long x) { Arrays.fill(array, x); } void fill(double[] array, double x) { Arrays.fill(array, x); } void fill(boolean[] array, boolean x) { Arrays.fill(array, x); } void fill(int[][] array, int x) { for(int[] a : array) { fill(a, x); } } void fill(long[][] array, long x) { for(long[] a : array) { fill(a, x); } } void fill(double[][] array, double x) { for(double[] a : array) { fill(a, x); } } void fill(boolean[][] array, boolean x) { for(boolean[] a : array) { fill(a, x); } } void fill(int[][][] array, int x) { for(int[][] a : array) { fill(a, x); } } void fill(long[][][] array, long x) { for(long[][] a : array) { fill(a, x); } } void fill(double[][][] array, double x) { for(double[][] a : array) { fill(a, x); } } void fill(boolean[][][] array, boolean x) { for(boolean[][] a : array) { fill(a, x); } } void shuffleArray(int[] array){ int n = array.length; Random rnd = new Random(); for(int i = 0; i < n; i ++){ int tmp = array[i]; int randomPos = i + rnd.nextInt(n - i); array[i] = array[randomPos]; array[randomPos] = tmp; } } void shuffleArray(long[] array){ int n = array.length; Random rnd = new Random(); for(int i = 0; i < n; i ++){ long tmp = array[i]; int randomPos = i + rnd.nextInt(n - i); array[i] = array[randomPos]; array[randomPos] = tmp; } } void shuffleArray(double[] array){ int n = array.length; Random rnd = new Random(); for(int i = 0; i < n; i ++){ double tmp = array[i]; int randomPos = i + rnd.nextInt(n - i); array[i] = array[randomPos]; array[randomPos] = tmp; } } void swap(int[] array, int i, int j) { int tmp = array[i]; array[i] = array[j]; array[j] = tmp; } void swap(long[] array, int i, int j) { long tmp = array[i]; array[i] = array[j]; array[j] = tmp; } void swap(double[] array, int i, int j) { double tmp = array[i]; array[i] = array[j]; array[j] = tmp; } long INF = (long)1e18 + 7; boolean isINF(long a) { return abs(a) > INF / 1000; } boolean isPlusINF(long a) { return a > 0 && isINF(a); } boolean isMinusINF(long a) { return isPlusINF(- a); } int I_INF = (int)1e9 + 7; boolean isINF(int a) { return abs(a) > I_INF / 1000; } boolean isPlusINF(int a) { return a > 0 && isINF(a); } boolean isMinusINF(int a) { return isPlusINF(- a); } // mods long MOD = (long)1e9 + 7; // 998244353; public long mod(long i) { i %= MOD; return i + (i < 0 ? MOD : 0); } long pow_m(long x, long y) { if(y == 0) { return 1; }else { long tmp = pow_m(x, y / 2); return mod(mod(tmp * tmp) * (y % 2 == 0 ? 1 : x)); } } long[] pows_m(long x, int max) { long pow[] = new long[max + 1]; pow[0] = 1; for(int i = 0; i < max; i ++) { pow[i + 1] = mod(pow[i] * x); } return pow; } int MAX_INV_SIZE = 100_100; HashMap<Long, Long> invMap = new HashMap<>(); long inv(long x) { x = mod(x); if(invMap.containsKey(x)) { return invMap.get(x); } if(invMap.size() >= MAX_INV_SIZE) { return calInv(x); } invMap.put(x, calInv(x)); return invMap.get(x); } long calInv(long x) { return pow_m(x, MOD - 2); } int MAX_FACT = 5_000_100; long fact[]; long invFact[]; boolean isFactPrepared = false; HashMap<Integer, long[]> factMap; void prepareFact() { fact = new long[MAX_FACT]; Arrays.fill(fact, 0); invFact = new long[MAX_FACT]; Arrays.fill(invFact, 0); fact[0] = 1; int maxIndex = min(MAX_FACT, (int)MOD); for(int i = 1; i < maxIndex; i ++) { fact[i] = mod(fact[i - 1] * i); } invFact[maxIndex - 1] = inv(fact[maxIndex - 1]); for(int i = maxIndex - 1; i > 0; i --) { invFact[i - 1] = mod(invFact[i] * i); } factMap = new HashMap<>(); isFactPrepared = true; } long P(int n, int r) { if(!isFactPrepared) { prepareFact(); } if(n < 0 || r < 0 || n < r) { return 0; } if(n >= MAX_FACT) { if(!factMap.containsKey(n)) { long largeFact[] = new long[MAX_FACT]; factMap.put(n, largeFact); fill(largeFact, -INF); largeFact[0] = 1; } long largeFact[] = factMap.get(n); int i = r; while(isINF(largeFact[i])) { i --; } for(; i < r; i ++) { largeFact[i + 1] = mod(largeFact[i] * (n - i)); } return largeFact[r]; } return mod(fact[n] * invFact[n - r]); } long C(int n, int r) { if(!isFactPrepared) { prepareFact(); } if(n < 0 || r < 0 || n < r) { return 0; } return mod(P(n, r) * invFact[r]); } long H(int n, int r) { return C((n - 1) + r, r); } // grid class Grids { int h; int w; Grid[][] gs; Grids(int h, int w) { this.h = h; this.w = w; gs = new Grid[h][w]; for(int i = 0; i < h; i ++) { for(int j = 0; j < w; j ++) { gs[i][j] = new Grid(i, j, h, w); } } } void init(boolean[][] b) { for(int i = 0; i < h; i ++) { for(int j = 0; j < w; j ++) { gs[i][j].b = b[i][j]; } } } void init(long[][] val) { for(int i = 0; i < h; i ++) { for(int j = 0; j < w; j ++) { gs[i][j].val = val[i][j]; } } } int dx[] = {0, -1, 1, 0, 0, -1, 1, -1, 1}; int dy[] = {0, 0, 0, -1, 1, -1, -1, 1, 1}; Grid next(Grid g, int i) { return isValid(g.x + dx[i], g.y + dy[i], g.h, g.w) ? gs[g.x + dx[i]][g.y + dy[i]] : null; } } class Grid implements Comparable<Grid> { int x; int y; int h; int w; int i; boolean b; long val; Grid() { } Grid(int x, int y, int h, int w) { init(x, y, h, w, false, 0); } Grid(int x, int y, int h, int w, boolean b) { init(x, y, h, w, b, 0); } Grid(int x, int y, int h, int w, long val) { init(x, y, h, w, false, val); } Grid(int x, int y, int h, int w, boolean b, long val) { init(x, y, h, w, b, val); } void init(int x, int y, int h, int w, boolean b, long val) { this.x = x; this.y = y; this.h = h; this.w = w; this.b = b; this.val = val; i = x * w + y; } @Override public int compareTo(Grid g) { return Long.compare(this.val, g.val); } } boolean isValid(int x, int y, int h, int w) { return x >= 0 && x < h && y >= 0 && y < w; } boolean isValid(Grid g) { return isValid(g.x, g.y, g.h, g.w); } // graph class Graph { int numNode; int numEdge; boolean directed; Edge edges[]; Node nodes[]; Node reversedNodes[]; Graph(int numNode, int numEdge, boolean directed) { this.numNode = numNode; this.numEdge = numEdge; this.directed = directed; nodes = new Node[numNode]; reversedNodes = new Node[numNode]; for(int i = 0; i < numNode; i ++) { nodes[i] = new Node(i); reversedNodes[i] = new Node(i); } } void init(Edge[] edges) { this.edges = edges; for(Edge edge : edges) { nodes[edge.source].add(edge.target, edge.cost); if(directed) { reversedNodes[edge.target].add(edge.source, edge.cost); }else { nodes[edge.target].add(edge.source, edge.cost); } } } void clearNodes() { for(Node n : nodes) { n.clear(); } for(Node n : reversedNodes) { n.clear(); } } } class Node extends ArrayList<Edge> { int id; Node(int id) { this.id = id; } void add(int target, long cost) { add(new Edge(id, target, cost)); } } class Edge implements Comparable<Edge> { int source; int target; long cost; Edge(int source, int target, long cost) { this.source = source; this.target = target; this.cost = cost; } @Override public int compareTo(Edge e) { return Long.compare(this.cost, e.cost); } } public void solve() { int x = 1000000000000; prtln(x); } } }
Main.java:888: error: integer number too large int x = 1000000000000; ^ 1 error
s767648292
p03866
Java
import java.io.Serializable; import java.util.AbstractCollection; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.ConcurrentModificationException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { new Main(); } private class Vertex { final int x, y, r; public Vertex(int x, int y, int r) { this.x = x; this.y = y; this.r = r; } } private class Edge{ public final int src, dest; public final double distance; public Edge(int src, int dest, ArrayList<Vertex> vertex) { this.src = src; this.dest = dest; Vertex s = vertex.get(src), d = vertex.get(dest); distance = Math.max(0, Math.sqrt((long)(d.x - s.x) * (d.x - s.x) + (long)(d.y - s.y) * (d.y - s.y)) - s.r - d.r); } public final double distance() { return distance; } } public Main() { try (Scanner sc = new Scanner(System.in)){ ArrayList<Vertex> vertex = new ArrayList<>(); vertex.add(new Vertex(sc.nextInt(), sc.nextInt(), 0)); vertex.add(new Vertex(sc.nextInt(), sc.nextInt(), 0)); int N = sc.nextInt(); while(N --> 0) vertex.add(new Vertex(sc.nextInt(), sc.nextInt(), sc.nextInt())); ArrayList<ArrayList<Edge>> graph = new ArrayList<>(vertex.size()); for (int i = 0;i < vertex.size();++ i) { graph.add(new ArrayList<>(vertex.size())); for (int j = 0;j < vertex.size();++ j) if (i != j) graph.get(i).add(new Edge(i, j, vertex)); } double[] dist = dijkstra(0, graph); System.out.println(dist[1]); } } public double[] dijkstra(int start, ArrayList<ArrayList<Edge>> graph) { double[] dist = new double[graph.size()]; boolean[] visited = new double[graph.size()]; Arrays.fill(dist, Double.MAX_VALUE); Arrays.fill(visited, false); dist[start] = 0; Heap<Integer, Double> heap = BinaryHeap.create(graph.size()); heap.put(start, 0.); final double EPS = 1e-10; while(!heap.isEmpty()) { int put = heap.poll(); if (visited[put]) continue; visited[put] = true; for (Edge i : graph.get(put)) { double nextDistance = dist[put] + i.distance(); if (dist[i.dest] > nextDistance + EPS) { dist[i.dest] = nextDistance; heap.put(i.dest, nextDistance); } } } return dist; } // 以下、ライブラリ /** * * @author 31536000 * 優先度が最小のものを高速に取り出すことのできるコレクションです。 * ヒープには、同一の要素を複数登録することができません。 * 各要素は設定した優先度の{@link Comparable 自然順序付け}に従って、あるいはヒープ構築時に提供される{@link Comparator}で順序付けされます。 * <p> * このヒープの先頭は、指定された順序付けの最小要素です。 * 複数の要素が最小の値に結び付けられている場合、先頭はこれらの要素の1つになります。 * 結付きの解除は任意です。 * ヒープの取得オペレーションpeek、pollは、ヒープの先頭の要素にアクセスします。 * ヒープの実装では、要素の追加、要素の優先度の変更、先頭の値の操作は高速であることが要求されます。 * * @param <E> このコレクション内に保持される要素の型 * @param <P> 要素の大小関係を決定する型 */ public interface Heap<E, P> extends Map<E, P>{ /** * 指定された要素をこの優先度で追加します。 * ヒープに既にこの要素が存在している場合、新たに要素を追加することはせず、優先度のみを変更します。 * @param element 追加する要素 * @param priority 要素の優先度 * @return この要素が以前に設定されていた優先度。ヒープに新たにこの要素が追加された場合はnull。 * @exception ClassCastException 指定された優先度と、このヒープ内に現在存在している優先度との比較を、このヒープの順序付けに従って行えない場合 * @exception NullPointerException 指定された優先度がnullである場合 */ @Override public P put(E element, P priority); /** * このヒープ内の要素を順序付けするために使うコンパレータを返します。 * ただし、このヒープがその優先度の自然順序付けに従ってソートされる場合はnullを返します。 * @return このヒープを順序付けするのに使うコンパレータ。ただし、このヒープがその優先度の自然順序付けに従ってソートされる場合はnull */ public Comparator<? super P> comparator(); /** * ヒープの先頭を取得しますが、削除しません。 * ヒープが空の場合はnullを返します。 * @return ヒープの先頭。ヒープが空の場合はnull */ public E peek(); /** * ヒープの先頭を取得および削除します。 * ヒープが空の場合はnullを返します。 * @return ヒープの先頭。ヒープが空の場合はnull */ public E poll(); /** * 指定されたヒープの全ての要素をこのヒープに移し替えます。 * この呼び出しの効果は、指定されたヒープを引数としてputAllを呼んだ後、指定されたヒープをclearするのと同じです。 * オペレーションの進行中に、指定されたヒープが変更された場合の、このオペレーションの動作は定義されていません。 * * @param heap このヒープに移し替えるヒープ * @exception ClassCastException 指定された優先度と、このヒープ内に現在存在している優先度との比較を、このヒープの順序付けに従って行えない場合 * @exception NullPointerException 指定されたヒープがnullである場合、またはこのヒープがnullの要素を許可せず、指定されたヒープにnullの要素が含まれている場合 * @exception IllegalArgumentException 指定されたヒープ内の要素または優先度のあるプロパティが原因で、このヒープにそれらを格納できない場合 */ public default void merge(Heap<E, P> heap) { for (E i : keySet()) put(i, heap.get(i)); heap.clear(); } } /** * Heapインターフェースの二分ヒープに基づく実装です。 * この実装は、null要素を使用できます。 * このクラスはヒープの順序を保証しません。 * 特に、その順序を常に一定に保つことを保証しません。 * <p> * <b>この実装はsynchronizedされません。</b> * 複数のスレッドが並行して二分ヒープにアクセスし、それらのスレッドの少なくとも1つが構造的にヒープを変更する場合は、外部でその同期をとる必要があります。 * 構造的な変更とは、1つ以上の要素を追加または削除するオペレーションのことです。 * すでにインスタンスに格納されている要素に設定された優先度を変更することは構造的な変更ではありません。 * これは通常、ヒープを自然にカプセル化する一部のオブジェクトでsynchronizedすることによって達成されます。 * <p> * このクラスの「コレクション・ビュー・メソッド」によって返されるイテレータはフェイルファストです。 * イテレータの作成後に、イテレータ自体のremoveメソッド以外の方法でマップが構造的に変更されると、イテレータは{@link ConcurrentModificationException}をスローします。 * このように、並行して変更が行われると、イテレータは、将来の予測できない時点において予測できない動作が発生する危険を回避するために、ただちにかつ手際よく例外をスローします。 * <p> * 通常、非同期の並行変更がある場合、確かな保証を行うことは不可能なので、イテレータのフェイルファストの動作を保証することはできません。 * フェイルファスト・イテレータは最善努力原則に基づき、ConcurrentModificationExceptionをスローします。 * したがって、正確を期すためにこの例外に依存するプログラムを書くことは誤りです。 * イテレータのフェイルファストの動作はバグを検出するためにのみ使用すべきです。 * * @author 31536000 * * @param <E> このヒープ内に保持される要素の型 * @param <P> 要素の大小関係を決定する型 */ public static class BinaryHeap<E, P> extends AbstractMap<E, P> implements Heap<E, P>, Cloneable, Serializable{ private static final long serialVersionUID = 4502431452720521563L; private class Entry implements Map.Entry<E, P>, Comparable<Entry>{ public final E element; public int index; public P priority; public Entry(E element, int index, P priority) { this.element = element; this.index = index; this.priority = priority; } @Override public int compareTo(Entry o) { return compare(priority, o.priority); } @Override public E getKey() { return element; } @Override public P getValue() { return priority; } @Override public P setValue(P value) { P last = priority; priority = value; set(index); return last; } } private final HashBiMap<E, Map.Entry<E, P>> map; private final ArrayList<Entry> heap; private final Comparator<? super P> comparator; @SuppressWarnings("unchecked") private BinaryHeap(BinaryHeap<E, P> heap) { map = (HashBiMap<E, Map.Entry<E, P>>) heap.map.clone(); this.heap = (ArrayList<Entry>) heap.heap.clone(); comparator = heap.comparator; } private BinaryHeap(int initialCapacity, Comparator<? super P> comparator) { this.comparator = comparator; heap = new ArrayList<>(initialCapacity); map = new HashBiMap<>(initialCapacity); } /** * {@link Comparable 自然順序付け}に従って要素を順序付けする、デフォルトの初期容量(11)を持つBinaryHeapを作成します。 * @return 作成されたBinaryHeap */ public static <E, P> BinaryHeap<E, P> create() { return new BinaryHeap<>(11, null); } /** * {@link Comparable 自然順序付け}に従って要素を順序付けする、指定された初期容量を持つBinaryHeapを作成します。 * @param initialCapacity この二分ヒープの初期容量 * @return 作成されたBinaryHeap * @exception IllegalArgumentException initialCapacityが1より小さい場合 */ public static <E, P> BinaryHeap<E, P> create(int initialCapacity) { if (initialCapacity < 1) throw new IllegalArgumentException(); return new BinaryHeap<>(initialCapacity, null); } /** * デフォルトの初期容量を持ち、指定されたコンパレータに従って要素が順序付けられるBinaryHeapを作成します。 * @param comparator この二分ヒープを順序付けするために使用されるコンパレータ。nullの場合、優先度の自然順序付けが使用される。 * @return 作成されたBinaryHeap */ public static <E, P> BinaryHeap<E, P> create(Comparator<? super P> comparator) { return new BinaryHeap<>(11, comparator); } /** * 指定されたコンパレータに従って優先度を順序付けする、指定された初期容量を持つPriorityQueueを作成します。 * @param initialCapacity この二分ヒープの初期容量 * @param comparator この二分ヒープを順序付けするために使用されるコンパレータ。nullの場合、優先度の自然順序付けが使用される。 * @return 作成されたBinaryHeap * @exception IllegalArgumentException initialCapacityが1より小さい場合 */ public static <E, P> BinaryHeap<E, P> create(int initialCapacity, Comparator<? super P> comparator) { if (initialCapacity < 1) throw new IllegalArgumentException(); return new BinaryHeap<>(initialCapacity, comparator); } /** * 指定されたヒープ内の要素を含むBinaryHeapを作成します。この二分ヒープの順序付けは、指定されたヒープと同じ順序付けに従って行われます。 * @param heap 要素がこの二分ヒープに配置されるヒープ * @return 作成されたBinaryHeap * @exception ClassCastException heapの要素をheapの順序付けに従って相互比較できない場合 * @exception NullPointerException 指定されたヒープまたはそのいずれかの要素がnullである場合 */ public static <E, P> BinaryHeap<E, P> create(Heap<E, P> heap) { if (heap == null) throw new NullPointerException(); if (heap instanceof BinaryHeap) return new BinaryHeap<>((BinaryHeap<E, P>)heap); BinaryHeap<E, P> ret = new BinaryHeap<>(heap.size(), heap.comparator()); ret.putAll(heap); return ret; } @SuppressWarnings("unchecked") private int compare(P l, P r) { return comparator() == null ? ((Comparable<P>) l).compareTo(r) : comparator().compare(l, r); } private Entry remove(int index) { Entry pop = heap.get(index); heap.set(index, heap.get(heap.size() - 1)); heap.get(index).index = index; heap.remove(heap.size() - 1); set(index); map.remove(pop.element); return pop; } private void set(int index) { while(index > 0) { int next = index >> 1; if (heap.get(next).compareTo(heap.get(index)) > 0) { Entry swap = heap.get(index); heap.set(index, heap.get(next)); heap.set(next, swap); swap.index = next; heap.get(index).index = index; } else break; } } @Override public Comparator<? super P> comparator() { return comparator; } @Override public E peek() { if (heap.isEmpty()) return null; return heap.get(0).element; } @Override public E poll() { if (heap.isEmpty()) return null; Entry poll = remove(0); return poll.element; } @Override public Set<Map.Entry<E, P>> entrySet() { return map.values(); } @Override public int size() { return map.size(); } @Override public boolean isEmpty() { return map.isEmpty(); } @Override public boolean containsKey(Object key) { return map.containsKey(key); } @Override public boolean containsValue(Object value) { if (value != null) { for (Map.Entry<E, P> i : map.values()) if (i.getValue().equals(value)) return true; }else { for (Map.Entry<E, P> i : map.values()) if (i.getValue() == null) return true; } return false; } @Override public P get(Object key) { Map.Entry<E, P> get = map.get(key); if (get != null) return get.getValue(); return null; } @Override public P remove(Object key) { Map.Entry<E, P> get = map.remove(key); if (get != null) return get.getValue(); return null; } @Override public void putAll(Map<? extends E, ? extends P> m) { for (Map.Entry<? extends E, ? extends P> i : m.entrySet()) put(i.getKey(), i.getValue()); } @Override public void clear() { map.clear(); } @Override public Set<E> keySet() { return map.keySet(); } private class Values extends AbstractCollection<P> implements Collection<P> { private Set<Map.Entry<E, P>> set = map.values(); @Override public int size() { return set.size(); } @Override public boolean isEmpty() { return set.isEmpty(); } @Override public boolean contains(Object o) { if (o == null) { for (Map.Entry<E, P> i : set) if (i.getValue() == null) return true; } else { for (Map.Entry<E, P> i : set) if (i.getValue().equals(o)) return true; } return false; } private class Iter implements Iterator<P> { private Iterator<Map.Entry<E, P>> iter = set.iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public P next() { return iter.next().getValue(); } } @Override public Iterator<P> iterator() { return new Iter(); } @Override public boolean remove(Object o) { if (o == null) { for (Iterator<Map.Entry<E, P>> iter = set.iterator();iter.hasNext();) { Map.Entry<E, P> i = iter.next(); if (i.getValue() == null) { iter.remove(); return true; } } } else { for (Iterator<Map.Entry<E, P>> iter = set.iterator();iter.hasNext();) { Map.Entry<E, P> i = iter.next(); if (i.getValue().equals(o)) { iter.remove(); return true; } } } return false; } @Override public void clear() { set.clear(); } } @Override public Collection<P> values() { return new Values(); } @Override public P put(E element, P priority) { Map.Entry<E, P> get = map.get(element); if (get == null) { Entry entry = new Entry(element, heap.size(), priority); heap.add(entry); set(entry.index); map.put(element, entry); return null; } Entry entry = (Entry) get; P ret = entry.priority; entry.priority = priority; set(entry.index); return ret; } @Override public Object clone() { return create(this); } } /** * 双方向マップは、その値とキーの一意性を保持するマップです。 * この制約により、双方向マップは「逆ビュー」をサポートできます。 * これは、この双方向マップと同じエントリを含み、逆のキーと値を持つ別の双方向マップです。 * @author 31536000 * * @param <K> このマップで保持されるキーの型 * @param <V> マップされる値の型 */ public interface BiMap<K, V> extends Map<K, V> { /** * 指定された値と指定されたキーをこのマップで関連付けます。 * マップにすでにこのキーに対するマッピングがある場合、古い値は指定された値に置き換えられます。 * {@link #containsKey(Object) m.containsKey(k)}がtrueを返す場合にかぎり、マップmはキーkのマッピングを含むと言えます。 * <br>この双方向マップでは、値の重複を許可しません。 * 従って、既に別のキーにvalueと同じ値が関連付けられている場合、そのキーを削除してからvalueと関連付けます。 * @param key 指定された値が関連付けられるキー * @param value 指定されたキーに関連付けられる値 * @return keyに以前に関連付けられていた値。keyのマッピングが存在しなかった場合はnull。 */ public V forcePut(K key, V value); /** * この双方向マップの逆ビューを返します。 * すなわち、この双方向マップの各値をキーにマッピングしたものを返します。 * 互いの双方向マップは連動しているので、片方に対する変更はもう片方の双方向マップに反映されます。 * @return この双方向マップの逆ビュー */ public BiMap<V, K> inverse(); /** * 指定された値と指定されたキーをこのマップで関連付けます。 * マップにすでにこのキーに対するマッピングがある場合、古い値は指定された値に置き換えられます。 * {@link #containsKey(Object) m.containsKey(k)}がtrueを返す場合にかぎり、マップmはキーkのマッピングを含むと言えます。 * <br>この双方向マップでは、値の重複を許可しません。 * 従って、既に別のキーにvalueと同じ値が関連付けられている場合には{@link IllegalArgumentException}が返ります。 * * @param key 指定された値が関連付けられるキー * @param value 指定されたキーに関連付けられる値 * @return keyに以前に関連付けられていた値。keyのマッピングが存在しなかった場合はnull。 * @exception IllegalArgumentException 別のキーにvalueと同じ値が関連付けられている場合。 この場合、双方向マップは更新されません。これを回避したい場合は代わりに{@link #forcePut(Object, Object) forcePut(K, V)}を使用できます。 */ @Override public V put(K key, V value); /** * 指定されたマップのすべてのマッピングをこのマップにコピーします。 * この呼出しの効果は、指定されたマップ内のキーkから値vへのマッピングごとに、このマップに対してput(k, v)を1回呼び出した場合と同じです。 * オペレーションの進行中に、指定されたマップが変更された場合の、このオペレーションの動作は定義されていません。 * また、このメソッドを呼び出した結果は、mapの反復順序によって異なる場合があります。 * @exception IllegalArgumentException putの試行が失敗した場合。例外が発生する前に、一部の要素が双方向マップに追加されている可能性に注意してください。 */ @Override public void putAll(Map<? extends K, ? extends V> map); /** * この双方向マップに含まれる値の{@link Set}ビューを返します。 * セットは双方向マップと連動しているので、双方向マップに対する変更はセットに反映され、またセットに対する変更は双方向マップに反映されます。 * セットの反復処理中に双方向マップが変更された場合、反復処理の結果は定義されていません(イテレータ自身のremoveオペレーション、またはイテレータにより返されるマップ・エントリに対するsetValueオペレーションを除く)。 * セットは要素の削除をサポートします。 * Iterator.remove、Set.remove、removeAll、retainAll、およびclearオペレーションで対応するマッピングを双方向マップから削除します。 * addまたはaddAllオペレーションはサポートしていません。 * @return マップ内に含まれている値のセット・ビュー */ @Override public Set<V> values(); } /** * {@link BiMap}インタフェースのハッシュ表に基づく実装です。 * この実装は、マップに関連するオプションのオペレーションをすべてサポートし、null値およびnullキーを使用できます。 * このクラスはマップの順序を保証しません。特に、その順序を常に一定に保つことを保証しません。 * <p> * この実装は、2つの{@link HashMap}に基づきます。 * 1つ目のHashMapはキーと値のマッピングを、2つ目のHashMapは値とキーのマッピングを保持し、互いに重複する要素を弾くことによって実装されています。 * 従って、計算量はHashMapにおける計算量に依存します。 * <p> *<b>この実装はsynchronizedされません。</b> *複数のスレッドが並行してハッシュ・マップにアクセスし、それらのスレッドの少なくとも1つが構造的にマップを変更する場合は、外部でその同期をとる必要があります。 *構造的な変更とは、1つ以上のマッピングを追加または削除するオペレーションのことです。 *すでにインスタンスに格納されているキーに関連付けられた値を変更することは構造的な変更ではありません。 *これは通常、マップを自然にカプセル化する一部のオブジェクトでsynchronizedすることによって達成されます。 *<p> *このクラスの「コレクション・ビュー・メソッド」によって返されるイテレータはフェイルファストです。 *イテレータの作成後に、イテレータ自体のremoveメソッド以外の方法でマップが構造的に変更されると、イテレータは{@link ConcurrentModificationException}をスローします。 *このように、並行して変更が行われると、イテレータは、将来の予測できない時点において予測できない動作が発生する危険を回避するために、ただちにかつ手際よく例外をスローします。 *<p> * 通常、非同期の並行変更がある場合、確かな保証を行うことは不可能なので、イテレータのフェイルファストの動作を保証することはできません。 * フェイルファスト・イテレータは最善努力原則に基づき、ConcurrentModificationExceptionをスローします。 * したがって、正確を期すためにこの例外に依存するプログラムを書くことは誤りです。イテレータのフェイルファストの動作はバグを検出するためにのみ使用すべきです。 * * @author 31536000 * * @param <K> このマップで保持されるキーの型 * @param <V> マップされる値の型 */ public static final class HashBiMap<K, V> extends AbstractMap<K, V> implements BiMap<K, V>, Cloneable, Serializable{ private static final long serialVersionUID = -3188523944909406241L; private final HashMap<K, V> keyMap; private final HashMap<V, K> valueMap; private HashBiMap() { keyMap = new HashMap<>(16); valueMap = new HashMap<>(16); } private HashBiMap(int initialCapacity) { keyMap = new HashMap<>(initialCapacity); valueMap = new HashMap<>(initialCapacity); } private HashBiMap(HashMap<K, V> keyMap, HashMap<V, K> valueMap) { this.keyMap = keyMap; this.valueMap = valueMap; } /** * デフォルトの初期容量(16)を持つ、空のHashBiMapを作成します。 * @param <K> このマップで保持されるキーの型 * @param <V> マップされる値の型 * @return 作成されたHashBiMap */ public static <K, V> HashBiMap<K, V> create() { return new HashBiMap<K, V>(); } /** * 指定された初期容量を持つ、空のHashBiMapを作成します。 * @param <K> このマップで保持されるキーの型 * @param <V> マップされる値の型 * @param initialCapacity 初期容量 * @return 作成されたHashBiMap * @exception IllegalArgumentException 初期容量が負の場合 */ public static <K, V> HashBiMap<K, V> create(int initialCapacity) { return new HashBiMap<K, V>(initialCapacity); } /** * 指定されたMapと同じマッピングで新しいHashBiMapを作成します。 * 指定されたMapのマッピングを保持するのに十分な初期容量で、HashBiMapは作成されます。 * @param <K> このマップで保持されるキーの型 * @param <V> マップされる値の型 * @param map マッピングがこのマップに配置されるマップ * @return 作成されたHashBiMap * @exception NullPointerException 指定されたマップがnullの場合 * @exception IllegalArgumentException 値がユニークではない場合 */ public static <K, V> HashBiMap<K, V> create(Map<? extends K, ? extends V> map) { if (map instanceof HashBiMap) { @SuppressWarnings("unchecked") HashBiMap<K, V> maps = ((HashBiMap<K, V>)map); return new HashBiMap<K, V>(maps.keyMap, maps.valueMap); } HashBiMap<K, V> ret = new HashBiMap<>(map.size()); ret.putAll(map); return ret; } @Override public void clear() { keyMap.clear(); valueMap.clear(); } @Override public boolean containsKey(Object key) { return keyMap.containsKey(key); } @Override public boolean containsValue(Object value) { return valueMap.containsValue(value); } private class EntrySet implements Set<Entry<K, V>> { private final Set<Entry<K, V>> set; public EntrySet(Set<Entry<K, V>> set) { this.set = set; } @Override public int size() { return set.size(); } @Override public boolean isEmpty() { return set.isEmpty(); } @Override public boolean contains(Object o) { return set.contains(o); } @Override public Iterator<Entry<K, V>> iterator() { return set.iterator(); } @Override public Object[] toArray() { return set.toArray(); } @Override public <T> T[] toArray(T[] a) { return set.toArray(a); } @Override public boolean add(Entry<K, V> e) { return set.add(e); } @Override public boolean remove(Object o) { if (set.remove(o)) { valueMap.remove(((Entry<?,?>) o).getValue()); return true; } return false; } @Override public boolean containsAll(Collection<?> c) { return set.containsAll(c); } @Override public boolean addAll(Collection<? extends Entry<K, V>> c) { return set.addAll(c); } @Override public boolean retainAll(Collection<?> c) { boolean ret= false; cont: for (Iterator<Entry<K, V>> iter = set.iterator();iter.hasNext();) { final Entry<K, V> i = iter.next(); for (Object j : c) if(i.equals(j)) continue cont; iter.remove(); valueMap.remove(i.getValue()); ret = true; } return ret; } @Override public boolean removeAll(Collection<?> c) { boolean ret = false; for (Object i : c) ret |= remove(i); return ret; } @Override public void clear() { keyMap.clear(); valueMap.clear(); } } @Override public Set<Entry<K, V>> entrySet() { return new EntrySet(keyMap.entrySet()); } @Override public V forcePut(K key, V value) { if (valueMap.containsKey(value)) { K lastKey = valueMap.get(value); keyMap.remove(lastKey); valueMap.remove(value); } valueMap.put(value, key); return keyMap.put(key, value); } @Override public V get(Object key) { return keyMap.get(key); } @Override public BiMap<V, K> inverse() { return new HashBiMap<V, K>(valueMap, keyMap); } private class KeySet implements Set<K> { private final Set<K> set; public KeySet(Set<K> set) { this.set = set; } @Override public int size() { return set.size(); } @Override public boolean isEmpty() { return set.isEmpty(); } @Override public boolean contains(Object o) { return set.contains(o); } @Override public Iterator<K> iterator() { return set.iterator(); } @Override public Object[] toArray() { return set.toArray(); } @Override public <T> T[] toArray(T[] a) { return set.toArray(a); } @Override public boolean add(K e) { return set.add(e); } @Override public boolean remove(Object o) { if (keyMap.containsKey(o)) { valueMap.remove(keyMap.remove(o)); return true; } return false; } @Override public boolean containsAll(Collection<?> c) { return set.containsAll(c); } @Override public boolean addAll(Collection<? extends K> c) { return set.addAll(c); } @Override public boolean retainAll(Collection<?> c) { boolean ret= false; cont: for (Iterator<K> iter = set.iterator();iter.hasNext();) { final K i = iter.next(); for (Object j : c) if(i.equals(j)) continue cont; V value = keyMap.get(i); iter.remove(); valueMap.remove(value); ret = true; } return ret; } @Override public boolean removeAll(Collection<?> c) { boolean ret = false; for (Object i : c) ret |= remove(i); return ret; } @Override public void clear() { keyMap.clear(); valueMap.clear(); } } @Override public Set<K> keySet() { return new KeySet(keyMap.keySet()); } @Override public V put(K key, V value) { if (valueMap.containsKey(value)) { if (valueMap.get(value).equals(key)) return value; throw new IllegalArgumentException(value + " is already mapping another key: " + valueMap.get(value)); } valueMap.put(value, key); return keyMap.put(key, value); } @Override public V remove(Object key) { V value = keyMap.remove(key); valueMap.remove(value); return value; } @Override public int size() { return keyMap.size(); } private class ValueSet implements Set<V> { private final Set<V> set; public ValueSet(Set<V> set) { this.set = set; } @Override public int size() { return set.size(); } @Override public boolean isEmpty() { return set.isEmpty(); } @Override public boolean contains(Object o) { return set.contains(o); } @Override public Iterator<V> iterator() { return set.iterator(); } @Override public Object[] toArray() { return set.toArray(); } @Override public <T> T[] toArray(T[] a) { return set.toArray(a); } @Override public boolean add(V e) { return set.add(e); } @Override public boolean remove(Object o) { if (valueMap.containsKey(o)) { keyMap.remove(valueMap.remove(o)); return true; } return false; } @Override public boolean containsAll(Collection<?> c) { return set.containsAll(c); } @Override public boolean addAll(Collection<? extends V> c) { return set.addAll(c); } @Override public boolean retainAll(Collection<?> c) { boolean ret= false; cont: for (Iterator<V> iter = set.iterator();iter.hasNext();) { final V i = iter.next(); for (Object j : c) if(i.equals(j)) continue cont; K key = valueMap.get(i); iter.remove(); keyMap.remove(key); ret = true; } return ret; } @Override public boolean removeAll(Collection<?> c) { boolean ret = false; for (Object i : c) ret |= remove(i); return ret; } @Override public void clear() { keyMap.clear(); valueMap.clear(); } } @Override public Set<V> values() { return new ValueSet(valueMap.keySet()); } @Override public Object clone() { @SuppressWarnings("unchecked") HashMap<K, V> key = (HashMap<K, V>) keyMap.clone(); @SuppressWarnings("unchecked") HashMap<V, K> value = (HashMap<V, K>) valueMap.clone(); return new HashBiMap<>(key, value); } } // コードは上の方だよ!下にあるのはライブラリ群だよ! }
Main.java:64: error: incompatible types: double[] cannot be converted to boolean[] boolean[] visited = new double[graph.size()]; ^ 1 error
s521539310
p03866
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pi; typedef vector <ll> vi; typedef pair<ll,double> pd; typedef pair<double,ll> pdi; typedef vector <pd> vpi; typedef pair<pi,ll> pii; #define f first #define s second #define FOR(i,s,e) for(ll i=s;i<=ll(e);++i) #define DEC(i,s,e) for(ll i=s;i>=ll(e);--i) #define pb push_back #define all(x) (x).begin(), (x).end() #define lbd(x, y) lower_bound(all(x), y) #define ubd(x, y) upper_bound(all(x), y) #define aFOR(i,x) for (auto i: x) #define mem(x,i) memset(x,i,sizeof x) #define fast ios_base::sync_with_stdio(false),cin.tie(0) #define maxn 1010 pi st,e; int N; pii points[maxn]; double cirtocir(pii c1,pii c2){ int dist = (c1.f.f - c2.f.f)*(c1.f.f - c2.f.f) + (c1.f.s - c2.f.s) * (c1.f.s - c2.f.s); double d = sqrt(dist); return max((double)0,d - c1.s - c2.s); } double ptop(pi p1,pi p2){ int dist = (p1.f - p2.f)*(p1.f - p2.f) + (p1.s - p2.s) * (p1.s - p2.s); return sqrt(dist); } double ptocir(pi p1,pii c2){ int dist = (p1.f - c2.f.f)*(p1.f - c2.f.f) + (p1.s - c2.f.s) * (p1.s - c2.f.s); return max((double)0,sqrt(dist) - c2.s); } vpi adj[maxn]; double dist[maxn]; int main(){ fast; cout<<setprecision(10) cin>>st.f>>st.s>>e.f>>e.s; cin>>N; FOR(i,1,N){ cin>>points[i].f.f>>points[i].f.s>>points[i].s; } FOR(i,0,N+1){ FOR(j,i+1,N+1){ double dist; if (i == 0 && j == N+1) dist = ptop(st,e); else if (i == 0) dist = ptocir(st,points[j]); else if (j == N+1) dist = ptocir(e,points[i]); else dist = cirtocir(points[i],points[j]); //cout<<i<<' '<<j<<' '<<dist<<'\n'; adj[i].pb(pd(j,dist)); adj[j].pb(pd(i,dist)); } } priority_queue <pdi,vector <pdi>, greater <pdi> > pq; pq.push(pdi(0,0)); FOR(i,0,N+1) dist[i] = -1; dist[0] = 0; while (!pq.empty()){ pdi cur = pq.top(); pq.pop(); //cout<<cur.f<<' '; if (dist[cur.s] != cur.f) continue; aFOR(i,adj[cur.s]){ if (dist[i.f] == -1 || dist[i.f] > cur.f + i.s){ dist[i.f] = cur.f + i.s; pq.push(pdi(dist[i.f],i.f)); } } } cout<<dist[N+1]; }
a.cc: In function 'int main()': a.cc:57:31: error: expected ';' before 'cin' 57 | cout<<setprecision(10) | ^ | ; 58 | 59 | cin>>st.f>>st.s>>e.f>>e.s; | ~~~
s239555937
p03866
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 sortDecending(X) sort(all(X), greater<ll>()) //降順 #define sortAscending(X) sort(all(X)) //昇順 #define pb push_back #define mp make_pair #define fi first #define sc second #define print(x) cout << x << endl #define printDouble(x) cout << fixed << setprecision(13) << x << endl #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) 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; long long gcd(long long m, long long n) { if (m < n) return gcd(n, m); if (n == 0) return m; return gcd(n, m % n); } long long lcm(long long m, long long n) { // m * nでlong型のオーバフローを発生させないため、先に割り算から行う return m * (n / gcd(m, n)); } // auto mod int // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu.be/8uowVvQ_-Mo?t=1329 : division const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; // combination mod prime // https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619 struct combination { vector<mint> fact, ifact; combination(int n) : fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; vector<long long> SieveOfEratosthenes(int max) { vector<long long> sieve; vector<long long> primes; for (int i = 1; i < max + 1; ++i) { sieve.push_back(i); } sieve[0] = 0; for (int i = 2; i < max + 1; ++i) { if (sieve[i - 1] != 0) { primes.push_back(sieve[i - 1]); for (int j = 2 * sieve[i - 1]; j < max + 1; j += sieve[i - 1]) { sieve[j - 1] = 0; } } } return primes; } 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; double cost; Edge() {} Edge(ll from, ll to, double cost) { this->from = from; this->to = to; this->cost = cost; } bool operator<(const Edge &edge) const { return cost < edge.cost; //昇順 } }; class Graph { public: ll nodes; // ノード数 vector<Edge> edges; Graph() {} Graph(ll nodes) { this->nodes = nodes; } void addEdge(ll from, ll to, double cost) { this->edges.push_back(Edge(from, to, cost)); } }; // クラスカル法 // 連結グラフの最小全域木を求める class Kruskal { private: Graph graph; vector<Edge> MinimumSpanningTree; ll minimumCost; void 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(Graph graph) { this->graph = graph; } ll getMinimumSpanningTreeCost() { searchMinimumSpanningTree(); ll cost = 0; itrep(it, MinimumSpanningTree) { cost += it->cost; } return cost; } }; // ダイクストラ法 O((E+V)logV) // 最小経路問題を解くためのアルゴリズム。辺の重みに負数を含む場合は利用不可 // 無向グラフの場合はコメントアウト箇所をコメントイン class Dijkstra { private: Graph graph; map<ll, vector<Edge>> fromPaths; vector<double> distances; vl srcs; public: Dijkstra(Graph graph) { this->graph = graph; itrep(edge, graph.edges) { fromPaths[edge->from].push_back(*edge); fromPaths[edge->to].push_back(Edge(edge->to, edge->from, edge->cost)); } } void searchMinimumPathFrom(ll src) { // 複数回呼ばれる度に計算する distances = vector<double>(graph.nodes + 1, INF); srcs = vl(graph.nodes + 1, INF); // 距離が近い順番に捜査していく priority_queue<pair<double, ll>, vector<pair<double, ll>, greater<pair<double, ll>>>> pq; distances[src] = 0; srcs[src] = -1; pq.push(mp(0.0, src)); while (!pq.empty()) { int u = pq.top().second; pq.pop(); itrep(edge, fromPaths[u]) { int v = edge->to; double w = edge->cost; if (distances[v] > distances[u] + w) { distances[v] = distances[u] + w; srcs[v] = u; pq.push(mp(distances[v], v)); } } } }; double getDistance(ll n) { return distances[n]; } ll getFrom(ll n) { return srcs[n]; } }; // ベルマンフォード O(|V||E|) // 負コストが含まれていても最短経路問題を解くためのアルゴリズム。閉路の検出も可能 // 有向グラフ class BellmanFord { private: Graph graph; // 閉路が含まれるかは個々のノードごとに管理する必要あり vector<bool> hasNegativeCycles; vector<ll> distances; vl srcs; public: BellmanFord(Graph graph) { ll nodes = graph.nodes + 1; this->graph = graph; distances = vector<ll>(nodes, INF); hasNegativeCycles = vector<bool>(nodes, false); } void searchMinimumPathFrom(ll src) { distances[src] = 0; 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 (distances[u] != INF) { chmin(distances[v], distances[u] + w); } } } itrep(edge, graph.edges) { ll u = edge->from; ll v = edge->to; ll w = edge->cost; if (distances[u] == INF) { continue; } if (distances[u] + w < distances[v]) { hasNegativeCycles[v] = true; } } for (ll i = 0; i < graph.nodes; i++) { itrep(edge, graph.edges) { ll u = edge->from; ll v = edge->to; ll w = edge->cost; if (distances[u] == INF) { continue; } chmin(distances[v], distances[u] + w); if (hasNegativeCycles[u] == true) { hasNegativeCycles[v] = true; } } } } ll getDistance(ll n) { return distances[n]; } bool hasNegativeCycle(ll n) { return hasNegativeCycles[n]; } ll getFrom(ll n) { return srcs[n]; } }; // O(V^3) 有向グラフ class WarshallFloyd { private: Graph graph; int nodes = this->graph.nodes + 1; vector<vector<ll>> distances; public: WarshallFloyd(Graph graph) { this->graph = graph; nodes = this->graph.nodes + 1; this->distances = vector<vector<ll>>(nodes, vector<ll>(nodes, INF)); itrep(edge, graph.edges) { int from = edge->from; int to = edge->to; int cost = edge->cost; distances[from][to] = cost; } } void searchMinimumPath() { for (int k = 0; k < nodes; k++) { for (int i = 0; i < nodes; i++) { for (int j = 0; j < nodes; j++) { if (distances[i][k] == INF || distances[k][j] == INF) { continue; } if (distances[i][k] + distances[k][j] < distances[i][j]) { distances[i][j] = distances[i][k] + distances[k][j]; } } } } } ll getDistance(int from, int to) { return distances[from][to]; } }; double calcCost(ll x1, ll y1, ll r1, ll x2, ll y2, ll r2) { double dist = sqrt(((double)x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); return max(0.0, dist - r1 - r2); } void solve(long long x_s, long long y_s, long long x_t, long long y_t, long long N, std::vector<long long> x, std::vector<long long> y, std::vector<long long> r) { Graph g(N + 2); // start:N, end:N+1 rep(i, 0, N) { g.addEdge(i, N, calcCost(x[i], y[i], r[i], x_s, y_s, 0)); g.addEdge(i, N + 1, calcCost(x[i], y[i], r[i], x_t, y_t, 0)); } rep(i, 0, N) { rep(j, i + 1, N) { g.addEdge(i, j, calcCost(x[i], y[i], r[i], x[j], y[j], r[j])); } } Dijkstra dijkstra(g); dijkstra.searchMinimumPathFrom(N); printDouble(dijkstra.getDistance(N + 1)); } int main() { long long x_s; scanf("%lld", &x_s); long long y_s; scanf("%lld", &y_s); long long x_t; scanf("%lld", &x_t); long long y_t; scanf("%lld", &y_t); long long N; scanf("%lld", &N); std::vector<long long> x(N); std::vector<long long> y(N); std::vector<long long> r(N); for (int i = 0; i < N; i++) { scanf("%lld", &x[i]); scanf("%lld", &y[i]); scanf("%lld", &r[i]); } solve(x_s, y_s, x_t, y_t, N, std::move(x), std::move(y), std::move(r)); return 0; }
In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:2: /usr/include/c++/14/bits/stl_vector.h: In instantiation of 'struct std::_Vector_base<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >': /usr/include/c++/14/bits/stl_vector.h:428:11: required from 'class std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >' 428 | class vector : protected _Vector_base<_Tp, _Alloc> | ^~~~~~ a.cc:287:70: required from here 287 | vector<pair<double, ll>, greater<pair<double, ll>>>> | ^~ /usr/include/c++/14/bits/stl_vector.h:87:28: error: no type named 'value_type' in 'struct std::greater<std::pair<double, long long int> >' 87 | rebind<_Tp>::other _Tp_alloc_type; | ^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:89:9: error: no type named 'value_type' in 'struct std::greater<std::pair<double, long long int> >' 89 | pointer; | ^~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In instantiation of 'class std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >': a.cc:287:70: required from here 287 | vector<pair<double, ll>, greater<pair<double, ll>>>> | ^~ /usr/include/c++/14/bits/stl_vector.h:518:20: error: '_M_allocate' has not been declared in 'std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >::_Base' 518 | using _Base::_M_allocate; | ^~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:519:20: error: '_M_deallocate' has not been declared in 'std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >::_Base' 519 | using _Base::_M_deallocate; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:521:20: error: '_M_get_Tp_allocator' has not been declared in 'std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >::_Base' 521 | using _Base::_M_get_Tp_allocator; | ^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:59, from /usr/include/c++/14/algorithm:60, from a.cc:1: /usr/include/c++/14/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl() [with _Tp = std::pair<double, long long int>; _Alloc = std::greater<std::pair<double, long long int> >]': /usr/include/c++/14/type_traits:1110:25: required by substitution of 'template<class _Tp, class ... _Args> using std::__is_constructible_impl = std::__bool_constant<__is_constructible(_Tp, _Args ...)> [with _Tp = std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >; _Args = {}]' 1110 | = __bool_constant<__is_constructible(_Tp, _Args...)>; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/type_traits:1124:12: required from 'struct std::is_default_constructible<std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > > >' 1124 | struct is_default_constructible | ^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/type_traits:183:35: required by substitution of 'template<class ... _Bn> std::__detail::__first_t<std::integral_constant<bool, true>, typename std::enable_if<(bool)(_Bn::value), void>::type ...> std::__detail::__and_fn(int) [with _Bn = {std::is_default_constructible<std::less<std::pair<double, long long int> > >, std::is_default_constructible<std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > > >}]' 183 | __enable_if_t<bool(_Bn::value)>...>; | ^~~~~ /usr/include/c++/14/type_traits:199:42: required from 'struct std::__and_<std::is_default_constructible<std::less<std::pair<double, long long int> > >, std::is_default_constructible<std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > > > >' 199 | : decltype(__detail::__and_fn<_Bn...>(0)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_queue.h:551:43: required by substitution of 'template<class _Seq, class _Requires> std::priority_queue<std::pair<double, long long int>, std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > > >::priority_queue() [with _Seq = std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >; _Requires = <missing>]' 551 | template<typename _Seq = _Sequence, typename _Requires = typename | ^~~~~~~~ a.cc:288:9: required from here 288 | pq; | ^~ /usr/include/c++/14/bits/stl_vector.h:136:24: error: no type named 'value_type' in 'struct std::greater<std::pair<double, long long int> >' 136 | _Vector_impl() _GLIBCXX_NOEXCEPT_IF( | ^~~~~~~~~~~~~~~~~~~~ a.cc: In member function 'void Dijkstra::searchMinimumPathFrom(ll)': a.cc:294:18: error: 'class std::priority_queue<std::pair<double, long long int>, std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > > >' has no member named 'top'; did you mean 'pop'? 294 | int u = pq.top().second; | ^~~ | pop In file included from /usr/include/c++/14/queue:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157: /usr/include/c++/14/bits/stl_queue.h: In instantiation of 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<double, long long int>; _Sequence = std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >; _Compare = std::less<std::pair<double, long long int> >; value_type = std::pair<double, long long int>]': a.cc:292:12: required from here 292 | pq.push(mp(0.0, src)); | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:747:26: error: 'class std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >' has no member named 'begin' 747 | std::push_heap(c.begin(), c.end(), comp); | ~~^~~~~ /usr/include/c++/14/bits/stl_queue.h:747:37: error: 'class std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >' has no member named 'end' 747 | std::push_heap(c.begin(), c.end(), comp); | ~~^~~ /usr/include/c++/14/bits/stl_queue.h: In instantiation of 'void std::priority_queue<_Tp, _Sequence, _Compare>::pop() [with _Tp = std::pair<double, long long int>; _Sequence = std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >; _Compare = std::less<std::pair<double, long long int> >]': a.cc:295:13: required from here 295 | pq.pop(); | ~~~~~~^~ /usr/include/c++/14/bits/stl_queue.h:774:25: error: 'class std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >' has no member named 'begin' 774 | std::pop_heap(c.begin(), c.end(), comp); | ~~^~~~~ /usr/include/c++/14/bits/stl_queue.h:774:36: error: 'class std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >' has no member named 'end' 774 | std::pop_heap(c.begin(), c.end(), comp); | ~~^~~ /usr/include/c++/14/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl() [with _Tp = std::pair<double, long long int>; _Alloc = std::greater<std::pair<double, long long int> >]': /usr/include/c++/14/bits/stl_vector.h:314:7: required from 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue() [with _Seq = std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >; _Requires = void; _Tp = std::pair<double, long long int>; _Sequence = std::vector<std::pair<double, long long int>, std::greater<std::pair<double, long long int> > >; _Compare = std::less<std::pair<double, long long int> >]' 314 | _Vector_base() = default; | ^~~~~~~~~~~~ a.cc:288:9: required from here 288 | pq; | ^~ /usr/include/c++/14/bits/stl_vector.h:141:26: error: no type named 'value_type' in 'struct std::greater<std::pair<double, long long int> >' 141 | : _Tp_alloc_type() | ^
s857784721
p03866
C++
4 -2 -2 4 3 0 0 2 4 0 1 0 4 1
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 4 -2 -2 4 | ^
s150485041
p03866
C++
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=ja" #include<bits/stdc++.h> using namespace std; #include "../../datastructure/FibHeapMap.cpp" namespace dijkstra_n { template<class W> struct Edge { using type = Edge<W>; int to; W w; template<class... Args> Edge(int t, Args... args) : to(t), w(args...) {} inline bool operator<(const Edge& rhs) const { return w < rhs.w; } inline bool operator>(const type& rhs) const { return rhs < *this; } inline bool operator>=(const type& rhs) const { return !(*this < rhs); } inline bool operator<=(const type& rhs) const { return !(rhs < *this); } inline bool operator==(const type& rhs) const { return !(*this < rhs) && !(rhs < *this); } inline bool operator!=(const type& rhs) const { return (*this < rhs) || (rhs < *this); } }; template<class W> struct Edges : private vector<vector<Edge<W>>> { using type = vector<vector<Edge<W>>>; template<class... Args> Edges(Args... args) : type(args...) {} template<class... Args> void add_edge(int u, int v, Args... args) { (*this)[u].emplace_back(v, args...); } using type::begin; using type::end; using type::rbegin; using type::rend; using type::cbegin; using type::cend; using type::crbegin; using type::crend; using type::size; using type::operator[]; using type::at; using type::back; using type::front; using type::reserve; using type::resize; using type::assign; using type::shrink_to_fit; using type::clear; using type::erase; using type::insert; using type::swap; using type::push_back; using type::pop_back; using type::emplace_back; using type::empty; }; template<class W> struct Graph { const int sz; Edges<W> e; Graph(int n) : sz(n), e(sz) {} template<class... Args> void add_edge(int u, int v, Args... args) { e.add_edge(u, v, args...); } int size() { return sz; } }; template<class W, class T = W> struct Graph_D : public Graph<W> { vector<T> dist; Graph_D(int n) : Graph<W>(n), dist(n) {} }; template<class W, class T> void Dijkstra(Graph_D<W, T>& g, int start, T INF_COST) { auto& dist = g.dist; auto& e = g.e; for (auto& ww : dist) ww = INF_COST; using heap = FibHeapMap<T, int, greater<>>; heap q; vector<typename heap::np> node(g.size(), nullptr); q.push(0, start); dist[start] = 0; while (!q.empty()) { auto a = q.top(); q.pop(); if (dist[a.second] < a.first) continue; for (auto& p : e[a.second]) { if (p.w == INF_COST) continue; W w = dist[a.second] + p.w; if (w < dist[p.to]) { dist[p.to] = w; if (!node[p.to]) node[p.to] = q.push(w, p.to); q.increase_key(node[p.to], w); } } } } } using dijkstra_n::Dijkstra; template<class T, class U = T> using graph = dijkstra_n::Graph_D<T, U>; // int main() { // int V, E, S; // scanf("%d%d%d", &V, &E, &S); // graph<int> D(V); // for (int i = 0; i < E; i++) { // int a, b, c; // scanf("%d%d%d", &a, &b, &c); // D.add_edge(a, b, c); // } // Dijkstra(D, S, INT_MAX); // for (int i = 0; i < V; i++) { // if (D.dist[i] == INT_MAX) cout << "INF" << endl; // else cout << D.dist[i] << endl; // } // } signed main() { int N; vector<int> x, y, r; { int a, b, c, d; assert(scanf("%lld%lld%lld%lld", &a, &b, &c, &d) == 4); x.push_back(a); y.push_back(b); r.push_back(0); x.push_back(c); y.push_back(d); r.push_back(0); } assert(scanf("%lld", &N) == 1); for (int i = 0; i < N; i++) { int a, b, c; assert(scanf("%lld%lld%lld", &a, &b, &c) == 3); x.push_back(a); y.push_back(b); r.push_back(c); } graph<double> G(N+2); for (int i = 0; i < N+2; i++) { for (int j = 0; j < N+2; j++) { double dx = x[i] - x[j]; double dy = y[i] - y[j]; dx *= dx; dy *= dy; G.add_edge(i, j, max<double>(0, sqrt(dx + dy) - r[i] - r[j])); } } Dijkstra(G, 0, 1e18); cout << fixed << setprecision(12) << G.dist[1] << endl; }
a.cc:7:10: fatal error: ../../datastructure/FibHeapMap.cpp: No such file or directory 7 | #include "../../datastructure/FibHeapMap.cpp" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s765244524
p03866
C++
#include<iostream> #include<string> #include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<deque> #include<ciso646> #include<random> #include<map> #include<set> #include<complex> #include<bitset> #include<stack> #include<unordered_map> #include<utility> #include<cassert> using namespace std; typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; typedef long double ld; const int inf=1e9+7; const ll INF=1LL<<60 ; const ll mod=1e9+7 ; #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<int, int> P; typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; #define fr first #define sc second #define all(c) c.begin(),c.end() #define pb push_back #define debug(x) cout << #x << " = " << (x) << endl; using Graph = vector<vector<int> >; 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; } //#define int long long //////////////////////////// // 基本要素 (点, 線分, 円) //////////////////////////// using DD = double; const DD INF = 1LL<<60; // to be set appropriately const DD EPS = 1e-10; // to be set appropriately const DD PI = acos(-1.0); DD torad(int deg) {return (DD)(deg) * PI / 180;} DD todeg(DD ang) {return ang * 180 / PI;} /* Point */ struct Point { DD x, y; Point(DD x = 0.0, DD y = 0.0) : x(x), y(y) {} friend ostream& operator << (ostream &s, const Point &p) {return s << '(' << p.x << ", " << p.y << ')';} }; inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);} inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);} inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);} inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);} inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);} inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);} inline Point conj(const Point &p) {return Point(p.x, -p.y);} inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);} inline Point rot90(const Point &p) {return Point(-p.y, p.x);} inline DD cross(const Point &p, const Point &q) {return p.x * q.y - p.y * q.x;} inline DD dot(const Point &p, const Point &q) {return p.x * q.x + p.y * q.y;} inline DD norm(const Point &p) {return dot(p, p);} inline DD abs(const Point &p) {return sqrt(dot(p, p));} inline DD amp(const Point &p) {DD res = atan2(p.y, p.x); if (res < 0) res += PI*2; return res;} inline bool eq(const Point &p, const Point &q) {return abs(p - q) < EPS;} inline bool operator < (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x < q.x : p.y < q.y);} inline bool operator > (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x > q.x : p.y > q.y);} inline Point operator / (const Point &p, const Point &q) {return p * conj(q) / norm(q);} /* Line */ struct Line : vector<Point> { Line(Point a = Point(0.0, 0.0), Point b = Point(0.0, 0.0)) { this->push_back(a); this->push_back(b); } friend ostream& operator << (ostream &s, const Line &l) {return s << '{' << l[0] << ", " << l[1] << '}';} }; /* Circle */ struct Circle : Point { DD r; Circle(Point p = Point(0.0, 0.0), DD r = 0.0) : Point(p), r(r) {} friend ostream& operator << (ostream &s, const Circle &c) {return s << '(' << c.x << ", " << c.y << ", " << c.r << ')';} }; int n; Point sp, tp; vector<Circle> c; double dist[1010][1010]; double d[1010]; bool seen[1010]; //Dijkstra法 は 隣接リスト で O(V^2) ,PriorityQueue で O(ElogV) //密グラフなら隣接リストでok void solve() { cin >> sp.x >> sp.y >> tp.x >> tp.y; cin >> n; c.resize(n); rep(i, n) { cin >> c[i].x >> c[i].y >> c[i].r; } int s = n, t = n + 1; rep(i, n) { double ds = abs(c[i] - sp); dist[i][s] = dist[s][i] = max(0.0, ds - c[i].r); double dt = abs(c[i] - tp); dist[i][t] = dist[t][i] = max(0.0, dt - c[i].r); } rep(i, n) { rep(j, n) { double di = abs(c[i] - c[j]); dist[i][j] = dist[j][i] = max(0.0, di - c[i].r - c[j].r); } } rep(i, n + 2) { d[i] = INF; seen[i] = false; } d[s] = 0; while(true) { int v = -1; rep(u, n + 2) { if(!seen[u] && (v == -1 || d[u] < d[v])) v = u; } if(v == -1) break; seen[v] = true; rep(u, n + 2) { chmin(d[u], d[v] + dist[v][u]); } } cout << d[t] << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); //cout << fixed << setprecision(10); //init(); solve(); //cout << "finish" << endl; return 0; }
a.cc:58:10: error: conflicting declaration 'const DD INF' 58 | const DD INF = 1LL<<60; // to be set appropriately | ^~~ a.cc:29:10: note: previous declaration as 'const ll INF' 29 | const ll INF=1LL<<60 ; | ^~~ a.cc:65:8: error: using typedef-name 'Point' after 'struct' 65 | struct Point { | ^~~~~ a.cc:37:21: note: 'Point' has a previous declaration here 37 | typedef complex<ld> Point; | ^~~~~ a.cc: In function 'Point operator+(const Point&, const Point&)': a.cc:70:74: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 70 | inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);} | ^ a.cc:70:80: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 70 | inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);} | ^ a.cc:70:85: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 70 | inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);} | ^ a.cc:70:91: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 70 | inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);} | ^ a.cc: In function 'Point operator-(const Point&, const Point&)': a.cc:71:74: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 71 | inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);} | ^ a.cc:71:80: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 71 | inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);} | ^ a.cc:71:85: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 71 | inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);} | ^ a.cc:71:91: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 71 | inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);} | ^ a.cc: In function 'Point operator*(const Point&, DD)': a.cc:72:64: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 72 | inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);} | ^ a.cc:72:73: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 72 | inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);} | ^ a.cc: In function 'Point operator*(DD, const Point&)': a.cc:73:68: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 73 | inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);} | ^ a.cc:73:77: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 73 | inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);} | ^ a.cc: In function 'Point operator*(const Point&, const Point&)': a.cc:74:74: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);} | ^ a.cc:74:80: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);} | ^ a.cc:74:86: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);} | ^ a.cc:74:92: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);} | ^ a.cc:74:97: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);} | ^ a.cc:74:103: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);} | ^ a.cc:74:109: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);} | ^ a.cc:74:115: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);} | ^ a.cc: In function 'Point operator/(const Point&, DD)': a.cc:75:64: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 75 | inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);} | ^ a.cc:75:73: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 75 | inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);} | ^ a.cc: In function 'Point conj(const Point&)': a.cc:76:51: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 76 | inline Point conj(const Point &p) {return Point(p.x, -p.y);} | ^ a.cc:76:57: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 76 | inline Point conj(const Point &p) {return Point(p.x, -p.y);} | ^ a.cc: In function 'Point rot(const Point&, DD)': a.cc:77:69: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 77 | inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);} | ^ a.cc:77:86: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 77 | inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);} | ^ a.cc:77:102: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 77 | inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);} | ^ a.cc:77:119: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 77 | inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);} | ^ a.cc: In function 'Point rot90(const Point&)': a.cc:78:53: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y' 78 | inline Point rot90(const Point &p) {return Point(-p.y, p.x);} | ^ a.cc:78:58: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 78 | inline Point rot90(const Point &p) {return Point(-p.y, p.x);} | ^ a.cc: In function 'DD cross(const Point&, const Point&)': a.cc:79:59: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x' 79 | inline DD cross(const Point &p, const Point &q) {return p.x * q.y - p.y * q.x;} |
s858914377
p03866
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; using Pll = pair<ll, ll>; constexpr long double INF = 1e10; constexpr int MAX_N = 2000; vector<long double> d(MAX_N, INF); priority_queue<pair<long double, ll>, vector<pair<long double, ll>>, greater<pair<long double, ll>>> que; vector<vector<pair<ll, long double>>> edges(MAX_N); struct Point { Pll pos; long double r; Point(ll x=0, ll y=0, long double r=0.0): r(r) { pos = {x, y}; } Point operator - (const Point &p) const { return Point(pos.first-p.pos.first, pos.second-p.pos.second); } long double abs() const { return sqrt(norm()); } long double norm() const { return pos.first*pos.first + pos.second*pos.second; } long double dot(Point &p) const { return pos.first*p.pos.first + pos.second*p.pos.second; } }; void dijkstra(ll start){ d[start] = 0; que.push({0, start}); while(!que.empty()){ auto v = que.top(); que.pop(); if(d[v.second] < v.first) continue; for(auto e: edges[v.second]){ if(d[e.first] > d[v.second] + e.second){ d[e.first] = d[v.second] + e.second; que.push({d[e.first], e.first}); } } } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); Point s, t; cin >> s.pos.first >> s.pos.second >> t.pos.first >> t.pos.second; int n; cin >> n; vector<Point> points(n); for(int i=0;i<n;++i){ cin >> points[i].pos.first >> points[i].pos.second >> points[i].r; } for(int i=0;i<n;++i) { for(int j=i+1;j<n;++j) { long double dist = max(0.0, (points[i]-points[j]).abs() - points[i].r - points[j].r); edges[i].emplace_back(j, dist); edges[j].emplace_back(i, dist); } edges[n].emplace_back(i, max(0.0, (points[i]-s).abs() - points[i].r)); edges[i].emplace_back(n+1, max(0.0, (points[i]-t).abs() - points[i].r)); } dijkstra(n); cout << fixed << setprecision(15) << d[n+1] << endl; }
a.cc: In function 'int main()': a.cc:56:35: error: no matching function for call to 'max(double, long double)' 56 | long double dist = max(0.0, (points[i]-points[j]).abs() - points[i].r - points[j].r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:56:35: note: deduced conflicting types for parameter 'const _Tp' ('double' and 'long double') 56 | long double dist = max(0.0, (points[i]-points[j]).abs() - points[i].r - points[j].r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:56:35: note: mismatched types 'std::initializer_list<_Tp>' and 'double' 56 | long double dist = max(0.0, (points[i]-points[j]).abs() - points[i].r - points[j].r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:60:37: error: no matching function for call to 'max(double, long double)' 60 | edges[n].emplace_back(i, max(0.0, (points[i]-s).abs() - points[i].r)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:60:37: note: deduced conflicting types for parameter 'const _Tp' ('double' and 'long double') 60 | edges[n].emplace_back(i, max(0.0, (points[i]-s).abs() - points[i].r)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:60:37: note: mismatched types 'std::initializer_list<_Tp>' and 'double' 60 | edges[n].emplace_back(i, max(0.0, (points[i]-s).abs() - points[i].r)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:61:39: error: no matching function for call to 'max(double, long double)' 61 | edges[i].emplace_back(n+1, max(0.0, (points[i]-t).abs() - points[i].r)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:61:39: note: deduced conflicting types for parameter 'const _Tp' ('double' and 'long double') 61 | edges[i].emplace_back(n+1, max(0.0, (points[i]-t).abs() - points[i].r)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:61:39: note: mismatched types 'std::initializer_list<_Tp>' and 'double' 61 | edges[i].emplace_back(n+1, max(0.0, (points[i]-t).abs() - points[i].r)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s574291269
p03866
C++
#include<iostream> #include<algorithm> #include<functional> #include<queue> #include<vector> #include<cmath> #include<iomanip> using namespace std; typedef pair<double, int> P; struct Edge { int to; double cost; Edge(int a, double b) { to = a, cost = b; } }; struct shelter { double x, y, r; shelter(double a, double b, double c) { x = a, y = b, r = c; } shelter() { x - 0, y = 0, r = 0; } }; double getdis(shelter &A, shelter &B) { double dis = sqrt(pow(A.x - B.x, 2) + pow(A.y - B.y, 2)) - A.r - B.r; if (dis > 0) return dis; else return 0; } double sx, sy, tx, ty; int N; vector<shelter> S; vector<vector<Edge>> E; double dis[1002]; void djk(int s) { for (int i = 0; i < N + 2; i++)dis[i] = 10000000000; priority_queue<P, vector<P>, greater<P>> pq; pq.push(P(0, s)); dis[s] = 0.0; while (pq.size()) { P now = pq.top(); pq.pop(); int pos = now.second; double totalcost = now.first; if (totalcost > dis[pos])continue; for (int i = 0; i < E[pos].size(); i++) { int nxt = E[pos][i].to; double cost = E[pos][i].cost; if (dis[nxt] > dis[pos] + cost) { dis[nxt] = dis[pos] + cost; pq.push(P(dis[nxt], nxt)); } } } } int main() { cin >> sx >> sy >> tx >> ty; cin >> N; S.resize(N); for (int i = 0; i < N; i++) { cin >> S[i].x >> S[i].y >> S[i].r; } E.resize(N + 2); for (int i = 0; i < N; i++) { E[0].push_back(Edge(i + 1, getdis(shelter(sx, sy, 0), S[i])));//どうせ最初のスタートに戻らないので一方通行の辺でもいい E[i + 1].push_back(Edge(N + 1, getdis(shelter(tx, ty, 0), S[i])));//上と同じ理由でゴールも一方通行 } for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i == j)continue; E[i + 1].push_back(Edge(j + 1, getdis(S[i], S[j]))); E[j + 1].push_back(Edge(i + 1, getdis(S[j], S[i]))); } } djk(0); cout << setprecision(12) << dis[N + 1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:75:51: error: cannot bind non-const lvalue reference of type 'shelter&' to an rvalue of type 'shelter' 75 | E[0].push_back(Edge(i + 1, getdis(shelter(sx, sy, 0), S[i])));//どうせ最初のスタートに戻らないので一方通行の辺でもいい | ^~~~~~~~~~~~~~~~~~ a.cc:27:24: note: initializing argument 1 of 'double getdis(shelter&, shelter&)' 27 | double getdis(shelter &A, shelter &B) { | ~~~~~~~~~^ a.cc:76:55: error: cannot bind non-const lvalue reference of type 'shelter&' to an rvalue of type 'shelter' 76 | E[i + 1].push_back(Edge(N + 1, getdis(shelter(tx, ty, 0), S[i])));//上と同じ理由でゴールも一方通行 | ^~~~~~~~~~~~~~~~~~ a.cc:27:24: note: initializing argument 1 of 'double getdis(shelter&, shelter&)' 27 | double getdis(shelter &A, shelter &B) { | ~~~~~~~~~^
s915666093
p03866
C++
#include <iostream> #include <vector> #include <queue> #include <cmath> #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) struct edge{ int to; double cost; }; using namespace std; //ダイクストラで多用する型 typedef pair<double, int> P;//(その頂点までの距離,頂点)として使う。 vector<edge> G[1'010];//頂点iから出る辺の配列G[i]の配列。 double dist[1'010];//特定の頂点から各頂点への距離が格納される。 bool used[1'010];//dijkstra実行中に、頂点iまでの距離を確定したかどうかを持つ。 void dijkstra(int v){//vは始点。 //以下のリンクでpriority_queueの使い方を参照 //http://shirokurostone.hatenablog.com/entry/20110522/1306052844 priority_queue<P, vector<P>, greater<P>> que; que.push(P(0, v)); while(!que.empty()){ P top = que.top(); que.pop(); int u = top.second; double d = top.first; //cout << u << ' ' << d << endl; if(used[u]) continue; dist[u] = d; used[u] = true; for(int i = 0; i < G[u].size(); i++){ if(!used[G[u][i].to]){ que.push(P(d+G[u][i].cost, G[u][i].to)); //cout << G[u][i].to << ' ' << d+G[u][i].cost << endl; } } } } int main(){ double xs,ys,xt,yt; cin>>xs>>ys>>xt>>yt; int n; cin>>n; double x[n+2],y[n+2],r[n+2]; x[0] = xs; y[0] = ys; r[0] = 0.0; REPP(i,n){ cin>>x[i]>>y[i]>>r[i]; } x[n+1] = xt; y[n+1] = yt; r[n+1] = 0; double temp; REP(i,n+2){ REP(j,n+2){ if(i==j)continue; temp = hypot(x[j]-x[i], y[j]-y[i]) - r[i] - r[j]; temp = max(temp, 0.0); G[i].push_back(edge{j, temp}); } } dijkstra(0); double ans; ans = dist[n+1]; cout << fixed << setprecision(10) << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:72:22: error: 'setprecision' was not declared in this scope 72 | cout << fixed << setprecision(10) << ans << endl; | ^~~~~~~~~~~~ a.cc:5:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>' 4 | #include <cmath> +++ |+#include <iomanip> 5 | #define REP(i,n) for(int i=0;i<n;i++)
s811545645
p03866
C++
#include <iostream> #include <vector> #include <queue> #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) struct edge{ int to; double cost; }; using namespace std; //ダイクストラで多用する型 typedef pair<double, int> P;//(その頂点までの距離,頂点)として使う。 vector<edge> G[1'010];//頂点iから出る辺の配列G[i]の配列。 double dist[1'010];//特定の頂点から各頂点への距離が格納される。 bool used[1'010];//dijkstra実行中に、頂点iまでの距離を確定したかどうかを持つ。 void dijkstra(int v){//vは始点。 //以下のリンクでpriority_queueの使い方を参照 //http://shirokurostone.hatenablog.com/entry/20110522/1306052844 priority_queue<P, vector<P>, greater<P>> que; que.push(P(0, v)); while(!que.empty()){ P top = que.top(); que.pop(); int u = top.second; double d = top.first; //cout << u << ' ' << d << endl; if(used[u]) continue; dist[u] = d; used[u] = true; for(int i = 0; i < G[u].size(); i++){ if(!used[G[u][i].to]){ que.push(P(d+G[u][i].cost, G[u][i].to)); //cout << G[u][i].to << ' ' << d+G[u][i].cost << endl; } } } } int main(){ double xs,ys,xt,yt; cin>>xs>>ys>>xt>>yt; int n; cin>>n; double x[n+2],y[n+2],r[n+2]; x[0] = xs; y[0] = ys; r[0] = 0.0; REPP(i,n){ cin>>x[i]>>y[i]>>r[i]; } x[n+1] = xt; y[n+1] = yt; r[n+1] = 0; double temp; REP(i,n+2){ REP(j,n+2){ if(i==j)continue; temp = hypot(x[j]-x[i], y[j]-y[i]) - r[i] - r[j]; temp = max(temp, 0.0); G[i].push_back(edge{j, temp}); } } dijkstra(0); double ans; ans = dist[n+1]; cout << fixed << setprecision(10) << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:63:16: error: 'hypot' was not declared in this scope 63 | temp = hypot(x[j]-x[i], y[j]-y[i]) - r[i] - r[j]; | ^~~~~ a.cc:71:22: error: 'setprecision' was not declared in this scope 71 | cout << fixed << setprecision(10) << ans << endl; | ^~~~~~~~~~~~ a.cc:4:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>' 3 | #include <queue> +++ |+#include <iomanip> 4 | #define REP(i,n) for(int i=0;i<n;i++)
s413886318
p03866
C++
#include <iostream> #include <vector> #include <queue> #define REP(i,n) for(int i=0;i<n;i++) struct edge{ int to; double cost; }; using namespace std; //ダイクストラで多用する型 typedef pair<double, int> P;//(その頂点までの距離,頂点)として使う。 vector<edge> G[1'010];//頂点iから出る辺の配列G[i]の配列。 double dist[1'010];//特定の頂点から各頂点への距離が格納される。 bool used[1'010];//dijkstra実行中に、頂点iまでの距離を確定したかどうかを持つ。 void dijkstra(int v){//vは始点。 //以下のリンクでpriority_queueの使い方を参照 //http://shirokurostone.hatenablog.com/entry/20110522/1306052844 priority_queue<P, vector<P>, greater<P>> que; que.push(P(0, v)); while(!que.empty()){ P top = que.top(); que.pop(); int u = top.second; double d = top.first; //cout << u << ' ' << d << endl; if(used[u]) continue; dist[u] = d; used[u] = true; for(int i = 0; i < G[u].size(); i++){ if(!used[G[u][i].to]){ que.push(P(d+G[u][i].cost, G[u][i].to)); //cout << G[u][i].to << ' ' << d+G[u][i].cost << endl; } } } } int main(){ double xs,ys,xt,yt; cin>>xs>>ys>>xt>>yt; int n; cin>>n; double x[n+2],y[n+2],r[n+2]; x[0] = xs; y[0] = ys; r[0] = 0.0; REPP(i,n){ cin>>x[i]>>y[i]>>r[i]; } x[n+1] = xt; y[n+1] = yt; r[n+1] = 0; double temp; REP(i,n+2){ REP(j,n+2){ if(i==j)continue; temp = hypot(x[j]-x[i], y[j]-y[i]) - r[i] - r[j]; temp = max(temp, 0.0); G[i].push_back(edge{j, temp}); } } dijkstra(0); double ans; ans = dist[n+1]; cout << fixed << setprecision(10) << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:52:10: error: 'i' was not declared in this scope 52 | REPP(i,n){ | ^ a.cc:52:5: error: 'REPP' was not declared in this scope; did you mean 'REP'? 52 | REPP(i,n){ | ^~~~ | REP a.cc:62:16: error: 'hypot' was not declared in this scope 62 | temp = hypot(x[j]-x[i], y[j]-y[i]) - r[i] - r[j]; | ^~~~~ a.cc:70:22: error: 'setprecision' was not declared in this scope 70 | cout << fixed << setprecision(10) << ans << endl; | ^~~~~~~~~~~~ a.cc:4:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>' 3 | #include <queue> +++ |+#include <iomanip> 4 | #define REP(i,n) for(int i=0;i<n;i++)
s303720769
p03866
C++
#include <iostream> #include <vector> #include <queue> #define REP(i,n) for(int i=0;i<n;i++) struct edge{ int to; double cost; }; using namespace std; //ダイクストラで多用する型 typedef pair<double, int> P;//(その頂点までの距離,頂点)として使う。 vector<edge> G[1'010];//頂点iから出る辺の配列G[i]の配列。 double dist[1'010];//特定の頂点から各頂点への距離が格納される。 bool used[1'010];//dijkstra実行中に、頂点iまでの距離を確定したかどうかを持つ。 void dijkstra(int v){//vは始点。 //以下のリンクでpriority_queueの使い方を参照 //http://shirokurostone.hatenablog.com/entry/20110522/1306052844 priority_queue<P, vector<P>, greater<P>> que; que.push(P(0, v)); while(!que.empty()){ P top = que.top(); que.pop(); int u = top.second; double d = top.first; //cout << u << ' ' << d << endl; if(used[u]) continue; dist[u] = d; used[u] = true; for(int i = 0; i < G[u].size(); i++){ if(!used[G[u][i].to]){ que.push(P(d+G[u][i].cost, G[u][i].to)); //cout << G[u][i].to << ' ' << d+G[u][i].cost << endl; } } } } int main(){ double xs,ys,xt,yt; cin>>xs>>ys>>xt>>yt; int n; cin>>n; double x[n+2],y[n+2],r[n+2]; x[0] = xs; y[0] = ys; r[0] = 0.0; REPP(i,n){ cin>>x[i]>>y[i]>>r[i]; } x[n+1] = xt; y[n+1] = yt; r[n+1] = 0; double temp; REP(i,n+2){ REP(j,n+2){ if(i==j)continue; temp = hypot(x[j]-x[i], y[j]-y[i]) - r[i] - r[j]; temp = max(temp, 0.0); G[i].push_back(edge{temp, j}); } } dijkstra(0); double ans; ans = dist[n+1]; cout << fixed << setprecision(10) << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:52:10: error: 'i' was not declared in this scope 52 | REPP(i,n){ | ^ a.cc:52:5: error: 'REPP' was not declared in this scope; did you mean 'REP'? 52 | REPP(i,n){ | ^~~~ | REP a.cc:62:16: error: 'hypot' was not declared in this scope 62 | temp = hypot(x[j]-x[i], y[j]-y[i]) - r[i] - r[j]; | ^~~~~ a.cc:64:29: warning: narrowing conversion of 'temp' from 'double' to 'int' [-Wnarrowing] 64 | G[i].push_back(edge{temp, j}); | ^~~~ a.cc:64:35: warning: narrowing conversion of 'j' from 'int' to 'double' [-Wnarrowing] 64 | G[i].push_back(edge{temp, j}); | ^ a.cc:70:22: error: 'setprecision' was not declared in this scope 70 | cout << fixed << setprecision(10) << ans << endl; | ^~~~~~~~~~~~ a.cc:4:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>' 3 | #include <queue> +++ |+#include <iomanip> 4 | #define REP(i,n) for(int i=0;i<n;i++)
s200931317
p03866
C
#include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)(n);++i) #define rep1(i,n) for(int i=1;i<=(int)(n);++i) #define rep11(i,n) for(int i=1;i<(int)(n);++i) #define repo(i,o,n) for(int i=o;i<(int)(n);++i) #define repm(i,n) for(int i=(int)(n)-1;i>=0;--i) #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define sperase(v,n) (v).erase(remove(all(v), n), (v).end()) #define vdelete(v) (v).erase(unique(all(v)), (v).end()) #define pb(n) push_back(n) #define mp make_pair #define MOD 1000000007 #define INF LONG_LONG_MAX double kr(double a, double b, double c, double d) { return sqrt((a-c)*(a-c) + (b-d)*(b-d)); } #define P pair<double,int> int n; bool visited[1002]; double x[1002],y[1002],r[1002]; vector<P> v[1002]; priority_queue<P,vector<P>,greater<P>> pq; signed main() { cin >> x[0] >> y[0] >> x[1] >> y[1] >> n;n+=2; repo(i,2,n) cin >> x[i] >> y[i] >> r[i]; rep(i,n) repo(j,i+1,n) { double hoge = max(0.0,kr(x[i],y[i],x[j],y[j])-r[i]-r[j]); v[i].pb(mp(hoge,j)); v[j].pb(mp(hoge,i)); } visited[0] = true; rep(i,v[0].size()) pq.push(v[0][i]); while(!pq.empty()) { int k = pq.top().se; double a = pq.top().fi; pq.pop(); if (visited[k]) continue; if (k == 1) { cout << setprecision(20) << a << endl; return 0; } visited[k] = true; rep(i,v[k].size()) pq.push(mp(v[k][i].fi + a,v[k][i].se)); } }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s870135235
p03866
C++
#define LOCAL #include <map> #include <unordered_map> #include <unordered_set> #include <set> #include <vector> #include <numeric> #include <algorithm> #include <iostream> #include <string> #include <cstring> #include <sstream> #include <functional> #include <queue> #include <deque> #include <stack> #include <iomanip> using namespace std; // From Errichto's Youtube stream #define sim template < class c #define ris return * this #define dor > debug & operator << #define eni(x) sim > typename \ enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c&) { ris; } #endif }; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " using int64 = long long; ///////////////////// // Code starts here// ///////////////////// const double INF = 1e12; struct Circle { int x, y, r; }; vector<Circle> circles; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int xa, ya, xb, yb, xc, yc, r; int N; cin >> xa >> ya >> xb >> yb; cin >> N; circles.push_back(Circle{xa, ya, 0}); for (int i = 0; i < N; i++) { cin >> xc >> yc >> r; circles.push_back(Circle{xc, yc, r}); } circles.push_back(Circle{xb, yb, 0}); N += 2; vector<double> dist(N, INF); vector<char> seen(N); dist[0] = 0; for (int steps = 0; steps < N; steps++) { auto el = min_element(dist.begin(), dist.end()) - dist.begin(); auto d = dist[el]; seen[el] = true; dist[el] = INF; //debug() << el << " " << d; if (el == N - 1) { cout << setprecision(10) << d << "\n"; return 0; } for (int i = 0; i < N; i++) { if (!seen[i]) { auto cost = hypot(1.0 * circles[i].x - circles[el].x, 1.0 * circles[i].y - circles[el].y); double common = circles[i].r + circles[el].r; if (cost >= common) { cost = abs(cost - common); } else { cost = 0; } if (dist[i] > d + cost) { dist[i] = d + cost; } } } } return 0; }
a.cc: In function 'int main()': a.cc:104:29: error: 'hypot' was not declared in this scope 104 | auto cost = hypot(1.0 * circles[i].x - circles[el].x, 1.0 * circles[i].y - circles[el].y); | ^~~~~
s841060356
p03866
C++
/// kAAzuki Hoshino /* #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") */ #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define int long long typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set; typedef long double ld; typedef vector<int> vi; typedef pair<int,int> pi; typedef vector<pi> vpi; #define inf 1000000000 #define mod 1000000007 #define rep(i,a,b) for (int i = a; i <= b; i++) #define rep1(i, a, b) for(int i =a; i >=b; i--) #define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl #define fs first #define sc second #define pb push_back #define all(c) (c).begin(),(c).end() #define mt make_tuple template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){ return o<<"("<<p.fs<<","<<p.sc<<")"; } template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){ o<<"{"; for(const T& v:vc) o<<v<<","; o<<"}"; return o; } int n,vis[1003]; double dist[1003],x[1003],y[1003],r[1003],x1,y1; vector<pair<int , ld>> adj[1003]; ld getdist( int i, int j ){ return sqrt(( x[i]-x[j] )*( x[i] - x[j] ) + ( y[i] - y[j] )*( y[i] - y[j] ) ); } void djikstra( int s ){ priority_queue<pair<int , ld>> q; q.push( {0, s} ); for(int i=1;i<=n+1;i++){ dist[i] = 1e18; } while(!q.empty()){ s = q.top().second;q.pop(); if(vis[s])continue; vis[s]=1; for(auto t:adj[s]){ if( dist[t.fs] > dist[s]+t.sc ){ dist[t.fs] = dist[s]+t.sc; q.push({ -dist[t.fs], t.fs }); } } } } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); cin >> x[0] >> y[0] >> x1 >> y1; cin >> n; x[n+1]=x1; y[n+1]=y1; for(int i=1;i<=n;i++){ cin >> x[i] >> y[i] >> r[i]; } for(int i=0;i<=n+1;i++){ for(int j=i+1;j<=n+1;j++){ ld d = max( (ld)0 , getdist( i, j ) - (r[i]+r[j])); adj[i].pb( {j, d} ); adj[j].pb( {i, d} ); } } djikstra( 0 ); cout << fixed << setprecision(12); cout << dist[n+1] << endl; return 0; } ///....
a.cc:41:46: error: 'double y1' redeclared as different kind of entity 41 | double dist[1003],x[1003],y[1003],r[1003],x1,y1; | ^~ In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683, from /usr/include/c++/14/cassert:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33, from a.cc:9: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)' 257 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:75:35: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept') 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~ | | | | | double(double) noexcept | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept' 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(short int)y1' to 'short int&' /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&' /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(int)y1' to 'int&' /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&' /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(long int)y1' to 'long int&' /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&' /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(long long int)y1' to 'long long int&' /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&' /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(void*)y1' to 'void*&' /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 75 |
s390526437
p03866
C++
/// kAAzuki Hoshino /* #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") */ #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define int long long typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set; typedef long double ld; typedef vector<int> vi; typedef pair<int,int> pi; typedef vector<pi> vpi; #define inf 1000000000 #define mod 1000000007 #define rep(i,a,b) for (int i = a; i <= b; i++) #define rep1(i, a, b) for(int i =a; i >=b; i--) #define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl #define fs first #define sc second #define pb push_back #define all(c) (c).begin(),(c).end() #define mt make_tuple template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){ return o<<"("<<p.fs<<","<<p.sc<<")"; } template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){ o<<"{"; for(const T& v:vc) o<<v<<","; o<<"}"; return o; } int n,vis[1003]; ld dist[1003],x[1003],y[1003],r[1003],x1,y1; vector<pair<int , ld>> adj[1003]; ld getdist( int i, int j ){ return sqrt(( x[i]-x[j] )*( x[i] - x[j] ) + ( y[i] - y[j] )*( y[i] - y[j] ) ); } void djikstra( int s ){ priority_queue<pair<int , ld>> q; q.push( {0, s} ); for(int i=1;i<=n+1;i++){ dist[i] = 1e18; } while(!q.empty()){ s = q.top().second;q.pop(); if(vis[s])continue; vis[s]=1; for(auto t:adj[s]){ if( dist[t.fs] > dist[s]+t.sc ){ dist[t.fs] = dist[s]+t.sc; q.push({ -dist[t.fs], t.fs }); } } } } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); cin >> x[0] >> y[0] >> x1 >> y1; cin >> n; x[n+1]=x1; y[n+1]=y1; for(int i=1;i<=n;i++){ cin >> x[i] >> y[i] >> r[i]; } for(int i=0;i<=n+1;i++){ for(int j=i+1;j<=n+1;j++){ ld d = max( (ld)0 , getdist( i, j ) - (r[i]+r[j])); adj[i].pb( {j, d} ); adj[j].pb( {i, d} ); } } djikstra( 0 ); cout << fixed << setprecision(12); cout << dist[n+1] << endl; return 0; } ///....
a.cc:41:42: error: 'ld y1' redeclared as different kind of entity 41 | ld dist[1003],x[1003],y[1003],r[1003],x1,y1; | ^~ In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683, from /usr/include/c++/14/cassert:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33, from a.cc:9: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)' 257 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:75:35: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept') 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~ | | | | | double(double) noexcept | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept' 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(short int)y1' to 'short int&' /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&' /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(int)y1' to 'int&' /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&' /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(long int)y1' to 'long int&' /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&' /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(long long int)y1' to 'long long int&' /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&' /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive] 75 | cin >> x[0] >> y[0] >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:75:38: error: cannot bind rvalue '(void*)y1' to 'void*&' /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: a.cc:75:38: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 75 | cin >>
s198891089
p03866
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, double> lpair; typedef pair<double, ll> lpair2; const ll MOD = 1e9 + 7; #define rep(i,m,n) for(ll i = (m); i < (n); i++) #define rrep(i,m,n) for(ll i = (m); i >= (n); i--) #define print(x) cout << (x) << endl; #define print2(x,y) cout << (x) << " " << (y) << endl; #define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];} #define INF (1e18) int main(){ cin.tie(0); ios::sync_with_stdio(false); double xs, ys, xt, yt; ll N; double x[1010], y[1010], r[1010]; cin >> xs >> ys >> xt >> yt; cin >> N; rep(i,1,N+1) cin >> x[i] >> y[i] >> r[i]; x[0] = xs; y[0] = ys, r[0] = 0; x[N+1] = xt; y[N+1] = yt; r[N+1] = 0; vector<lpair> tree[1010]; rep(i,0,N+2){ rep(j,0,N+2){ if(i == j) continue; double dist = sqrt(pow(x[i] - x[j],2) + pow(y[i] - y[j], 2)); double hankei = r[i] + r[j]; dist = max(0.0, dist - hankei); tree[i].push_back(make_pair(j, dist)); } } priority_queue<lpair2, vector<lpair2> ,greater<lpair2> > pq; double dist[1010] = {}; rep(i,1,N+2) dist[i] = INF; rep(i,0,N+2) pq.push(make_pair(dist[i], i)); ll is_visit[1010] = {}; while(!pq.empty()){ lpair2 l1 = pq.top(); pq.pop(); is_visit[l1.second] = 1; for(auto &e: tree[l1.second]){ if(dist[e.first] > dist[l1.second] + e.second){ if(!is_visit[e.first]){ dist[e.first] = dist[l1.second] + e.second; pq.push(make_pair(dist[e.first], e.first)); } } } } // printa(dist, N+2); cout << setprecision(12) << dist[N+1] << endl;
a.cc: In function 'int main()': a.cc:55:51: error: expected '}' at end of input 55 | cout << setprecision(12) << dist[N+1] << endl; | ^ a.cc:14:11: note: to match this '{' 14 | int main(){ | ^
s586791593
p03866
C
//#include "pch.h" #include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <vector> #include <set> #include <map> #include <iostream> #include <utility> #include <queue> #define ll long long #define fri(n) for(i=0;i<(n);i++) #define frj(n) for(j=0;j<(n);i++) #define min(p,q) ((p)<(q)?(p):(q)) #define max(p,q) ((p)>(q)?(p):(q)) #define swap(p,q) r=(p);(p)=(q);(q)=r #define INF 1000000000000//10^12 #define INFINT 2000000001//2*10^9+1 using namespace std; struct edge{ int to; double cost; }; typedef pair<int, int> P; int V;//辺の本数 static vector<edge> G[1000010];//辺の情報 手で埋めておく必要あり double d[1010]; ll int n,xs,ys,xt,yt; void init(double dd[], int num){ int i; for(i=0;i<num;i++){ dd[i]=INFINT; } } void dijkstra(int s){ priority_queue<P, vector<P>, greater<P> > que; init(d,1010); // printf("d[1]=%lf\n",d[1]); d[s]=0; que.push(P(0,s)); while(!que.empty()){ P p=que.top(); que.pop(); int v=p.second; if(d[v]<p.first) continue; for(int i=0; i<G[v].size(); i++){ edge e=G[v][i]; // printf("d[0]=%lf,d[1]=%lf,d[2]=%lf",d[0],d[1],d[2]); if(d[e.to]>d[v]+e.cost){ d[e.to]=d[v]+e.cost; que.push(P(d[e.to],e.to)); } } } } int main(void) { //変数の宣言 // int n,xs,ys,xt,yt; static ll int x[100010]; static ll int y[100010]; static int r[100010]; //よく使う変数 int i,j,k,l; int flag=0; int ans=0; int count=0; double temp,temp1,temp2; int max,min; int len; int sum=0; //データの読み込み scanf("%lld %lld %lld %lld\n%lld",&xs,&ys,&xt,&yt,&n); // scanf_s("%lld %lld %lld %lld\n%lld",&xs,&ys,&xt,&yt,&n); for(i=1;i<=n;i++){ scanf("%lld %lld %d",&x[i],&y[i],&r[i]); // scanf_s("%lld %lld %d",&x[i],&y[i],&r[i]); } // printf("nは%dです\n", n); // printf("データの読み込み終了\n"); //実際の処理 x[0]=xs; y[0]=ys; r[0]=0; x[n+1]=xt; y[n+1]=yt; r[n+1]=0; for(i=0;i<=n;i++){ for(j=i+1;j<=n+1;j++){ temp=max(0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]); edge p; p.to=j; p.cost=temp; G[i].push_back(p); p.to=i; G[j].push_back(p); } } dijkstra(0); // printf("計算部分終了\n"); //出力 printf("%1.10lf",d[n+1]); // printf("結果の出力終了\n"); return 0; }
main.c:8:10: fatal error: vector: No such file or directory 8 | #include <vector> | ^~~~~~~~ compilation terminated.
s508493555
p03866
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define repe(i,n) rep(i,(n)+1) #define per(i,n) for(int i=(int)(n)-1;i>=0;i--) #define pere(i,n) rep(i,(n)+1) #define all(x) (x).begin(),(x).end() #define SP <<" "<< #define MOD 1000000007 #define IINF 1000000000 #define LINF 1000000000000000000 typedef long long LL; typedef long double LD; int main(){ LD xs,ys,xt,yt; cin >> xs >> ys >> xt >> yt; int n; cin >> n; vector<LD> x(n+2),y(n+2),r(n+2); x[0]=xs,y[0]=ys,r[0]=0; x[n+1]=xt,y[n+1]=yt,r[n+1]=0; for(int i=1;i<=n;i++){ cin >> x[i] >> y[i] >> r[i]; } vector<vector<LD>> e(n+2,vector<LD>(n+2)); for(int i=0;i<=n+1;i++){ for(int j=0;j<=n+1;j++){ e[i][j]=max(0.0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]); } } vector<LD> dist(n+2,LINF); priority_queue<pair<LD,int>,vector<pair<LD,int>>,function<bool(pair<LD,int>,pair<LD,int>)>> dijk([](const pair<LD,int> &a, const pair<LD,int> &b){return a>b;}); dijk.push({0,0}); pair<LD,int> now; while(!dijk.empty()){ now=dijk.top(); dijk.pop(); if(dist[now.second]==LINF){ dist[now.second]=now.first; if(now.second==n+1) break; for(int i=1;i<=n+1;i++){ if(dist[i]==LINF){ dijk.push({now.first+e[now.second][i],i}); } } } } cout << fixed << setprecision(10) << dist[n+1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:31:18: error: no matching function for call to 'max(double, long double)' 31 | e[i][j]=max(0.0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:31:18: note: deduced conflicting types for parameter 'const _Tp' ('double' and 'long double') 31 | e[i][j]=max(0.0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:31:18: note: mismatched types 'std::initializer_list<_Tp>' and 'double' 31 | e[i][j]=max(0.0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s433716358
p03866
C++
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <utility> #include <string> #include <algorithm> #include <map> #include <vector> #include <climits> #include <numeric> #include<stdio.h> #include <queue> #include <iomanip> #include <float.h> #include <set> #include<functional> #include <stack> #include <time.h> #include <climits> #include <bitset> using namespace std; long long gcd(long long a, long long b) { if (a < b) gcd(b, a); long long r; while ((r = a%b)) { a = b; b = r; } return b; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } 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 * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long mod) { long long b = mod, u = 1, v = 0; while (b) { long long t = a / b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); } u %= mod; if (u < 0) u += mod; return u; } namespace NTT { const int MOD = 998244353; // to be set appropriately const long long PR = 3; // to be set appropriately void trans(vector<long long> &v, bool inv = false) { int n = (int)v.size(); for (int i = 0, j = 1; j < n - 1; j++) { for (int k = n >> 1; k >(i ^= k); k >>= 1); if (i > j) swap(v[i], v[j]); } for (int t = 2; t <= n; t <<= 1) { long long bw = modpow(PR, (MOD - 1) / t, MOD); if (inv) bw = modinv(bw, MOD); for (int i = 0; i < n; i += t) { long long w = 1; for (int j = 0; j < t / 2; ++j) { int j1 = i + j, j2 = i + j + t / 2; long long c1 = v[j1], c2 = v[j2] * w % MOD; v[j1] = c1 + c2; v[j2] = c1 - c2 + MOD; while (v[j1] >= MOD) v[j1] -= MOD; while (v[j2] >= MOD) v[j2] -= MOD; w = w * bw % MOD; } } } if (inv) { long long inv_n = modinv(n, MOD); for (int i = 0; i < n; ++i) v[i] = v[i] * inv_n % MOD; } } // C is A*B vector<long long> mult(vector<long long> A, vector<long long> B) { int size_a = 1; while (size_a < A.size()) size_a <<= 1; int size_b = 1; while (size_b < B.size()) size_b <<= 1; int size_fft = max(size_a, size_b) << 1; vector<long long> cA(size_fft, 0), cB(size_fft, 0), cC(size_fft, 0); for (int i = 0; i < A.size(); ++i) cA[i] = A[i]; for (int i = 0; i < B.size(); ++i) cB[i] = B[i]; trans(cA); trans(cB); for (int i = 0; i < size_fft; ++i) cC[i] = cA[i] * cB[i] % MOD; trans(cC, true); vector<long long> res((int)A.size() + (int)B.size() - 1); for (int i = 0; i < res.size(); ++i) res[i] = cC[i]; return res; } }; typedef pair<double, double>p; double kyori(p x,p y) { return sqrt((x.first - y.first)*(x.first - y.first) + (x.second - y.second)*(x.second - y.second)); } signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(15); double dist[1004]; p point[1005]; double r[1004]; int used[1005] = { 0 }; cin >> point[0].first >> point[0].second; double x, y; cin >> x >> y; int n; cin >> n; point[n + 1].first = x; point[n + 1].second = y; r[0] = r[n + 1] = 0; for (int i = 1; i <= n; i++) { cin >> point[i].first >> point[i].second >> r[i]; } for (int i = 0; i <= n + 1; i++) { dist[i] = DBL_MAX; } dist[0] = 0; while (1) { int v = -1; for (int i = 0; i <= n + 1; i++) { if (used[i] == 0 & (v == -1 || dist[i] < dist[v]))v = i; } if (v == -1)break; used[v] = 1; for (int u = 0; u <= n + 1; u++) { dist[u] = min(dist[u], max((double)dist[v], dist[v]+kyori(point[u], point[v]) - r[u] - r[v])); } } cout << dist[n + 1]; }
a.cc: In function 'double kyori(p, p)': a.cc:107:16: error: 'sqrt' was not declared in this scope 107 | return sqrt((x.first - y.first)*(x.first - y.first) + (x.second - y.second)*(x.second - y.second)); | ^~~~
s194821956
p03866
C++
#include<iostream> #include<iomanip> #include<cmath> #include<climits> #include<queue> using namespace std; #define SQ(x) ((x)*(x)) struct B { long long x,y,r; double dist(B b) { long long sqd = SQ(b.x - x) + SQ(b.y - y); if (sqd <= SQ(b.r + r)) return 0; return sqrt(sqd) - b.r - r; } }; typedef pair<double, int> P;//cost, to int main() { cin.tie(0); ios::sync_with_stdio(false); long long xs, ys, xt, yt, n; cin >> xs >> ys >> xt >> yt >> n; vector<B> bar(n + 2); bar[0] = { xs,ys,0 }; bar[n+1] = { xt,yt,0 }; long long xi, yi, ri; for (int i = 1; i <= n; ++i) { cin >> xi >> yi >> ri; bar[i] = { xi,yi,ri }; } vector<vector<double>> g(n + 2,vector<double>(n+2)); for (int i = 0; i < n + 2; ++i) { for (int j = i + 1; j < n + 2; ++j) { double d = bar[i].dist(bar[j]); g[i][j] = d; g[j][i] = d; } } vector<double> d(n+2, DBL_MAX); priority_queue<P> que; d[0]=0;que.push({0,0}); while(que.size()) { P p = que.top();que.pop(); double dist1 = d[p.second]; if (dist1 < -p.first) continue; for (int i = 0; i < n + 2; ++i) { if (i == p.second) continue; double dist2 = g[p.second][i]; if (d[i] > dist1 + dist2) { d[i] = dist1 + dist2; que.push({ -d[i],i }); } } } cout<<fixed<<setprecision(15)<<d[n+1]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:43:31: error: 'DBL_MAX' was not declared in this scope 43 | vector<double> d(n+2, DBL_MAX); | ^~~~~~~ a.cc:6:1: note: 'DBL_MAX' is defined in header '<cfloat>'; this is probably fixable by adding '#include <cfloat>' 5 | #include<queue> +++ |+#include <cfloat> 6 | using namespace std;
s460736949
p03866
C++
#include<iostream> #include<iomanip> #include<cmath> #include<queue> using namespace std; #define SQ(x) ((x)*(x)) struct B { long long x,y,r; double dist(B b) { long long sqd = SQ(b.x - x) + SQ(b.y - y); if (sqd <= SQ(b.r + r)) return 0; return sqrt(sqd) - b.r - r; } }; typedef pair<double, int> P;//cost, to int main() { cin.tie(0); ios::sync_with_stdio(false); long long xs, ys, xt, yt, n; cin >> xs >> ys >> xt >> yt >> n; vector<B> bar(n + 2); bar[0] = { xs,ys,0 }; bar[n+1] = { xt,yt,0 }; long long xi, yi, ri; for (int i = 1; i <= n; ++i) { cin >> xi >> yi >> ri; bar[i] = { xi,yi,ri }; } vector<vector<double>> g(n + 2,vector<double>(n+2)); for (int i = 0; i < n + 2; ++i) { for (int j = i + 1; j < n + 2; ++j) { double d = bar[i].dist(bar[j]); g[i][j] = d; g[j][i] = d; } } vector<double> d(n+2, DBL_MAX); priority_queue<P> que; d[0]=0;que.push({0,0}); while(que.size()) { P p = que.top();que.pop(); double dist1 = d[p.second]; if (dist1 < -p.first) continue; for (int i = 0; i < n + 2; ++i) { if (i == p.second) continue; double dist2 = g[p.second][i]; if (d[i] > dist1 + dist2) { d[i] = dist1 + dist2; que.push({ -d[i],i }); } } } cout<<fixed<<setprecision(15)<<d[n+1]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:42:31: error: 'DBL_MAX' was not declared in this scope 42 | vector<double> d(n+2, DBL_MAX); | ^~~~~~~ a.cc:5:1: note: 'DBL_MAX' is defined in header '<cfloat>'; this is probably fixable by adding '#include <cfloat>' 4 | #include<queue> +++ |+#include <cfloat> 5 | using namespace std;
s993899977
p03866
C++
#include<iostream> #include<queue> using namespace std; #define SQ(x) ((x)*(x)) struct B { long long x,y,r; double dist(B b) { long long sqd = SQ(b.x - x) + SQ(b.y - y); if (sqd <= SQ(b.r + r)) return 0; return sqrt(sqd) - b.r - r; } }; typedef pair<double, int> P;//cost, to int main() { cin.tie(0); ios::sync_with_stdio(false); long long xs, ys, xt, yt, n; cin >> xs >> ys >> xt >> yt >> n; vector<B> bar(n + 2); bar[0] = { xs,ys,0 }; bar[n+1] = { xt,yt,0 }; long long xi, yi, ri; for (int i = 1; i <= n; ++i) { cin >> xi >> yi >> ri; bar[i] = { xi,yi,ri }; } vector<vector<double>> g(n + 2,vector<double>(n+2)); for (int i = 0; i < n + 2; ++i) { for (int j = i + 1; j < n + 2; ++j) { double d = bar[i].dist(bar[j]); g[i][j] = d; g[j][i] = d; } } vector<double> d(n+2, INT32_MAX); priority_queue<P> que; d[0]=0;que.push({0,0}); while(que.size()) { P p = que.top();que.pop(); double dist1 = d[p.second]; if (dist1 < -p.first) continue; for (int i = 0; i < n + 2; ++i) { if (i == p.second) continue; double dist2 = g[p.second][i]; if (d[i] > dist1 + dist2) { d[i] = dist1 + dist2; que.push({ -d[i],i }); } } } cout<<d[n+1]<<endl; return 0; }
a.cc: In member function 'double B::dist(B)': a.cc:11:24: error: 'sqrt' was not declared in this scope 11 | return sqrt(sqd) - b.r - r; | ^~~~ a.cc: In function 'int main()': a.cc:40:31: error: 'INT32_MAX' was not declared in this scope 40 | vector<double> d(n+2, INT32_MAX); | ^~~~~~~~~ a.cc:3:1: note: 'INT32_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 2 | #include<queue> +++ |+#include <cstdint> 3 | using namespace std;
s271700787
p03866
C++
#include<iostream> #include<queue> #include<bitset> #include<algorithm> #include<climits> #include<vector> #include<deque> #include<cmath> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> P; #define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++) #define rep(i,n) repl(i,0,n) #define fill(x,y) memset(x,y,sizeof(x)) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<x<<endl #define dump(a) rep(i,a.size()){ cout<<a[i]<<" "; } cout<<endl; #define dumparr(a,n) rep(i,n){ cout<<a[i]<<" "; } cout<<endl; #define mmax(x,y) (x>y?x:y) #define mmin(x,y) (x<y?x:y) #define INF INT_MAX/3 #define EPS 1e-7 /* 基本的にダイクストラ * nodeをバリアの中心点、edgeを全点間に張って、その長さを(中心同士の距離-半径二つ)とする */ int main(){ ll xs,ys, xt,yt; ll n; ll x[1003], y[1003], r[1003]; cin>>xs>>ys>>xt>>yt>>n; rep(i,n){ cin>>x[i]>>y[i]>>r[i]; } // x[0]~x[n-1]は点, x[n]がstart, x[n+1]がend x[n]=xs; y[n]=ys; r[n]=0; x[n+1]=xt; y[n+1]=yt; r[n+1]=0; // ダイクストラ double d[1003]; // sからの最小距離 bool used[1003]; rep(i,n+2) d[i]=INF; fill(used, false); d[n] = 0; while(true) { /* dumparr(used, n+2); */ /* dumparr(d,n+2); */ ll v = -1; // 残ってるうちで最短のもの rep(i,n+2){ if(!used[i] && (v == -1 || d[i] < d[v])) v = i; } /* dbg(v); */ if(v==-1) break; // 終わり used[v] = true; rep(u,n+2) { /* dbg(sqrt((x[u]-x[v])*(x[u]-x[v])+(y[u]-y[v])*(y[u]-y[v]))); */ double dist = mmax(0, sqrt((x[u]-x[v])*(x[u]-x[v])+(y[u]-y[v])*(y[u]-y[v]))-r[u]-r[v]); d[u] = mmin( d[u], d[v]+dist ); } } /* dumparr(d, n+2); */ cout<<d[n+1]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:15:19: error: 'memset' was not declared in this scope 15 | #define fill(x,y) memset(x,y,sizeof(x)) | ^~~~~~ a.cc:45:3: note: in expansion of macro 'fill' 45 | fill(used, false); | ^~~~ a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 8 | #include<cmath> +++ |+#include <cstring> 9 | using namespace std;
s863666309
p03866
C++
import java.util.*; import java.lang.*; import java.io.*; class Pair<E extends Comparable<E>,F extends Comparable<F>> implements Comparable<Pair<E,F>>{ E first; F second; public Pair(E first, F second){ this.first=first; this.second=second; } public E getFirst(){return first;} public F getSecond(){return second;} public String toString(){ return "<"+first.toString()+","+second.toString()+">"; } public int hashCode(){ return first.hashCode()*30011+second.hashCode()+2; } public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Pair another = (Pair) obj; return this.getFirst().equals(another.getFirst())&&this.getSecond().equals(another.getSecond()); } public int compareTo(Pair<E,F> another){ if(this.getFirst().equals(another.getFirst())){ return this.getSecond().compareTo(another.getSecond()); } return this.getFirst().compareTo(another.getFirst()); } } class Edge implements Comparable<Edge>{ Node end; double weight; public Edge(Node end, double weight){ this.end = end; this.weight = weight; } public Edge(Node end){ this.end = end; this.weight = 1; } public double getWeight(){ return weight; } public Node getEnd(){ return end; } public int compareTo(Edge another){ if(this.getWeight()==another.getWeight()) return this.getEnd().compareTo(another.getEnd()); else return (new Double(this.getWeight())).compareTo(new Double(another.getWeight())); } public String toString(){ return "->"+end.toString()+"["+weight+"]"; } } class Node implements Comparable<Node>{ int id; List<Edge> edges; public Node(int id){ this.id = id; this.edges = new LinkedList<>(); } public void addEdge(Edge e){ edges.add(e); } public void addEdge(Node n, double weight){ this.addEdge(new Edge(n,weight)); } public void addEdge(Node n){ this.addEdge(n,1); } public void connect(Node n, double weight){ edges.add(new Edge(n,weight)); } public void connect(Node n){ edges.add(new Edge(n)); } public int getID(){ return id; } public List<Edge> getEdges(){ return edges; } public List<Node> getNeighbors(){ LinkedList<Node> neighbors = new LinkedList<>(); for(Edge e:this.getEdges()){ neighbors.add(e.getEnd()); } return neighbors; } public int compareTo(Node another){ return this.getID()-another.getID(); } public String toString(){ return "N"+id; } } class Graph{ int size; List<Node> nodes;//nodes[i] have ID "i" public Graph(int size){ this.size = size; nodes = new ArrayList<>(size); for(int i=0;i<size;i++){ nodes.add(new Node(i)); } } public void addNode(){ nodes.add(new Node(size)); size++; } public void addDirectionalEdge(int i, int j, double w){ // i->j if(i>=size || j>=size)return; nodes.get(i).addEdge(nodes.get(j),w); } public void addDirectionalEdge(int i, int j){ // i->j if(i>=size || j>=size)return; nodes.get(i).addEdge(nodes.get(j)); } public void addEdge(int i, int j, double w){ addDirectionalEdge(i,j,w); addDirectionalEdge(j,i,w); } public void addEdge(int i, int j){ addDirectionalEdge(i,j); addDirectionalEdge(j,i); } public int getSize(){ return size; } public List<Edge> getEdges(int i){ return nodes.get(i).getEdges(); } public List<Node> getNeighbors(int i){ return nodes.get(i).getNeighbors(); } public double getDistance(int i, int j){ double ans = Double.POSITIVE_INFINITY; for(Edge e:this.getEdges(i)){ if(e.getEnd().getID()==j) ans = Math.min(ans,e.getWeight()); } return ans; } public double pathDistance(int[] nodes){ double ans = 0; for(int n=1;n<nodes.length;n++){ ans += this.getDistance(nodes[n-1],nodes[n]); } return ans; } public double pathDistance(Integer[] nodes){ double ans = 0; for(int n=1;n<nodes.length;n++){ ans += this.getDistance(nodes[n-1],nodes[n]); } return ans; } public double pathDistance(List<Integer> nodes){ return pathDistance(nodes.toArray(new Integer[0])); } public List<Integer> dijkstra(int start, int end){ double[] distance = new double[size]; for(int n=0;n<size;n++) distance[n]=Double.POSITIVE_INFINITY; distance[start]=0; int[] prev = new int[size]; for(int n=0;n<size;n++) prev[n]=-1; PriorityQueue<Pair<Double,Integer>> A = new PriorityQueue<>(); A.add(new Pair<>(distance[start],start)); while(A.size()>0){ Pair<Double, Integer> p = A.poll(); int u = p.getSecond(); if(distance[u] < p.getFirst()) continue; for(Node nodeV :getNeighbors(u)){ int v = nodeV.getID(); double newDistance = distance[u] + getDistance(u,v); if(distance[v]>newDistance){ A.remove(new Pair<>(distance[v],v)); distance[v] = newDistance; prev[v] = u; A.add(new Pair<>(distance[v],v)); } } } LinkedList<Integer> ans = new LinkedList<>(); ans.push(end); int cur = end; while(cur!=start){ ans.push(prev[cur]); cur = prev[cur]; } return ans; } } class Barrier{ double x,y,r; public Barrier(double x, double y, double r){ this.x=x; this.y=y; this.r=r; } public double distance(Barrier another){ double d = Math.sqrt((this.x-another.x)*(this.x-another.x) + (this.y-another.y)*(this.y-another.y)); return Math.max(0,d-this.r-another.r); } } public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double startX = sc.nextDouble(); double startY = sc.nextDouble(); double endX = sc.nextDouble(); double endY = sc.nextDouble(); int N = sc.nextInt(); Barrier[] barrier = new Barrier[N+2]; barrier[0] = new Barrier(startX,startY,0); barrier[1] = new Barrier(endX,endY,0); for(int n=2;n<N+2;n++){ double x = sc.nextDouble(); double y = sc.nextDouble(); double r = sc.nextDouble(); barrier[n] = new Barrier(x,y,r); } Graph graph = new Graph(N+2); for(int i=0;i<N+1;i++)for(int j=i+1;j<=N+1;j++){ graph.addEdge(i,j,barrier[i].distance(barrier[j])); } System.out.println(graph.pathDistance(graph.dijkstra(0,1))); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*; | ^~~~~~ 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.lang.*; | ^~~~~~ 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.*; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:7: error: 'Pair' is not a class template 4 | class Pair<E extends Comparable<E>,F extends Comparable<F>> implements Comparable<Pair<E,F>>{ | ^~~~ a.cc:4:12: error: 'E' was not declared in this scope 4 | class Pair<E extends Comparable<E>,F extends Comparable<F>> implements Comparable<Pair<E,F>>{ | ^ a.cc:4:72: error: expected initializer before 'Comparable' 4 | class Pair<E extends Comparable<E>,F extends Comparable<F>> implements Comparable<Pair<E,F>>{ | ^~~~~~~~~~ a.cc:38:23: error: expected initializer before 'Comparable' 38 | class Edge implements Comparable<Edge>{ | ^~~~~~~~~~ a.cc:63:23: error: expected initializer before 'Comparable' 63 | class Node implements Comparable<Node>{ | ^~~~~~~~~~ a.cc:107:5: error: 'List' does not name a type 107 | List<Node> nodes;//nodes[i] have ID "i" | ^~~~ a.cc:108:11: error: expected ':' before 'Graph' 108 | public Graph(int size){ | ^~~~~~ | : a.cc:115:11: error: expected ':' before 'void' 115 | public void addNode(){ | ^~~~~ | : a.cc:119:11: error: expected ':' before 'void' 119 | public void addDirectionalEdge(int i, int j, double w){ // i->j | ^~~~~ | : a.cc:123:11: error: expected ':' before 'void' 123 | public void addDirectionalEdge(int i, int j){ // i->j | ^~~~~ | : a.cc:127:11: error: expected ':' before 'void' 127 | public void addEdge(int i, int j, double w){ | ^~~~~ | : a.cc:131:11: error: expected ':' before 'void' 131 | public void addEdge(int i, int j){ | ^~~~~ | : a.cc:135:11: error: expected ':' before 'int' 135 | public int getSize(){ | ^~~~ | : a.cc:138:11: error: expected ':' before 'List' 138 | public List<Edge> getEdges(int i){ | ^~~~~ | : a.cc:138:12: error: 'List' does not name a type 138 | public List<Edge> getEdges(int i){ | ^~~~ a.cc:141:11: error: expected ':' before 'List' 141 | public List<Node> getNeighbors(int i){ | ^~~~~ | : a.cc:141:12: error: 'List' does not name a type 141 | public List<Node> getNeighbors(int i){ | ^~~~ a.cc:144:11: error: expected ':' before 'double' 144 | public double getDistance(int i, int j){ | ^~~~~~~ | : a.cc:151:11: error: expected ':' before 'double' 151 | public double pathDistance(int[] nodes){ | ^~~~~~~ | : a.cc:151:38: error: expected ',' or '...' before 'nodes' 151 | public double pathDistance(int[] nodes){ | ^~~~~ a.cc:158:11: error: expected ':' before 'double' 158 | public double pathDistance(Integer[] nodes){ | ^~~~~~~ | : a.cc:158:32: error: 'Integer' has not been declared 158 | public double pathDistance(Integer[] nodes){ | ^~~~~~~ a.cc:158:42: error: expected ',' or '...' before 'nodes' 158 | public double pathDistance(Integer[] nodes){ | ^~~~~ a.cc:158:19: error: 'double Graph::pathDistance(int*)' cannot be overloaded with 'double Graph::pathDistance(int*)' 158 | public double pathDistance(Integer[] nodes){ | ^~~~~~~~~~~~ a.cc:151:19: note: previous declaration 'double Graph::pathDistance(int*)' 151 | public double pathDistance(int[] nodes){ | ^~~~~~~~~~~~ a.cc:165:11: error: expected ':' before 'double' 165 | public double pathDistance(List<Integer> nodes){ | ^~~~~~~ | : a.cc:165:32: error: 'List' has not been declared 165 | public double pathDistance(List<Integer> nodes){ | ^~~~ a.cc:165:36: error: expected ',' or '...' before '<' token 165 | public double pathDistance(List<Integer> nodes){ | ^ a.cc:168:11: error: expected ':' before 'List' 168 | public List<Integer> dijkstra(int start, int end){ | ^~~~~ | : a.cc:168:12: error: 'List' does not name a type 168 | public List<Integer> dijkstra(int start, int end){ | ^~~~ a.cc:203:2: error: expected ';' after class definition 203 | } | ^ | ; a.cc: In constructor 'Graph::Graph(int)': a.cc:109:14: error: request for member 'size' in '(Graph*)this', which is of pointer type 'Graph*' (maybe you meant to use '->' ?) 109 | this.size = size; | ^~~~ a.cc:110:9: error: 'nodes' was not declared in this scope 110 | nodes = new ArrayList<>(size); | ^~~~~ a.cc:110:21: error: 'ArrayList' does not name a type 110 | nodes = new ArrayList<>(size); | ^~~~~~~~~ a.cc:110:31: error: expected primary-expression before '>' token 110 | nodes = new ArrayList<>(size); | ^ a.cc:112:37: error: invalid use of incomplete type 'class Node' 112 | nodes.add(new Node(i)); | ^ a.cc:63:7: note: forward declaration of 'class Node' 63 | class Node implements Comparable<Node>{ | ^~~~ a.cc: In member function 'void Graph::addNode()': a.cc:116:9: error: 'nodes' was not declared in this scope 116 | nodes.add(new Node(size)); | ^~~~~ a.cc:116:32: error: invalid use of incomplete type 'class Node' 116 | nodes.add(new Node(size)); | ^ a.cc:63:7: note: forward declaration of 'class Node' 63 | class Node implements Comparable<Node>{ | ^~~~ a.cc: In member function 'void Graph::addDirectionalEdge(int, int, double)': a.cc:121:9: error: 'nodes' was not declared in this scope 121 | nodes.get(i).addEdge(nodes.get(j),w); | ^~~~~ a.cc: In member function 'void Graph::addDirectionalEdge(int, int)': a.cc:125:9: error: 'nodes' was not declared in this scope 125 | nodes.get(i).addEdge(nodes.get(j)); | ^~~~~ a.cc: In member function 'double Graph::getDistance(int, int)': a.cc:145:22: error: 'Double' was not declared in this scope; did you mean 'double'? 145 | double ans = Double.POSITIVE_INFINITY; | ^~~~~~ | double a.cc:146:18: error: variable 'Edge e' has initializer but incomplete type 146 | for(Edge e:this.getEdges(i)){ | ^ a.cc:146:25: error: request for member 'getEdges' in '(Graph*)this', which is of pointer type 'Graph*' (maybe you meant to use '->' ?) 146 | for(Edge e:this.getEdges(i)){ | ^~~~~~~~ a.cc:147:49: error: 'Math' was not declared in this scope 147 | if(e.getEnd().getID()==j) ans = Math.min(ans,e.getWeight()); | ^~~~ a.cc: In member function 'double Graph::pathDistance(int*)': a.cc:153:23: error: 'nodes' was not declared in this scope 153 | for(int n=1;n<nodes.length;n++){ | ^~~~~ a.cc:154:29: error: request for member 'getDistance' in '(Graph*)this', which is of pointer type 'Graph*' (maybe you meant to use '->' ?) 154 | ans += this.getDistance(nodes[n-1],nodes[n]); | ^~~~~~~~~~~ a.cc: In member function 'double Graph::pathDistance(int*)': a.cc:160:23: error: 'nodes' was not declared in this scope 160 | for(int n=1;n<nodes.length;n++){ | ^~~~~ a.cc:161:29: error: request for member 'getDistance' in '(Graph*)this', which is of pointer type 'Graph*' (maybe you meant to use '->' ?) 161 | ans += this.getDistance(nodes[n-1],nodes[n]); | ^~~~~~~~~~~ a.cc: In member function 'double Graph::pathDistance(int)': a.cc:166:29: error: 'nodes' was not declared in this scope 166 | return pathDistance(nodes.toArray(new Integer[0])); | ^~~~~ a.cc:166:47: error: 'Integer' does not name a type 166 | return pathDistance(nodes.toArray(new Integer[0])); | ^~~~~~~ a.cc: At global scope: a.cc:208:11: error: expected ':' before 'Barrier' 208 | public Barrier(double x, double y, double r){ | ^~~~~~~~ | : a.cc:213:11: error: expected ':' before 'double' 213 | public double distance(Barrier another){ | ^~~~~~~ | : a.cc:217:2: error: expected ';' after class definition 217 | } | ^ | ; a.cc: In constructor 'Barrier::Barrier(double, double, double)': a.cc:209:14: error: request for member 'x' in '(Barrier*)this', which is of pointer type 'Barrier*' (maybe you meant to use '->' ?) 209 | this.x=x; | ^ a.cc:210:14: error: request for member 'y' in '(Barrier*)this', which is of pointer type 'Barrier*' (maybe you meant to use '->' ?) 210 | this.y=y; | ^ a.cc:211:14: error: request for member 'r' in '(Barrier*)this', which is of pointer type 'Barrier*' (maybe you meant to use '->' ?) 211 | this.r=r; | ^ a.cc: In member function 'double Barrier::distance(Barrier)': a.cc:214:20: error: 'Math' was not declared in
s720542623
p03866
C++
#include<queue> #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; void Read(int &p) { p=0; int f=1; char c=getchar(); while(c<'0' || c>'9') { if(c=='-') f=-1; c=getchar(); } while(c>='0' && c<='9') p=p*10+c-'0',c=getchar(); p*=f; } const int MAXN=1000+24; int N,x[MAXN],y[MAXN],r[MAXN],vis[MAXN]; double Dis[MAXN]; #define ids(i,j) max(0.0,sqrt(1.0*(x[i]-x[j])*(x[i]-x[j])+1.0*(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]) bool inq[MAXN]; int showup[MAXN]; int Spfa() { int s=1,t=2; queue<int>Q; for(int i=1;i<=N;i++) Dis[i]=(i==s)?0:INF; Q.push(s),inq[s]=1,showup[s]++; int v,p,m,sz; while(!Q.empty()) { p=Q.front(),Q.pop(),inq[p]=0, for(int i=1;i<=N;i++) if(Dis[i]>ids(p,o)+Dis[t]) { Dis[i]=v+Dis[t]; if(!inq[i]) { Q.push(i),inq[i]=1,showup[i]++; if(showup[i]>N) return -1; } } } if(Dis[t]==INF) return -2; return Dis[t]; } int main() { Read(x[1]); Read(y[1]); Read(x[2]); Read(y[2]); Read(N),N+=2; for(int i=3;i<=N;i++) Read(x[i]),Read(y[i]),Read(r[i]); Dijkstra(); printf("%.10lf",dis[2]); }
a.cc: In function 'int Spfa()': a.cc:34:43: error: 'INF' was not declared in this scope 34 | for(int i=1;i<=N;i++) Dis[i]=(i==s)?0:INF; | ^~~ a.cc:42:9: error: expected primary-expression before 'for' 42 | for(int i=1;i<=N;i++) | ^~~ a.cc:42:21: error: 'i' was not declared in this scope 42 | for(int i=1;i<=N;i++) | ^ a.cc:53:16: error: 'INF' was not declared in this scope 53 | if(Dis[t]==INF) return -2; | ^~~ a.cc: In function 'int main()': a.cc:62:9: error: 'Dijkstra' was not declared in this scope 62 | Dijkstra(); | ^~~~~~~~ a.cc:63:25: error: 'dis' was not declared in this scope; did you mean 'Dis'? 63 | printf("%.10lf",dis[2]); | ^~~ | Dis
s935796354
p03866
C++
#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <string> #include <vector> #include <queue> #include <cmath> using namespace std; const int MAXN = 1000 + 10; #define y1 __y1 #define y2 __y2 struct barrier { int x, y, r; }; int N; int x1, x2, y1, y2; vector <barrier> vbar; double dist[MAXN]; bool inQueue[MAXN]; double getDist(int from, int to) { double deltaX = vbar[from].x - vbar[to].x; double deltaY = vbar[from].y - vbar[to].y; return max(sqrt(deltaX * deltaX + deltaY * deltaY) - vbar[from].r - vbar[to].r, 0.0); } void SPFA() { fill(dist, dist + N + 2, 0x7FFFFFFF); memset(inQueue, 0x00, sizeof inQueue); queue <int> q; q.push(0); dist[0] = 0, inQueue[0] = true; while(!q.empty()) { int to = q.front(); inQueue[to] = false; q.pop(); for(int i = 0; i <= N + 1; i++) { if(i == to) continue; if(dist[i] > dist[to] + getDist(i, to)) { dist[i] = dist[to] + getDist(i, to); if(!inQueue[i]) { inQueue[i] = true; q.push(i); } } } } } int main() { int u, v, w; cin >> x1 >> y1 >> x2 >> y2 ; vbar.push_back(barrier{x1, y1, 0}); vbar.push_back(barrier{x2, y2, 0}); cin >> N ; for(int i = 1; i <= N; i++) cin >> u >> v >> w, vbar.push_back(barrier{u, v, w}); SPFA(); cout << fixed << setprecision(10) << dist[1] << endl ; return 0; }
a.cc:13:12: error: 'int __y1' redeclared as different kind of entity 13 | #define y1 __y1 | ^~~~ a.cc:22:13: note: in expansion of macro 'y1' 22 | int x1, x2, y1, y2; | ^~ In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683, from /usr/include/c++/14/bits/stl_algobase.h:59, from /usr/include/c++/14/algorithm:60, from a.cc:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double __y1(double)' 257 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:71:15: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept') 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ~~~~~~~~~ ^~ | | | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42, from a.cc:2: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:13:12: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept' 13 | #define y1 __y1 | ^~~~ a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:13:12: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive] 13 | #define y1 __y1 | ^~~~ | | | double (*)(double) noexcept a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ a.cc:13:12: error: cannot bind rvalue '(short int)__y1' to 'short int&' 13 | #define y1 __y1 | ^~~~ a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:13:12: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive] 13 | #define y1 __y1 | ^~~~ | | | double (*)(double) noexcept a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ a.cc:13:12: error: cannot bind rvalue '(short unsigned int)__y1' to 'short unsigned int&' 13 | #define y1 __y1 | ^~~~ a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: a.cc:13:12: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 13 | #define y1 __y1 | ^~~~ | | | double (*)(double) noexcept a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ a.cc:13:12: error: cannot bind rvalue '(int)__y1' to 'int&' 13 | #define y1 __y1 | ^~~~ a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:13:12: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive] 13 | #define y1 __y1 | ^~~~ | | | double (*)(double) noexcept a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ a.cc:13:12: error: cannot bind rvalue '(unsigned int)__y1' to 'unsigned int&' 13 | #define y1 __y1 | ^~~~ a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:13:12: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive] 13 | #define y1 __y1 | ^~~~ | | | double (*)(double) noexcept a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ a.cc:13:12: error: cannot bind rvalue '(long int)__y1' to 'long int&' 13 | #define y1 __y1 | ^~~~ a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:13:12: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive] 13 | #define y1 __y1 | ^~~~ | | | double (*)(double) noexcept a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ a.cc:13:12: error: cannot bind rvalue '(long unsigned int)__y1' to 'long unsigned int&' 13 | #define y1 __y1 | ^~~~ a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:13:12: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive] 13 | #define y1 __y1 | ^~~~ | | | double (*)(double) noexcept a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ a.cc:13:12: error: cannot bind rvalue '(long long int)__y1' to 'long long int&' 13 | #define y1 __y1 | ^~~~ a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:13:12: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive] 13 | #define y1 __y1 | ^~~~ | | | double (*)(double) noexcept a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ a.cc:13:12: error: cannot bind rvalue '(long long unsigned int)__y1' to 'long long unsigned int&' 13 | #define y1 __y1 | ^~~~ a.cc:71:18: note: in expansion of macro 'y1' 71 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 328 | operator>>(void*& __p) |
s777252818
p03866
C++
#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <string> #include <vector> #include <queue> #include <cmath> using namespace std; const int MAXN = 1000 + 10; struct barrier { int x, y, r; }; int N; int x1, x2, y1, y2; vector <barrier> vbar; double dist[MAXN]; bool inQueue[MAXN]; double getDist(int from, int to) { double deltaX = vbar[from].x - vbar[to].x; double deltaY = vbar[from].y - vbar[to].y; return max(sqrt(deltaX * deltaX + deltaY * deltaY) - vbar[from].r - vbar[to].r, 0.0); } void SPFA() { fill(dist, dist + N + 2, 0x7FFFFFFF); memset(inQueue, 0x00, sizeof inQueue); queue <int> q; q.push(0); dist[0] = 0, inQueue[0] = true; while(!q.empty()) { int to = q.front(); inQueue[to] = false; q.pop(); for(int i = 0; i <= N + 1; i++) { if(i == to) continue; if(dist[i] > dist[to] + getDist(i, to)) { dist[i] = dist[to] + getDist(i, to); if(!inQueue[i]) { inQueue[i] = true; q.push(i); } } } } } int main() { int u, v, w; cin >> x1 >> y1 >> x2 >> y2 ; vbar.push_back(barrier{x1, y1, 0}); vbar.push_back(barrier{x2, y2, 0}); cin >> N ; for(int i = 1; i <= N; i++) cin >> u >> v >> w, vbar.push_back(barrier{u, v, w}); SPFA(); cout << fixed << setprecision(10) << dist[1] << endl ; return 0; }
a.cc:19:13: error: 'int y1' redeclared as different kind of entity 19 | int x1, x2, y1, y2; | ^~ In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683, from /usr/include/c++/14/bits/stl_algobase.h:59, from /usr/include/c++/14/algorithm:60, from a.cc:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)' 257 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:68:15: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept') 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ~~~~~~~~~ ^~ ~~ | | | | | double(double) noexcept | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42, from a.cc:2: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept' 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(short int)y1' to 'short int&' /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&' /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(int)y1' to 'int&' /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&' /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(long int)y1' to 'long int&' /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&' /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(long long int)y1' to 'long long int&' /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&' /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(void*)y1' to 'void*&' /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match) 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:126:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~
s858308092
p03866
C++
#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <string> #include <vector> #include <queue> #include <cmath> using namespace std; const int MAXN = 1000 + 10; struct barrier { int x, y, r; }; int N; int x1, x2, y1, y2; vector <barrier> vbar; double dist[MAXN]; bool inQueue[MAXN]; double getDist(int from, int to) { double deltaX = vbar[from].x - vbar[to].x; double deltaY = vbar[from].y - vbar[to].y; return max(sqrt(deltaX * deltaX + deltaY * deltaY) - vbar[from].r - vbar[to].r, 0.0); } void SPFA() { fill(dist, dist + N + 2, 0x7FFFFFFF); memset(inQueue, 0x00, sizeof inQueue); queue <int> q; q.push(0); dist[0] = 0, inQueue[0] = true; while(!q.empty()) { int to = q.front(); inQueue[to] = false; q.pop(); for(int i = 0; i <= N + 1; i++) { if(i == to) continue; if(dist[i] > dist[to] + getDist(i, to)) { dist[i] = dist[to] + getDist(i, to); if(!inQueue[i]) { inQueue[i] = true; q.push(i); } } } } } int main() { int u, v, w; cin >> x1 >> y1 >> x2 >> y2 ; vbar.push_back(barrier{x1, y1, 0}); vbar.push_back(barrier{x2, y2, 0}); cin >> N ; for(int i = 1; i <= N; i++) cin >> u >> v >> w, vbar.push_back(barrier{u, v, w}); SPFA(); cout << fixed << setprecision(10) << dist[1] << endl ; return 0; }
a.cc:19:13: error: 'int y1' redeclared as different kind of entity 19 | int x1, x2, y1, y2; | ^~ In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683, from /usr/include/c++/14/bits/stl_algobase.h:59, from /usr/include/c++/14/algorithm:60, from a.cc:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)' 257 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:68:15: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept') 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ~~~~~~~~~ ^~ ~~ | | | | | double(double) noexcept | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42, from a.cc:2: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept' 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(short int)y1' to 'short int&' /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&' /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(int)y1' to 'int&' /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&' /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(long int)y1' to 'long int&' /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&' /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(long long int)y1' to 'long long int&' /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&' /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept a.cc:68:18: error: cannot bind rvalue '(void*)y1' to 'void*&' /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~ | | | double (*)(double) noexcept /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match) 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:126:7: note: conversion of argument 1 would be ill-formed: a.cc:68:18: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} [-fpermissive] 68 | cin >> x1 >> y1 >> x2 >> y2 ; | ^~
s683226753
p03866
C++
#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <string> #include <vector> #include <queue> using namespace std; const int MAXN = 1000 + 10; struct barrier { int x, y, r; }; int N; int x1, x2, y1, y2; vector <barrier> vbar; double dist[MAXN]; bool inQueue[MAXN]; double getDist(int from, int to) { double deltaX = vbar[from].x - vbar[to].x; double deltaY = vbar[from].y - vbar[to].y; return max(sqrt(deltaX * deltaX + deltaY * deltaY) - vbar[from].r - vbar[to].r, 0.0); } void SPFA() { fill(dist, dist + N + 2, 0x7FFFFFFF); memset(inQueue, 0x00, sizeof inQueue); queue <int> q; q.push(0); dist[0] = 0, inQueue[0] = true; while(!q.empty()) { int to = q.front(); inQueue[to] = false; q.pop(); for(int i = 0; i <= N + 1; i++) { if(i == to) continue; if(dist[i] > dist[to] + getDist(i, to)) { dist[i] = dist[to] + getDist(i, to); if(!inQueue[i]) { inQueue[i] = true; q.push(i); } } } } } int main() { int u, v, w; cin >> x1 >> y1 >> x2 >> y2 ; vbar.push_back(barrier{x1, y1, 0}); vbar.push_back(barrier{x2, y2, 0}); cin >> N ; for(int i = 1; i <= N; i++) cin >> u >> v >> w, vbar.push_back(barrier{u, v, w}); SPFA(); cout << fixed << setprecision(10) << dist[1] << endl ; return 0; }
a.cc:18:13: warning: built-in function 'y1' declared as non-function [-Wbuiltin-declaration-mismatch] 18 | int x1, x2, y1, y2; | ^~ a.cc: In function 'double getDist(int, int)': a.cc:27:16: error: 'sqrt' was not declared in this scope 27 | return max(sqrt(deltaX * deltaX + deltaY * deltaY) - vbar[from].r - vbar[to].r, 0.0); | ^~~~
s772181722
p03866
C++
#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <string> #include <vector> #include <queue> using namespace std; const int MAXN = 1000 + 10; struct barrier { int x, y, r; }; int N; int x1, x2, y1, y2; vector <barrier> vbar; double dist[MAXN]; bool inQueue[MAXN]; double getDist(int from, int to) { double deltaX = vbar[from].x - vbar[to].x; double deltaY = vbar[from].y - vbar[to].y; return max(sqrt(deltaX * deltaX + deltaY * deltaY) - vbar[from].r - vbar[to].r, 0.0); } void SPFA() { fill(dist, dist + N + 2, 0x7FFFFFFF); memset(inQueue, 0x00, sizeof inQueue); queue <int> q; q.push(0); dist[0] = 0, inQueue[0] = true; while(!q.empty()) { int to = q.front(); inQueue[to] = false; q.pop(); for(int i = 0; i <= N + 1; i++) { if(i == to) continue; if(dist[i] > dist[to] + getDist(i, to)) { dist[i] = dist[to] + getDist(i, to); if(!inQueue[i]) { inQueue[i] = true; q.push(i); } } } } } int main() { int u, v, w; cin >> x1 >> y1 >> x2 >> y2 ; vbar.push_back(barrier{x1, y1, 0}); vbar.push_back(barrier{x2, y2, 0}); cin >> N ; for(int i = 1; i <= N; i++) cin >> u >> v >> w, vbar.push_back(barrier{u, v, w}); SPFA(); cout << fixed << setprecision(10) << dist[1] << endl ; return 0; }
a.cc:18:13: warning: built-in function 'y1' declared as non-function [-Wbuiltin-declaration-mismatch] 18 | int x1, x2, y1, y2; | ^~ a.cc: In function 'double getDist(int, int)': a.cc:27:16: error: 'sqrt' was not declared in this scope 27 | return max(sqrt(deltaX * deltaX + deltaY * deltaY) - vbar[from].r - vbar[to].r, 0.0); | ^~~~
s288866195
p03866
C++
#include<iostream> #include<algorithm> #include<vector> #define REP(x,y) for(int i=x;i<=y;i++) using namespace std; struct point { double x; double y; }; double INF = 100000000000000000; int const MAX = 1005; point a[MAX]; double radius[MAX]; double g[MAX][MAX]; int color[MAX]; double dist[MAX]; int main() { cin >> a[0].x >> a[0].y >> a[1].x >> a[1].y; radius[1] = radius[0] = 0; int n; cin >> n; REP(2, n + 1) { cin >> a[i].x >> a[i].y; cin >> radius[i]; } REP(0, n + 1) { for (int j = 0; j <= i; j++) { double dist_x, dist_y; dist_x = a[i].x - a[j].x; dist_y = a[i].y - a[j].y; g[i][j] = g[j][i] = max(double(0),sqrt(dist_x*dist_x + dist_y * dist_y)-radius[i]-radius[j]); } } double ans = 0; int now = 0; REP(0, n + 1) color[i] = 0; REP(0, n + 1) dist[i] = INF; color[0] = 1; while (now != 1) { int nearest = 1; double nearest_dist = INF; REP(1, n + 1) { if (color[i] == 0) { dist[i] = min(dist[i], g[i][now]); if (nearest_dist >= dist[i]) { nearest_dist = dist[i]; nearest = i; } } } now = nearest; color[now] = 1; ans += nearest_dist; } cout.precision(20); cout << ans << endl; }
a.cc: In function 'int main()': a.cc:32:59: error: 'sqrt' was not declared in this scope 32 | g[i][j] = g[j][i] = max(double(0),sqrt(dist_x*dist_x + dist_y * dist_y)-radius[i]-radius[j]); | ^~~~
s743788182
p03866
C++
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <cstdio> #include <cstring> using namespace std; typedef long long ll; typedef double D; typedef pair<D,int> P; #define M 1000000007 #define F first #define S second #define PB push_back vector<P>g[1005]; int n; D xs,ys,xt,yt; D x[1005],y[1005],r[1005],d[1005]; int main(void){ cin>>xs>>ys>>xt>>yt>>n; for(int i=1;i<=n;i++){ cin>>x[i]>>y[i]>>r[i]; g[0].PB(P(max(D(0),sqrt((xs-x[i])*(xs-x[i])+(ys-y[i])*(ys-y[i]))-r[i]),i)); g[i].PB(P(max(D(0),sqrt((xt-x[i])*(xt-x[i])+(yt-y[i])*(yt-y[i]))-r[i]),n+1)); } for(int i=1;i<=n;i++){ for(int j=i+1;j<=n;j++){ g[i].PB(P(max(D(0),sqrt((x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i]))-r[i]-r[j]),j)); g[j].PB(P(max(D(0),sqrt((x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i]))-r[i]-r[j]),i)); } } for(int i=1;i<=n+1;i++)d[i]=10000000000; priority_queue<P,vector<P>,greater<P> >dik; dik.push(P(0,0)); while(!dik.empty()){ int v=dik.top().S; D c=dik.top().F; dik.pop(); if(c>d[v])continue; for(int i=0;i<g[v].size();i++){ int u=g[v][i].S; D l=g[v][i].F; if(d[u]>c+l){ d[u]=c+l; dik.push(P(c+l,u)); } } } printf("%.10lf\n",d[n+1]); }
a.cc: In function 'int main()': a.cc:26:28: error: 'sqrt' was not declared in this scope 26 | g[0].PB(P(max(D(0),sqrt((xs-x[i])*(xs-x[i])+(ys-y[i])*(ys-y[i]))-r[i]),i)); | ^~~~ a.cc:31:32: error: 'sqrt' was not declared in this scope 31 | g[i].PB(P(max(D(0),sqrt((x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i]))-r[i]-r[j]),j)); | ^~~~
s226792738
p03866
C++
#include <bits/stdc++.h> using namespace std; using lint = long long int; using P = pair<lint, lint>; class Dijkstra { int V; double inf; vector<double> distance; double eps; public: vector<vector<double> > e; Dijkstra(int V, double inf) : V(V), inf(inf), eps(1E-5) { e = vector<vector<double> >(V, vector<double>(V, inf)); for (int i=0; i<V; i++) e[i][i] = 0; } void update_edge(int v1, int v2, double d) { e[v1][v2] = e[v2][v1] = min(e[v1][v2], d); } double dijkstra(int from, int to) { distance = vector<double>(V, inf); using Pque = pair<double, int>; priority_queue<Pque, vector<Pque>, greater<Pque> > que; que.push(make_pair(0.0, from)); while (true) { int now = que.top().second; double dist_tmp = que.top().first; if (now == to) return dist_tmp; que.pop(); if (distance[now] > dist_tmp + eps) { distance[now] = dist_tmp; for (int i=0; i<V; i++) { if (i == now) continue; if (distance[i] > distance[now] + e[now][i] + eps) { que.push(make_pair(distance[now] + e[now][i], i)); } } } } } }; int N; lint xs, ys, xt, yt; vector<int> r; vector<P> x; double d(P p1, P p2) { return sqrt((double)((p1.first - p2.first) * (p1.first - p2.first) + (p1.second - p2.second) * (p1.second - p2.second))); } int main() { cin >> xs >> ys >> xt >> yt >> N; r.resize(N); x.resize(N); for (int i=0; i<N; i++) cin >> x[i].first >> x[i].second >> r[i]; Dijkstra dij(N+2, 1E10); for (int i=0; i<N; i++) { dij.update_edge(i+1, 0, max(d(make_pair(xs, ys), x[i]) - r[i], 0.0)); dij.update_edge(i+1, N+1, max(d(make_pair(xt, yt), x[i]) - r[i], 0.0)); for (int j=0; j<i; j++) { dij.update_edge(i+1, j+1, max(0.0, d(x[i], x[j]) - r[i] - r[j])); } } dij.update_edge(0, N+1, d(make_pair(xs, ys), make_pair(xt, yt))); cout << set_ << dij.dijkstra(0, N+1) << endl; }
a.cc: In function 'int main()': a.cc:82:13: error: 'set_' was not declared in this scope 82 | cout << set_ << dij.dijkstra(0, N+1) << endl; | ^~~~
s565447771
p03866
C++
#include "bits/stdc++.h" #define ll long long #define rep2(i,a,b) for(int i=(a);i<=(b);++i) #define rep(i,n) for(int i=0;i<n;i++) #define pii pair<int,int> #define ti3 tuple<int,int,int> ll int MOD=998244353; double INF=1000000000.0; using namespace std; string alphabet("abcdefghijklmnopqrstuvwxyz"); main(){ double xs,ys,xg,yg; cin>>xs>>ys>>xg>>yg; int n; cin>>n; long double t[2100][3]; rep2(i,1,n){ cin>>t[i][0]>>t[i][1]>>t[i][2]; } t[0][0]=xs;t[0][1]=ys; t[0][2]=0; n++; t[n][0]=xg;t[n][1]=yg; t[n][2]=0; long double d[2100]={}; d[0]=0.0000000000; int visited[1100]={}; visited[0]=1; rep2(i,1,n){d[i]=INF;} int pos=0; while(1){ long double minimum=INF*3; int minimumnum=0; rep2(i,0,n){ d[i]=min(d[i],d[pos]+max(0.0,sqrt((pow(t[pos][0]-t[i][0],2) +pow(t[pos][1]-t[i][1],2)))-t[pos][2]-t[i][2])); } rep2(i,0,n){ if(d[i]<minimum&&!visited[i]){ minimum=d[i]; minimumnum=i; } } pos=minimumnum; visited[minimumnum]=1; if(minimumnum==n){ printf("%.15f",d[n]); return 0; } } }
a.cc:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 13 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:38:37: error: no matching function for call to 'max(double, long double)' 38 | d[i]=min(d[i],d[pos]+max(0.0,sqrt((pow(t[pos][0]-t[i][0],2) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 39 | +pow(t[pos][1]-t[i][1],2)))-t[pos][2]-t[i][2])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:38:37: note: deduced conflicting types for parameter 'const _Tp' ('double' and 'long double') 38 | d[i]=min(d[i],d[pos]+max(0.0,sqrt((pow(t[pos][0]-t[i][0],2) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 39 | +pow(t[pos][1]-t[i][1],2)))-t[pos][2]-t[i][2])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:38:37: note: mismatched types 'std::initializer_list<_Tp>' and 'double' 38 | d[i]=min(d[i],d[pos]+max(0.0,sqrt((pow(t[pos][0]-t[i][0],2) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 39 | +pow(t[pos][1]-t[i][1],2)))-t[pos][2]-t[i][2])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s708447487
p03866
C++
#include <iostream> #include <vector> #include <map> #include <unordered_map> #include <queue> #include <set> #include <algorithm> #include <string> using namespace std; typedef long long ll; double dis[1002][1002]; double px[1002], py[1002], r[1002]; double cost[1002]; bool used[1002]; double euclid(int i, int j){ double square = (px[i] - px[j])*(px[i] - px[j]) + (py[i] - py[j])*(py[i] - py[j]); return sqrt(square); } void dijkstra(int s, int N){ cost[s] = 0.0; while(true){ int v = -1; for(int u = 0; u < N+2; u++){ if(!used[u] && (v == -1 || cost[u] < cost[v])) v = u; } if(v == -1) break; used[v] = true; for(int u = 0; u < N+2; u++){ cost[u] = min(cost[u], cost[v]+dis[v][u]); } } } int main(){ double xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt; int N; cin >> N; px[0] = xs; py[0] = ys; r[0] = 0.0; px[N+1] = xt; py[N+1] = yt; r[N+1] = 0.0; for(int i = 1; i <= N; i++){ double x, y, rr; cin >> x >> y >> rr; px[i] = x; py[i] = y; r[i] = rr; } for(int i = 0; i < N+2; i++){ for(int j = 0; j < N+2; j++){ dis[i][j] = max(euclid(i, j) - r[i] - r[j], 0.0); } used[i] = false; cost[i] = 1e9 * 5; } dijkstra(0, N); printf("%.10f", cost[N+1]); return 0; }
a.cc: In function 'double euclid(int, int)': a.cc:21:12: error: 'sqrt' was not declared in this scope 21 | return sqrt(square); | ^~~~
s415757105
p03866
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2000; long double x[N], y[N], r[N]; long double a[N][N]; long double dist(long double x1, long double y1, long double x2, long double y2) { return sqrt(pow(x1 - x2, 2.0) + pow(y1 - y2, 2.0)); } int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> x[0] >> y[0] >> x[1] >> y[1]; int n; cin >> n; for (int i = 2; i < n + 2; ++i) { cin >> x[i] >> y[i] >> r[i]; } for (int i = 0; i < n + 2; ++i) { for (int j = 0; j < n + 2; ++j) { a[i][j] = max(0.0, dist(x[i], y[i], x[j], y[j]) - r[i] - r[j]); } } vector<long double> d(n + 2, 1e10); d[0] = 0; set<pair<long double, int>> q; q.insert({ 0, 0 }); while (!q.empty()) { int v = q.begin()->second; q.erase(q.begin()); for (int j = 0; j < n + 2; ++j) { if (d[v] + a[v][j] < d[j]) { q.erase({ d[j], j }); d[j] = d[v] + a[v][j]; q.insert({ d[j], j }); } } } cout << fixed << setprecision(30) << d[1]; return 0; }
a.cc: In function 'int main()': a.cc:30:26: error: no matching function for call to 'max(double, long double)' 30 | a[i][j] = max(0.0, dist(x[i], y[i], x[j], y[j]) - r[i] - r[j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:30:26: note: deduced conflicting types for parameter 'const _Tp' ('double' and 'long double') 30 | a[i][j] = max(0.0, dist(x[i], y[i], x[j], y[j]) - r[i] - r[j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:30:26: note: mismatched types 'std::initializer_list<_Tp>' and 'double' 30 | a[i][j] = max(0.0, dist(x[i], y[i], x[j], y[j]) - r[i] - r[j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s434549473
p03866
C++
#include <stdio.h> #include <string.h> #include <math.h> #include <algorithm> #include <vector> using namespace std; const int N = 1010; struct node { int x,y,r; } a[N]; struct edge { int v; double cost; edge(int x,double b):v(x),cost(b){}; }; int n; double d[N]; bool vis[N]; vector<edge> G[N]; double cal(int i,int j) { double sum = a[i].r + a[j].r; double xx = 1.0 * (a[i].x - a[j].x) * (a[i].x - a[j].x); double yy = 1.0 * (a[i].y - a[j].y) * (a[i].y - a[j].y); double ans = sqrt(); if (sum >= ans) return 0; else return ans - sum; } void dij(void) { for (int i = 0;i <= n + 1;i++) d[i] = 1e30; d[0] = 0; for (int i = 0;i <= n;i++) { double mi = 1e30; int x; for (int j = 0;j <= n + 1;j++) { if (!vis[j] && d[j] < mi) { mi = d[j]; x = j; } } if (mi == 1e30) break; vis[x] = 1; for (auto e : G[x]) { double cost = e.cost; int v = e.v; if (d[v] > cost + d[x]) { d[v] = cost + d[x]; } } } } int main() { scanf("%d%d",&a[0].x,&a[0].y); a[0].r = 0; int x,y; scanf("%d%d",&x,&y); scanf("%d",&n); a[n+1].x = x,a[n+1].y = y,a[n+1].r = 0; for (int i = 1;i <= n;i++) scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].r); for (int i = 0;i <= n + 1;i++) { for (int j = i + 1;j <= n + 1;j++) { double len = cal(i,j); G[i].push_back(edge(j,len)); G[j].push_back(edge(i,len)); } } dij(); printf("%.15f\n",d[n+1]); return 0; }
a.cc: In function 'double cal(int, int)': a.cc:32:26: error: no matching function for call to 'sqrt()' 32 | double ans = sqrt(); | ~~~~^~ In file included from /usr/include/c++/14/math.h:36, from a.cc:3: /usr/include/c++/14/cmath:454:5: note: candidate: 'template<class _Tp> constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::sqrt(_Tp)' 454 | sqrt(_Tp __x) | ^~~~ /usr/include/c++/14/cmath:454:5: note: candidate expects 1 argument, 0 provided In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33, from /usr/include/stdio.h:28, from a.cc:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:176:1: note: candidate: 'double sqrt(double)' 176 | __MATHCALL (sqrt,, (_Mdouble_ __x)); | ^~~~~~~~~~ /usr/include/x86_64-linux-gnu/bits/mathcalls.h:176:1: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/cmath:446:3: note: candidate: 'constexpr long double std::sqrt(long double)' 446 | sqrt(long double __x) | ^~~~ /usr/include/c++/14/cmath:446:3: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/cmath:442:3: note: candidate: 'constexpr float std::sqrt(float)' 442 | sqrt(float __x) | ^~~~ /usr/include/c++/14/cmath:442:3: note: candidate expects 1 argument, 0 provided
s694418370
p03866
C++
#include<bits/stdc++.h> using namespace std; struct node { int x,y,r; }s[1005]; int n; double map1[1005][1005],double d[1005]; bool vis[1005]; long double cal(node a,node b) { return (long double)sqrt((long double)(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); } void dijkstra(int s) { d[s]=0; while(1) { int v=-1; for(int i=0; i<=n+1; i++) { if(!vis[i] && (v==-1 || d[i]<d[v])) v=i; } if (v==-1) break; vis[v]=1; for(int i=0; i<=n+1;i++) d[i]=min(d[i],d[v]+map1[v][i]); } } int main() { int x1,y1; scanf("%d%d%d%d",&s[0].x,&s[0].y,&x1,&y1); scanf("%d",&n); s[n+1].x=x1; s[n+1].y=y1; for(int i=1;i<=n;i++) { scanf("%d%d%d",&s[i].x,&s[i].y,&s[i].r); } for(int i=0; i<=n+1; i++) { for(int j=i+1; j<=n+1; j++) { map1[i][j]=cal(s[i],s[j]); map1[i][j]-=s[i].r+s[j].r; if(map1[i][j]<0) map1[i][j]=0; map1[j][i]=map1[i][j]; } } for(int i=0; i<=n+1; i++) d[i]=1e37; dijkstra(0); printf("%lf\n",d[n+1]); return 0; }
a.cc:9:25: error: expected unqualified-id before 'double' 9 | double map1[1005][1005],double d[1005]; | ^~~~~~ a.cc: In function 'void dijkstra(int)': a.cc:18:5: error: 'd' was not declared in this scope 18 | d[s]=0; | ^ a.cc: In function 'int main()': a.cc:57:9: error: 'd' was not declared in this scope 57 | d[i]=1e37; | ^ a.cc:59:20: error: 'd' was not declared in this scope 59 | printf("%lf\n",d[n+1]); | ^
s335200138
p03866
C++
#include <cstdio> #include <queue> #include <functional> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++) typedef pair<double, int> P; const int N_MAX = 1000; const int V_MAX = N_MAX + 2; const double INF = 1e10; int xs, ys, xt, yt; int N; int x[V_MAX]; int y[V_MAX]; int r[V_MAX]; int V; double d[V_MAX]; void dijkstra(int s) { priority_queue<P, vector<P>, greater<P> > que; fill(d, d + V, INF); d[s] = 0.0; que.push(P(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); int v = p.second; if (d[v] < p.first) continue; REP(u, V) { double dist = sqrt((x[u] - x[v]) * (x[u] - x[v]) + (y[u] - y[v]) * (y[u] - y[v])); dist = max(dist - r[u] - r[v], 0.0); if (d[u] > d[v] + dist) { d[u] = d[v] + dist; que.push(P(d[u], u)); } } } } void solve() { V = N + 2; x[0] = xs; x[V - 1] = xt; y[0] = ys; y[V - 1] = yt; r[0] = r[V - 1] = 0; dijkstra(0); printf("%.10f\n", d[V - 1]); } void input() { scanf("%d%d%d%d", &xs, &ys, &xt, &yt); scanf("%d", &N); FOR(i, 1, N) scanf("%d%d%d", x + i, y + i, r + i); } int main() { input(); solve(); return 0; }
a.cc: In function 'void dijkstra(int)': a.cc:35:21: error: 'sqrt' was not declared in this scope 35 | double dist = sqrt((x[u] - x[v]) * (x[u] - x[v]) + (y[u] - y[v]) * (y[u] - y[v])); | ^~~~
s202470736
p03866
C++
#include <bits/stdc++.h> typedef long long ll; const int INF = 1e9; const int MOD = 1e9+7; const ll LINF = 1e18; using namespace std; #define dump(x) cout << #x << " = " << (x) << endl; #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl #define Possible(n) cout << ((n) ? "Possible" : "Impossible" ) << endl #define possible(n) cout << ((n) ? "possible" : "impossible" ) << endl #define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) for(int i=0;i<(n);++i) #define REPR(i,n) for(int i=n;i>=0;i--) #define FOREACH(x,a) for(auto& (x) : (a) ) #define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]) #define SCOUT(x) cout<<(x)<<" " #define ENDL cout<<endl #define VECCIN(x) for(auto&youso_: (x) )cin>>youso_ #define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i] #define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;} #define ALL(obj) (obj).begin(),(obj).end() #define EXIST(n,x) (find(ALL(n),x)!=n.end()) #define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end()) #define EN(x) if(1){cout<<#x<<endl;return 0;} #define COUT(x) cout<<(x)<<endl void CINT(){} template <class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){ cin>>head; CINT(move(tail)...); } #define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__) #define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__) #define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__) template <class T = ll> T IN(){T x;cin>>x;return (x);} template <class Head> void VT(Head head){} template <class Head,class Seco,class... Tail> void VT(Head&& head,Seco&& seco,Tail&&... tail){ seco.resize(head); VT(head,move(tail)...); } void VT2(){} template <class Head,class... Tail> void VT2(Head&& head,Tail&&... tail){ VECCIN(head); VT2(move(tail)...); } template <class Head> void VT3(Head&& head){} template <class Head,class Seco,class... Tail> void VT3(Head&& head,Seco&& seco,Tail&&... tail){ seco[head]=IN(); VT3(head,move(tail)...); } #define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc #define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc //#include <boost/multiprecision/cpp_int.hpp> //using namespace boost::multiprecision; // cpp_int #define P pair<ll,ll> #define V vector<ll> #define M map<ll,ll> #define S set<ll> #define pb(a) push_back(a) #define mp make_pair class Dijkstra{ public: Dijkstra(vector<vector<pair<ll,double>>> ed,int firs,int pnum); void Solve(); vector<double> range;// range[a]=b; vector<vector<pair<ll,double>>> edges;// [a][b]=c; // priority_queue<P,vector<P>,greater<P>> que;// queue=(range,point); priority_queue<pair<double,ll>,vector<pair<double,ll>>,greater<pair<double,ll>>> que; }; Dijkstra::Dijkstra(vector<vector<pair<ll,double>>> ed,int firs,int pnum){ edges=ed; vector<double> ttt(pnum,INF); range=ttt; range[firs]=0; que.push(mp(0,firs)); } void Dijkstra::Solve(){ while(!que.empty()){ pair<double,ll> top_=que.top(); que.pop(); FOREACH(x,edges[top_.second]){ if(range[x.first] > range[top_.second] + x.second){ range[x.first] = range[top_.second] + x.second; que.push(mp(range[x.first],x.first)); } } } } int main(){ CIN(x1,y1,x2,y2); CIN(n);VC2(n,x,y,r); x.pb(x1);x.pb(x2); y.pb(y1);y.pb(y2); r.pb(0);r.pb(0); vector<vector<pair<ll,double>>> edges(x.size()); REP(i,x.size()){ REP(j,x.size()){ edges[i].pb(mp(j,max(0.0, sqrt( ((x[i]-x[j])*(x[i]-x[j])) + ((y[i]-y[j])*(y[i]-y[j])) ) - r[i]-r[j] ))); edges[j].pb(mp(i,max(0.0, sqrt( ((x[i]-x[j])*(x[i]-x[j])) + ((y[i]-y[j])*(y[i]-y[j])) ) - r[i]-r[j] ))); } } } Dijkstra dijk(move(edges),n,x.size()); dijk.Solve(); //VECCOUT(dijk.range); printf("%.12lf\n",dijk.range[n+1]); return 0; }
a.cc:147:24: error: 'edges' was not declared in this scope 147 | Dijkstra dijk(move(edges),n,x.size()); | ^~~~~ a.cc:147:31: error: 'n' was not declared in this scope; did you mean 'yn'? 147 | Dijkstra dijk(move(edges),n,x.size()); | ^ | yn a.cc:147:33: error: 'x' was not declared in this scope 147 | Dijkstra dijk(move(edges),n,x.size()); | ^ a.cc:148:5: error: 'dijk' does not name a type 148 | dijk.Solve(); | ^~~~ a.cc:150:11: error: expected constructor, destructor, or type conversion before '(' token 150 | printf("%.12lf\n",dijk.range[n+1]); | ^ a.cc:152:5: error: expected unqualified-id before 'return' 152 | return 0; | ^~~~~~ a.cc:153:1: error: expected declaration before '}' token 153 | } | ^
s694070388
p03866
C++
// see https://github.com/LumaKernel/vimfiles/tree/master/snippets/cp-cpp/temp.snip /// --- .lumrc Template {{{ /// // #define DEBUG // #define assert(...) #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using P = tuple<ll, ll>; using P3 = tuple<ll, ll, ll>; using VI = vector<int>; using VL = vector<ll>; using VVI = vector<VI>; using VVL = vector<VL>; using VP = vector<P>; using VS = vector<string>; #define omajinai ios::sync_with_stdio(false),cin.tie(0) #define FOR(i,a,b) for(int i=int(a);i<int(b);++i) #define FORI(i,a,b) for(int i=int(a);i<=int(b);++i) #define REP(i,n) FOR(i,0,n) #define REPI(i,n) FORI(i,0,n) #define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i) #define RFORI(i,a,b) for(int i=int(b);i>=int(a);--i) #define RREP(i,n) RFOR(i,0,n) #define RREPI(i,n) RFORI(i,0,n) #define ALL(a) begin(a),end(a) #define UNIQUE(a) (a).erase(unique(ALL(a)),(a).end()) #define PB push_back #define EACH(i,c) REP(i,(c).size()) #define REACH(i,c) RREP(i,(c).size()) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort(ALL(c)) #define BR cout<<"\n"; #ifdef DEBUG #define dump(...) cerr<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n"; #else #define dump(...) #endif #define YES(x) cout<<((x)?"YES":"NO")<<"\n"; #define Yes(x) cout<<((x)?"Yes":"No")<<"\n"; #define yes(x) cout<<((x)?"yes":"no")<<"\n"; int __int_temp; ll __ll_temp; string __string_temp; #define oini (omajinai, cin>>__int_temp, __int_temp) #define oinl (omajinai, cin>>__ll_temp, __ll_temp) #define oins (omajinai, cin>>__string_temp, __string_temp) #define ini (cin>>__int_temp, __int_temp) #define inl (cin>>__ll_temp, __ll_temp) #define ins (cin>>__string_temp, __string_temp) #define isInside(y,x) (0<=(y)&&(y)<h&&0<=(x)&&(x)<w) #define fi(x) (get<0>(x)) #define se(x) (get<1>(x)) #define th(x) (get<2>(x)) #define fo(x) (get<3>(x)) #define fif(x) (get<4>(x)) template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '{'; EACH(i, v) o << v[i] << (i != (int)v.size()-1 ? ", " : ""); o << "}"; return o; } template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){} template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); } template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; } template <typename T> inline void smax(T &a, T b) { a = a > b ? a : b; } template <typename T> inline void smin(T &a, T b) { a = a < b ? a : b; } template<typename T> inline int intlog2(T x); template<> inline int intlog2(int x) { return x == 0 ? 0 : 32 - __builtin_clz(x); } template<> inline int intlog2(ll x) { return x == 0 ? 0 : 64 - __builtin_clzll(x); } constexpr double PI = acos(-1); /// }}}--- /// constexpr int INF = 1e9+1; constexpr ll LINF = 1e18+1; constexpr int MOD = 1e9+7; #define double ld // EPS constexpr double EPS = 1e-9; /// --- Geometory Library {{{ /// using Point = complex<double>; #define X real() #define Y imag() #define dot(a, b) real(conj(a)*b) #define cross(a, b) imag(conj(a)*b) #define norm abs // +1 : ccw // -1 : cw // +2 : a--b--c // -2 : b--c--a // 0 : b--a--c int ccw(Point a, Point b, Point c) { b -= a; c -= a; if(cross(b, c) > EPS) return +1; if(cross(b, c) < -EPS) return -1; if(dot(b, c) < 0) return 0; if(norm(b) < norm(c)) return +2; return -2; } double arg(Point a, Point b) { return acos(dot(a, b) / norm(a) / norm(b)); } /// ---}}} /// using D = tuple<double, int>; Point ps[1002]; int sx=ini,sy=ini,tx=ini,ty=ini; int n=ini; int r[1002]; inline double dis(int ida, int idb) { return max(norm(ps[ida] - ps[idb]) - r[ida] - r[idb], .0); } int main() { REP(i, n) { int x=ini,y=ini; r[i]=ini; ps[i] = Point(x, y); } ps[n] = Point(sx, sy); ps[n+1] = Point(tx, ty); vector<double> dist(n + 2, INF * 4.0); priority_queue<D, vector<D>, greater<D>> pq; dist[n] = 0; pq.push(D(0, n)); n += 2; while(pq.size()) { double d = fi(pq.top()); int i = se(pq.top()); pq.pop(); if(dist[i] < d) continue; if(i == n-1) break; REP(j, n) if(i != j) { double nd = d + dis(i, j); if(nd < dist[j]) { dist[j] = nd; pq.push(D(nd, j)); } } } cout << setprecision(10) << dist[n-1] << endl; }
a.cc: In function 'ld dis(int, int)': a.cc:127:13: error: no matching function for call to 'max(long double, double)' 127 | return max(norm(ps[ida] - ps[idb]) - r[ida] - r[idb], .0); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:5: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:127:13: note: deduced conflicting types for parameter 'const _Tp' ('long double' and 'double') 127 | return max(norm(ps[ida] - ps[idb]) - r[ida] - r[idb], .0); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:127:13: note: mismatched types 'std::initializer_list<_Tp>' and 'long double' 127 | return max(norm(ps[ida] - ps[idb]) - r[ida] - r[idb], .0); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s152971563
p03866
C++
#include<iostream> #include<algorithm> #include<vector> #include<cstring> using namespace std; #define fi(a,b) for(int i=a;i<b;++i) #define fj(a,b) for(int j=a;j<b;++j) typedef long long ll; typedef long double ld; /////////////////// int const N = 1e3 + 41; ld const INF = 9e18 + 41; int n; ld xa, ya, xb, yb; ld x[N], y[N], r[N]; int w[N]; ld d[N]; ld ans; ld sqr(ld x){ return x * x; } ld getdist(ld x0, ld y0, ld x1, ld y1){ return sqrt( sqr(x0 - x1) + sqr(y0 - y1) ); } void solve(){ fi(0, n) d[i] = INF; fi(0, n){ d[i] = max((ld)0, getdist(xa, ya, x[i], y[i]) - r[i]); } while(1){ int id = -1; fi(0, n){ if(!w[i] && (id == -1 || d[id] > d[i])){ id = i; } } if(id == -1) break; w[id] = 1; fi(0, n){ if(w[i]) continue; if(i == id) continue; ld d0 = d[id] + max((ld)0, getdist(x[i], y[i], x[id], y[id]) - r[id] - r[i]); d[i] = min(d[i], d0); } } ans = INF; fi(0, n){ ld pans = d[i] + max((ld)0, getdist(xb, yb, x[i], y[i]) - r[i]); ans = min(ans, pans); } } int main(){ #ifdef _DEBUG freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif scanf("%Lf %Lf %Lf %Lf",&xa,&ya,&xb,&yb); scanf("%d",&n); fi(0, n) scanf("%Lf %Lf %Lf",&x[i],&y[i],&r[i]); solve(); printf("%.15Lf\n",ans); return 0; }
a.cc: In function 'ld getdist(ld, ld, ld, ld)': a.cc:28:16: error: 'sqrt' was not declared in this scope; did you mean 'sqr'? 28 | return sqrt( sqr(x0 - x1) + sqr(y0 - y1) ); | ^~~~ | sqr
s949181300
p03866
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<vector> #include<string> #include<utility> #include<cmath> #include<complex> #define REP(i,n) for(int i = 0;i < (n);i++) #define pb push_back using namespace std; //const int INF = 1e9; typedef long long ll; #define MV 1010 const double EPS = 1e-8; const double INF = 1e9+10; typedef complex<double> P; namespace std { bool operator < (const P& a, const P& b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); } } double cross(const P& a, const P& b) { return imag(conj(a)*b); } double dot(const P& a, const P& b) { return real(conj(a)*b); } struct L : public vector<P> { L(const P &a, const P &b) { push_back(a); push_back(b); } }; struct edge{double cost;int to; }; vector <edge> G[MV]; bool used[MV+2]; double d[MV+1]; int V,E; void dijkstra(int first){ fill(d,d+MV,INF); fill(used,used+MV,false); d[first] = 0; for(int i = 0;i < V;i++){ int now = MV-1; for(int j = 0;j < V;j++){ //cout << d[now] <<" " << d[j] << endl; if(used[j] == false && d[now] > d[j]){ now = j; } } //cout << now << endl; used[now] = true; //cout << used[now] << endl; for(int j = 0;j < G[now].size();j++){ edge e = G[now][j]; //cout << d[e.to] << " " << d[now]+e.cost << endl; d[e.to] = min(d[e.to] , d[now]+e.cost); } for(int j = 0;j < V;j++) //cout << d[j] << " "; //cout << endl; } } struct C { P p; double r; C(const P &p, double r) : p(p), r(r) { } }; int main(){ vector <C> c; double a,b,o; cin >> a >> b; P p = P(a,b); C cc = C(p,0); c.pb(cc); cin >> a >> b; p = P(a,b); cc = C(p,0); c.pb(cc); int n; cin >> n; REP(i,n){ cin >> a >> b >> o; p = P(a,b); cc = C(p,o); c.pb(cc); } REP(i,c.size()){ //cout << "c[i].p" << " " << (double)c[i].r << endl; } V = n+2; REP(i,n+1){ for(int j = i+1;j < n+2;j++){ edge e; e.to = j; double x = (double)abs(c[i].p-c[j].p); //cout << "x = " << x << endl; e.cost = (double)max(x-c[i].r-c[j].r,0.0); //cout << e.cost << endl; G[i].pb(e); //cout <<i <<" from " <<j <<" to " << G[i][j].cost << endl; e.to = i; G[j].pb(e); } } REP(i,n+2){ REP(j,G[i].size()){ //cout <<i <<" from " <<j <<" to " << G[i][j].cost << endl; } } dijkstra(0); printf("%.10lf\n",d[1]); return 0; }
a.cc: In function 'void dijkstra(int)': a.cc:72:3: error: expected primary-expression before '}' token 72 | } | ^
s884970435
p03866
C++
#include<iostream> #include<stdio.h> #include<math.h> #include<vector> #include<queue> using namespace std; struct P { double x,y,r; }; using Q = pair<int,double>; double dist (P& a, P& b) { return max(hypot(a.x-b.x,a.y-b.y)-a.r-b.r,0.0); } int main () { double xs,ys,xt,yt; cin>>xs>>ys>>xt>>yt; int n; cin>>n; vector<P> circles; circles.push_back((P){xs,ys,0}); for(int i=0;i<n;++i){ double x,y,r; cin>>x>>y>>r; circles.push_back((P){x,y,r}); } circles.push_back((P){xt,yt,0}); n+=2; double dp[n]; dp[0]=0; for(int i=1;i<n;++i) dp[i] = 1.7e308; priority_queue< Q, vector<Q> , greater<Q> > q; for(int i = 0; i < n; ++i) { q.push(make_pair(i,dp[i])); } while(!q.empty()){ Q qf = q.top();q.pop(); int id = qf.first; if(dp[id] < qf.SE)continue; P& p = circles[id]; for(int i = 1; i < n; ++i) { if(i == id) continue; double d = dp[id] + dist(p,circles[i]); if(d < dp[i]){ dp[i] = d; if(i != n-1) q.push(make_pair(i,d)); } } } printf("%.10f\n", dp[n-1]); }
a.cc: In function 'int main()': a.cc:39:24: error: 'using Q = struct std::pair<int, double>' {aka 'struct std::pair<int, double>'} has no member named 'SE' 39 | if(dp[id] < qf.SE)continue; | ^~
s478690919
p03866
C++
#include<iostream> #include<stdio.h> #include<math.h> #include<vector> #include<queue> using namespace std; struct P { double x,y,r; }; using Q = pair<int,double>; double dist (P& a, P& b) { return max(hypot(a.x-b.x,a.y-b.y)-a.r-b.r,0.0); } int main () { double xs,ys,xt,yt; cin>>xs>>ys>>xt>>yt; int n; cin>>n; vector<P> circles; circles.push_back((P){xs,ys,0}); for(int i=0;i<n;++i){ double x,y,r; cin>>x>>y>>r; circles.push_back((P){x,y,r}); } circles.push_back((P){xt,yt,0}); n+=2; double dp[n]; dp[0]=0; for(int i=1;i<n;++i) dp[i] = 1.7e308; priority_queue< Q, vector<Q> , greater<Q> > q; for(int i = 0; i < n; ++i) { q.push(make_pair(i,dp[i])); } while(!q.empty()){ Q qf = q.top();q.pop(); int id = qf.first; if(dp[id] < pf.SE)continue; P& p = circles[id]; for(int i = 1; i < n; ++i) { if(i == id) continue; double d = dp[id] + dist(p,circles[i]); if(d < dp[i]){ dp[i] = d; if(i != n-1) q.push(make_pair(i,d)); } } } printf("%.10f\n", dp[n-1]); }
a.cc: In function 'int main()': a.cc:39:21: error: 'pf' was not declared in this scope; did you mean 'qf'? 39 | if(dp[id] < pf.SE)continue; | ^~ | qf
s607383271
p03866
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define double long double #define vi vector<int> #define vvi vector<vi> #define pb push_back #define P pair<double,int> #define PP pair<P,int> #define fi first #define se second #define INF 1e9 #define MOD 1000000007 #define REP(i,n) for(int i=0;i<n;i++) #define REPR(i,n) for(int i=n;i>=0;i--) #define FOR(i,m,n) for(int i=m;i<n;i++) #define all(x) (x).begin(),(x).end() struct edge{ int to; double cost; }; const int MAX_V=1002; int V; vector<edge> G[MAX_V]; double d[MAX_V]; void dijkstra(int s){ fill(d,d+V,INF); priority_queue<P,vector<P>,greater<P> > que; d[s]=0.0; que.push(P(0,s)); while(que.size()){ P p=que.top();que.pop(); if(p.fi>d[p.se])continue; REP(i,G[p.se].size()){ edge e=G[p.se][i]; if(d[e.to]>p.fi+e.cost){ d[e.to]=p.fi+e.cost; que.push(P(d[e.to],e.to)); } } } } struct T{ double x,y,r; }; signed main(){ vector<T> vec; REP(i,2){ T t; cin>>t.x>>t.y; t.r=0; vec.pb(t); } cin>>V; REP(i,V){ T t; cin>>t.x>>t.y>>t.r; vec.pb(t); } V+=2; REP(i,V){ REP(j,V){ edge t; t.to=j; t.cost=max(0.0LL,sqrt(pow(vec[i].x-vec[j].x,2)+pow(vec[i].y-vec[j].y,2))-vec[i].r-vec[j].r); G[i].pb(t); } } dijkstra(0); printf("%.10lf\n",d[1]); return 0; }
a.cc: In function 'int main()': a.cc:65:24: error: unable to find numeric literal operator 'operator""LL' 65 | t.cost=max(0.0LL,sqrt(pow(vec[i].x-vec[j].x,2)+pow(vec[i].y-vec[j].y,2))-vec[i].r-vec[j].r); | ^~~~~
s608609088
p03866
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define double long double #define vi vector<int> #define vvi vector<vi> #define pb push_back #define P pair<double,int> #define PP pair<P,int> #define fi first #define se second #define INF 1e9 #define MOD 1000000007 #define REP(i,n) for(int i=0;i<n;i++) #define REPR(i,n) for(int i=n;i>=0;i--) #define FOR(i,m,n) for(int i=m;i<n;i++) #define all(x) (x).begin(),(x).end() struct edge{ int to; double cost; }; const int MAX_V=1002; int V; vector<edge> G[MAX_V]; double d[MAX_V]; void dijkstra(int s){ fill(d,d+V,INF); priority_queue<P,vector<P>,greater<P> > que; d[s]=0.0; que.push(P(0,s)); while(que.size()){ P p=que.top();que.pop(); if(p.fi>d[p.se])continue; REP(i,G[p.se].size()){ edge e=G[p.se][i]; if(d[e.to]>p.fi+e.cost){ d[e.to]=p.fi+e.cost; que.push(P(d[e.to],e.to)); } } } } struct T{ double x,y,r; }; signed main(){ vector<T> vec; REP(i,2){ T t; cin>>t.x>>t.y; t.r=0; vec.pb(t); } cin>>V; REP(i,V){ T t; cin>>t.x>>t.y>>t.r; vec.pb(t); } V+=2; REP(i,V){ REP(j,V){ edge t; t.to=j; t.cost=max(0.0,sqrt(pow(vec[i].x-vec[j].x,2)+pow(vec[i].y-vec[j].y,2))-vec[i].r-vec[j].r); G[i].pb(t); } } dijkstra(0); printf("%.10f\n",d[1]); return 0; }
a.cc: In function 'int main()': a.cc:65:23: error: no matching function for call to 'max(double, long double)' 65 | t.cost=max(0.0,sqrt(pow(vec[i].x-vec[j].x,2)+pow(vec[i].y-vec[j].y,2))-vec[i].r-vec[j].r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:65:23: note: deduced conflicting types for parameter 'const _Tp' ('double' and 'long double') 65 | t.cost=max(0.0,sqrt(pow(vec[i].x-vec[j].x,2)+pow(vec[i].y-vec[j].y,2))-vec[i].r-vec[j].r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:65:23: note: mismatched types 'std::initializer_list<_Tp>' and 'double' 65 | t.cost=max(0.0,sqrt(pow(vec[i].x-vec[j].x,2)+pow(vec[i].y-vec[j].y,2))-vec[i].r-vec[j].r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s402512925
p03866
C++
#include<bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++) const ll mod = 1e9 + 7; const ld INF = 1e9; const int MAX_N = 1002; struct edge { int to; ld cost; }; typedef pair<ld, int>P; int N; vector<edge>G[MAX_N]; ld d[MAX_N]; void dijkstra(int s) { priority_queue<P, vector<P>, greater<P>>que; fill(d, d + N, INF); d[s] = 0.0; que.push(P(0.0, s)); while (!que.empty()) { P p = que.top(); que.pop(); int 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)); } } } } int main() { cin.sync_with_stdio(false); int xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt; cin >> N; vector<int>x(N+2), y(N+2),r(N+2); x[0] = xs; y[0] = ys; x[N + 1] = xt; y[N + 1] = yt; rep(i, N) { cin >> x[i + 1] >> y[i + 1] >> r[i + 1]; } rep(i, N + 2) { rep(j, N + 2) { if (i == j)continue; edge e1; e1.to = j; e1.cost =(ld)max(0,0,sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])) - r[i] - r[j]); G[i].push_back(e1); } } dijkstra(0); cout << setprecision(10) << d[N + 1] << endl; return 0; }
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: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = double]': a.cc:51:31: required from here 51 | e1.to = j; e1.cost =(ld)max(0,0,sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])) - r[i] - r[j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function 306 | if (__comp(__a, __b)) | ~~~~~~^~~~~~~~~~
s348601329
p03866
C++
#include <bits/stdc++.h> typedef long long ll; using namespace std; struct s { int x, y, r; }; s f; s p[(int)1005]; long double dist(s x, s y) { // cout << x.x << " " << x.y << " " << x.r << endl ; // cout << y.x << " " << y.y << " " << y.r << endl ; long double X = x.x-y.x; X*=X; // cout << X << " " ; long double Y = x.y-y.y; Y*=Y; X+=Y; X = sqrt(X); X -= x.r; X -= y.r; //// cout << X << " " << x.x << " " << x.y << " ~ " << y.x << " " << y.y << endl; // cout << Y << endl; return max(0.0,X); } int n ; bool ss(s x, s y) { if(dist(x,f) != dist(y,f)) return (dist(x,f)-dist(y,f) >= 1e-16); else return (dist(y,p[0])-dist(x,p[0]) >= 1e-16); } long double dp[1005][1005]; long double solve(int idx, int bef) { if(idx == n+1) { return dist(p[bef],f); } if(dp[idx][bef] != -1) return dp[idx][bef]; long double ret = dist(p[bef],f)+dist(p[idx],p[bef]); ret = min(ret,dist(p[idx],p[bef])+solve(idx+1,idx)); ret = min(ret,solve(idx+1,bef)); return dp[idx][bef] = ret; } int main() { for(int i = 0 ; i < 1005 ; i++) for(int j = 0 ; j < 1005; j++) dp[i][j] = -1; cin >>p[0].x >> p[0].y ; p[0].r = 0; cin >> f.x >> f.y; f.r = 0 ; cin >> n; for(int i = 1 ; i <= n ; i++) cin >>p[i].x >> p[i].y >> p[i].r; sort(p+1,p+n+1,ss); cout << fixed << setprecision(10) << solve(0,0) << "\n"; }
a.cc: In function 'long double dist(s, s)': a.cc:25:15: error: no matching function for call to 'max(double, long double&)' 25 | return max(0.0,X); | ~~~^~~~~~~ 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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:25:15: note: deduced conflicting types for parameter 'const _Tp' ('double' and 'long double') 25 | return max(0.0,X); | ~~~^~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:25:15: note: mismatched types 'std::initializer_list<_Tp>' and 'double' 25 | return max(0.0,X); | ~~~^~~~~~~
s469008119
p03866
C++
#include <bits/stdc++.h> using namespace std; #define ll long long struct circle { double x, y, r; }; double x1, y1, x2, y2; double dist(double x, double y) { return ((x1 - x) * (x1 - x)) + ((y1 - y) * (y1 - y)); } double meh(double a1, double b1, double a2, double b2) { return sqrt(((a1 - a2) * (a1 - a2)) + ((b1 - b2) * (b1 - b2))); } int main() { cin >> x1 >> y1 >> x2 >> y2; int n; cin >> n; circle arr[1010]; for (int i = 0; i < n; i++) cin >> arr[i].x >> arr[i].y >> arr[i].r; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (dist(arr[i].x, arr[i].y) > dist(arr[j].x, arr[j].y)) swap(arr[i], arr[j]); } } double mini = 1e18; for (int i = 0; i < n; i++) { double d = 0; double prevx = x1, prevy = y1, prevr = 0; for (int j = i; j < n; j++) { d += max(0.0, meh(arr[j].x, arr[j].y, prevx, prevy) - arr[j].r - prevr); prevx = arr[j].x, prevy = arr[j].y, prevr = arr[j].r; } d += max(0.0, meh(x2, y2, prevx, prevy) - prevr); mini = min(mini, d); } cout << fixed << setprecision(10) << mini << "\n"; return 0; }
a.cc:8:12: error: 'double y1' redeclared as different kind of entity 8 | double x1, y1, x2, y2; | ^~ In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683, from /usr/include/c++/14/cassert:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33, from a.cc:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)' 257 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ a.cc: In function 'double dist(double, double)': a.cc:10:41: error: invalid operands of types 'double(double) noexcept' and 'double' to binary 'operator-' 10 | return ((x1 - x) * (x1 - x)) + ((y1 - y) * (y1 - y)); | ~~ ^ ~ | | | | | double | double(double) noexcept a.cc:10:52: error: invalid operands of types 'double(double) noexcept' and 'double' to binary 'operator-' 10 | return ((x1 - x) * (x1 - x)) + ((y1 - y) * (y1 - y)); | ~~ ^ ~ | | | | | double | double(double) noexcept a.cc: In function 'int main()': a.cc:17:15: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept') 17 | cin >> x1 >> y1 >> x2 >> y2; | ~~~~~~~~~ ^~ ~~ | | | | | double(double) noexcept | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:17:18: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept' 17 | cin >> x1 >> y1 >> x2 >> y2; | ^~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:17:18: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive] 17 | cin >> x1 >> y1 >> x2 >> y2; | ^~ | | | double (*)(double) noexcept a.cc:17:18: error: cannot bind rvalue '(short int)y1' to 'short int&' /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:17:18: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive] 17 | cin >> x1 >> y1 >> x2 >> y2; | ^~ | | | double (*)(double) noexcept a.cc:17:18: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&' /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: a.cc:17:18: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 17 | cin >> x1 >> y1 >> x2 >> y2; | ^~ | | | double (*)(double) noexcept a.cc:17:18: error: cannot bind rvalue '(int)y1' to 'int&' /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:17:18: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive] 17 | cin >> x1 >> y1 >> x2 >> y2; | ^~ | | | double (*)(double) noexcept a.cc:17:18: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&' /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:17:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive] 17 | cin >> x1 >> y1 >> x2 >> y2; | ^~ | | | double (*)(double) noexcept a.cc:17:18: error: cannot bind rvalue '(long int)y1' to 'long int&' /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:17:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive] 17 | cin >> x1 >> y1 >> x2 >> y2; | ^~ | | | double (*)(double) noexcept a.cc:17:18: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&' /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:17:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive] 17 | cin >> x1 >> y1 >> x2 >> y2; | ^~ | | | double (*)(double) noexcept a.cc:17:18: error: cannot bind rvalue '(long long int)y1' to 'long long int&' /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:17:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive] 17 | cin >> x1 >> y1 >> x2 >> y2; | ^~ | | | double (*)(double) noexcept a.cc:17:18: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&' /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: a.cc:17:18: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive] 17 | cin >> x1 >> y1 >> x2 >> y2; | ^~ | | | double (*)(double) noexcept a.cc:17:18: error: cannot bind rvalue '(void*)y1' to 'void*&' /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: a.cc:17:18: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::
s307475537
p03866
C++
#include "bits/stdc++.h" using namespace std; #ifdef _DEBUG #include "dump.hpp" #else #define dump(...) #endif //#define int long long #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define all(c) begin(c),end(c) const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = (int)(1e9) + 7; template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } #define double long double const double EPS = 1e-10; const double PI = acos(-1); #define equals(a,b) (fabs((a)-(b)) < EPS) #define next(P,i) P[(i+1)%P.size()] #define prev(P,i) P[(i+P.size()-1)%P.size()] struct Point { double x, y; Point() {} Point(double x, double y) :x(x), y(y) {} Point &operator+=(const Point &p) { x += p.x; y += p.y; return *this; } Point &operator-=(const Point &p) { x -= p.x; y -= p.y; return *this; } Point &operator*=(double a) { x *= a; y *= a; return *this; } Point &operator/=(double a) { x /= a; y /= a; return *this; } double abs() { return sqrt(norm()); } double norm() { return x*x + y*y; } }; Point operator+(const Point &p1, const Point &p2) { return Point(p1) += p2; } Point operator-(const Point &p1, const Point &p2) { return Point(p1) -= p2; } Point operator*(const Point &p, double a) { return Point(p) *= a; } Point operator/(const Point &p, double a) { return Point(p) /= a; } bool operator==(const Point &p1, const Point &p2) { return equals(p1.x, p2.x) && equals(p1.y, p2.y); } bool operator<(const Point &p1, const Point &p2) { //return p1.y != p2.y ? p1.y < p2.y : p1.x < p2.x; //y昇順 -> x昇順 return p1.x != p2.x ? p1.x < p2.x : p1.y < p2.y; //x昇順 -> y昇順 } bool operator>(const Point &p1, const Point &p2) { return p2 < p1; } inline istream &operator >> (istream &is, Point &p) { double x, y; is >> x >> y; p = Point(x, y); return is; } inline ostream &operator << (ostream &os, const Point &p) { os << p.x << ' ' << p.y; return os; } struct Vector :public Point { using Point::Point; Vector() {} Vector(const Point &P) { x = P.x; y = P.y; } Vector rotate(double rad) { return Vector(x*cos(rad) - y*sin(rad), x*sin(rad) + y*cos(rad)); } Vector unit() { return *this / abs(); } }; //内積 dot product double dot(Vector a, Vector b) { return a.x*b.x + a.y*b.y; } //外積 cross product の大きさ(正負あり) double cross(Vector a, Vector b) { return a.x*b.y - a.y*b.x; } struct Line { Point p1, p2; Line() {} Line(Point p1, Point p2) :p1(p1), p2(p2) {} }; struct Segment :public Line { using Line::Line; Segment() {} Segment(const Line &L) { p1 = L.p1; p2 = L.p2; } Vector vec() { return p2 - p1; } }; struct Circle { Point c; //center double r; //radius Circle() {} Circle(Point c, double r) :c(c), r(r) {} }; using Polygon = vector<Point>; //degree to radian double rad(double deg) { return PI*deg / 180; } //radian to degree double deg(double rad) { return rad / PI * 180; } //偏角 argument double arg(Vector p) { return atan2(p.y, p.x); } //極形式 polar form Vector polar(double r, double a) { return Point(cos(a)*r, sin(a)*r); } //2つのベクトルの角度 double angle(Vector a, Vector b) { double lena = a.abs(), lenb = b.abs(); if (lena == 0 || lenb == 0)return 0; //解なし double costheta = dot(a, b) / (lena*lenb); if (equals(costheta, 1))costheta = 1; //誤差対策 return acos(costheta); } bool inrange(Point p, double x1, double y1, double x2, double y2) { return x1 <= p.x&&p.x <= x2&&y1 <= p.y&&p.y <= y2; } //直交判定 bool is_orthogonal(Vector a, Vector b) { return equals(dot(a, b), 0.0); } bool is_orthogonal(Segment s1, Segment s2) { return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } //平行判定 bool is_parallel(Vector a, Vector b) { return equals(cross(a, b), 0.0); } bool is_parallel(Segment s1, Segment s2) { return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } //射影 Point project(Segment s, Point p) { Vector base = s.p2 - s.p1; double r = dot(p - s.p1, base) / base.norm(); return s.p1 + base*r; } //反射 Point reflect(Segment s, Point p) { return p + (project(s, p) - p)*2.0; } //線分(p0,p1)に対するp2の位置関係 enum { ONLINE_FRONT = -2, CLOCKWISE, ON_SEGMENT, COUNTER_CLOCKWISE, ONLINE_BACK }; int ccw(Point p0, Point p1, Point p2) { Vector a = p1 - p0, b = p2 - p0; if (cross(a, b) > EPS)return COUNTER_CLOCKWISE; if (cross(a, b) < -EPS)return CLOCKWISE; if (dot(a, b) < -EPS)return ONLINE_BACK; //p2 p0 p1 if (a.norm() < b.norm())return ONLINE_FRONT; //p0 p1 p2 return ON_SEGMENT; } int ccw(Vector a, Vector b) { if (cross(a, b) > EPS)return COUNTER_CLOCKWISE; if (cross(a, b) < -EPS)return CLOCKWISE; if (dot(a, b) < -EPS)return ONLINE_BACK; //p2 p0 p1 if (a.norm() < b.norm())return ONLINE_FRONT; //p0 p1 p2 return ON_SEGMENT; } //直線と直線の交差判定 bool intersect(Segment a, Segment b) { Point p1 = a.p1, p2 = a.p2, p3 = b.p1, p4 = b.p2; return (ccw(p1, p2, p3)*ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1)*ccw(p3, p4, p2) <= 0); } //(交差判定続く) //2点間の距離 double get_distance(Point a, Point b) { return (a - b).abs(); } //直線と点の距離 double get_distance(Line l, Point p) { return abs(cross(l.p2 - l.p1, p - l.p1) / (l.p2 - l.p1).abs()); } //線分と点の距離 double get_distance(Segment s, Point p) { if (dot(s.p2 - s.p1, p - s.p1) < 0.0)return (p - s.p1).abs(); if (dot(s.p1 - s.p2, p - s.p2) < 0.0)return (p - s.p2).abs(); return get_distance(Line(s), p); } //線分と線分の距離 double get_distance(Segment s1, Segment s2) { if (intersect(s1, s2))return 0.0; return min( min(get_distance(s1, s2.p1), get_distance(s1, s2.p2)), min(get_distance(s2, s1.p1), get_distance(s2, s1.p2)) ); } //円と直線の交差判定 bool intersect(Circle c, Line l) { return get_distance(l, c.c) <= c.r + EPS; } //円と円の交差判定 共通接線の数 int intersect(Circle c1, Circle c2) { double d = get_distance(c1.c, c2.c); if (d > c1.r + c2.r)return 4; if (d == c1.r + c2.r)return 3; if (d + c1.r == c2.r || d + c2.r == c1.r)return 1; if (d + c1.r < c2.r || d + c2.r < c1.r)return 0; return 2; } //線分と線分の交点 Point get_cross_point(Segment a, Segment b) { assert(intersect(a, b)); Vector base = b.p2 - b.p1; double area1 = abs(cross(base, a.p1 - b.p1)); double area2 = abs(cross(base, a.p2 - b.p1)); double t = area1 / (area1 + area2); return a.p1 + (a.p2 - a.p1)*t; } //円と直線の交点 pair<Point, Point> get_cross_points(Circle c, Line l) { assert(intersect(c, l)); Vector pr = project(l, c.c); Vector e = (l.p2 - l.p1) / (l.p2 - l.p1).abs(); double base = sqrt(c.r*c.r - (pr - c.c).norm()); return make_pair(pr + e*base, pr - e*base); } //円と円の交点 pair<Point, Point> get_cross_points(Circle c1, Circle c2) { int m = intersect(c1, c2); assert(m != 4 && m != 0); double d = (c1.c - c2.c).abs(); double a = acos((c1.r*c1.r - c2.r*c2.r + d*d) / (2 * c1.r*d)); double t = arg(c2.c - c1.c); return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a)); } //点の内包 enum { OUT = 0, ON, IN }; int contains(const Polygon &pl, Point p) { int n = pl.size(); bool x = false; for (int i = 0; i < n; i++) { Point a = pl[i] - p, b = pl[(i + 1) % n] - p; if (abs(cross(a, b)) < EPS&&dot(a, b) < EPS)return ON; if (a.y > b.y)swap(a, b); if (a.y < EPS&&EPS<b.y&&cross(a, b)>EPS)x = !x; } return (x ? IN : OUT); } int contains(Circle c, Point p) { double d = get_distance(c.c, p); if (equals(d, c.r))return ON; if (d < c.r)return IN; return OUT; } //多角形の面積 double area(const Polygon &p) { double a = 0; for (size_t i = 0; i < p.size(); i++) a += cross(p[i], p[(i + 1) % p.size()]); return fabs(a / 2.0); } //凸性判定(反時計回り) bool is_convex(Polygon g) { for (size_t i = 0; i < g.size(); i++) if (ccw(g[i], g[(i + 1) % g.size()], g[(i + 2) % g.size()]) == CLOCKWISE) return false; return true; } //凸包 //Graham scan https://en.wikipedia.org/wiki/Graham_scan //辺上の点を含めない Polygon convex_hull(Polygon P) { sort(P.begin(), P.end()); Polygon up; for (Point &p : P) { while (up.size() > 1 && ccw(up[up.size() - 2], up[up.size() - 1], p) != CLOCKWISE)up.pop_back(); up.emplace_back(p); } Polygon down; for (Point &p : P) { while (down.size() > 1 && ccw(down[down.size() - 2], down[down.size() - 1], p) != COUNTER_CLOCKWISE)down.pop_back(); down.emplace_back(p); } reverse(up.begin(), up.end()); //反時計回りに down.insert(down.end(), up.begin() + 1, up.end() - 1); return down; } //凸包 //Graham scan https://en.wikipedia.org/wiki/Graham_scan //辺上の点を含む Polygon convex_hull_with_points_online(Polygon P) { sort(P.begin(), P.end()); Polygon up; for (Point &p : P) { int _ccw; while (up.size() > 1 && (_ccw = ccw(up[up.size() - 2], up[up.size() - 1], p)) != CLOCKWISE &&_ccw != ONLINE_FRONT) up.pop_back(); up.emplace_back(p); } Polygon down; for (Point &p : P) { int _ccw; while (down.size() > 1 && (_ccw = ccw(down[down.size() - 2], down[down.size() - 1], p)) != COUNTER_CLOCKWISE && _ccw != ONLINE_FRONT) down.pop_back(); down.emplace_back(p); } reverse(up.begin(), up.end()); //反時計回りに down.insert(down.end(), up.begin() + 1, up.end() - 1); return down; } //凸多角形の最遠頂点対間距離 //calipers https://en.wikipedia.org/wiki/Rotating_calipers double diameter(Polygon P) { P = convex_hull(P); auto mima = minmax_element(P.begin(), P.end()); int I = mima.first - P.begin(); int J = mima.second - P.begin(); double maxd = get_distance(P[I], P[J]); int maxi, maxj, i, j; i = maxi = I; j = maxj = J; do { if (ccw(next(P, i) - P[i], next(P, j) - P[j]) == COUNTER_CLOCKWISE) j = (j + 1) % P.size(); else i = (i + 1) % P.size(); if (maxd < get_distance(P[i], P[j])) { maxd = get_distance(P[i], P[j]); maxi = i, maxj = j; } } while (!(i == I&&j == J)); return maxd; } //多角形を(0,0)を中心として回転 Polygon rotate(const Polygon &P, double rad) { Polygon ret; for (auto &p : P) ret.emplace_back(p.x*cos(rad) - p.y*sin(rad), p.x*sin(rad) + p.y*cos(rad)); return ret; } //Heron's formula double area(double a, double b, double c) { double s = (a + b + c) / 2; return sqrt(s*(s - a)*(s - b)*(s - c)); } //多角形の重心 Point center(const Polygon &P) { Point ret(0, 0); for (auto &p : P)ret = ret + p; ret = ret / P.size(); return ret; } //垂直二等分線 Line get_bisection(const Point &p1, const Point &p2) { Circle c1(p1, INF), c2(p2, INF); //INF だと誤差が酷い auto ps = get_cross_points(c1, c2); return Line(ps.first, ps.second); } //3点から距離が等しい点 (3点を円周上に持つ円の中心) Point get_center(const Point &p1, const Point &p2, const Point &p3) { Line l1 = get_bisection(p1, p2), l2 = get_bisection(p2, p3); return get_cross_point(l1, l2); } //点pを通る円cの接線における接点 pair<Point, Point> get_tangent(const Circle &c, const Point &p) { double d = get_distance(c.c, p); Circle c2((c.c + p) / 2, d / 2); return get_cross_points(c, c2); } using Weight = double; using Flow = int; struct Edge { int s, d; Weight w; Flow c; Edge() {}; Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {}; }; bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; } bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; } inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); } using Edges = vector<Edge>; using Graph = vector<Edges>; using Array = vector<Weight>; using Matrix = vector<Array>; void addArc(Graph &g, int s, int d, Weight w = 1) { g[s].emplace_back(s, d, w); } void addEdge(Graph &g, int a, int b, Weight w = 1) { addArc(g, a, b, w); addArc(g, b, a, w); } vector<int> dijkstra(const Graph &g, int s, Array &dist) { int n = g.size(); assert(s < n); enum { WHITE, GRAY, BLACK }; vector<int> color(n, WHITE); color[s] = GRAY; vector<int> _prev(n, -1); dist.assign(n, INF); dist[s] = 0; using State = tuple<Weight, int, int>; priority_queue<State, vector<State>, greater<State>> pq; pq.emplace(0, s, -1); while (pq.size()) { Weight d; int v, u; tie(d, v, u) = pq.top(); pq.pop(); if (dist[v] < d)continue; color[v] = BLACK; _prev[v] = u; for (auto &e : g[v]) { if (color[e.d] == BLACK)continue; if (dist[e.d] > dist[v] + e.w) { dist[e.d] = dist[v] + e.w; pq.emplace(dist[e.d], e.d, v); color[e.d] = GRAY; } } } return _prev; } double get_distance(Circle c, Point p) { return max(0.0, get_distance(c.c, p) - c.r); } double get_distance(Circle c1, Circle c2) { return max(0.0, get_distance(c1.c, c2.c) - c1.r - c2.r); } signed main() { cin.tie(0); ios::sync_with_stdio(false); Point s, t; cin >> s >> t; int N; cin >> N; vector<Circle> cs(N); rep(i, 0, N) { cin >> cs[i].c >> cs[i].r; } Graph g(N + 2); rep(i, 0, N) { addEdge(g, N, i, get_distance(cs[i], s)); addEdge(g, N + 1, i, get_distance(cs[i], t)); } rep(i, 0, N) { rep(j, i + 1, N) { addEdge(g, i, j, get_distance(cs[i], cs[j])); } } Array dist; dijkstra(g, N, dist); dump(dist); cout << fixed << setprecision(12); cout << dist[N + 1] << endl; return 0; }
a.cc: In function 'long double get_distance(Circle, Point)': a.cc:414:19: error: no matching function for call to 'max(double, long double)' 414 | return max(0.0, get_distance(c.c, p) - c.r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:414:19: note: deduced conflicting types for parameter 'const _Tp' ('double' and 'long double') 414 | return max(0.0, get_distance(c.c, p) - c.r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:414:19: note: mismatched types 'std::initializer_list<_Tp>' and 'double' 414 | return max(0.0, get_distance(c.c, p) - c.r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc: In function 'long double get_distance(Circle, Circle)': a.cc:418:19: error: no matching function for call to 'max(double, long double)' 418 | return max(0.0, get_distance(c1.c, c2.c) - c1.r - c2.r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:418:19: note: deduced conflicting types for parameter 'const _Tp' ('double' and 'long double') 418 | return max(0.0, get_distance(c1.c, c2.c) - c1.r - c2.r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:418:19: note: mismatched types 'std::initializer_list<_Tp>' and 'double' 418 | return max(0.0, get_distance(c1.c, c2.c) - c1.r - c2.r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s416844021
p03866
C++
#include<bits\stdc++.h> using namespace std; typedef pair<int,int> pii; typedef pair<double,double > pdd; typedef pair<int,pii > pipdd; typedef pair<int,double> pid; typedef pair<pii,pdd> ppiipdd; typedef pair<double,int> pdi; vector<ppiipdd> V; vector<pid> G[1010]; int N; double sx,sy,gx,gy; double D[1010]; int main() { scanf("%lf%lf%lf%lf",&sx,&sy,&gx,&gy); scanf("%d",&N); for(int i = 0; i < N + 2; i++) { D[i] = -1; } V.push_back(make_pair(make_pair(N,0),make_pair(sx,sy))); V.push_back(make_pair(make_pair(N + 1,0),make_pair(gx,gy))); for(int i = 0; i < N; i++) { double x,y; int r; scanf("%lf%lf%d",&x,&y,&r); V.push_back(make_pair(make_pair(i,r),make_pair(x,y))); } for(int i = 0; i < V.size(); i++) { for(int j = i; j < V.size(); j++) { double x = (V[i].second.first - V[j].second.first) * (V[i].second.first - V[j].second.first); double y = (V[i].second.second - V[j].second.second) * (V[i].second.second - V[j].second.second); double length = max(0.0,sqrt(x + y) - (double)V[i].first.second - (double)V[j].first.second); G[V[i].first.first].push_back(make_pair(V[j].first.first,length)); G[V[j].first.first].push_back(make_pair(V[i].first.first,length)); } } priority_queue<pdi ,vector<pdi>,greater<pdi> > Q; Q.push(make_pair(0,N)); while(Q.size()) { pdi now = Q.top(); Q.pop(); if(D[now.second] != -1) { continue; } D[now.second] = now.first; for(int i = 0; i < G[now.second].size(); i++) { Q.push(make_pair(now.first + G[now.second][i].second,G[now.second][i].first)); } } printf("%lf\n",D[N + 1]); return 0; }
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory 1 | #include<bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s409228160
p03866
C++
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end def inpf() a=gets.chomp.split(" ").map(&:to_f)end def inps() a=gets.chomp.split(" ")end def copy(a) Marshal.load(Marshal.dump(a)) end def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end def na(n,d=0) Array.new(n,d)end def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end def bit(n) n.to_s(2).split("").map(&:to_i) end def inp() a=gets.chomp.split(" ").map(&:to_i)end sx,sy,ex,ey = inp n = inp[0] t = [] rec = na(n+2,999999999) t[0] = [sx,sy,0] t[1] = [ex,ey,0] n.times do t.push(inp) end ind = 0 tab = (1..n+1).to_a rec[0] = 0 (n+1).times do max = 999999999 nex = -1 tab.each do |d| kyori = [(((t[ind][0] - t[d][0])**2 + (t[ind][1] - t[d][1])**2))**0.5 - (t[ind][2] + t[d][2]) + rec[ind],0].max if rec[d] > kyori rec[d] = kyori if max > kyori max = kyori nex = d end end end ind = nex tab.delete(ind) end p rec[1]
a.cc:5:28: error: too many decimal points in number 5 | def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end | ^~~~ a.cc:23:8: error: too many decimal points in number 23 | tab = (1..n+1).to_a | ^~~~ a.cc:1:1: error: 'def' does not name a type 1 | def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end | ^~~ a.cc:6:29: error: 'a' does not name a type 6 | def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end | ^ a.cc:6:48: error: expected unqualified-id before 'return' 6 | def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end | ^~~~~~ a.cc:8:46: error: 'end' does not name a type 8 | def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end | ^~~ a.cc:9:62: error: 'end' does not name a type 9 | def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end | ^~~
s355024354
p03866
C++
#include<iostream> #include<cstdio> #include<cmath> #include<vector> #include<queue> #include<map> #include<algorithm> #include<set> #include<complex> #include<string> #include<cstring> using namespace std; #define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++) #define rep(x,to) rep2(x,0,to) #define INF 100000000 #define debug(x) cout<<#x<<": "<<x<<endl #define eps 0.00000000001 #define all(x) x.begin(),x.end() typedef pair<double,int> P; typedef pair<int,P> PP; int xs,ys,xt,yt; int n; double x[2000]; double y[2000]; double r[2000]; double d[1000000]; int V,E; class edge { public:int to; double cost; }; vector<edge> G[1001]; void dijkstra(int s) { priority_queue<P,vector<P>,greater<P> > que; que.push(P(0.000,s)); fill(d,d+V,INF); d[s]=0.000; while(!que.empty()) { P p=que.top();que/.pop(); int v=p.second; if(d[v]<p.first) continue; rep(i,G[v].size()) { edge e=G[v][i]; int vv=e.to; if(d[e.to]>d[v]+e.cost) { d[e.to]=d[v]+e.cost; que.push(P(d[e.to],e.to)); } } } } double dis; int main() { cin>>xs>>ys>>xt>>yt; //scanf("%lf%lf%lf%lf",&xs,&ys,&xt,&yt); cin>>n; V=n+2; E=(n+2)*(n+3)/2; rep(i,n) { //scanf("%lf%lf%lf",&x[i],&y[i],&r[i]); cin>>x[i]>>y[i]>>r[i]; } x[n]=xs; y[n]=ys; r[n]=0.000000; r[n+1]=0.000000; x[n+1]=xt; y[n+1]=yt; rep(i,n+2) { rep2(j,i+1,n+2) { dis=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]; if(dis<0)dis=0.000; edge ee; ee.to=j; ee.cost=dis; G[i].push_back(ee); ee.to=i; G[j].push_back(ee); } } dijkstra(n); //cout<<d[n+1]<<endl; printf("%.11f\n",d[n+1]); /*getchar(); fflush(stdin);*/ return 0; }
a.cc: In function 'void dijkstra(int)': a.cc:42:35: error: expected primary-expression before '.' token 42 | P p=que.top();que/.pop(); | ^
s930789098
p03866
C++
struct edge{ int to; double cost; edge(int _to, double _cost) :to(_to), cost(_cost){} }; vector<edge> G[1010]; double xs, ys, xt, yt; int n; double d[1010]; void dijkstra(){ REP(i, 1010)d[i] = 1e18; d[0] = 0; typedef pair<double, int> PD; priority_queue<PD, vector<PD>, greater<PD>> que; que.push(pair<double, int>(0, 0)); while (!que.empty()){ pair<double, int> p = que.top(); que.pop(); int 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(pair<double, int>(d[e.to], e.to)); } } } } int main(){ cin >> xs >> ys >> xt >> yt >> n; vector<double> x(1010), y(1010), r(1010); x[0] = xs; y[0] = ys; r[0] = 0; x[n + 1] = xt; y[n + 1] = yt; r[n + 1] = 0; FOR(i, 1, n + 1){ cin >> x[i] >> y[i] >> r[i]; } REP(i, n + 2){ REP(j, n + 2){ if (i == j)continue; G[i].push_back( edge(j, max(0.0, sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])) - (r[i] + r[j])))); //cout << i << " " << j << sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])) - (r[i] + r[j]) << endl; } } dijkstra(); printf("%.10lf\n", d[n + 1]); }
a.cc:7:1: error: 'vector' does not name a type 7 | vector<edge> G[1010]; | ^~~~~~ a.cc: In function 'void dijkstra()': a.cc:13:13: error: 'i' was not declared in this scope 13 | REP(i, 1010)d[i] = 1e18; | ^ a.cc:13:9: error: 'REP' was not declared in this scope 13 | REP(i, 1010)d[i] = 1e18; | ^~~ a.cc:16:17: error: 'pair' does not name a type 16 | typedef pair<double, int> PD; | ^~~~ a.cc:17:9: error: 'priority_queue' was not declared in this scope 17 | priority_queue<PD, vector<PD>, greater<PD>> que; | ^~~~~~~~~~~~~~ a.cc:17:24: error: 'PD' was not declared in this scope 17 | priority_queue<PD, vector<PD>, greater<PD>> que; | ^~ a.cc:17:28: error: 'vector' was not declared in this scope 17 | priority_queue<PD, vector<PD>, greater<PD>> que; | ^~~~~~ a.cc:17:38: error: expected primary-expression before ',' token 17 | priority_queue<PD, vector<PD>, greater<PD>> que; | ^ a.cc:17:40: error: 'greater' was not declared in this scope 17 | priority_queue<PD, vector<PD>, greater<PD>> que; | ^~~~~~~ a.cc:17:53: error: 'que' was not declared in this scope 17 | priority_queue<PD, vector<PD>, greater<PD>> que; | ^~~ a.cc:18:18: error: 'pair' was not declared in this scope 18 | que.push(pair<double, int>(0, 0)); | ^~~~ a.cc:18:23: error: expected primary-expression before 'double' 18 | que.push(pair<double, int>(0, 0)); | ^~~~~~ a.cc:18:31: error: expected primary-expression before 'int' 18 | que.push(pair<double, int>(0, 0)); | ^~~ a.cc:21:22: error: expected primary-expression before 'double' 21 | pair<double, int> p = que.top(); | ^~~~~~ a.cc:23:25: error: 'p' was not declared in this scope 23 | int v = p.second; | ^ a.cc:25:37: error: 'G' was not declared in this scope 25 | for (int i = 0; i < G[v].size(); i++){ | ^ a.cc:29:47: error: expected primary-expression before 'double' 29 | que.push(pair<double, int>(d[e.to], e.to)); | ^~~~~~ a.cc:29:55: error: expected primary-expression before 'int' 29 | que.push(pair<double, int>(d[e.to], e.to)); | ^~~ a.cc: In function 'int main()': a.cc:36:9: error: 'cin' was not declared in this scope 36 | cin >> xs >> ys >> xt >> yt >> n; | ^~~ a.cc:37:9: error: 'vector' was not declared in this scope 37 | vector<double> x(1010), y(1010), r(1010); | ^~~~~~ a.cc:37:16: error: expected primary-expression before 'double' 37 | vector<double> x(1010), y(1010), r(1010); | ^~~~~~ a.cc:38:9: error: 'x' was not declared in this scope; did you mean 'xt'? 38 | x[0] = xs; | ^ | xt a.cc:39:9: error: 'y' was not declared in this scope; did you mean 'yt'? 39 | y[0] = ys; | ^ | yt a.cc:40:9: error: 'r' was not declared in this scope 40 | r[0] = 0; | ^ a.cc:44:13: error: 'i' was not declared in this scope 44 | FOR(i, 1, n + 1){ | ^ a.cc:44:9: error: 'FOR' was not declared in this scope 44 | FOR(i, 1, n + 1){ | ^~~ a.cc:47:9: error: 'REP' was not declared in this scope 47 | REP(i, n + 2){ | ^~~ a.cc:58:9: error: 'printf' was not declared in this scope 58 | printf("%.10lf\n", d[n + 1]); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | struct edge{
s399004999
p03866
C++
#include<bits/stdc++.h> #define EPS (1e-10) #define INF (double)(0x3f3f3f3f) #define equals(a,b)(fabs((a)-(b))<EPS) #define rep(i,n)for(int i=0;i<n;i++) using namespace std; typedef pair<double, int>P; struct Point { double x, y; Point(double x = 0, double y = 0) :x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a*x, a*y); } Point operator/(double a) { return Point(x / a, y / a); } double norm() { return x*x + y*y; } double abs() { return sqrt(norm()); } bool operator<(const Point&p)const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point&p)const { return fabs(x - p.x) < EPS&&fabs(y - p.y) < EPS; } }; typedef Point Vector; double norm(Vector a) { return a.x*a.x + a.y*a.y; } double abs(Vector a) { return sqrt(norm(a)); } double getDistance(Point a, Point b) { return abs(a - b); } class Circle { public: Point c; double r; Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {} }; double getDistance(Circle c1, Circle c2) { return max(0.0L, getDistance(c1.c, c2.c) - c1.r - c2.r); } double getDistance(Circle c, Point p) { return max(0.0L, getDistance(c.c, p) - c.r); } double dist[1200][1200]; double d[1200]; Circle c[1200]; int main() { double xs, ys, xt, yt; scanf("%lf%lf%lf%lf", &xs, &ys, &xt, &yt); int n; scanf("%d", &n); rep(i, n) { double x, y, r; scanf("%lf%lf%lf", &x, &y, &r); c[i] = { { x,y },r }; } c[n] = { {xs,ys} }; c[n + 1] = { {xt,yt} }; n += 2; rep(i, n)for (int j = i + 1; j < n; j++) { dist[i][j] = dist[j][i] = getDistance(c[i], c[j]); } fill(d, d + n, INF); priority_queue<P, vector<P>, greater<P>>que; d[n - 2] = 0; que.push(P(0, n - 2)); while (!que.empty()) { P p = que.top(); que.pop(); if (p.first != d[p.second])continue; rep(j, n) { if (d[j] > p.first + dist[p.second][j]) { d[j] = p.first + dist[p.second][j]; que.push(P(d[j], j)); } } } printf("%.12lf\n", d[n - 1]); }
a.cc: In function 'double getDistance(Circle, Circle)': a.cc:44:19: error: no matching function for call to 'max(long double, double)' 44 | return max(0.0L, getDistance(c1.c, c2.c) - c1.r - c2.r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:44:19: note: deduced conflicting types for parameter 'const _Tp' ('long double' and 'double') 44 | return max(0.0L, getDistance(c1.c, c2.c) - c1.r - c2.r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:44:19: note: mismatched types 'std::initializer_list<_Tp>' and 'long double' 44 | return max(0.0L, getDistance(c1.c, c2.c) - c1.r - c2.r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc: In function 'double getDistance(Circle, Point)': a.cc:47:19: error: no matching function for call to 'max(long double, double)' 47 | return max(0.0L, getDistance(c.c, p) - c.r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:47:19: note: deduced conflicting types for parameter 'const _Tp' ('long double' and 'double') 47 | return max(0.0L, getDistance(c.c, p) - c.r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:47:19: note: mismatched types 'std::initializer_list<_Tp>' and 'long double' 47 | return max(0.0L, getDistance(c.c, p) - c.r); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s479777025
p03866
C++
#include <iostream> #include <cmath> #include <cstdio> #include <queue> #include <utility> #define INF 1000000005 #define MP make_pair using namespace std; long long int x[1005],y[1005],r[1005],n,dis[1005],edge[1005][1005]; bool use[1005]; pair<double,int> P; priority_queue<pair<double,int>>Q; double cal(double a,double b,double r){ double ans=sqrt(pow(a,2)+pow(b,2))-r; if(ans<0)ans=0; return ans; } int main() { cin>>x[0]>>y[0]>>x[1]>>y[1]; r[0]=r[1]=0; cin>>n; for(int i=2;i<n+2;i++){ cin>>x[i]>>y[i]>>r[i]; use[i]=false; dis[i]=INF; } dis[0]=0;dis[1]=INF; use[0]=true;use[1]=false; for(int i=0;i<n+2:i++){ for(int j=0;j<n+2;i++){ edge[i][j]=cal(x[i]-x[j],y[i]-y[j],r[i]+r[j]); } } for(int i=0;i<n+2;i++){ Q.push(MP(edge[0][i],i)); } while(!Q.empty()){ P=Q.top(); Q.pop(); if(use[P.second]==true)continue; if(P.second==2){ cout<<P.first; return 0; } dis[P.second]=P.first; use[P.second]=true; for(int i=0;i<n+2;i++){ if(dis[i]<P.first+edge[i][P.second]){ Q.push(MP(P.first+edge[i][P.second],i)); } } } return 0; }
a.cc: In function 'int main()': a.cc:34:17: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions] 34 | for(int i=0;i<n+2:i++){ | ^ a.cc:34:22: error: expected ';' before ':' token 34 | for(int i=0;i<n+2:i++){ | ^ | ; a.cc:39:5: error: expected primary-expression before 'for' 39 | for(int i=0;i<n+2;i++){ | ^~~ a.cc:38:6: error: expected ';' before 'for' 38 | } | ^ | ; 39 | for(int i=0;i<n+2;i++){ | ~~~ a.cc:39:5: error: expected primary-expression before 'for' 39 | for(int i=0;i<n+2;i++){ | ^~~ a.cc:38:6: error: expected ')' before 'for' 38 | } | ^ | ) 39 | for(int i=0;i<n+2;i++){ | ~~~ a.cc:34:8: note: to match this '(' 34 | for(int i=0;i<n+2:i++){ | ^
s153883798
p03866
C++
#include<bits/stdc++.h> using namespace std; #define MAX_N 1111 #define pb push_back #define fi first #define sc second typedef pair<ouble,int> P; int N; double Xs,Ys,Xt,Yt; double X[MAX_N],Y[MAX_N],R[MAX_N]; double cost[MAX_N][MAX_N]; double s[MAX_N]; double dis(int i,int j); int main() { cout.precision(22);cin.precision(22); //printf("long double : %d\n", sizeof(long double)); cin >> Xs >> Ys >> Xt >> Yt; cin >> N; for(int i=0;i<N;i++){ cin >> X[i] >> Y[i] >> R[i]; } X[N]=Xs;Y[N]=Ys;R[N]=0; X[N+1]=Xt;Y[N+1]=Yt;R[N+1]=0;N+=2; for(int i=0;i<N;i++){ for(int j=i+1;j<N;j++){ cost[i][j]=dis(i,j); //cout << i << " " << j << " " << cost[i][j] << "\n"; cost[j][i]=cost[i][j]; } } for(int i=0;i<N;i++){ s[i]=3000000000; } priority_queue<P,vector<P>,greater<P> >que; que.push(P(0,N-2)); while(!que.empty()){ P p=que.top();que.pop(); if(s[p.sc]<=p.fi)continue; s[p.sc]=p.fi; for(int i=0;i<N;i++){ if(p.fi+cost[p.sc][i]<s[i]){ que.push(P(p.fi+cost[p.sc][i],i)); } } } cout << s[N-1] << "\n"; return 0; } double dis(int i,int j){ double l=sqrt((Y[j]-Y[i])*(Y[j]-Y[i])+(X[j]-X[i])*(X[j]-X[i])); l-=(R[i]+R[j]); if(l<0)return 0; return l; }
a.cc:7:14: error: 'ouble' was not declared in this scope; did you mean 'double'? 7 | typedef pair<ouble,int> P; | ^~~~~ | double a.cc:7:23: error: template argument 1 is invalid 7 | typedef pair<ouble,int> P; | ^ a.cc: In function 'int main()': a.cc:36:25: error: expression list treated as compound expression in functional cast [-fpermissive] 36 | que.push(P(0,N-2)); | ^ a.cc:6:12: error: request for member 'second' in 'p', which is of non-class type 'P' {aka 'int'} 6 | #define sc second | ^~~~~~ a.cc:39:24: note: in expansion of macro 'sc' 39 | if(s[p.sc]<=p.fi)continue; | ^~ a.cc:5:12: error: request for member 'first' in 'p', which is of non-class type 'P' {aka 'int'} 5 | #define fi first | ^~~~~ a.cc:39:31: note: in expansion of macro 'fi' 39 | if(s[p.sc]<=p.fi)continue; | ^~ a.cc:6:12: error: request for member 'second' in 'p', which is of non-class type 'P' {aka 'int'} 6 | #define sc second | ^~~~~~ a.cc:40:21: note: in expansion of macro 'sc' 40 | s[p.sc]=p.fi; | ^~ a.cc:5:12: error: request for member 'first' in 'p', which is of non-class type 'P' {aka 'int'} 5 | #define fi first | ^~~~~ a.cc:40:27: note: in expansion of macro 'fi' 40 | s[p.sc]=p.fi; | ^~ a.cc:5:12: error: request for member 'first' in 'p', which is of non-class type 'P' {aka 'int'} 5 | #define fi first | ^~~~~ a.cc:42:30: note: in expansion of macro 'fi' 42 | if(p.fi+cost[p.sc][i]<s[i]){ | ^~ a.cc:6:12: error: request for member 'second' in 'p', which is of non-class type 'P' {aka 'int'} 6 | #define sc second | ^~~~~~ a.cc:42:40: note: in expansion of macro 'sc' 42 | if(p.fi+cost[p.sc][i]<s[i]){ | ^~ a.cc:5:12: error: request for member 'first' in 'p', which is of non-class type 'P' {aka 'int'} 5 | #define fi first | ^~~~~ a.cc:43:46: note: in expansion of macro 'fi' 43 | que.push(P(p.fi+cost[p.sc][i],i)); | ^~ a.cc:6:12: error: request for member 'second' in 'p', which is of non-class type 'P' {aka 'int'} 6 | #define sc second | ^~~~~~ a.cc:43:56: note: in expansion of macro 'sc' 43 | que.push(P(p.fi+cost[p.sc][i],i)); | ^~ a.cc:43:64: error: expression list treated as compound expression in functional cast [-fpermissive] 43 | que.push(P(p.fi+cost[p.sc][i],i)); | ^
s410862910
p03866
C++
#include <iostream> #include <cmath> #include <cstdio> #include <queue> #include <pair> #define INF 1000000005 #define MP make_pair using namespace std; long long int x[1005],y[1005],r[1005],n,dis[1005],edge[1005][1005]; bool use[1005]; pair<double,int> P; priority_queue<pair<double,int>>Q; double cal(double a,double b,double r){ double ans=sqrt(pow(a,2)+pow(b,2))-r; if(ans<0)ans=0; return ans; } int main() { cin>>x[0]>>y[0]>>x[1]>>y[1]; r[0]=r[1]=0; cin>>n; for(int i=2;i<n+2;i++){ cin>>x[i]>>y[i]>>r[i]; use[i]=false; dis[i]=INF; } dis[0]=0;dis[1]=INF; use[0]=true;use[1]=false; for(int i=0;i<n+2:i++){ for(int j=0;j<n+2;i++){ edge[i][j]=cal(x[i]-x[j],y[i]-y[j],r[i]+r[j]); } } for(int i=0;i<n+2;i++){ Q.push(MP(edge[0][i],i)); } while(!Q.empty()){ P=Q.top(); Q.pop(); if(use[P.second]==true)continue; if(P.second==2){ cout<<P.first; return 0; } dis[P.second]=P.first; use[P.second]=true; for(int i=0;i<n+2;i++){ if(dis[i]<P.first+edge[i][P.second]){ Q.push(MP(P.first+edge[i][P.second],i)); } } } return 0; }
a.cc:5:10: fatal error: pair: No such file or directory 5 | #include <pair> | ^~~~~~ compilation terminated.
s834338037
p03866
C++
#include<iostream> #include<string> #include<vector> #include<map> #include<algorithm> #include<cmath> #include<queue> #include<set> using namespace std; const int MAX_V=1010;//頂点数の最大値 const double INF=999999999999.9; double cost[MAX_V][MAX_V];//cost[u][v]は辺e=(u,v)のコスト、辺が無い場合はINF double d[MAX_V];//頂点sからの最小距離 bool used[MAX_V];//既に使われたかのフラグ int V;//頂点数 void dijkstra(int s){ fill(d,d+V,INF); fill(used,used+V,false); d[s]=0.0; while(true){ int v = -1; //まだ使われていない頂点のうち距離が最小のものを探す。 for(int u=0;u<V;u++){ if(!used[u] && (v==-1 || d[u]<d[v])){ v=u; } } if(v==-1) break; used[v]=true; for(int u=0;u<V;u++){ d[u] = min(d[u],d[v]+cost[v][u]); } } } double dist(double xi,double yi,double xj,double yj){ double res = sqrt(1.0*(xi-xj)*(xi-xj)+1.0*(yi-yj)*(yi-yj)); return res; } int main(){ double xs,ys,xt,yt; int a,b,c,d; cin>>a>>b>>c>>d; xs=1.0*a; ys=1.0*b; xt=1.0*c; yt=1.0*d; int N; cin>>N; V=N+2; double x[1010],y[1010],r[1010]; for(int i=0;i<N;i++){ int x,y,r; cin>>x>>y>>r; x[i]=1.0*x; y[i]=1.0*y; r[i]=1.0*r; } cost[N][N+1]=dist(xs,ys,xt,yt); cost[N][N]=0.0; cost[N+1][N]=dist(xs,ys,xt,yt); cost[N+1][N+1]=0.0; for(int i=0;i<N;i++){ cost[i][N]=max(dist(x[i],y[i],xs,ys)-1.0*r[i], 0.0); cost[N][i]=max(dist(x[i],y[i],xs,ys)-1.0*r[i], 0.0); cost[i][N+1]=max(dist(x[i],y[i],xt,yt)-1.0*r[i], 0.0); cost[N+1][i]=max(dist(x[i],y[i],xt,yt)-1.0*r[i], 0.0); for(int j=0;j<N;j++){ cost[i][j]=max(dist(x[i],y[i],x[j],y[j])-1.0*r[i]-1.0*r[j] , 0.0); } } dijkstra(N); cout<<d[N+1]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:55:10: error: invalid types 'int[int]' for array subscript 55 | x[i]=1.0*x; y[i]=1.0*y; r[i]=1.0*r; | ^ a.cc:55:22: error: invalid types 'int[int]' for array subscript 55 | x[i]=1.0*x; y[i]=1.0*y; r[i]=1.0*r; | ^ a.cc:55:34: error: invalid types 'int[int]' for array subscript 55 | x[i]=1.0*x; y[i]=1.0*y; r[i]=1.0*r; | ^ a.cc:71:12: error: invalid types 'int[int]' for array subscript 71 | cout<<d[N+1]<<endl; | ^
s896571172
p03866
C++
#include <cstdio> #include <cstring> #include <cmath> #include <climits> #include <cfloat> #include <algorithm> #include <sstream> #include <tuple> #include <queue> #include <iostream> #include <iomanip> #include <vector> #include <map> #include <set> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef vector<int> vi; typedef vector<long> vl; #define ten(n) ((int)1e##n) #define COUT cout << #define SPACE_COUT << " " << #define COMMA_COUT << ", " << #define ENDL << endl; double distance(tuple<ll, ll, ll> n1, tuple<ll, ll, ll> n2) { double x = get<0>(n1) - get<0>(n2); double y = get<1>(n1) - get<1>(n2); double r = get<2>(n1) + get<2>(n2); double dist = sqrt(x * x + y * y) - r; return dist > 0 ? dist : 0; } class AscendPair { public: bool operator() (pair<double, int> n1, pair<double, int> n2) { return n1.first > n2.first; } }; int main() { cin.tie(0); cout << setprecision(12); ios::sync_with_stdio(false); int N; vector<tuple<ll, ll, ll> > nodes; ll x, y, r; cin >> x >> y; nodes.push_back(make_tuple(x, y, 0)); cin >> x >> y; nodes.push_back(make_tuple(x, y, 0)); cin >> N; for (int i = 0; i < N; ++i) { cin >> x >> y >> r; nodes.push_back(make_tuple(x, y, r)); } vector<double> dijkstra(nodes.size()); vector<vector<double> > paths(nodes.size()); for (int i = 0; i < nodes.size(); ++i) { tuple<ll, ll, ll> node = nodes[i]; vector<double>& path = paths[i]; for (int j = 0; j < nodes.size(); ++j) { double dist = distance(node, nodes[j]); path[j].push_back(dist); } dijkstra[i] = DBL_MAX; } set<int> used; priority_queue<pair<double, int> , vector<pair<double, int> >, AscendPair > pq; pq.push(make_pair(0, 0)); while(!pq.empty()) { pair<double, int> kv = pq.top(); pq.pop(); double cost = kv.first; int index = kv.second; used.insert(index); if (dijkstra[index] < cost) continue; dijkstra[index] = cost; vector<double> path = paths[index]; for (int i = 0; i < nodes.size(); ++i) { if (used.find(i) != used.end()) continue; pq.push(make_pair(cost + path[i], i)); } } cout << dijkstra[1] << endl; return 0; }
a.cc: In function 'int main()': a.cc:71:21: error: request for member 'push_back' in '(& path)->std::vector<double>::operator[](((std::vector<double>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type' {aka 'double'} 71 | path[j].push_back(dist); | ^~~~~~~~~