submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s540029206
p00523
Java
import java.io.*; public class Main0600{ public static void main(String[] args) throws IOException{ InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(is); String str = br.readLine(); int N = Integer.parseInt(str); int[] A = new int[N]; int m = 2000000000, M = 0; int kei = 0; int kei1 = 0, kei2 = 0, kei3 = 0;//3つの切り分けた領域の合計を表す int tmp; for(int i = 0; i < N; i++){ str = br.readLine(); A[i] = Integer.parseInt(str); } //主処理 for(int n = 0; n < N; n++){ for(int i = 1; i < N; i++){ for(int j = i + 1; j < N + 1; j++){ for(int i2 = 1; i2 <= i; i2++) kei1 = kei1 + A[i2 - 1]; if(m > kei1) m = kei1; for(int j2 = i + 1; j2 <= j; j2++) kei2 = kei2 + A[j2 - 1]; if(m > kei2) m = kei2; for(int k2 = j + 1; k2 <= N; k2++) kei3 = kei3 + A[k2 - 1]; if(m > kei3) m = kei3; if(m > M) M = m; kei1 = 0; kei2 = 0; kei3 = 0; m = 2000000000; } } //1番目に切れ込みを入れるパターンしか計算されないので、バウムクーヘンを回す(配列を循環させる) tmp = A[0]; for(int n2 = 0; n2 < N - 1; n2++) A[n2] = A[n2 + 1]; A[N - 1] =tmp; } System.out.println(M); } }
Main.java:3: error: class Main0600 is public, should be declared in a file named Main0600.java public class Main0600{ ^ 1 error
s410659322
p00523
Java
import java.io.*; public class Main{ public static void main(String[] args) throws IOException{ InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(is); String str = br.readLine(); int N = Integer.parseInt(str); int[] A = new int[N]; long int m = 200000000000, M = 0; int kei = 0; int kei1 = 0, kei2 = 0, kei3 = 0;//3つの切り分けた領域の合計を表す int tmp; for(int i = 0; i < N; i++){ str = br.readLine(); A[i] = Integer.parseInt(str); } //主処理 for(int n = 0; n < N; n++){ for(int i = 1; i < N; i++){ for(int j = i + 1; j < N + 1; j++){ for(int i2 = 1; i2 <= i; i2++) kei1 = kei1 + A[i2 - 1]; if(m > kei1) m = kei1; for(int j2 = i + 1; j2 <= j; j2++) kei2 = kei2 + A[j2 - 1]; if(m > kei2) m = kei2; for(int k2 = j + 1; k2 <= N; k2++) kei3 = kei3 + A[k2 - 1]; if(m > kei3) m = kei3; if(m > M) M = m; kei1 = 0; kei2 = 0; kei3 = 0; m = 200000000000; } } //1番目に切れ込みを入れるパターンしか計算されないので、バウムクーヘンを回す(配列を循環させる) tmp = A[0]; for(int n2 = 0; n2 < N - 1; n2++) A[n2] = A[n2 + 1]; A[N - 1] =tmp; } System.out.println(M); } }
Main.java:11: error: not a statement long int m = 200000000000, M = 0; ^ Main.java:11: error: ';' expected long int m = 200000000000, M = 0; ^ Main.java:11: error: integer number too large long int m = 200000000000, M = 0; ^ Main.java:37: error: integer number too large m = 200000000000; ^ 4 errors
s562501838
p00523
Java
import java.io.*; public class Main{ public static void main(String[] args) throws IOException{ InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(is); String str = br.readLine(); int N = Integer.parseInt(str); int[] A = new int[N]; long m = 200000000000, M = 0; int kei = 0; int kei1 = 0, kei2 = 0, kei3 = 0;//3つの切り分けた領域の合計を表す int tmp; for(int i = 0; i < N; i++){ str = br.readLine(); A[i] = Integer.parseInt(str); } //主処理 for(int n = 0; n < N; n++){ for(int i = 1; i < N; i++){ for(int j = i + 1; j < N + 1; j++){ for(int i2 = 1; i2 <= i; i2++) kei1 = kei1 + A[i2 - 1]; if(m > kei1) m = kei1; for(int j2 = i + 1; j2 <= j; j2++) kei2 = kei2 + A[j2 - 1]; if(m > kei2) m = kei2; for(int k2 = j + 1; k2 <= N; k2++) kei3 = kei3 + A[k2 - 1]; if(m > kei3) m = kei3; if(m > M) M = m; kei1 = 0; kei2 = 0; kei3 = 0; m = 200000000000; } } //1番目に切れ込みを入れるパターンしか計算されないので、バウムクーヘンを回す(配列を循環させる) tmp = A[0]; for(int n2 = 0; n2 < N - 1; n2++) A[n2] = A[n2 + 1]; A[N - 1] =tmp; } System.out.println(M); } }
Main.java:11: error: integer number too large long m = 200000000000, M = 0; ^ Main.java:37: error: integer number too large m = 200000000000; ^ 2 errors
s362519978
p00523
Java
import java.io.*; public class Main{ public static void main(String[] args) throws IOException{ InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(is); String str = br.readLine(); int N = Integer.parseInt(str); int[] A = new int[N]; long m = 20000000000, M = 0; int kei = 0; int kei1 = 0, kei2 = 0, kei3 = 0;//3つの切り分けた領域の合計を表す int tmp; for(int i = 0; i < N; i++){ str = br.readLine(); A[i] = Integer.parseInt(str); } //主処理 for(int n = 0; n < N; n++){ for(int i = 1; i < N; i++){ for(int j = i + 1; j < N + 1; j++){ for(int i2 = 1; i2 <= i; i2++) kei1 = kei1 + A[i2 - 1]; if(m > kei1) m = kei1; for(int j2 = i + 1; j2 <= j; j2++) kei2 = kei2 + A[j2 - 1]; if(m > kei2) m = kei2; for(int k2 = j + 1; k2 <= N; k2++) kei3 = kei3 + A[k2 - 1]; if(m > kei3) m = kei3; if(m > M) M = m; kei1 = 0; kei2 = 0; kei3 = 0; m = 20000000000; } } //1番目に切れ込みを入れるパターンしか計算されないので、バウムクーヘンを回す(配列を循環させる) tmp = A[0]; for(int n2 = 0; n2 < N - 1; n2++) A[n2] = A[n2 + 1]; A[N - 1] =tmp; } System.out.println(M); } }
Main.java:11: error: integer number too large long m = 20000000000, M = 0; ^ Main.java:37: error: integer number too large m = 20000000000; ^ 2 errors
s509127515
p00523
Java
import java.io.*; public class Main{ public static void main(String[] args) throws IOException{ InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(is); String str = br.readLine(); int N = Integer.parseInt(str); long[] A = new int[N]; long m = 1000000000000L, M = 0L; long tmp; long kei1 = 0L, kei2 = 0L, kei3 = 0L;//3つの切り分けた領域の合計を表す for(int i = 0; i < N; i++){ str = br.readLine(); A[i] = Integer.parseInt(str); } //主処理 for(int n = 0; n < N; n++){ for(int i = 1; i < N; i++){ for(int j = i + 1; j < N + 1; j++){ for(int i2 = 1; i2 <= i; i2++) kei1 = kei1 + A[i2 - 1]; if(m > kei1) m = kei1; for(int j2 = i + 1; j2 <= j; j2++) kei2 = kei2 + A[j2 - 1]; if(m > kei2) m = kei2; for(int k2 = j + 1; k2 <= N; k2++) kei3 = kei3 + A[k2 - 1]; if(m > kei3) m = kei3; if(m > M) M = m; kei1 = 0; kei2 = 0; kei3 = 0; m = 2000000000000L; } } //1番目に切れ込みを入れるパターンしか計算されないので、バウムクーヘンを回す(配列を循環させる) tmp = A[0]; for(int n2 = 0; n2 < N - 1; n2++) A[n2] = A[n2 + 1]; A[N - 1] =tmp; } System.out.println(M); } }
Main.java:10: error: incompatible types: int[] cannot be converted to long[] long[] A = new int[N]; ^ 1 error
s531444976
p00523
Java
import java.io.*; public class Main0600{ public static void main(String[] args) throws IOException{ InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(is); String str = br.readLine(); int N = Integer.parseInt(str); int[] A = new int[N]; int m = 2000000000, M = 0; int kei = 0; int kei1 = 0, kei2 = 0, kei3 = 0;//3つの切り分けた領域の合計を表す int tmp; for(int i = 0; i < N; i++){ str = br.readLine(); A[i] = Integer.parseInt(str); } //主処理 for(int n = 0; n < N; n++){ for(int i = 1; i < N; i++){ for(int j = i + 1; j < N + 1; j++){ for(int i2 = 1; i2 <= i; i2++) kei1 = kei1 + A[i2 - 1]; if(m > kei1) m = kei1; for(int j2 = i + 1; j2 <= j; j2++) kei2 = kei2 + A[j2 - 1]; if(m > kei2) m = kei2; for(int k2 = j + 1; k2 <= N; k2++) kei3 = kei3 + A[k2 - 1]; if(m > kei3) m = kei3; if(m > M) M = m; kei1 = 0; kei2 = 0; kei3 = 0; m = 2000000000; } } //1番目に切れ込みを入れるパターンしか計算されないので、バウムクーヘンを回す(配列を循環させる) tmp = A[0]; for(int n2 = 0; n2 < N - 1; n2++) A[n2] = A[n2 + 1]; A[N - 1] =tmp; } System.out.println(M); } }
Main.java:3: error: class Main0600 is public, should be declared in a file named Main0600.java public class Main0600{ ^ 1 error
s814865687
p00523
C++
#include <cstdio> #include <algorithm> using namespace std; #define MAX_N 100000 #define INF 100000000000000 typedef __int64 Int; int N; Int A[MAX_N * 2 + 1]; bool CC(int a, int b, Int x){ return A[b] - A[a] >= x; } bool C(Int x){ int lb, ub, left; bool cut; for(int i = 0; i <= N; i++){ left = i; lb = i; ub = 2 * N + 1; cut = false; while(ub - lb > 1){ int mid = (lb + ub) / 2; if(CC(left, mid, x)){ ub = mid; cut = true; } else lb = mid; } if(!cut) continue; left = ub; ub = 2 * N + 1; cut = false; while(ub - lb > 1){ int mid = (lb + ub) / 2; if(CC(left, mid, x)){ ub = mid; cut = true; } else lb = mid; } if(!cut) continue; left = ub; ub = 2 * N + 1; cut = false; while(ub - lb > 1){ int mid = (lb + ub) / 2; if(CC(left, mid, x)){ ub = mid; cut = true; } else lb = mid; } if(!cut) continue; if(ub - i < N + 1) return true; } return false; } int main(){ scanf("%d", &N); A[0] = 0; scanf("%I64d", &A[1]); A[N + 1] = A[1]; for(int i = 2; i <= N; i++){ scanf("%I64d", &A[i]); A[i] += A[i - 1]; A[i + N] = A[i]; } for(int i = N + 1; i <= N * 2; i++){ A[i] += A[N]; } Int lb = 0, ub = INF; while(ub - lb > 1){ Int mid = (lb + ub) / 2; if(C(mid)) lb = mid; else ub = mid; } printf("%I64d\n", lb); return 0; }
a.cc:7:9: error: '__int64' does not name a type; did you mean '__int64_t'? 7 | typedef __int64 Int; | ^~~~~~~ | __int64_t a.cc:9:1: error: 'Int' does not name a type; did you mean 'int'? 9 | Int A[MAX_N * 2 + 1]; | ^~~ | int a.cc:11:23: error: 'Int' has not been declared 11 | bool CC(int a, int b, Int x){ | ^~~ a.cc: In function 'bool CC(int, int, int)': a.cc:12:16: error: 'A' was not declared in this scope 12 | return A[b] - A[a] >= x; | ^ a.cc: At global scope: a.cc:15:8: error: 'Int' was not declared in this scope; did you mean 'int'? 15 | bool C(Int x){ | ^~~ | int a.cc: In function 'int main()': a.cc:59:9: error: 'A' was not declared in this scope 59 | A[0] = 0; | ^ a.cc:71:9: error: 'Int' was not declared in this scope; did you mean 'int'? 71 | Int lb = 0, ub = INF; | ^~~ | int a.cc:72:15: error: 'ub' was not declared in this scope 72 | while(ub - lb > 1){ | ^~ a.cc:72:20: error: 'lb' was not declared in this scope; did you mean 'labs'? 72 | while(ub - lb > 1){ | ^~ | labs a.cc:73:20: error: expected ';' before 'mid' 73 | Int mid = (lb + ub) / 2; | ^~~~ | ; a.cc:74:22: error: 'mid' was not declared in this scope 74 | if(C(mid)) lb = mid; | ^~~ a.cc:74:25: error: 'C' cannot be used as a function 74 | if(C(mid)) lb = mid; | ^ a.cc:78:27: error: 'lb' was not declared in this scope; did you mean 'labs'? 78 | printf("%I64d\n", lb); | ^~ | labs
s548639678
p00523
C++
#include<iostream> #define REP(i,n) for(int i=0;i<(int)(n);i++) using namespace std; typedef long long int Num; const int NMAX = 100010; int N; Num A[NMAX]; Num acc[NMAX]; void accumulate() { for (int i = 1; i <= N; i++) { acc[i] = acc[i - 1] + A[i]; } } int increment(int i) { return (i + 1) % N + 1; } Num range(int l, int r) { if (l <= r) { return acc[r] - acc[l]; } else { return range(0, r) + range(l, N); } } Num solve() { Num ans = 0; const Num Whole = acc[N]; int left = 1, medium
a.cc: In function 'Num solve()': a.cc:33:23: error: expected initializer at end of input 33 | int left = 1, medium | ^ a.cc:33:23: error: expected '}' at end of input a.cc:30:13: note: to match this '{' 30 | Num solve() { | ^ a.cc:33:23: warning: no return statement in function returning non-void [-Wreturn-type] 33 | int left = 1, medium | ^
s908127932
p00523
C++
#include<iostream> #include<algorithm> #include<limits> using namespace std; typedef long long llong; int N; llong *v_list; double tripartition; llong BaumukuchenGetAnswer(); llong searchOne(int n0); llong getMinV(int n0, int n1, int n2); int findIndex(int from_n, int to_n, double target); int main(){ /* ifstream fin("input.txt"); fin >> N; v_list = new llong[N+1]; v_list[0] = 0; for(int n=1; n<N+1; n++){ llong A; fin >> A; v_list[n] = v_list[n-1] + A; } fin.close(); /*/ cin >> N; v_list = new llong[N+1]; v_list[0] = 0; for(int n=1; n<N+1; n++){ llong A; cin >> A; v_list[n] = v_list[n-1] + A; } //*/ cout << BaumukuchenGetAnswer() <<endl; delete[] v_list; } llong BaumukuchenGetAnswer(){ tripartition = v_list[N] / 3.0; llong interm_maxV = -1; int n0_max = findIndex(0, N, tripartition); for (int n0 = 0; n0 <= n0_max; n0++){ llong tmp = searchOne(n0); if (tmp > interm_maxV) interm_maxV = tmp; } return interm_maxV; } llong searchOne(int n0){ int n1_left = findIndex(n0 + 1, N, tripartition + v_list[n0]); int n2_left = findIndex(n1_left+1, N, 2 * tripartition + v_list[n0]); llong V_ll = getMinV(n0, n1_left, n2_left); llong V_lr = getMinV(n0, n1_left, n2_left+1); llong V_rl = getMinV(n0, n1_left+1, n2_left); llong V_rr = getMinV(n0, n1_left+1, n2_left+1); return max( max(V_ll,V_lr), max(V_rl, V_rr)); } llong getMinV(int n0, int n1, int n2){ if (n1 == -1 || n2 == -1) return LLONG_MAX; else { llong V0 = v_list[n1] - v_list[n0]; llong V1 = v_list[n2] - v_list[n1]; llong V2 = v_list[n0] - v_list[n2] + v_list[N]; return min(min(V0,V1),V2); } } int findIndex(int from_n, int to_n, double target){ int n_left = from_n; int n_right = to_n; while (n_right - n_left != 1) { int n_mid = (n_right + n_left) / 2; if (v_list[n_mid] <= target) n_left = n_mid; else n_right = n_mid; } return n_left; }
a.cc: In function 'llong getMinV(int, int, int)': a.cc:66:42: error: 'LLONG_MAX' was not declared in this scope 66 | if (n1 == -1 || n2 == -1) return LLONG_MAX; | ^~~~~~~~~ a.cc:4:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include<limits> +++ |+#include <climits> 4 |
s677464374
p00523
C++
using System; using System.Collections.Generic; using System.Linq; namespace Baumkuchen { class Baumkuchen { static void Main(string[] args) { System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); //* System.IO.StreamReader sr = new System.IO.StreamReader("input33.txt"); int N = int.Parse(sr.ReadLine()); long[] v_list = new long[N + 1]; v_list[0] = 0; for (int n = 1; n < N+1; n++) { v_list[n] = v_list[n - 1] + long.Parse(sr.ReadLine()); } sr.Close(); /*/ int N = int.Parse(Console.ReadLine()); long[] v_list = new long[N + 1]; v_list[0] = 0; for (int n = 1; n < N + 1; n++) { v_list[n] = v_list[n - 1] + long.Parse(Console.ReadLine()); } //*/ sw.Start(); Baumkuchen baumkuchen = new Baumkuchen(v_list); Console.WriteLine(baumkuchen.GetAnwser()); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); } readonly long[] v_list; readonly int N; readonly double tripartition; public Baumkuchen(long[] _v_list) { N = _v_list.Length - 1; v_list = _v_list; tripartition = v_list[N] / 3.0; } public long GetAnwser() { long interm_maxV = -1; int n0_max = findIndex(0, N, tripartition)[0]; for (int n0 = 0; n0 <= n0_max; n0++){ long tmp = searchOne(n0); if (tmp > interm_maxV) interm_maxV = tmp; } return interm_maxV; } private long searchOne(int n0) { int[] n1 = findIndex(n0, N, tripartition + v_list[n0]); int[] n2 = findIndex(n1[0], N, 2 * tripartition + v_list[n0]); return (from nn1 in n1 from nn2 in n2 select getMinV(n0, nn1, nn2)).Max(); } private long getMinV(int n0, int n1, int n2) { if (n1 == -1 || n2 == -1) return long.MaxValue; else { long[] V0_V1_V2 = new long[] { v_list[n1] - v_list[n0], v_list[n2] - v_list[n1], v_list[n0] - v_list[n2] + v_list[N] }; return V0_V1_V2.Min(); } } private int[] findIndex(int from_n, int to_n, double target) { int n_left = from_n; int n_right = to_n; while (n_right - n_left >1) { int n_mid = (n_right + n_left) / 2; if (v_list[n_mid] <= target) n_left = n_mid; else n_right = n_mid; } return new int[] { n_left, n_right }; } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:3:7: error: expected nested-name-specifier before 'System' 3 | using System.Linq; | ^~~~~~ a.cc:7:34: error: 'string' has not been declared 7 | static void Main(string[] args) { | ^~~~~~ a.cc:7:43: error: expected ',' or '...' before 'args' 7 | static void Main(string[] args) { | ^~~~ a.cc:35:17: error: 'readonly' does not name a type 35 | readonly long[] v_list; | ^~~~~~~~ a.cc:36:17: error: 'readonly' does not name a type 36 | readonly int N; | ^~~~~~~~ a.cc:37:17: error: 'readonly' does not name a type 37 | readonly double tripartition; | ^~~~~~~~ a.cc:38:23: error: expected ':' before 'Baumkuchen' 38 | public Baumkuchen(long[] _v_list) { | ^~~~~~~~~~~ | : a.cc:38:42: error: expected ',' or '...' before '_v_list' 38 | public Baumkuchen(long[] _v_list) { | ^~~~~~~ a.cc:43:23: error: expected ':' before 'long' 43 | public long GetAnwser() { | ^~~~~ | : a.cc:53:24: error: expected ':' before 'long' 53 | private long searchOne(int n0) { | ^~~~~ | : a.cc:59:24: error: expected ':' before 'long' 59 | private long getMinV(int n0, int n1, int n2) { | ^~~~~ | : a.cc:70:24: error: expected ':' before 'int' 70 | private int[] findIndex(int from_n, int to_n, double target) { | ^~~~ | : a.cc:70:28: error: expected unqualified-id before '[' token 70 | private int[] findIndex(int from_n, int to_n, double target) { | ^ a.cc:80:10: error: expected ';' after class definition 80 | } | ^ | ; a.cc: In static member function 'static void Baumkuchen::Baumkuchen::Main(int*)': a.cc:8:25: error: 'System' was not declared in this scope 8 | System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); | ^~~~~~ a.cc:12:33: error: expected primary-expression before 'int' 12 | int N = int.Parse(sr.ReadLine()); | ^~~ a.cc:13:29: error: structured binding declaration cannot have type 'long int' 13 | long[] v_list = new long[N + 1]; | ^~ a.cc:13:29: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:13:29: error: empty structured binding declaration a.cc:13:32: error: expected initializer before 'v_list' 13 | long[] v_list = new long[N + 1]; | ^~~~~~ a.cc:14:25: error: 'v_list' was not declared in this scope 14 | v_list[0] = 0; | ^~~~~~ a.cc:16:61: error: expected primary-expression before 'long' 16 | v_list[n] = v_list[n - 1] + long.Parse(sr.ReadLine()); | ^~~~ a.cc:18:25: error: 'sr' was not declared in this scope 18 | sr.Close(); | ^~ a.cc:27:25: error: 'sw' was not declared in this scope 27 | sw.Start(); | ^~ a.cc:29:25: error: 'Console' was not declared in this scope 29 | Console.WriteLine(baumkuchen.GetAnwser()); | ^~~~~~~ a.cc: In constructor 'Baumkuchen::Baumkuchen::Baumkuchen(long int*)': a.cc:39:25: error: 'N' was not declared in this scope 39 | N = _v_list.Length - 1; | ^ a.cc:39:29: error: '_v_list' was not declared in this scope 39 | N = _v_list.Length - 1; | ^~~~~~~ a.cc:40:25: error: 'v_list' was not declared in this scope 40 | v_list = _v_list; | ^~~~~~ a.cc:41:25: error: 'tripartition' was not declared in this scope 41 | tripartition = v_list[N] / 3.0; | ^~~~~~~~~~~~ a.cc: In member function 'long int Baumkuchen::Baumkuchen::GetAnwser()': a.cc:45:51: error: 'N' was not declared in this scope 45 | int n0_max = findIndex(0, N, tripartition)[0]; | ^ a.cc:45:54: error: 'tripartition' was not declared in this scope 45 | int n0_max = findIndex(0, N, tripartition)[0]; | ^~~~~~~~~~~~ a.cc:45:38: error: 'findIndex' was not declared in this scope 45 | int n0_max = findIndex(0, N, tripartition)[0]; | ^~~~~~~~~ a.cc: In member function 'long int Baumkuchen::Baumkuchen::searchOne(int)': a.cc:54:28: error: structured binding declaration cannot have type 'int' 54 | int[] n1 = findIndex(n0, N, tripartition + v_list[n0]); | ^~ a.cc:54:28: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:54:28: error: empty structured binding declaration a.cc:54:31: error: expected initializer before 'n1' 54 | int[] n1 = findIndex(n0, N, tripartition + v_list[n0]); | ^~ a.cc:55:28: error: structured binding declaration cannot have type 'int' 55 | int[] n2 = findIndex(n1[0], N, 2 * tripartition + v_list[n0]); | ^~ a.cc:55:28: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:55:28: error: empty structured binding declaration a.cc:55:31: error: expected initializer before 'n2' 55 | int[] n2 = findIndex(n1[0], N, 2 * tripartition + v_list[n0]); | ^~ a.cc:56:33: error: 'from' was not declared in this scope 56 | return (from nn1 in n1 from nn2 in n2 select getMinV(n0, nn1, nn2)).Max(); | ^~~~ a.cc:56:38: error: expected ')' before 'nn1' 56 | return (from nn1 in n1 from nn2 in n2 select getMinV(n0, nn1, nn2)).Max(); | ^~~ a.cc:56:32: note: to match this '(' 56 | return (from nn1 in n1 from nn2 in n2 select getMinV(n0, nn1, nn2)).Max(); | ^ a.cc: In member function 'long int Baumkuchen::Baumkuchen::getMinV(int, int, int)': a.cc:60:58: error: expected primary-expression before 'long' 60 | if (n1 == -1 || n2 == -1) return long.MaxValue; | ^~~~ a.cc:60:58: error: expected ';' before 'long' a.cc:60:62: error: expected unqualified-id before '.' token 60 | if (n1 == -1 || n2 == -1) return long.MaxValue; | ^ a.cc:61:25: error: 'else' without a previous 'if' 61 | else { | ^~~~ a.cc:62:37: error: structured binding declaration cannot have type 'long int' 62 | long[] V0_V1_V2 = new long[] { | ^~ a.cc:62:37: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:62:37: error: empty structured binding declaration a.cc:62:40: error: expected initializer before 'V0_V1_V2' 62 | long[] V0_V1_V2 = new long[] { | ^~~~~~~~ a.cc:66:40: error: 'V0_V1_V2' was not declared in this scope 66 | return V0_V1_V2.Min(); | ^~~~~~~~
s928595284
p00523
C++
#include <cstdio> #include <algorithm> using namespace std; int main(){ int N; scanf("%d", &N); long long int whole = 0; //バームクーヘンの大きさ int* A = new int[N]; for (int i = 0; i < N; i++){ scanf("%d", &A[i]); whole += (long long int)A[i]; } long long int one_third = whole / 3; int ini = 0; long long int piece1 = 0; while (piece1 + (long long int)A[ini] <= one_third){ piece1 += (long long int)A[ini]; ini++; } int piece2_i = ini; long long int piece2 = 0; while (1){ piece2 += (long long int)A[ini]; ini++; if (piece2 >= piece1) break; } int piece3_i = ini; long long int piece3 = whole - piece1 - piece2; long long int ans = min(piece1, piece3); for (int i = 1; i < N; i++){ if (piece1 == 0){ piece2 -= (long long int)A[piece2_i]; piece2_i++; } else piece1 -= (long long int)A[i-1]; while (piece1 + (long long int)A[piece2_i] <= one_third){ piece1 += (long long int)A[piece2_i]; piece2 -= (long long int)A[piece2_i]; piece2_i++; if (piece2_i == N) piece2_i -= N; //周期的境界条件 } while (piece2 < piece1){ piece2 += (long long int)A[piece3_i]; piece3_i++; if (piece3_i == N) piece3_i -= N; //周期的境界条件 } piece3 = whole - piece1 - piece2; ans = max(ans, min(piece1, piece3)); } cout << ans << endl; delete[] A; return 0; }
a.cc: In function 'int main()': a.cc:61:9: error: 'cout' was not declared in this scope 61 | cout << ans << endl; | ^~~~ a.cc:3:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include <algorithm> +++ |+#include <iostream> 3 | using namespace std; a.cc:61:24: error: 'endl' was not declared in this scope 61 | cout << ans << endl; | ^~~~ a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 2 | #include <algorithm> +++ |+#include <ostream> 3 | using namespace std;
s294398642
p00523
C++
#include<iostream> using namespace std; cin.tie(0); ios::sync_with_stdio(false); class baumkuchen{ public: baumkuchen(); ~baumkuchen(); int N; //切れ込みの数 long long* A; //一つ一つのバウムクーヘンの大きさ void set_value(); //値のセットをする関数 bool set; //値のセットを行ったかどうかを判別する変数 long long* memo; //バウムクーヘンの面積をメモ void memo_all_piece(); //バウムクーヘンの面積をメモ long long sum_baum; //全てのバウムクーヘンの大きさの和 double tripartition; //全てのバウムクーヘンの大きさの三分の一 long long extended_full_search(); //計算 long long set_board(); //最初の盤面の作成 int cut_b; //2つ目の切れ込み int cut_c; //3つ目の切れ込み long long check(); //例外パターンのときの計算 bool check_bool; //例外パターンがおきたかどうか }; baumkuchen::baumkuchen(){ set = false; check_bool = false; } baumkuchen::~baumkuchen(){ if (set)delete[] A; if (set)delete[] memo; } void baumkuchen::set_value(){ sum_baum = 0; cin >> N; A = new long long[3 * N]; memo = new long long[3 * N](); //バウムクーヘンの大きさの入力 for (int i = 0; i < N; i++){ cin >> A[i]; A[N + i] = A[i]; A[2 * N + i] = A[i]; } //バウムクーヘンの面積をメモ memo_all_piece(); set = true; //セットの判定 } void baumkuchen::memo_all_piece(){ for (int i = 1; i < 3 * N; i++){ memo[i] = memo[i - 1] + A[i - 1]; } sum_baum = memo[N]; //バウムクーヘンの和 tripartition = sum_baum / 3.0; //バウムクーヘンの和の三分の一 } long long baumkuchen::check(){ long long min_value; double half = 0.0 + sum_baum; half += memo[cut_b] / 2.0; cut_b = N; cut_c = cut_b; while (half > memo[cut_c])cut_c++; if (half - memo[cut_c - 1] < memo[cut_c] - half)cut_c--; if (memo[cut_b] - memo[cut_b - 1] > memo[cut_c] - memo[cut_b]) min_value = memo[cut_c] - memo[cut_b]; if (memo[cut_c] - memo[cut_b] > (sum_baum + memo[cut_b - 1]) - memo[cut_c]) min_value = (sum_baum + memo[cut_b - 1]) - memo[cut_c]; check_bool = true; return min_value; } long long baumkuchen::set_board(){ long long min_value; cut_b = 0; while (tripartition > memo[cut_b])cut_b++; if (tripartition - memo[cut_b - 1] < memo[cut_b] - tripartition)cut_b--; double half = 0.0 + memo[cut_b]; half += (sum_baum - memo[cut_b]) / 2.0; cut_c = cut_b; while (half > memo[cut_c])cut_c++; if (half - memo[cut_c - 1] < memo[cut_c] - half)cut_c--; min_value = memo[cut_b]; if (min_value > memo[cut_c] - memo[cut_b]) min_value = memo[cut_c] - memo[cut_b]; if (min_value > sum_baum - memo[cut_c]) min_value = sum_baum - memo[cut_c]; if (cut_b == N - 1) return check(); return min_value; } long long baumkuchen::extended_full_search(){ long long set_value = 0; long long min_value; set_value = set_board(); //一番最初の盤面の作成 if (check_bool)return set_value; //例外パターンのときはcheck()の値を返す //一つずつずらしていく for (int cut_a = 1; cut_a < N; cut_a++){ while (memo[cut_a] + tripartition > memo[cut_b])cut_b++; if (memo[cut_a] + tripartition - memo[cut_b - 1] < memo[cut_b] - (memo[cut_a]+ tripartition))cut_b--; double half = 0.0 + memo[cut_b]; half += (memo[N + cut_a] - memo[cut_b]) / 2.0; while (half > memo[cut_c])cut_c++; if (half - memo[cut_c - 1] < memo[cut_c] - half)cut_c--; //3つのバウムクーヘンの大きさ比較 min_value = memo[cut_b] - memo[cut_a]; if (min_value > memo[cut_c] - memo[cut_b]) min_value = memo[cut_c] - memo[cut_b]; if (min_value > memo[N + cut_a] - memo[cut_c]) min_value = memo[N + cut_a] - memo[cut_c]; if (set_value < min_value)set_value = min_value; //最大値の更新 if (cut_c == N || cut_c == 2 * N || cut_c == 3 * N)break; //切れ込みが重なったらループ終了 } return set_value; } int main(){ baumkuchen *solve = new baumkuchen(); solve->set_value(); cout << solve->extended_full_search() << endl; delete solve; return 0; }
a.cc:3:1: error: 'cin' does not name a type 3 | cin.tie(0); | ^~~ a.cc:4:1: error: specializing member 'std::basic_ios<char>::sync_with_stdio' requires 'template<>' syntax 4 | ios::sync_with_stdio(false); | ^~~
s252967772
p00523
C++
#include<iostream>#include<vector>#include<algorithm>#include<string>#define rep(i,n) for(int i=0;i<(int)(n);i++)using namespace std;int n;vector<long long > rui;bool check(int i,long long m){ vector<long long >::iterator hoge=rui.end(); hoge = lower_bound(rui.begin() + i, rui.begin() +n-1+ i, m+rui[i]-1); if (hoge == rui.end())return false; vector<long long >::iterator hage = rui.end(); hage = lower_bound(hoge, rui.begin() + n - 1 + i, m + *hoge); if (hage == rui.end())return false; if (*(rui.begin() + n - 1 + i) - (*hage) >= m)return true; return false;}int main(){ cin >> n; rep(i, n) { long long int x; cin >> x; (i == 0) ? rui.push_back(x) : rui.push_back(rui[i - 1] + x); } rep(i, n)(i == 0) ? rui.push_back(rui[0] + rui[n - 1]) : rui.push_back(rui[n - 1 + i] + rui[i] - rui[i - 1]); long long int ans = 0; rep(i, n) { long long l = 0; long long r = 500000000000000000; while (r != l) { long long int m = (l + r) / 2; if (check(i, m)) { l = m+1; } else { r = m; } } ans = max(ans, l); } cout << ans << endl;}
a.cc:1:19: warning: extra tokens at end of #include directive 1 | #include<iostream>#include<vector>#include<algorithm>#include<string>#define rep(i,n) for(int i=0;i<(int)(n);i++)using namespace std;int n;vector<long long > rui;bool check(int i,long long m){ vector<long long >::iterator hoge=rui.end(); hoge = lower_bound(rui.begin() + i, rui.begin() +n-1+ i, m+rui[i]-1); if (hoge == rui.end())return false; vector<long long >::iterator hage = rui.end(); hage = lower_bound(hoge, rui.begin() + n - 1 + i, m + *hoge); if (hage == rui.end())return false; if (*(rui.begin() + n - 1 + i) - (*hage) >= m)return true; return false;}int main(){ cin >> n; rep(i, n) { long long int x; cin >> x; (i == 0) ? rui.push_back(x) : rui.push_back(rui[i - 1] + x); } rep(i, n)(i == 0) ? rui.push_back(rui[0] + rui[n - 1]) : rui.push_back(rui[n - 1 + i] + rui[i] - rui[i - 1]); long long int ans = 0; rep(i, n) { long long l = 0; long long r = 500000000000000000; while (r != l) { long long int m = (l + r) / 2; if (check(i, m)) { l = m+1; } else { r = m; } } ans = max(ans, l); } cout << ans << endl;} | ^ /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s085089403
p00523
C++
#include "bits/stdc++.h" #define int long long using namespace std; #define rep(i, n) for(int i = 0; i < signed(n); i++) #define REP(i, s, n) for(int i = (s); i < signed(n); i++) #define rrep(i, n) for(int i = signed(n) - 1; i >= 0; i--) #define all(co) co.begin(), co.end() typedef pair<int, int> P; typedef long long LL; typedef pair<P, int> PI; typedef pair<int, P> IP; const int INF = 1 << 29; const LL LINF = 1ll << 62ll; struct edge{ int from, to, cost; }; int dr[] = { -1, 0, 1, 0 }; int dc[] = { 0, 1, 0, -1 }; template<typename T = int> vector<vector<T>> vvector(int h, int w, T def = T()){ return move(vector<vector<T>>(h, vector<T>(w, def))); } class range { private: struct I{ int x; int operator*(){ return x; }bool operator!=(I& lhs){ return x < lhs.x; }void operator++(){ ++x; } }; I i, n; public:range(int n) :i({ 0 }), n({ n }){}range(int i, int n) :i({ i }), n({ n }){}I& begin(){ return i; }I& end(){ return n; } }; const int MOD = 10000; signed main() { int n; while (cin >> n && n) { vector<int> cuts(n + n + 2); rep(i, n) cin >> cuts[i + 1]; int sum = accumulate(all(cuts), 0); rep(i, n + 1) cuts[i + n + 1] = cuts[i]; rep(i, n + n + 1) cuts[i + 1] += cuts[i]; int ideal = int(((double)sum / 3.0) + 0.5); int ans = 0; rep(i, n) { int idx = lower_bound(all(cuts), ideal + cuts[i]) - cuts.begin(); int len = cuts[idx] - cuts[i]; int rem = (sum - len) / 2; int remidx = lower_bound(all(cuts), rem + cuts[idx]) - cuts.begin(); int remlen = cuts[remidx] - cuts[idx]; ans = max(ans, sum - len - remlen); } cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:3:13: error: expected primary-expression before 'long' 3 | #define int long long | ^~~~ a.cc:40:29: note: in expansion of macro 'int' 40 | int ideal = int(((double)sum / 3.0) + 0.5); | ^~~
s957800339
p00523
C++
#include "bits/stdc++.h" #define int long long using namespace std; #define rep(i, n) for(int i = 0; i < signed(n); i++) #define REP(i, s, n) for(int i = (s); i < signed(n); i++) #define rrep(i, n) for(int i = signed(n) - 1; i >= 0; i--) #define all(co) co.begin(), co.end() typedef pair<int, int> P; typedef long long LL; typedef pair<P, int> PI; typedef pair<int, P> IP; const int INF = 1 << 29; const LL LINF = 1ll << 62ll; struct edge{ int from, to, cost; }; int dr[] = { -1, 0, 1, 0 }; int dc[] = { 0, 1, 0, -1 }; template<typename T = int> vector<vector<T>> vvector(int h, int w, T def = T()){ return move(vector<vector<T>>(h, vector<T>(w, def))); } class range { private: struct I{ int x; int operator*(){ return x; }bool operator!=(I& lhs){ return x < lhs.x; }void operator++(){ ++x; } }; I i, n; public:range(int n) :i({ 0 }), n({ n }){}range(int i, int n) :i({ i }), n({ n }){}I& begin(){ return i; }I& end(){ return n; } }; const int MOD = 10000; signed main() { int n; while (cin >> n && n) { //brute-fource vector<int> cuts(n + n + 2); rep(i, n) cin >> cuts[i + 1]; int sum = accumulate(all(cuts), 0); n++; rep(i, n) cuts[i + n] = cuts[i]; rep(i, n + n - 1) cuts[i + 1] += cuts[i]; int ans = 0; rep(i, n - 2) REP(j, i + 1, n - 1) { int size = cuts[j] - cuts[i]; int rem = (sum - size) / 2; //int sep = upper_bound(all(cuts), cuts[j] + rem) - cuts.begin() - 1; //int k = max(j + 1, min(sep, n - 1)); int sep = j + 1; REP(k, n) if (cuts[k] - cuts[j] >= rem) { sep = k; break; } int k = sep; int a = cuts[i + n] - cuts[k], b = cuts[j] - cuts[i], c = cuts[k] - cuts[j]; ans = max(ans, min({ a, b, c })); } cout << ans << endl; } return 0; }
a.cc:53:33: error: macro "REP" requires 3 arguments, but only 2 given 53 | REP(k, n) if (cuts[k] - cuts[j] >= rem) | ^ a.cc:7:9: note: macro "REP" defined here 7 | #define REP(i, s, n) for(int i = (s); i < signed(n); i++) | ^~~ a.cc: In function 'int main()': a.cc:53:25: error: 'REP' was not declared in this scope 53 | REP(k, n) if (cuts[k] - cuts[j] >= rem) | ^~~
s270890895
p00523
C++
#include "bits/stdc++.h" #define int long long using namespace std; #define rep(i, n) for(int i = 0; i < signed(n); i++) #define REP(i, s, n) for(int i = (s); i < signed(n); i++) #define rrep(i, n) for(int i = signed(n) - 1; i >= 0; i--) #define all(co) co.begin(), co.end() typedef pair<int, int> P; typedef long long LL; typedef pair<P, int> PI; typedef pair<int, P> IP; const int INF = 1 << 29; const LL LINF = 1ll << 62ll; struct edge{ int from, to, cost; }; int dr[] = { -1, 0, 1, 0 }; int dc[] = { 0, 1, 0, -1 }; template<typename T = int> vector<vector<T>> vvector(int h, int w, T def = T()){ return move(vector<vector<T>>(h, vector<T>(w, def))); } class range { private: struct I{ int x; int operator*(){ return x; }bool operator!=(I& lhs){ return x < lhs.x; }void operator++(){ ++x; } }; I i, n; public:range(int n) :i({ 0 }), n({ n }){}range(int i, int n) :i({ i }), n({ n }){}I& begin(){ return i; }I& end(){ return n; } }; const int MOD = 10000; signed main() { int n; while (cin >> n && n) { //brute-fource vector<int> cuts(n + n + 2); rep(i, n) cin >> cuts[i + 1]; int sum = accumulate(all(cuts), 0); n++; rep(i, n) cuts[i + n] = cuts[i]; rep(i, n + n - 1) cuts[i + 1] += cuts[i]; int ans = 0; rep(i, n - 2) REP(j, i + 1, n - 1) { int size = cuts[j] - cuts[i]; int rem = (sum - size) / 2; //int sep = upper_bound(all(cuts), cuts[j] + rem) - cuts.begin() - 1; //int k = max(j + 1, min(sep, n - 1)); int sep = j + 1; REP(k, n) if (cuts[k] - cuts[j] >= rem) { sep = k; break; } int k = sep; int a = cuts[i + n] - cuts[k], b = cuts[j] - cuts[i], c = cuts[k] - cuts[j]; ans = max(ans, min({ a, b, c })); } cout << ans << endl; } return 0; }
a.cc:53:33: error: macro "REP" requires 3 arguments, but only 2 given 53 | REP(k, n) if (cuts[k] - cuts[j] >= rem) | ^ a.cc:7:9: note: macro "REP" defined here 7 | #define REP(i, s, n) for(int i = (s); i < signed(n); i++) | ^~~ a.cc: In function 'int main()': a.cc:53:25: error: 'REP' was not declared in this scope 53 | REP(k, n) if (cuts[k] - cuts[j] >= rem) | ^~~
s834674911
p00523
C++
#include<cstdio> #include<math.h> #include<algorithm> const int INF=1001001001; #define rep(i,n) for(int i=0;i<n;i++) int N; int A[200004]; long long int B[100002]; int main(){ FILE *fp; fp=fopen("F:\\1JOI本選\\2014\\joi2014-ho-data\\joi2014-ho-data\\2014-ho-t3\\in\\03-06.txt","r"); fscanf(fp,"%d",&N); long long int MAX = 0; rep(i,N){ fscanf(fp,"%d",&A[i]); MAX+=A[i]; B[i]=MAX; } memcpy(&A[N],A,sizeof(int)*N); long long int M=MAX/3;//全てのピースがM以上になる切り方は存在するか? long long int m=0; do{ bool cann=false;//全てのピースがn以上になる切り方は存在するか? long long int n=(M+m)/2; rep(i,N-2){//どこで最初に切るか int a=i;//よりあとで切る int b=N-2;//以前で切る do{//次に切る場所を探す int c=(a+b)/2; long long int piece1=B[c]-B[i]; if(piece1>=n){b=c;}//c以前で切れる else a=c;//cよりあとで切るべき }while(b>a+1); long long int p1=B[b]-B[i]; if(p1<n)continue;//1個目がもうだめ int x=b; int y=N-1; do{//最後に切る場所を探す int z=(x+y)/2; long long int piece2=B[z]-B[b]; if(piece2>=n){y=z;} else x=z; }while(y>x+1); long long int p2=B[y]-B[b]; if(p2<n)continue;//2個目がもうだめ if(MAX-p1-p2>=n){cann=true;} } if(cann){m=n;}//すべて(3つ)のピースがn以上になりえる else{M=n;} }while(M>m+1); printf("%lld\n",m); return 1; }
a.cc: In function 'int main()': a.cc:22:9: error: 'memcpy' was not declared in this scope 22 | memcpy(&A[N],A,sizeof(int)*N); | ^~~~~~ a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<algorithm> +++ |+#include <cstring> 4 |
s078046553
p00523
C++
#include <cstdio> using namespace std; #define MAX_N 100000 #define MAX_A 1000000000 #define INF 100000000000000 typedef __int64 Int; int N; Int A[MAX_N * 2 + 1]; bool C(int p, Int x){ int lb, ub, mid; int ed = p + N; lb = p; ub = ed; while(ub - lb > 1){ mid = (lb + ub) / 2; if(A[mid] - A[p] >= x) ub = mid; else lb = mid; } if(A[ub] - A[p] < x) return false; p = ub; lb = ub; ub = ed; while(ub - lb > 1){ mid = (lb + ub) / 2; if(A[mid] - A[p] >= x) ub = mid; else lb = mid; } if(A[ub] - A[p] < x) return false; if(A[ed] - A[ub] < x) return false; return true; } Int Max(Int a, Int b){ return (a > b)? a : b; } int main(){ Int n, res, lb, ub, mid; scanf("%d", &N); for(int i = 0; i < N; i++){ scanf("%I64d", &n); A[i + 1] = A[i] + n; } for(int i = N + 1; i <= N * 2; i++){ A[i] = A[i - 1] + A[i - N] - A[i - N - 1]; } res = 0; for(int i = 1; i <= N; i++){ lb = 0; ub = INF; while(ub - lb > 1){ mid = (ub + lb) / 2; if(C(i - 1, mid)) lb = mid; else ub = mid; } res = Max(res, lb); } printf("%I64d\n", res); return 0; }
a.cc:7:9: error: '__int64' does not name a type; did you mean '__int64_t'? 7 | typedef __int64 Int; | ^~~~~~~ | __int64_t a.cc:9:1: error: 'Int' does not name a type; did you mean 'int'? 9 | Int A[MAX_N * 2 + 1]; | ^~~ | int a.cc:11:15: error: 'Int' has not been declared 11 | bool C(int p, Int x){ | ^~~ a.cc: In function 'bool C(int, int)': a.cc:18:20: error: 'A' was not declared in this scope 18 | if(A[mid] - A[p] >= x) ub = mid; | ^ a.cc:21:12: error: 'A' was not declared in this scope 21 | if(A[ub] - A[p] < x) return false; | ^ a.cc:26:20: error: 'A' was not declared in this scope 26 | if(A[mid] - A[p] >= x) ub = mid; | ^ a.cc:29:12: error: 'A' was not declared in this scope 29 | if(A[ub] - A[p] < x) return false; | ^ a.cc:31:12: error: 'A' was not declared in this scope 31 | if(A[ed] - A[ub] < x) return false; | ^ a.cc: At global scope: a.cc:36:1: error: 'Int' does not name a type; did you mean 'int'? 36 | Int Max(Int a, Int b){ | ^~~ | int a.cc: In function 'int main()': a.cc:41:9: error: 'Int' was not declared in this scope; did you mean 'int'? 41 | Int n, res, lb, ub, mid; | ^~~ | int a.cc:44:33: error: 'n' was not declared in this scope 44 | scanf("%I64d", &n); | ^ a.cc:45:17: error: 'A' was not declared in this scope 45 | A[i + 1] = A[i] + n; | ^ a.cc:48:17: error: 'A' was not declared in this scope 48 | A[i] = A[i - 1] + A[i - N] - A[i - N - 1]; | ^ a.cc:51:9: error: 'res' was not declared in this scope 51 | res = 0; | ^~~ a.cc:53:17: error: 'lb' was not declared in this scope 53 | lb = 0; ub = INF; | ^~ a.cc:53:25: error: 'ub' was not declared in this scope 53 | lb = 0; ub = INF; | ^~ a.cc:55:25: error: 'mid' was not declared in this scope 55 | mid = (ub + lb) / 2; | ^~~ a.cc:60:23: error: 'Max' was not declared in this scope 60 | res = Max(res, lb); | ^~~
s702336092
p00523
C++
#include<iostream> #include <algorithm> using namespace std; int b; int c; int d; int e; int f; int main(){ int n; cin>>n; int a[2n]; int z[n] for(int i;i<n;i++){ cin>>a[i]; c=c+a{i} a[n+i]=a[i];} for(int j;j<n;j++){ d=j-1; while(b<c/3){ d++; b=b+a[d]; } b=b-a[d] while(e<=c/3){ d++; e=e+a[d];} f=c-b-e; if(f>b){ z[j]=b; }else{ z[j]=f;} } sort(z,z+n); cout<<z[n]<<endl; }
a.cc: In function 'int main()': a.cc:13:9: error: unable to find numeric literal operator 'operator""n' 13 | int a[2n]; | ^~ a.cc:15:3: error: expected initializer before 'for' 15 | for(int i;i<n;i++){ | ^~~ a.cc:15:13: error: 'i' was not declared in this scope 15 | for(int i;i<n;i++){ | ^ a.cc:23:11: error: 'a' was not declared in this scope 23 | b=b+a[d]; | ^ a.cc:25:9: error: 'a' was not declared in this scope 25 | b=b-a[d] | ^ a.cc:31:7: error: 'z' was not declared in this scope 31 | z[j]=b; | ^ a.cc:33:7: error: 'z' was not declared in this scope 33 | z[j]=f;} | ^ a.cc:35:8: error: 'z' was not declared in this scope 35 | sort(z,z+n); | ^
s078686116
p00523
C++
#include<iostream> #include <algorithm> using namespace std; int n; int b; int c; int d; int e; int f; int main(){ cin>>n; int a[2n]; int z[n] for(int i;i<n;i++){ cin>>a[i]; c=c+a{i} a[n+i]=a[i];} for(int j;j<n;j++){ d=j-1; while(b<c/3){ d++; b=b+a[d]; } b=b-a[d] while(e<=c/3){ d++; e=e+a[d];} f=c-b-e; if(f>b){ z[j]=b; }else{ z[j]=f;} } sort(z,z+n); cout<<z[n]<<endl; }
a.cc: In function 'int main()': a.cc:12:9: error: unable to find numeric literal operator 'operator""n' 12 | int a[2n]; | ^~ a.cc:14:3: error: expected initializer before 'for' 14 | for(int i;i<n;i++){ | ^~~ a.cc:14:13: error: 'i' was not declared in this scope 14 | for(int i;i<n;i++){ | ^ a.cc:22:11: error: 'a' was not declared in this scope 22 | b=b+a[d]; | ^ a.cc:24:9: error: 'a' was not declared in this scope 24 | b=b-a[d] | ^ a.cc:30:7: error: 'z' was not declared in this scope 30 | z[j]=b; | ^ a.cc:32:7: error: 'z' was not declared in this scope 32 | z[j]=f;} | ^ a.cc:34:8: error: 'z' was not declared in this scope 34 | sort(z,z+n); | ^
s015826576
p00523
C++
#include<iostream> #include <algorithm> using namespace std; int n; int b; int c; int d; int e; int f; int main(){ cin>>n; int a[200000]; int z[200000]; for(int i;i<n;i++){ cin>>a[i]; c=c+a[i]; a[n+i]=a[i];} for(int j;j<n;j++){ d=j-1; while(b<=c/3){ d++; b=b+a[d]; } b=b-a[d]; while(e<c/3){ d++; e=e+a[d];} f=c-b-e; if(f>b){ z[j]=b; }else{ z[j]=f;} } b=0; c=0; j=0; e=0; f=0; d=0; for(int j;j<n;j++){ d=j-1; while(b<c/3){ d++; b=b+a[d]; }; while(e<=c/3){ d++; e=e+a[d];} e=e-a[d]; f=c-b-e; if(f>b){ z[j]=b; }else{ z[j]=f;} } sort(z,z+2n); cout<<z[2n-1]<<endl; }
a.cc: In function 'int main()': a.cc:36:5: error: 'j' was not declared in this scope 36 | j=0; | ^ a.cc:56:12: error: unable to find numeric literal operator 'operator""n' 56 | sort(z,z+2n); | ^~ a.cc:57:11: error: unable to find numeric literal operator 'operator""n' 57 | cout<<z[2n-1]<<endl; | ^~
s497707080
p00523
C++
#include<iostream> #include <algorithm> using namespace std; int n; int b; int c; int d; int e; int f; int main(){ cin>>n; int a[200000]; int z[200000]; for(int i;i<n;i++){ cin>>a[i]; c=c+a[i]; a[n+i]=a[i];} for(int j;j<n;j++){ d=j-1; while(b<=c/3){ d++; b=b+a[d]; } b=b-a[d]; d=d-1; while(e<c/3){ d++; e=e+a[d];} f=c-b-e; if(f>b){ z[j]=b; }else{ z[j]=f;} } b=0; c=0; e=0; f=0; d=0; for(int m;m<n;m++){ d=j-1; while(b<c/3){ d++; b=b+a[d]; }; while(e<=c/3){ d++; e=e+a[d];} e=e-a[d]; f=c-b-e; if(f>b){ z[m]=b; }else{ z[m]=f;} } sort(z,z+2n); cout<<z[2n-1]<<endl; }
a.cc: In function 'int main()': a.cc:41:7: error: 'j' was not declared in this scope 41 | d=j-1; | ^ a.cc:56:12: error: unable to find numeric literal operator 'operator""n' 56 | sort(z,z+2n); | ^~ a.cc:57:11: error: unable to find numeric literal operator 'operator""n' 57 | cout<<z[2n-1]<<endl; | ^~
s650928139
p00523
C++
#include<iostream> #include <algorithm> using namespace std; int n; int b; int c; int d; int e; int f; int ushi; int uma; int j; int main(){ cin>>n; int a[300000]; int z[300000]; for(int i;i<n;i++){ cin>>a[i]; c=c+a[i]; a[n+i]=a[i];} for(int j;j<n;j++){ d=j-1; while(b<=c/3){ d++; b=b+a[d]; } b=b-a[d]; d=d-1; while(e<c/3){ d++; e=e+a[d];} f=c-b-e; if(f>b){ z[j]=b; }else{ z[j]=f;} } b=0; c=0; e=0; f=0; d=0; for(int m;m<n;m++){ d=j-1; while(b<c/3){ d++; b=b+a[d]; }; while(e<=c/3){ d++; e=e+a[d];} e=e-a[d]; f=c-b-e; if(f>b){ z[m]=b; }else{ z[m]=f;} } ushi=2*n-1; uma=z+2*n; sort(z,uma); cout<<z[ushi]<<endl; }
a.cc: In function 'int main()': a.cc:61:8: error: invalid conversion from 'int*' to 'int' [-fpermissive] 61 | uma=z+2*n; | ~^~~~ | | | int* a.cc:62:7: error: no matching function for call to 'sort(int [300000], int&)' 62 | sort(z,uma); | ~~~~^~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)' 4762 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last) | ^~~~ /usr/include/c++/14/bits/stl_algo.h:4762:5: note: template argument deduction/substitution failed: a.cc:62:7: note: deduced conflicting types for parameter '_RAIter' ('int*' and 'int') 62 | sort(z,uma); | ~~~~^~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)' 4793 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)' 292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate expects 4 arguments, 2 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)' 296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate expects 3 arguments, 2 provided
s211327825
p00523
C++
#include<iostream> #include<stdio.h> #include<math.h> #include <iomanip> using namespace std; int main(){ double a,b,c,d,e; int num; cin>>num; long int A[100001]; for (int i=0; i<num; i++) { cin>>A[i]; } int mi=0; for (int i=0; i<num-2; i++) { for (int j=i+1; j<num-1; j++) { for (int k=j+1; k<num; k++) { long int aa=0,bb=0,cc=0; for (int i2=i; i2< j; i2++) { aa+=A[i2]; } for (int i3=j; i3< k; i3++) { bb+=A[i3]; } for (int i4=k; i4< num; i4++) { cc+=A[i4]; } for (int i4=0; i4< i; i4++) { cc+=A[i4]; } mi=max(mi,min(aa,min(bb,cc))); } } } cout<<mi<<endl; return 0; }
a.cc: In function 'int main()': a.cc:36:23: error: no matching function for call to 'max(int&, const long int&)' 36 | mi=max(mi,min(aa,min(bb,cc))); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/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:36:23: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long int') 36 | mi=max(mi,min(aa,min(bb,cc))); | ~~~^~~~~~~~~~~~~~~~~~~~~~~ /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
s166416814
p00523
C++
??£??£??£???
a.cc:1:3: error: extended character £ is not valid in an identifier 1 | ??£??£??£??? | ^ a.cc:1:6: error: extended character £ is not valid in an identifier 1 | ??£??£??£??? | ^ a.cc:1:9: error: extended character £ is not valid in an identifier 1 | ??£??£??£??? | ^ a.cc:1:1: error: expected unqualified-id before '?' token 1 | ??£??£??£??? | ^
s635163939
p00523
C++
#include<bits/stdc++.h> using namespace std; template <typename T> T binary_search(function<bool(T)> func, T include, T exclude) { while (abs(exclude - include) > 1) { auto middle = (include + exclude) / 2; (func(middle) ? include : exclude) = middle; } return include; }
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s048473626
p00523
C++
#include <vector> using namespace std; int main(){ long long num_cut = 0; long long sum = 0L; long long oneThird = 0L; int cuts[100000]; long long min_piece=0L; int a=0; long long restCake=0L; cin >> num_cut; for(int i = 0; i < num_cut; i++){ cin >> a; sum += a; cuts[i] = a; } oneThird = (sum + 2) / 3; long long firstSize = 0L; long long secondSize = 0L; long long thirdSize = 0L; long long thirdSize_in1 = 0L; bool fi_se = false; // 1st >= 2nd bool se_th = false; // 2nd >= 3rd bool fi_th = false; // 1st >= 3rd // start for(int start=0; restCake < oneThird; start++){ firstSize = 0L; // 1st for(int first=start+1; firstSize < oneThird; first++){ firstSize += cuts[first]; secondSize = 0L; thirdSize_in1 = sum-firstSize; // 2nd for(int second=first+1; secondSize < oneThird; second++){ secondSize += cuts[second]; // 3rd thirdSize = thirdSize_in1 - secondSize; fi_se = (firstSize >= secondSize); se_th = (secondSize >= thirdSize); fi_th = (firstSize >= thirdSize); if(!fi_se && !fi_th){ if(firstSize > min_piece) min_piece = firstSize; }else if(fi_se && !se_th){ if(secondSize > min_piece) min_piece =secondSize; }else{ if(thirdSize > min_piece) min_piece =thirdSize; } } } restCake += cuts[start]; } cout << min_piece << endl; return 0; }
a.cc: In function 'int main()': a.cc:15:9: error: 'cin' was not declared in this scope 15 | cin >> num_cut; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include <vector> +++ |+#include <iostream> 2 | using namespace std; a.cc:59:9: error: 'cout' was not declared in this scope 59 | cout << min_piece << endl; | ^~~~ a.cc:59:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:59:30: error: 'endl' was not declared in this scope 59 | cout << min_piece << endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include <vector> +++ |+#include <ostream> 2 | using namespace std;
s390560518
p00523
C++
s
a.cc:1:1: error: 's' does not name a type 1 | s | ^
s803260149
p00523
C++
#include <bits/stdc++.h> using namespace std; #define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++) #define REP(i,n) FOR(i,0,n) #define ALL(a) a.begin(), a.end() #define MS(m,v) memset(m,v,sizeof(m)) typedef long long ll; typedef long double ld; typedef vector<ll> vi; typedef vector<string> vs; typedef pair<int, int> pii; const int MOD = 1000000007; const ll INF = LLONG_MAX / 3; const ld EPS = 1e-12; template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); } template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); } /*--------------------template--------------------*/ int main() { cin.sync_with_stdio(false); cout << fixed << setprecision(10); ll n; cin >> n; vi a(n); REP(i, n) cin >> a[i]; ll lb = 0, ub = INF; while (ub - lb > 1) { ll mid = (ub + lb) / 2; bool ok = false; int div0, div1, div2; div0 = 0; int p = 0; ll tmpa = 0; while (tmpa < mid) { tmpa += a[p]; p++; if (p == n) goto end; } div1 = p; ll tmpb = 0; while (tmpb < mid) { tmpb += a[p]; p++; if (p == n) goto end; } div2 = p; ll tmpc = 0; FOR(i, p, n) tmpc += a[i]; while (1) { if (tmpa >= mid && tmpb >= mid && tmpc >= mid) { ok = true; break; } if (div2 == n) break; tmpa -= a[div0]; tmpc += a[div0]; div0++; while (tmpa < mid) { tmpa += a[div1]; tmpb -= a[div1]; div1++; if (div1 == div2) goto end; } while (tmpb < mid) { if (div2 == n) break; tmpb += a[div2]; tmpc -= a[div2]; div2++; if (div2 == div0) goto end; } } end:; if (ok) lb = mid; else ub = mid; } cout << lb << endl; return 0; }
a.cc: In function 'int main()': a.cc:78:9: error: jump to label 'end' 78 | end:; | ^~~ a.cc:46:42: note: from here 46 | if (p == n) goto end; | ^~~ a.cc:49:20: note: crosses initialization of 'll tmpc' 49 | ll tmpc = 0; | ^~~~ a.cc:78:9: error: jump to label 'end' 78 | end:; | ^~~ a.cc:38:42: note: from here 38 | if (p == n) goto end; | ^~~ a.cc:49:20: note: crosses initialization of 'll tmpc' 49 | ll tmpc = 0; | ^~~~ a.cc:41:20: note: crosses initialization of 'll tmpb' 41 | ll tmpb = 0; | ^~~~
s248084952
p00523
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<vector> #include<queue> #include<set> #include<functional> #include<map> #define int long long using namespace std; int a[200000]; signed main() { int b; cin >> b; int c = 0; for (int d = 0; d < b ; d++) { int e; scanf("%lld", &e); c += e; a[d + 1] = c; } for (int d = 1; d < b; d++) { a[b + d] = a[d] + c; } int MIN = LLONG_MAX / 3; int k = 0; for (int d = 0; d < b; d++) { int e = d + 1, f = d + b - 1; while (f - e >= 1) { int g = (e + f) / 2; auto h = lower_bound(a + d, a + d + b, a[d]+2*(a[g] - a[d])); if (h == a + d + b || a[d + b] - *h < a[g] - a[d]) { f = g; } else { e = g + 1; k = max(k, a[g] - a[d]); } } } cout << k << endl; }
a.cc: In function 'int main()': a.cc:26:19: error: 'LLONG_MAX' was not declared in this scope 26 | int MIN = LLONG_MAX / 3; | ^~~~~~~~~ a.cc:10:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 9 | #include<map> +++ |+#include <climits> 10 | #define int long long
s007502394
p00523
C++
#include<iostream> #include<algorithm> using namespace std; int n; long long sum[110000]; bool Func(long long key){ for(int i=1;i<n;i++){ int f=lower_bound(sum+i,sum+n+1,key+sum[i-1]); int g=lower_bound(f,sum+n+1,key+*f); if(*g&&*g+key-sum[i-1]<=sum[n]){ return true; } } return false; } int main(){ cin>>n; sum[0]=0; for(int i=0;i<n;i++){ cin>>sum[i+1]; sum[i+1]+=sum[i]; } long long left=0,right=sum[n]/3+1,mid; long long ans=0; while(left<right){ mid=(left+right)/2; if(Func(mid)){ left=mid+1; ans=max(ans,mid); } else right=mid; } cout<<ans<<endl; return 0; }
a.cc: In function 'bool Func(long long int)': a.cc:12:34: error: invalid conversion from 'long long int*' to 'int' [-fpermissive] 12 | int f=lower_bound(sum+i,sum+n+1,key+sum[i-1]); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long long int* a.cc:13:49: error: invalid type argument of unary '*' (have 'int') 13 | int g=lower_bound(f,sum+n+1,key+*f); | ^~ a.cc:15:20: error: invalid type argument of unary '*' (have 'int') 15 | if(*g&&*g+key-sum[i-1]<=sum[n]){ | ^~ a.cc:15:24: error: invalid type argument of unary '*' (have 'int') 15 | if(*g&&*g+key-sum[i-1]<=sum[n]){ | ^~
s172702610
p00523
C++
#include<bits/stdc++.h> #define N 100005 using namespace std; typedef long long ll; ll n,sum,a[N],A[2*N]; ll bynary_search(){ } void solve(){ ll ans=0; for(int cut1=0;cut1<n;cut1++){ ll cut2=; } } int main(){ cin>>n; for(int i=0;i<n;i++)cin>>a[i]; A[0]=a[0]; for(int i=1;i<2*n;i++)A[i]=a[i%n]+A[i-1]; solve(); return 0; }
a.cc: In function 'll bynary_search()': a.cc:9:1: warning: no return statement in function returning non-void [-Wreturn-type] 9 | } | ^ a.cc: In function 'void solve()': a.cc:15:13: error: expected primary-expression before ';' token 15 | ll cut2=; | ^
s001424779
p00523
C++
#include <iostream> #include <cstdio> using namespace std; long InArray[100000] = {0}; int N = 0; long sumArray(int, int); long getLocalMin(int, int, int); int main() { // initialize input if(1){ FILE *inputFile = fopen("0600_in33.txt", "r"); fscanf(inputFile, "%d", &N); for(int i = 0; i < N; i++){ fscanf(inputFile, "%d", &InArray[i]); } fclose( inputFile); } else { cin >> N; for(int i = 0; i < N; i++){cin >> InArray[i];} } // Calculate sum and average long sum = sumArray(0, N); long average = sum / 3; cout << "sum:\t" << sum << endl; cout << "average:" << average << endl; long MaxMin = 0; long tempMin; long a3_sum, a1_sum, a2_sum; a3_sum = InArray[0]; for(int a1 = 0; a3 < N-1; a1++){ a1_sum = InArray[a1]; for(int a2 = a1+1;;a2++){ //if(sumArray(a1, a2+1) < average) continue; a1_sum += InArray[a2]; if(a1_sum < average) continue; a2_sum = InArray[a2]; for(int a3 = a2+1; a3 < N; a3++){ //if(sumArray(a2, a3+1) < average) continue; a2_sum += InArray[a3]; if(a2_sum < average) continue; tempMin = getLocalMin(a1, a2, a3); if(MaxMin < tempMin) MaxMin = tempMin; tempMin = getLocalMin(a1, a2, a3+1); if(MaxMin < tempMin) MaxMin = tempMin; break; } a2 = a2+1; a2_sum = InArray[a2]; for(int a3 = a2+1; a3 < N; a3++){ //if(sumArray(a2, a3+1) < average) continue; a2_sum += InArray[a3]; if(a2_sum < average) continue; tempMin = getLocalMin(a1, a2, a3); if(MaxMin < tempMin) MaxMin = tempMin; tempMin = getLocalMin(a1, a2, a3+1); if(MaxMin < tempMin) MaxMin = tempMin; break; } break; } //if(sumArray(0, a1+1) > average) break; a3_sum += InArray[a1]; if(a3_sum > average) break; } cout << MaxMin << endl; return 0; } long sumArray(int start, int end) { long sum = 0; for(int i = start; i < end; i++){ sum += InArray[i]; } return sum; } long getLocalMin(int p1, int p2, int p3) { long LocalMin = sumArray(p1, p2); long tempSum = sumArray(p2, p3); if(LocalMin > tempSum){ LocalMin = tempSum; } tempSum = sumArray(0, p1) + sumArray(p3, N); if(LocalMin > tempSum){ LocalMin = tempSum; } //cout << "getLocalMin(a1, a2, a3)\t" << LocalMin << "\t" << p1 << "\t" << p2 << "\t" << p3 << endl; return LocalMin; }
a.cc: In function 'int main()': a.cc:39:25: error: 'a3' was not declared in this scope; did you mean 'a1'? 39 | for(int a1 = 0; a3 < N-1; a1++){ | ^~ | a1
s907615874
p00523
C++
#include <iostream> #include <cstdio> using namespace std; long InArray[100000] = {0}; int N = 0; long sumArray(int, int); long getLocalMin(int, int, int); int main() { // initialize input if(0){ FILE *inputFile = fopen("0600_in33.txt", "r"); fscanf(inputFile, "%d", &N); for(int i = 0; i < N; i++){ fscanf(inputFile, "%d", &InArray[i]); } fclose( inputFile); } else { cin >> N; for(int i = 0; i < N; i++){cin >> InArray[i];} } // Calculate sum and average long sum = sumArray(0, N); long average = sum / 3; cout << "sum:\t" << sum << endl; cout << "average:" << average << endl; long MaxMin = 0; long tempMin; long a3_sum, a1_sum, a2_sum; a3_sum = InArray[0]; for(int a1 = 0; a3 < N-1; a1++){ a1_sum = InArray[a1]; for(int a2 = a1+1;;a2++){ //if(sumArray(a1, a2+1) < average) continue; a1_sum += InArray[a2]; if(a1_sum < average) continue; a2_sum = InArray[a2]; for(int a3 = a2+1; a3 < N; a3++){ //if(sumArray(a2, a3+1) < average) continue; a2_sum += InArray[a3]; if(a2_sum < average) continue; tempMin = getLocalMin(a1, a2, a3); if(MaxMin < tempMin) MaxMin = tempMin; tempMin = getLocalMin(a1, a2, a3+1); if(MaxMin < tempMin) MaxMin = tempMin; break; } a2 = a2+1; a2_sum = InArray[a2]; for(int a3 = a2+1; a3 < N; a3++){ //if(sumArray(a2, a3+1) < average) continue; a2_sum += InArray[a3]; if(a2_sum < average) continue; tempMin = getLocalMin(a1, a2, a3); if(MaxMin < tempMin) MaxMin = tempMin; tempMin = getLocalMin(a1, a2, a3+1); if(MaxMin < tempMin) MaxMin = tempMin; break; } break; } //if(sumArray(0, a1+1) > average) break; a3_sum += InArray[a1]; if(a3_sum > average) break; } cout << MaxMin << endl; return 0; } long sumArray(int start, int end) { long sum = 0; for(int i = start; i < end; i++){ sum += InArray[i]; } return sum; } long getLocalMin(int p1, int p2, int p3) { long LocalMin = sumArray(p1, p2); long tempSum = sumArray(p2, p3); if(LocalMin > tempSum){ LocalMin = tempSum; } tempSum = sumArray(0, p1) + sumArray(p3, N); if(LocalMin > tempSum){ LocalMin = tempSum; } //cout << "getLocalMin(a1, a2, a3)\t" << LocalMin << "\t" << p1 << "\t" << p2 << "\t" << p3 << endl; return LocalMin; }
a.cc: In function 'int main()': a.cc:39:25: error: 'a3' was not declared in this scope; did you mean 'a1'? 39 | for(int a1 = 0; a3 < N-1; a1++){ | ^~ | a1
s467952499
p00523
C++
/* 2017/09/17 data will be seperated to 3 groups, a b c the bigest(a) should >= sum / 3 then the second should >= (sum - a) / 3 loop to find the just data that comply with the previous conditions */ #include <iostream> #include <cstdio> using namespace std; int main() { // end link to head int InArray[200000] = {0}; int N = 0; // initialize input int temp; cin >> N; for(int i = 0; i < N; i++){ cin >> temp; InArray[i] = temp; InArray[i + N] = temp; // Calculate sum and average long long sum = 0; for(int i = start; i < end; i++){ sum += InArray[i]; } long long average; if(sum % 3 == 0){ average = sum / 3; }else{ average = sum / 3 + 1; } long long MaxMin = 0; long long tempMin; long long a1_sum, a2_sum; long long average2; for(int a1 = 0; a1 < N; a1++){ a1_sum = 0; for(int a2 = a1 + 1; a2 < (a1 + N); a2++){ a1_sum += InArray[a2 - 1]; if(a1_sum < average) continue; if((sum - a1_sum) % 2 == 0){ average2 = (sum - a1_sum) / 2; }else{ average2 = (sum - a1_sum + 1) / 2; } a2_sum = 0; for(int a3 = a2 + 1; a3 < (a1 + N); a3++){ // left 1 for a3_sum a2_sum += InArray[a3 -1]; if(a2_sum < average2) continue; if(a2_sum - InArray[a3 -1] > MaxMin){ MaxMin = a2_sum - InArray[a3 -1]; } if(sum - a1_sum - a2_sum > MaxMin){ MaxMin = sum - a1_sum - a2_sum; } break; } break; } } cout << MaxMin << endl; return 0; }
a.cc: In function 'int main()': a.cc:27:21: error: 'start' was not declared in this scope 27 | for(int i = start; i < end; i++){ | ^~~~~ a.cc:27:30: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<' 27 | for(int i = start; i < end; i++){ | ~~^~~~~ a.cc:74:2: error: expected '}' at end of input 74 | } | ^ a.cc:12:1: note: to match this '{' 12 | { | ^
s329283722
p00523
C++
/* 2017/09/17 data will be seperated to 3 groups, a b c the bigest(a) should >= sum / 3 then the second should >= (sum - a) / 3 loop to find the just data that comply with the previous conditions */ #include <iostream> #include <cstdio> using namespace std; int main() { // end link to head int InArray[200000] = {0}; int N = 0; // initialize input int temp; cin >> N; for(int i = 0; i < N; i++){ cin >> temp; InArray[i] = temp; InArray[i + N] = temp; // Calculate sum and average long long sum = 0; for(int i = 0; i < N; i++){ sum += InArray[i]; } long long average; if(sum % 3 == 0){ average = sum / 3; }else{ average = sum / 3 + 1; } long long MaxMin = 0; long long tempMin; long long a1_sum, a2_sum; long long average2; for(int a1 = 0; a1 < N; a1++){ a1_sum = 0; for(int a2 = a1 + 1; a2 < (a1 + N); a2++){ a1_sum += InArray[a2 - 1]; if(a1_sum < average) continue; if((sum - a1_sum) % 2 == 0){ average2 = (sum - a1_sum) / 2; }else{ average2 = (sum - a1_sum + 1) / 2; } a2_sum = 0; for(int a3 = a2 + 1; a3 < (a1 + N); a3++){ // left 1 for a3_sum a2_sum += InArray[a3 -1]; if(a2_sum < average2) continue; if(a2_sum - InArray[a3 -1] > MaxMin){ MaxMin = a2_sum - InArray[a3 -1]; } if(sum - a1_sum - a2_sum > MaxMin){ MaxMin = sum - a1_sum - a2_sum; } break; } break; } } cout << MaxMin << endl; return 0; }
a.cc: In function 'int main()': a.cc:74:2: error: expected '}' at end of input 74 | } | ^ a.cc:12:1: note: to match this '{' 12 | { | ^
s638195417
p00523
C++
#include <stdio.h> int main() { int InArray[200000] = {0}; // end is linked to start (Baumkuchen is round) int N; // total data input int i; // for counter int inputBuffer; // buffer for input data int a1, a2, a3; // the start index of each region long long sum; // buffer for sum long long average, average2; // sum / 3, (sum - region1) / 2 long long a1_sum, a2_sum; // sum of region1, region2 long long MaxMin; // final result scanf("%d", &N); for(i = 0; i < N; i++){ scanf("%d", &inputBuffer); InArray[i] = inputBuffer; InArray[i + N] = inputBuffer; // Calculate sum and average sum = 0; for(i = 0; i < N; i++){ sum += InArray[i]; } if(sum % 3 == 0){ average = sum / 3; }else{ average = sum / 3 + 1; } MaxMin = 0; for(a1 = 0; a1 < N; a1++){ a1_sum = 0; for(a2 = a1 + 1; a2 < (a1 + N); a2++){ a1_sum += InArray[a2 - 1]; if(a1_sum < average) continue; if((sum - a1_sum) % 2 == 0){ average2 = (sum - a1_sum) / 2; }else{ average2 = (sum - a1_sum + 1) / 2; } a2_sum = 0; for(a3 = a2 + 1; a3 < (a1 + N); a3++){ // left 1 for a3_sum a2_sum += InArray[a3 -1]; if(a2_sum < average2) continue; if(a2_sum - InArray[a3 -1] > MaxMin){ MaxMin = a2_sum - InArray[a3 -1]; } if(sum - a1_sum - a2_sum > MaxMin){ MaxMin = sum - a1_sum - a2_sum; } break; } break; } } printf("%lld", MaxMin); return 0; }
a.cc: In function 'int main()': a.cc:66:2: error: expected '}' at end of input 66 | } | ^ a.cc:4:1: note: to match this '{' 4 | { | ^
s501827279
p00523
C++
#include <cstdio> #include <iostream> int main() { int InArray[200000] = {0}; // end is linked to start (Baumkuchen is round) int N; // total data input int i; // for counter int inputBuffer; // buffer for input data int a1, a2, a3; // the start index of each region long long sum; // buffer for sum long long average, average2; // sum / 3, (sum - region1) / 2 long long a1_sum, a2_sum; // sum of region1, region2 long long MaxMin; // final result scanf("%d", &N); for(i = 0; i < N; i++){ cin >> inputBuffer; InArray[i] = inputBuffer; InArray[i + N] = inputBuffer; } // Calculate sum and average sum = 0; for(i = 0; i < N; i++){ sum += InArray[i]; } if(sum % 3 == 0){ average = sum / 3; }else{ average = sum / 3 + 1; } MaxMin = 0; for(a1 = 0; a1 < N; a1++){ a1_sum = 0; for(a2 = a1 + 1; a2 < (a1 + N); a2++){ a1_sum += InArray[a2 - 1]; if(a1_sum < average) continue; if((sum - a1_sum) % 2 == 0){ average2 = (sum - a1_sum) / 2; }else{ average2 = (sum - a1_sum + 1) / 2; } a2_sum = 0; for(a3 = a2 + 1; a3 < (a1 + N); a3++){ // left 1 for a3_sum a2_sum += InArray[a3 -1]; if(a2_sum < average2) continue; if(a2_sum - InArray[a3 -1] > MaxMin){ MaxMin = a2_sum - InArray[a3 -1]; } if(sum - a1_sum - a2_sum > MaxMin){ MaxMin = sum - a1_sum - a2_sum; } break; } break; } } printf("%lld", MaxMin); return 0; }
a.cc: In function 'int main()': a.cc:18:17: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 18 | cin >> inputBuffer; | ^~~ | std::cin In file included from a.cc:2: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~
s301828130
p00523
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; int N; bool func(long long mid, vector<long long>&line) { int lp = 0, hp = 1; while (true) { if (line[hp] - line[lp] >= mid) {/* int fp = hp + 1; int bp = lp + N; while (fp < bp) { int mp = (fp + bp) >> 1; if (line[mp] - line[hp+1] >= mid) { if (line[lp + N] - line[mp] >= mid) { return true; } bp = mp; } else { fp = mp + 1; } }*/ int it = lower_bound(line.begin() + hp + 1, line.begin() + lp + N, mid + line[hp])-line.begin(); if (line[lp + N] - line[it] >= mid) { return true; } ++lp; } else { ++hp; if (hp == N - 1) { break; } } } return false; } int main() { cin >> N; vector<long long> line(N+1); for (int i = 1; i <= N; ++i) { cin >> line[i]; line.push_back(line[i]); } line[0] = 0; for (int i = 1; i < line.size(); ++i) { line[i] = line[i] + line[i - 1]; } long long lp = 0, hp = INT64_MAX; while (lp < hp) { long long mid = (lp + hp) >> 1; if (func(mid, line)) { lp = mid+1; } else { hp = mid; } } cout << lp - 1 << endl; }
a.cc: In function 'int main()': a.cc:50:32: error: 'INT64_MAX' was not declared in this scope 50 | long long lp = 0, hp = INT64_MAX; | ^~~~~~~~~ a.cc:4:1: note: 'INT64_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 3 | #include<algorithm> +++ |+#include <cstdint> 4 | using namespace std;
s530330465
p00523
C++
import java.io.*; public class Main{ public static void main(String[] args){ InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = BufferedReader(is); String str = br.readLine(); int kosuu = Integer.perseInt(str); int[] A = new int[kosuu];//配列の宣言の仕方自信なし int m = 2000000000, M = 0; int kei = 0; int kei1 = 0, kei2 = 0, kei3 = 0;//3つの切り分けた領域の合計を表す for(int i = 0; i < kosuu; i++){ str = br.readLine() A[i] = Integer.perseInt(str)//引数に戻り値のあるメソッドを指定してよいかわからない } for(int i = 1; i < kosuu; i++){ for(int j = i + 1; j < kosuu + 1; j++){ for(int k = j + 1; k < kosuu + 2; k++){ for(int i2 = 0; i2 < i; i2++) kei1 = kei1 + A[i2]; if(m > kei1) m = kei1; for(int j2 = i; j2 < j; j2++) kei2 = kei2 + A[j2]; if(m > kei2) m = kei2; for(int k2 = j; k2 < k; k2++) kei3 = kei3 + A[k2]; if(m > kei3) m = kei3; if(m > M) M = m; } } } System.out.println(M); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main{ | ^~~~~~
s041844880
p00523
C++
import java.io.*; public class Main{ public static void main(String[] args){ InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = BufferedReader(is); String str = br.readLine(); int kosuu = Integer.perseInt(str); int[] A = new int[kosuu];//配列の宣言の仕方自信なし int m = 2000000000, M = 0; int kei = 0; int kei1 = 0, kei2 = 0, kei3 = 0;//3つの切り分けた領域の合計を表す for(int i = 0; i < kosuu; i++){ str = br.readLine(); A[i] = Integer.perseInt(str);//引数に戻り値のあるメソッドを指定してよいかわからない } for(int i = 1; i < kosuu; i++){ for(int j = i + 1; j < kosuu + 1; j++){ for(int k = j + 1; k < kosuu + 2; k++){ for(int i2 = 0; i2 < i; i2++) kei1 = kei1 + A[i2]; if(m > kei1) m = kei1; for(int j2 = i; j2 < j; j2++) kei2 = kei2 + A[j2]; if(m > kei2) m = kei2; for(int k2 = j; k2 < k; k2++) kei3 = kei3 + A[k2]; if(m > kei3) m = kei3; if(m > M) M = m; } } } System.out.println(M); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main{ | ^~~~~~
s240175574
p00523
C++
import java.io.*; public class Main{ public static void main(String[] args) throws IOException{ InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(is); String str = br.readLine(); int N = Integer.parseInt(str); int[] A = new int[N]; int m = 2000000000, M = 0; int kei = 0; int kei1 = 0, kei2 = 0, kei3 = 0;//3つの切り分けた領域の合計を表す int tmp; for(int i = 0; i < N; i++){ str = br.readLine(); A[i] = Integer.parseInt(str); } //主処理 for(int n = 0; n < N; n++){ for(int i = 1; i < N; i++){ for(int j = i + 1; j < N + 1; j++){ for(int i2 = 1; i2 <= i; i2++) kei1 = kei1 + A[i2 - 1]; if(m > kei1) m = kei1; for(int j2 = i + 1; j2 <= j; j2++) kei2 = kei2 + A[j2 - 1]; if(m > kei2) m = kei2; for(int k2 = j + 1; k2 <= N; k2++) kei3 = kei3 + A[k2 - 1]; if(m > kei3) m = kei3; if(m > M) M = m; kei1 = 0; kei2 = 0; kei3 = 0; m = 2000000000; } } //1番目に切れ込みを入れるパターンしか計算されないので、バウムクーヘンを回す(配列を循環させる) tmp = A[0]; for(int n2 = 0; n2 < N - 1; n2++) A[n2] = A[n2 + 1]; A[N - 1] =tmp; } System.out.println(M); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main{ | ^~~~~~
s365018277
p00523
C++
import java.io.*; public class Main{ public static void main(String[] args) throws IOException{ InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(is); String str = br.readLine(); int N = Integer.parseInt(str); int[] A = new int[N]; long m = 200000000000, M = 0; int kei = 0; int kei1 = 0, kei2 = 0, kei3 = 0;//3つの切り分けた領域の合計を表す int tmp; for(int i = 0; i < N; i++){ str = br.readLine(); A[i] = Integer.parseInt(str); } //主処理 for(int n = 0; n < N; n++){ for(int i = 1; i < N; i++){ for(int j = i + 1; j < N + 1; j++){ for(int i2 = 1; i2 <= i; i2++) kei1 = kei1 + A[i2 - 1]; if(m > kei1) m = kei1; for(int j2 = i + 1; j2 <= j; j2++) kei2 = kei2 + A[j2 - 1]; if(m > kei2) m = kei2; for(int k2 = j + 1; k2 <= N; k2++) kei3 = kei3 + A[k2 - 1]; if(m > kei3) m = kei3; if(m > M) M = m; kei1 = 0; kei2 = 0; kei3 = 0; m = 200000000000; } } //1番目に切れ込みを入れるパターンしか計算されないので、バウムクーヘンを回す(配列を循環させる) tmp = A[0]; for(int n2 = 0; n2 < N - 1; n2++) A[n2] = A[n2 + 1]; A[N - 1] =tmp; } System.out.println(M); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main{ | ^~~~~~
s651318847
p00523
C++
import java.io.*; public class Main{ public static void main(String[] args) throws IOException{ InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(is); String str = br.readLine(); int N = Integer.parseInt(str); int[] A = new int[N]; long m = 20000000000, M = 0; int kei = 0; int kei1 = 0, kei2 = 0, kei3 = 0;//3つの切り分けた領域の合計を表す int tmp; for(int i = 0; i < N; i++){ str = br.readLine(); A[i] = Integer.parseInt(str); } //主処理 for(int n = 0; n < N; n++){ for(int i = 1; i < N; i++){ for(int j = i + 1; j < N + 1; j++){ for(int i2 = 1; i2 <= i; i2++) kei1 = kei1 + A[i2 - 1]; if(m > kei1) m = kei1; for(int j2 = i + 1; j2 <= j; j2++) kei2 = kei2 + A[j2 - 1]; if(m > kei2) m = kei2; for(int k2 = j + 1; k2 <= N; k2++) kei3 = kei3 + A[k2 - 1]; if(m > kei3) m = kei3; if(m > M) M = m; kei1 = 0; kei2 = 0; kei3 = 0; m = 20000000000; } } //1番目に切れ込みを入れるパターンしか計算されないので、バウムクーヘンを回す(配列を循環させる) tmp = A[0]; for(int n2 = 0; n2 < N - 1; n2++) A[n2] = A[n2 + 1]; A[N - 1] =tmp; } System.out.println(M); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main{ | ^~~~~~
s299945851
p00523
C++
import java.io.*; public class Main{ public static void main(String[] args) throws IOException{ InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(is); String str = br.readLine(); int N = Integer.parseInt(str); long[] A = new long[N]; long m = 1000000000000L, M = 0L; long tmp; long kei1 = 0L, kei2 = 0L, kei3 = 0L;//3つの切り分けた領域の合計を表す for(int i = 0; i < N; i++){ str = br.readLine(); A[i] = Integer.parseInt(str); } //主処理 for(int n = 0; n < N; n++){ for(int i = 1; i < N; i++){ for(int j = i + 1; j < N + 1; j++){ for(int i2 = 1; i2 <= i; i2++) kei1 = kei1 + A[i2 - 1]; if(m > kei1) m = kei1; for(int j2 = i + 1; j2 <= j; j2++) kei2 = kei2 + A[j2 - 1]; if(m > kei2) m = kei2; for(int k2 = j + 1; k2 <= N; k2++) kei3 = kei3 + A[k2 - 1]; if(m > kei3) m = kei3; if(m > M) M = m; kei1 = 0; kei2 = 0; kei3 = 0; m = 2000000000000L; } } //1番目に切れ込みを入れるパターンしか計算されないので、バウムクーヘンを回す(配列を循環させる) tmp = A[0]; for(int n2 = 0; n2 < N - 1; n2++) A[n2] = A[n2 + 1]; A[N - 1] =tmp; } System.out.println(M); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main{ | ^~~~~~
s061032101
p00524
Java
import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchException; import java.util.Map; import java.util.PriorityQueue; import java.math.BigDecimal; import java.math.BigInteger; public class Main{ static final InputStream in=System.in; static final PrintWriter out=new PrintWriter(System.out); static final int INF=Integer.MAX_VALUE/2; static final long LINF=Long.MAX_VALUE/2; static int N,M,X; static int[] H; static long[] dist; static MyArrayList[] list; static class Edge{ int to; int cost; public Edge(int to,int cost){ this.to=to; this.cost=cost; } } static class Pair{ long x; int y; public Pair(long x,int y){ this.x=x; this.y=y; } public static final Comparator<Pair> DISTANCE_ORDER=new Comp(); private static class Comp implements Comparator<Pair>{ public int compare(Pair p1,Pair p2){ return (p1.x>p2.x)?1:(p1.x<p2.x)?-1:0; } } } class MyArrayList extends ArrayList<Edge>{} public static void main(String[] args) throws IOException{ InputReader ir=new InputReader(in); N=ir.nextInt(); M=ir.nextInt(); X=ir.nextInt(); H=ir.toIntArray(N); dist=new long[N]; list=new MyArrayList[N]; for(int i=0;i<N;i++) list[i]=new MyArrayList(); for(int i=0;i<M;i++){ int A=ir.nextInt()-1; int B=ir.nextInt()-1; int T=ir.nextInt(); if(H[A]>=T) list[A].add(new Edge(B,T)); if(H[B]>=T) list[B].add(new Edge(A,T)); } dijkstra(0); if(dist[N-1]==LINF) out.println(-1); else{ long ans=dist[N-1]+(long)H[N-1]; if(dist[N-1]>=(long)X) ans+=(dist[N-1]-(long)X); out.println(ans); } out.flush(); } public static void dijkstra(int s){ PriorityQueue<Pair> pque=new PriorityQueue<Pair>(10,Pair.DISTANCE_ORDER); Arrays.fill(dist,LINF); dist[s]=0; pque.offer(new Pair(0,s)); while(!pque.isEmpty()){ Pair p=pque.poll(); int v=p.y; if(dist[v]<p.x) continue; MyArrayList array=list[v]; for(int i=0;i<array.size();i++){ Edge e=array.get(i); if(dist[e.to]>dist[v]+(long)e.cost){ dist[e.to]=dist[v]+(long)e.cost; pque.offer(new Pair(dist[e.to],e.to)); } } } } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in;} public int readByte() { if(lenbuf==-1) throw new InputMismatchException(); if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return -1; } return buffer[curbuf++]; } public boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private int skip() {int b; while((b = readByte())!=-1&&isSpaceChar(b)); return b;} public String next() { int b=skip(); StringBuilder sb=new StringBuilder(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public int[] toIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } } }
Main.java:61: error: non-static variable this cannot be referenced from a static context for(int i=0;i<N;i++) list[i]=new MyArrayList(); ^ 1 error
s503653391
p00524
Java
import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchException; import java.util.Map; import java.util.PriorityQueue; import java.math.BigDecimal; import java.math.BigInteger; public class Main{ static final InputStream in=System.in; static final PrintWriter out=new PrintWriter(System.out); static final int INF=Integer.MAX_VALUE/2; static final long LINF=Long.MAX_VALUE/2; static int N,M,X; static int[] H,prev; static long[] dist; static MyArrayList[] list; static class Edge{ int to; int cost; public Edge(int to,int cost){ this.to=to; this.cost=cost; } } static class Pair{ long x; int y; public Pair(long x,int y){ this.x=x; this.y=y; } public static final Comparator<Pair> DISTANCE_ORDER=new Comp(); private static class Comp implements Comparator<Pair>{ public int compare(Pair p1,Pair p2){ return (p1.x>p2.x)?1:(p1.x<p2.x)?-1:0; } } } static class MyArrayList extends ArrayList<Edge>{} public static void main(String[] args) throws IOException{ InputReader ir=new InputReader(in); N=ir.nextInt(); M=ir.nextInt(); X=ir.nextInt(); H=ir.toIntArray(N); prev=new int[N]; dist=new long[N]; list=new MyArrayList[N]; for(int i=0;i<N;i++) list[i]=new MyArrayList(); for(int i=0;i<M;i++){ int A=ir.nextInt()-1; int B=ir.nextInt()-1; int T=ir.nextInt(); if(H[A]>=T) list[A].add(new Edge(B,T)); if(H[B]>=T) list[B].add(new Edge(A,T)); } dijkstra(0); if(dist[N-1]==LINF) out.println(-1); else{ nh=H[N-1]; nv=N-1; long ans=0; while(nv!=0){ int d=dist[nv]-dist[prev[nv]]; nh+=d; ans+=d; if(nh>H[prev[nv]]){ ans+=nh-H[prev[nv]]; nh=H[prev[nv]]; } nv=prev[nv]; } ans+=Math.abs(nh-X); out.printn(ans); } out.flush(); } public static void dijkstra(int s){ PriorityQueue<Pair> pque=new PriorityQueue<Pair>(10,Pair.DISTANCE_ORDER); Arrays.fill(dist,LINF); dist[s]=0; pque.offer(new Pair(0,s)); while(!pque.isEmpty()){ Pair p=pque.poll(); int v=p.y; if(dist[v]<p.x) continue; MyArrayList array=list[v]; for(int i=0;i<array.size();i++){ Edge e=array.get(i); if(dist[e.to]>dist[v]+(long)e.cost){ dist[e.to]=dist[v]+(long)e.cost; prev[e.to]=v; pque.offer(new Pair(dist[e.to],e.to)); } } } } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in;} public int readByte() { if(lenbuf==-1) throw new InputMismatchException(); if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return -1; } return buffer[curbuf++]; } public boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private int skip() {int b; while((b = readByte())!=-1&&isSpaceChar(b)); return b;} public String next() { int b=skip(); StringBuilder sb=new StringBuilder(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public int[] toIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } } }
Main.java:73: error: cannot find symbol nh=H[N-1]; ^ symbol: variable nh location: class Main Main.java:74: error: cannot find symbol nv=N-1; ^ symbol: variable nv location: class Main Main.java:76: error: cannot find symbol while(nv!=0){ ^ symbol: variable nv location: class Main Main.java:77: error: cannot find symbol int d=dist[nv]-dist[prev[nv]]; ^ symbol: variable nv location: class Main Main.java:77: error: cannot find symbol int d=dist[nv]-dist[prev[nv]]; ^ symbol: variable nv location: class Main Main.java:77: error: incompatible types: possible lossy conversion from long to int int d=dist[nv]-dist[prev[nv]]; ^ Main.java:78: error: cannot find symbol nh+=d; ^ symbol: variable nh location: class Main Main.java:80: error: cannot find symbol if(nh>H[prev[nv]]){ ^ symbol: variable nh location: class Main Main.java:80: error: cannot find symbol if(nh>H[prev[nv]]){ ^ symbol: variable nv location: class Main Main.java:81: error: cannot find symbol ans+=nh-H[prev[nv]]; ^ symbol: variable nh location: class Main Main.java:81: error: cannot find symbol ans+=nh-H[prev[nv]]; ^ symbol: variable nv location: class Main Main.java:82: error: cannot find symbol nh=H[prev[nv]]; ^ symbol: variable nh location: class Main Main.java:82: error: cannot find symbol nh=H[prev[nv]]; ^ symbol: variable nv location: class Main Main.java:84: error: cannot find symbol nv=prev[nv]; ^ symbol: variable nv location: class Main Main.java:84: error: cannot find symbol nv=prev[nv]; ^ symbol: variable nv location: class Main Main.java:86: error: cannot find symbol ans+=Math.abs(nh-X); ^ symbol: variable nh location: class Main Main.java:87: error: cannot find symbol out.printn(ans); ^ symbol: method printn(long) location: variable out of type PrintWriter 17 errors
s389999925
p00524
Java
import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchException; import java.util.Map; import java.util.PriorityQueue; import java.math.BigDecimal; import java.math.BigInteger; public class Main{ static final InputStream in=System.in; static final PrintWriter out=new PrintWriter(System.out); static final int INF=Integer.MAX_VALUE/2; static final long LINF=Long.MAX_VALUE/2; static int N,M,X; static int[] H,prev; static long[] dist; static MyArrayList[] list; static class Edge{ int to; int cost; public Edge(int to,int cost){ this.to=to; this.cost=cost; } } static class Pair{ long x; int y; public Pair(long x,int y){ this.x=x; this.y=y; } public static final Comparator<Pair> DISTANCE_ORDER=new Comp(); private static class Comp implements Comparator<Pair>{ public int compare(Pair p1,Pair p2){ return (p1.x>p2.x)?1:(p1.x<p2.x)?-1:0; } } } static class MyArrayList extends ArrayList<Edge>{} public static void main(String[] args) throws IOException{ InputReader ir=new InputReader(in); N=ir.nextInt(); M=ir.nextInt(); X=ir.nextInt(); H=ir.toIntArray(N); prev=new int[N]; dist=new long[N]; list=new MyArrayList[N]; for(int i=0;i<N;i++) list[i]=new MyArrayList(); for(int i=0;i<M;i++){ int A=ir.nextInt()-1; int B=ir.nextInt()-1; int T=ir.nextInt(); if(H[A]>=T) list[A].add(new Edge(B,T)); if(H[B]>=T) list[B].add(new Edge(A,T)); } dijkstra(0); if(dist[N-1]==LINF) out.println(-1); else{ int nh=H[N-1]; int nv=N-1; long ans=0; while(nv!=0){ int d=dist[nv]-dist[prev[nv]]; nh+=d; ans+=d; if(nh>H[prev[nv]]){ ans+=nh-H[prev[nv]]; nh=H[prev[nv]]; } nv=prev[nv]; } ans+=Math.abs(nh-X); out.printn(ans); } out.flush(); } public static void dijkstra(int s){ PriorityQueue<Pair> pque=new PriorityQueue<Pair>(10,Pair.DISTANCE_ORDER); Arrays.fill(dist,LINF); dist[s]=0; pque.offer(new Pair(0,s)); while(!pque.isEmpty()){ Pair p=pque.poll(); int v=p.y; if(dist[v]<p.x) continue; MyArrayList array=list[v]; for(int i=0;i<array.size();i++){ Edge e=array.get(i); if(dist[e.to]>dist[v]+(long)e.cost){ dist[e.to]=dist[v]+(long)e.cost; prev[e.to]=v; pque.offer(new Pair(dist[e.to],e.to)); } } } } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in;} public int readByte() { if(lenbuf==-1) throw new InputMismatchException(); if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return -1; } return buffer[curbuf++]; } public boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private int skip() {int b; while((b = readByte())!=-1&&isSpaceChar(b)); return b;} public String next() { int b=skip(); StringBuilder sb=new StringBuilder(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public int[] toIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } } }
Main.java:77: error: incompatible types: possible lossy conversion from long to int int d=dist[nv]-dist[prev[nv]]; ^ Main.java:87: error: cannot find symbol out.printn(ans); ^ symbol: method printn(long) location: variable out of type PrintWriter 2 errors
s203420650
p00524
Java
import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchException; import java.util.Map; import java.util.PriorityQueue; import java.math.BigDecimal; import java.math.BigInteger; public class Main{ static final InputStream in=System.in; static final PrintWriter out=new PrintWriter(System.out); static final int INF=Integer.MAX_VALUE/2; static final long LINF=Long.MAX_VALUE/2; static int N,M,X; static int[] H,prev; static long[] dist; static MyArrayList[] list; static class Edge{ int to; long cost; public Edge(int to,int cost){ this.to=to; this.cost=cost; } } static class Pair{ long x; int y; public Pair(long x,int y){ this.x=x; this.y=y; } public static final Comparator<Pair> DISTANCE_ORDER=new Comp(); private static class Comp implements Comparator<Pair>{ public int compare(Pair p1,Pair p2){ return (p1.x>p2.x)?1:(p1.x<p2.x)?-1:0; } } } static class MyArrayList extends ArrayList<Edge>{} public static void main(String[] args) throws IOException{ InputReader ir=new InputReader(in); N=ir.nextInt(); M=ir.nextInt(); X=ir.nextInt(); H=ir.toIntArray(N); prev=new int[N]; dist=new long[N]; list=new MyArrayList[N]; for(int i=0;i<N;i++) list[i]=new MyArrayList(); for(int i=0;i<M;i++){ int A=ir.nextInt()-1; int B=ir.nextInt()-1; int T=ir.nextLong(); if(H[A]>=T) list[A].add(new Edge(B,T)); if(H[B]>=T) list[B].add(new Edge(A,T)); } dijkstra(0); if(dist[N-1]==LINF) out.println(-1); else{ long nh=H[N-1]; int nv=N-1; long ans=0; while(nv!=0){ long d=dist[nv]-dist[prev[nv]]; nh+=d; ans+=d; if(nh>H[prev[nv]]){ ans+=nh-H[prev[nv]]; nh=H[prev[nv]]; } nv=prev[nv]; } ans+=(nh>X)?nh-X:X-nh; out.println(ans); } out.flush(); } public static void dijkstra(int s){ PriorityQueue<Pair> pque=new PriorityQueue<Pair>(10,Pair.DISTANCE_ORDER); Arrays.fill(dist,LINF); dist[s]=0; pque.offer(new Pair(0,s)); while(!pque.isEmpty()){ Pair p=pque.poll(); int v=p.y; if(dist[v]<p.x) continue; MyArrayList array=list[v]; for(int i=0;i<array.size();i++){ Edge e=array.get(i); if(dist[e.to]>dist[v]+e.cost){ dist[e.to]=dist[v]+e.cost; prev[e.to]=v; pque.offer(new Pair(dist[e.to],e.to)); } else if(dist[e.to]==dist[v]+e.cost){ if(H[prev[e.to]]<H[v]) prev[e.to]=v; } } } } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in;} public int readByte() { if(lenbuf==-1) throw new InputMismatchException(); if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return -1; } return buffer[curbuf++]; } public boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private int skip() {int b; while((b = readByte())!=-1&&isSpaceChar(b)); return b;} public String next() { int b=skip(); StringBuilder sb=new StringBuilder(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public int[] toIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } } }
Main.java:66: error: incompatible types: possible lossy conversion from long to int int T=ir.nextLong(); ^ 1 error
s427584018
p00524
Java
import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchException; import java.util.Map; import java.util.PriorityQueue; import java.math.BigDecimal; import java.math.BigInteger; public class Main{ static final InputStream in=System.in; static final PrintWriter out=new PrintWriter(System.out); static final int INF=Integer.MAX_VALUE/2; static final long LINF=Long.MAX_VALUE/2; static int N,M,X; static int[] H,prev; static long[] dist; static MyArrayList[] list; static class Edge{ int to; long cost; public Edge(int to,int cost){ this.to=to; this.cost=cost; } } static class Pair{ long x; int y; public Pair(long x,int y){ this.x=x; this.y=y; } public static final Comparator<Pair> DISTANCE_ORDER=new Comp(); private static class Comp implements Comparator<Pair>{ public int compare(Pair p1,Pair p2){ return (p1.x>p2.x)?1:(p1.x<p2.x)?-1:0; } } } static class MyArrayList extends ArrayList<Edge>{} public static void main(String[] args) throws IOException{ InputReader ir=new InputReader(in); N=ir.nextInt(); M=ir.nextInt(); X=ir.nextInt(); H=ir.toIntArray(N); prev=new int[N]; dist=new long[N]; list=new MyArrayList[N]; for(int i=0;i<N;i++) list[i]=new MyArrayList(); for(int i=0;i<M;i++){ int A=ir.nextInt()-1; int B=ir.nextInt()-1; long T=ir.nextLong(); if(H[A]>=T) list[A].add(new Edge(B,T)); if(H[B]>=T) list[B].add(new Edge(A,T)); } dijkstra(0); if(dist[N-1]==LINF) out.println(-1); else{ long nh=H[N-1]; int nv=N-1; long ans=0; while(nv!=0){ long d=dist[nv]-dist[prev[nv]]; nh+=d; ans+=d; if(nh>H[prev[nv]]){ ans+=nh-H[prev[nv]]; nh=H[prev[nv]]; } nv=prev[nv]; } ans+=(nh>X)?nh-X:X-nh; out.println(ans); } out.flush(); } public static void dijkstra(int s){ PriorityQueue<Pair> pque=new PriorityQueue<Pair>(10,Pair.DISTANCE_ORDER); Arrays.fill(dist,LINF); dist[s]=0; pque.offer(new Pair(0,s)); while(!pque.isEmpty()){ Pair p=pque.poll(); int v=p.y; if(dist[v]<p.x) continue; MyArrayList array=list[v]; for(int i=0;i<array.size();i++){ Edge e=array.get(i); if(dist[e.to]>dist[v]+e.cost){ dist[e.to]=dist[v]+e.cost; prev[e.to]=v; pque.offer(new Pair(dist[e.to],e.to)); } else if(dist[e.to]==dist[v]+e.cost){ if(H[prev[e.to]]<H[v]) prev[e.to]=v; } } } } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in;} public int readByte() { if(lenbuf==-1) throw new InputMismatchException(); if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return -1; } return buffer[curbuf++]; } public boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private int skip() {int b; while((b = readByte())!=-1&&isSpaceChar(b)); return b;} public String next() { int b=skip(); StringBuilder sb=new StringBuilder(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public int[] toIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } } }
Main.java:67: error: incompatible types: possible lossy conversion from long to int if(H[A]>=T) list[A].add(new Edge(B,T)); ^ Main.java:68: error: incompatible types: possible lossy conversion from long to int if(H[B]>=T) list[B].add(new Edge(A,T)); ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 2 errors
s021588533
p00524
Java
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out; static InputReader ir; static void solve(){ int n=ir.nextInt(); int m=ir.nextInt(); int x=ir.nextInt(); int[] H=ir.nextIntArray(n); G g=new G(n,true,H); for(int i=0;i<m;i++){ int from=ir.nextInt()-1; int to=ir.nextInt()-1; int cost=ir.nextInt(); g.addEdge(from,to,cost); } int[] d=g.dijkstra(0,x); if(d[n-1]<=x) out.println(2*d[n-1]+H[n-1]-x); else out.println(d[n-1]+H[n-1]); } public static void main(String[] args) throws Exception{ ir=new InputReader(System.in); out=new PrintWriter(System.out); solve(); out.flush(); } static class G{ AL[] g,rg; private int V; private boolean ndir; int[] H; public G(int V,boolean ndir,int[] H){ this.V=V; this.ndir=ndir; g=new AL[V]; for(int i=0;i<V;i++) g[i]=new AL(); this.H=H; } public void addEdge(int u,int v,int t){ g[u].add(new int[]{v,t}); if(this.ndir) g[v].add(new int[]{u,t}); } public void addEdge(int u,int v){ addEdge(u,v,0); } public int to(int from,int ind){return g[from].get(ind)[0];} public int cost(int from,int ind){return g[from].get(ind)[1];} public int size(int from){return g[from].size();} public int[] dijkstra(int s,int x){ int[] dist=new int[this.V]; java.util.PriorityQueue<int[]> pque=new java.util.PriorityQueue<int[]>(11,new Comparator<int[]>(){ public int compare(int[] a,int[] b){ return Integer.compare(a[0],b[0]); } }); Arrays.fill(dist,1<<26); dist[s]=0; pque.offer(new int[]{0,s,x}); while(!pque.isEmpty()){ int[] p=pque.poll(); int v=p[1]; int h=p[2]; if(dist[v]<p[0]) continue; for(int i=0;i<g[v].size();i++){ int to=to(v,i),cost=cost(v,i),re=-1,nh=-1; if(H[to]<h-cost){ re=cost+h-cost-H[to]; nh=H[to]; } else if(h-cost<=H[to]&&0<=h-cost){ re=cost; nh=h-cost; } else if(H[v]>=cost){ re=cost-h; nh=0; } else continue; if(d[to]>d[v]+re){ d[to]=d[v]+re; pque.offerLast(new int[]{d[to],to,nh}) } } } return dist; } static class AL extends ArrayList<int[]>{}; } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;} public boolean hasNextByte() { if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); }catch(IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return false; } return true; } private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;} public boolean hasNext(){skip(); return hasNextByte();} public String next(){ if(!hasNext()) throw new NoSuchElementException(); StringBuilder sb=new StringBuilder(); int b=readByte(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public double nextDouble(){return Double.parseDouble(next());} public int[] nextIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } public long[] nextLongArray(int n){ long[] a=new long[n]; for(int i=0;i<n;i++) a[i]=nextLong(); return a; } public char[][] nextCharMap(int n,int m){ char[][] map=new char[n][m]; for(int i=0;i<n;i++) map[i]=next().toCharArray(); return map; } } }
Main.java:102: error: ';' expected pque.offerLast(new int[]{d[to],to,nh}) ^ 1 error
s339016594
p00524
Java
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out; static InputReader ir; static void solve(){ int n=ir.nextInt(); int m=ir.nextInt(); int x=ir.nextInt(); int[] H=ir.nextIntArray(n); G g=new G(n,true,H); for(int i=0;i<m;i++){ int from=ir.nextInt()-1; int to=ir.nextInt()-1; int cost=ir.nextInt(); g.addEdge(from,to,cost); } int[] d=g.dijkstra(0,x); if(d[n-1]<=x) out.println(2*d[n-1]+H[n-1]-x); else out.println(d[n-1]+H[n-1]); } public static void main(String[] args) throws Exception{ ir=new InputReader(System.in); out=new PrintWriter(System.out); solve(); out.flush(); } static class G{ AL[] g,rg; private int V; private boolean ndir; int[] H; public G(int V,boolean ndir,int[] H){ this.V=V; this.ndir=ndir; g=new AL[V]; for(int i=0;i<V;i++) g[i]=new AL(); this.H=H; } public void addEdge(int u,int v,int t){ g[u].add(new int[]{v,t}); if(this.ndir) g[v].add(new int[]{u,t}); } public void addEdge(int u,int v){ addEdge(u,v,0); } public int to(int from,int ind){return g[from].get(ind)[0];} public int cost(int from,int ind){return g[from].get(ind)[1];} public int size(int from){return g[from].size();} public int[] dijkstra(int s,int x){ int[] dist=new int[this.V]; java.util.PriorityQueue<int[]> pque=new java.util.PriorityQueue<int[]>(11,new Comparator<int[]>(){ public int compare(int[] a,int[] b){ return Integer.compare(a[0],b[0]); } }); Arrays.fill(dist,1<<26); dist[s]=0; pque.offer(new int[]{0,s,x}); while(!pque.isEmpty()){ int[] p=pque.poll(); int v=p[1]; int h=p[2]; if(dist[v]<p[0]) continue; for(int i=0;i<g[v].size();i++){ int to=to(v,i),cost=cost(v,i),re=-1,nh=-1; if(H[to]<h-cost){ re=cost+h-cost-H[to]; nh=H[to]; } else if(h-cost<=H[to]&&0<=h-cost){ re=cost; nh=h-cost; } else if(H[v]>=cost){ re=cost-h; nh=0; } else continue; if(d[to]>d[v]+re){ d[to]=d[v]+re; pque.offerLast(new int[]{d[to],to,nh}); } } } return dist; } static class AL extends ArrayList<int[]>{}; } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;} public boolean hasNextByte() { if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); }catch(IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return false; } return true; } private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;} public boolean hasNext(){skip(); return hasNextByte();} public String next(){ if(!hasNext()) throw new NoSuchElementException(); StringBuilder sb=new StringBuilder(); int b=readByte(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public double nextDouble(){return Double.parseDouble(next());} public int[] nextIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } public long[] nextLongArray(int n){ long[] a=new long[n]; for(int i=0;i<n;i++) a[i]=nextLong(); return a; } public char[][] nextCharMap(int n,int m){ char[][] map=new char[n][m]; for(int i=0;i<n;i++) map[i]=next().toCharArray(); return map; } } }
Main.java:100: error: cannot find symbol if(d[to]>d[v]+re){ ^ symbol: variable d location: class G Main.java:100: error: cannot find symbol if(d[to]>d[v]+re){ ^ symbol: variable d location: class G Main.java:101: error: cannot find symbol d[to]=d[v]+re; ^ symbol: variable d location: class G Main.java:101: error: cannot find symbol d[to]=d[v]+re; ^ symbol: variable d location: class G Main.java:102: error: cannot find symbol pque.offerLast(new int[]{d[to],to,nh}); ^ symbol: variable d location: class G Main.java:102: error: cannot find symbol pque.offerLast(new int[]{d[to],to,nh}); ^ symbol: method offerLast(int[]) location: variable pque of type PriorityQueue<int[]> 6 errors
s523691763
p00524
Java
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out; static InputReader ir; static void solve(){ int n=ir.nextInt(); int m=ir.nextInt(); int x=ir.nextInt(); int[] H=ir.nextIntArray(n); G g=new G(n,true,H); for(int i=0;i<m;i++){ int from=ir.nextInt()-1; int to=ir.nextInt()-1; int cost=ir.nextInt(); g.addEdge(from,to,cost); } int[] d=g.dijkstra(0,x); if(d[n-1]<=x) out.println(2*d[n-1]+H[n-1]-x); else out.println(d[n-1]+H[n-1]); } public static void main(String[] args) throws Exception{ ir=new InputReader(System.in); out=new PrintWriter(System.out); solve(); out.flush(); } static class G{ AL[] g,rg; private int V; private boolean ndir; int[] H; public G(int V,boolean ndir,int[] H){ this.V=V; this.ndir=ndir; g=new AL[V]; for(int i=0;i<V;i++) g[i]=new AL(); this.H=H; } public void addEdge(int u,int v,int t){ g[u].add(new int[]{v,t}); if(this.ndir) g[v].add(new int[]{u,t}); } public void addEdge(int u,int v){ addEdge(u,v,0); } public int to(int from,int ind){return g[from].get(ind)[0];} public int cost(int from,int ind){return g[from].get(ind)[1];} public int size(int from){return g[from].size();} public int[] dijkstra(int s,int x){ int[] dist=new int[this.V]; java.util.PriorityQueue<int[]> pque=new java.util.PriorityQueue<int[]>(11,new Comparator<int[]>(){ public int compare(int[] a,int[] b){ return Integer.compare(a[0],b[0]); } }); Arrays.fill(dist,1<<26); dist[s]=0; pque.offer(new int[]{0,s,x}); while(!pque.isEmpty()){ int[] p=pque.poll(); int v=p[1]; int h=p[2]; if(dist[v]<p[0]) continue; for(int i=0;i<g[v].size();i++){ int to=to(v,i),cost=cost(v,i),re=-1,nh=-1; if(H[to]<h-cost){ re=cost+h-cost-H[to]; nh=H[to]; } else if(h-cost<=H[to]&&0<=h-cost){ re=cost; nh=h-cost; } else if(H[v]>=cost){ re=cost-h; nh=0; } else continue; if(dist[to]>dist[v]+re){ dist[to]=dist[v]+re; pque.offerLast(new int[]{dist[to],to,nh}); } } } return dist; } static class AL extends ArrayList<int[]>{}; } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;} public boolean hasNextByte() { if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); }catch(IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return false; } return true; } private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;} public boolean hasNext(){skip(); return hasNextByte();} public String next(){ if(!hasNext()) throw new NoSuchElementException(); StringBuilder sb=new StringBuilder(); int b=readByte(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public double nextDouble(){return Double.parseDouble(next());} public int[] nextIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } public long[] nextLongArray(int n){ long[] a=new long[n]; for(int i=0;i<n;i++) a[i]=nextLong(); return a; } public char[][] nextCharMap(int n,int m){ char[][] map=new char[n][m]; for(int i=0;i<n;i++) map[i]=next().toCharArray(); return map; } } }
Main.java:102: error: cannot find symbol pque.offerLast(new int[]{dist[to],to,nh}); ^ symbol: method offerLast(int[]) location: variable pque of type PriorityQueue<int[]> 1 error
s121095985
p00524
Java
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out; static InputReader ir; static void solve(){ int n=ir.nextInt(); int m=ir.nextInt(); int x=ir.nextInt(); int[] H=ir.nextIntArray(n); G g=new G(n,true,H); for(int i=0;i<m;i++){ int from=ir.nextInt()-1; int to=ir.nextInt()-1; int cost=ir.nextInt(); g.addEdge(from,to,cost); } int[] d=g.dijkstra(0,x); if(d[n-1]<=x) out.println(2*d[n-1]+H[n-1]-x); else out.println(d[n-1]+H[n-1]); } public static void main(String[] args) throws Exception{ ir=new InputReader(System.in); out=new PrintWriter(System.out); solve(); out.flush(); } static class G{ AL[] g,rg; private int V; private boolean ndir; int[] H; public G(int V,boolean ndir,int[] H){ this.V=V; this.ndir=ndir; g=new AL[V]; for(int i=0;i<V;i++) g[i]=new AL(); this.H=H; } public void addEdge(int u,int v,int t){ g[u].add(new int[]{v,t}); if(this.ndir) g[v].add(new int[]{u,t}); } public void addEdge(int u,int v){ addEdge(u,v,0); } public int to(int from,int ind){return g[from].get(ind)[0];} public int cost(int from,int ind){return g[from].get(ind)[1];} public int size(int from){return g[from].size();} public int[] dijkstra(int s,int x){ long[] dist=new long[this.V]; java.util.PriorityQueue<long[]> pque=new java.util.PriorityQueue<long[]>(11,new Comparator<long[]>(){ public int compare(long[] a,long[] b){ return Long.compare(a[0],b[0]); } }); Arrays.fill(dist,1L<<(long)55); dist[s]=0; pque.offer(new long[]{0,s,x}); while(!pque.isEmpty()){ long[] p=pque.poll(); int v=(int)p[1]; long h=p[2]; if(dist[v]<p[0]) continue; for(int i=0;i<g[v].size();i++){ int to=to(v,i); long cost=(long)cost(v,i),re,nh; if(H[to]<h-cost){ re=h-(long)H[to]; nh=H[to]; } else if(h-cost<=H[to]&&0<=h-cost){ re=cost; nh=h-cost; } else if(H[v]>=cost){ re=2*cost-h; nh=0; } else continue; if(dist[to]>dist[v]+re){ dist[to]=dist[v]+re; pque.offer(new long[]{dist[to],to,nh}); } } } return dist; } static class AL extends ArrayList<int[]>{}; } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;} public boolean hasNextByte() { if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); }catch(IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return false; } return true; } private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;} public boolean hasNext(){skip(); return hasNextByte();} public String next(){ if(!hasNext()) throw new NoSuchElementException(); StringBuilder sb=new StringBuilder(); int b=readByte(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public double nextDouble(){return Double.parseDouble(next());} public int[] nextIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } public long[] nextLongArray(int n){ long[] a=new long[n]; for(int i=0;i<n;i++) a[i]=nextLong(); return a; } public char[][] nextCharMap(int n,int m){ char[][] map=new char[n][m]; for(int i=0;i<n;i++) map[i]=next().toCharArray(); return map; } } }
Main.java:107: error: incompatible types: long[] cannot be converted to int[] return dist; ^ 1 error
s322487409
p00524
C++
#include <iostream> #include <cstdlib> #include <vector> #include <algorithm> #include <queue> #include <tuple> #include <utility> using namespace std; using int64 = long long int; const int64 INF = 1LL << 60; int64 N, M, X, H[100010]; vector< pair<int64, int64> > G[100010]; int64 dist[100010][2]; struct Elem { int64 cur, f, cost; Elem() {} Elem(int64 a, int64 b, int64 c) : cur(a), f(b), cost(c) {} bool operator<(const Elem & e) const { return cost > e.cost; } }; int main() { cin >> N >> M >> X; for(int i=0; i<N; i++) cin >> H[i]; for(int i=0; i<M; i++) { int64 u, v, d; cin >> u >> v >> d; u--; v--; G[u].emplace_back(v, d); G[v].emplace_back(u, d); } fill(dist[0], dist[N], INF); dist[0][0] = abs(H[0] - X); dist[0][1] = X; priority_queue<Elem> que; que.emplace(0, 0, dist[0][0]); que.emplace(0, 1, dist[0][1]); while(que.size()) { auto e = que.top(); que.pop(); fprintf(stderr, "%lld %lld %lld\n", e.cur, e.f, e.cost); if(dist[e.cur][e.f] < e.cost) continue; for(auto edge : G[e.cur]) { int64 to, cost; tie(to, cost) = edge; int cur = e.cur; int64 dh = H[cur] - H[to]; if(H[cur] - cost < 0) continue; { int64 nc = e.cost + cost; // go down if(dh > cost) { int64 sub = dh - cost; nc -= sub; } else { nc += H[to] - H[cur] + cost; } if(dist[to][0] > nc) { dist[to][0] = nc; que.emplace(to, 1, nc); } } { // climb (cost) int64 nc = e.cost; if(dist[to][1] > nc) { dist[to][1] = nc; que.emplace(to, 1, nc); } } } } if(dist[N-1][0] == INF) cout << -1 << endl; else cout << dist[N-1][0] << endl; return 0; } #error "uku"
a.cc:82:2: error: #error "uku" 82 | #error "uku" | ^~~~~
s871266637
p00524
C++
#include<iostream> #include<vector> #include<string> #include<cstdio> #include<map> #include<algorithm> using namespace std; #define INF 10000000 struct Tree{ int E; int Time; bool used; }; int N,M,X; int H[100001]; int dis[100001]; int from,to,time; vector<Tree> t[100001]; Tree tree1,tree2; bool used[10001]; /* void dijkstra(int s){ fill(used,used+N+1,false); for(int i=1;i<=N;i++){ dis[i]=INF; } dis[s]=0; while(true){ int v = -1; for(int u = 1; u <= N; u++){ if(!used[u] && (v == -1 || dis[u] < dis[v])) v = u; } if(v == -1) break; used[v] = true; for(int u = 0; u < t[v].size(); u++){ if(0 < X-t[v][u].Time && t[v][u].Time <H[t[v][u].E]){ dis[t[v][u].E] = min(dis[t[v][u].E], dis[v]+t[v][u].Time); } } } } */ bool m(int node,int x,int d){ if(node == N){ d += H[N]-x; if(dis[N] > d){ dis[N] = d; } return true; }else{ int x1,d1,to; for(int u = 0; u < t[node].size(); u++){ x1 = x; d1 = d; cout<<t[node][u].E<<endl; if(t[node][u].used != false) continue; for(int i=0 ;t[t[node][u].E].size();i++){ if(t[t[node][u].E][i].E == node){ to = i; t[t[node][u].E][to].used = true; break; } } t[node][u].used = true; if(0 <= x1-t[node][u].Time && x1-t[node][u].Time <= H[t[node][u].E]){ d1 += t[node][u].Time; m(t[node][u].E,x1-t[node][u].Time,d1); }else{ if(0 > x1-t[node][u].Time){ d1 += -(x1-t[node][u].Time); x1 += -(x1-t[node][u].Time); if(x1 > H[node]){ t[node][u].used = false; continue; } d1 += t[node][u].Time; m(t[node][u].E,0,d1); }else{ d1 += x1-t[node][u].Time-H[t[node][u].E]; x1 = H[t[node][u].E]+t[node][u].Time; d1 += t[node][u].Time; m(t[node][u].E,H[t[node][u].E],d1); } } t[node][u].used = false; t[t[node][u].E][to].used = false; } } return false; } int main(){ cin>>N>>M>>X; for(int i=1;i<=N;i++){ cin>>H[i]; } for(int j=0;j<M;j++){ cin>>to>>from>>time; tree1.E=from; tree1.Time=time; tree1.used=false; tree2.E=to; tree2.Time=time; tree2.used=false; t[to].push_back(tree1); t[from].push_back(tree2); } dis[N] = INF; m(1,X,0); if(dis[N] !=INF)cout<<dis[N]<<endl; else cout<<-1<<endl; return 0; }
a.cc:20:21: error: 'int time' redeclared as different kind of entity 20 | int from,to,time; | ^~~~ In file included from /usr/include/pthread.h:23, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35, from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157, from /usr/include/c++/14/ext/atomicity.h:35, from /usr/include/c++/14/bits/ios_base.h:39, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)' 76 | extern time_t time (time_t *__timer) __THROW; | ^~~~ a.cc: In function 'int main()': a.cc:106:30: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}) 106 | cin>>to>>from>>time; | ~~~~~~~~~~~~~^~~~~~ | | | | | time_t(time_t*) noexcept {aka long int(long int*) noexcept} | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42: /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:106:32: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} 106 | cin>>to>>from>>time; | ^~~~ /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:106:32: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'short int' [-fpermissive] 106 | cin>>to>>from>>time; | ^~~~ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept} a.cc:106:32: error: cannot bind rvalue '(short int)time' 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:106:32: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'short unsigned int' [-fpermissive] 106 | cin>>to>>from>>time; | ^~~~ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept} a.cc:106:32: error: cannot bind rvalue '(short unsigned int)time' 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:106:32: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive] 106 | cin>>to>>from>>time; | ^~~~ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept} a.cc:106:32: error: cannot bind rvalue '(int)time' 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:106:32: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'unsigned int' [-fpermissive] 106 | cin>>to>>from>>time; | ^~~~ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept} a.cc:106:32: error: cannot bind rvalue '(unsigned int)time' 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:106:32: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'long int' [-fpermissive] 106 | cin>>to>>from>>time; | ^~~~ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept} a.cc:106:32: error: cannot bind rvalue '(long int)time' 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:106:32: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'long unsigned int' [-fpermissive] 106 | cin>>to>>from>>time; | ^~~~ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept} a.cc:106:32: error: cannot bind rvalue '(long unsigned int)time' 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:106:32: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'long long int' [-fpermissive] 106 | cin>>to>>from>>time; | ^~~~ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept} a.cc:106:32: error: cannot bind rvalue '(long long int)time' 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:106:32: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'long long unsigned int' [-fpermissive] 106 | cin>>to>>from>>time; | ^~~~ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept} a.cc:106:32: error: cannot bind rvalue '(long long unsigned int)time' 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:106:32: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'void*' [-fpermissive] 106 | cin>>to>>from>>time; | ^~~~ | | | time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept} a.cc:106:32: error: cannot bind rvalue '(void*)time' to 'void*&' /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::opera
s242310580
p00524
C++
#include <bits/stdc++.h> using namespace std; typedef long long LL; struct EDGE { int to; LL time; bool operator < (const EDGE &t) const { return time > t.time; } }; const LL INF = 1LL << 60; int n, m; LL x; LL h[100000]; vector<EDGE> g[100000]; LL d[100000]; LL search(LL x) { for (int i = 0; i < n; i++) d[i] = INF; priority_queue<EDGE> que; que.push((EDGE){0, 0}); while (!que.empty()){ EDGE e = que.top(); que.pop(); if (d[e.to] <= e.time) continue; d[e.to] = e.time; LL nowh = max(0LL, x - d[e.to]); for (int i = 0; i < g[e.to].size(); i++){ EDGE &ee = g[e.to][i]; if (nowh - ee.time > h[ee.to]){ LL diff = nowh - ee.time - h[ee.to]; que.push((EDGE){ee.to, e.time + ee.time + /*diff*/}); } else if (nowh >= ee.time){ que.push((EDGE){ee.to, e.time + ee.time}); } if (nowh - ee.time < 0){ LL tmph = - (nowh - ee.time); if (tmph <= h[e.to]){ que.push((EDGE){ee.to, e.time /*+ (tmph - nowh)*/ + ee.time}); } } } } if (d[n - 1] == INF) return -1; return d[n - 1] + h[n - 1] - max(0LL, x - d[n - 1]); //return d[n - 1] * 2 + h[n - 1]; } int main() { scanf("%d %d %lld", &n, &m, &x); for (int i = 0; i < n; i++){ scanf("%lld", &h[i]); } for (int i = 0; i < m; i++){ int a, b; LL t; scanf("%d %d %lld", &a, &b, &t); a--; b--; g[a].push_back((EDGE){b, t}); g[b].push_back((EDGE){a, t}); } printf("%lld\n", search(x)); return 0; }
a.cc: In function 'LL search(LL)': a.cc:34:47: error: expected primary-expression before ')' token 34 | que.push((EDGE){ee.to, e.time + ee.time + /*diff*/}); | ^
s990676527
p00524
C++
#include<cstdio> #include<math.h> #include<algorithm> #include<vector> #include<queue> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define mp make_pair const int INF=1001001001; int N,M,X; int H[100002]; vector< pair<int,long long int> > graph[100002]; long long int memo[100002];//djkstraメモ int main(){ //FILE *fp; //fp=fopen("C:\\Users\\ray\\Desktop\\1JOI本選\\2014\\joi2014-ho-data\\joi2014-ho-data\\2014-ho-t4\\in\\03-14.txt","r"); scanf("%d %d %d",&N,&M,&X); rep(i,N){scanf("%d",&H[i]);memo[i]=-1;}; rep(i,M){ int to,from,cost; scanf("%d %d %d",&to,&from,&cost); graph[from-1].push_back(make_pair(to-1,cost)); graph[to-1].push_back(make_pair(from-1,cost)); } //Djkstra queue< pair<int,long long int> > q1;//木の番号、到達コスト.木の上での位置はX-コストか0 q1.push(mp(0,0)); long long int ans=-1; do{ pair<int,long long int> a =q1.front(); q1.pop(); queue< pair<int,long long int> > q2; rep(i,graph[a.first].size()){ long long int ncost=-1; if(max(X-a.second,(long long int)(0))-graph[a.first][i].second>H[graph[a.first][i].first]){ //移動先>木の高さ 下がってから飛ぶ ncost=a.second+max(X-a.second,(long long int)(0))-H[graph[a.first][i].first]; }else if(max(X-a.second,(long long int)(0))-graph[a.first][i].second>=0){ //0<=移動先<=木の高さ そのまま飛ぶ ncost=a.second+graph[a.first][i].second; }else{ //0>移動先 上がってから飛ぶ if(H[a.first]<graph[a.first][i].second)continue; ncost=a.second+graph[a.first][i].second-max(X-a.second,(long long int)(0))+graph[a.first][i].second; } if(memo[graph[a.first][i].first]<0||memo[graph[a.first][i].first]>ncost){ memo[graph[a.first][i].first]=ncost; if(graph[a.first][i].first!=N-1)q2.push(mp(graph[a.first][i].first,ncost)); } } if(q1.empty())q1=q2; }while(!q1.empty()); printf("%lld",memo[N-1]+(memo[N-1]!=-1)*H[N-1]); }
a.cc:30:39: error: extended character   is not valid in an identifier 30 | queue< pair<int,long long int> > q1;//木の番号、到達コスト.木の上での位置はX-コストか0 | ^ a.cc:36:23: error: extended character   is not valid in an identifier 36 | queue< pair<int,long long int> > q2; | ^ a.cc:36:48: error: extended character   is not valid in an identifier 36 | queue< pair<int,long long int> > q2; | ^ a.cc: In function 'int main()': a.cc:30:41: error: template argument 1 is invalid 30 | queue< pair<int,long long int> > q1;//木の番号、到達コスト.木の上での位置はX-コストか0 | ^ a.cc:30:41: error: template argument 2 is invalid a.cc:31:12: error: request for member 'push' in 'q1', which is of non-class type 'int' 31 | q1.push(mp(0,0)); | ^~~~ a.cc:34:47: error: request for member 'front' in 'q1', which is of non-class type 'int' 34 | pair<int,long long int> a =q1.front(); | ^~~~~ a.cc:35:20: error: request for member 'pop' in 'q1', which is of non-class type 'int' 35 | q1.pop(); | ^~~ a.cc:36:23: error: '\U00003000pair' was not declared in this scope 36 | queue< pair<int,long long int> > q2; | ^~~~~~ a.cc:36:47: error: template argument 1 is invalid 36 | queue< pair<int,long long int> > q2; | ^ a.cc:36:47: error: template argument 2 is invalid a.cc:36:50: error: expected initializer before '>' token 36 | queue< pair<int,long long int> > q2; | ^ a.cc:53:65: error: 'q2' was not declared in this scope; did you mean 'q1'? 53 | if(graph[a.first][i].first!=N-1)q2.push(mp(graph[a.first][i].first,ncost)); | ^~ | q1 a.cc:57:23: error: request for member 'empty' in 'q1', which is of non-class type 'int' 57 | if(q1.empty())q1=q2; | ^~~~~ a.cc:57:34: error: 'q2' was not declared in this scope; did you mean 'q1'? 57 | if(q1.empty())q1=q2; | ^~ | q1 a.cc:58:20: error: request for member 'empty' in 'q1', which is of non-class type 'int' 58 | }while(!q1.empty()); | ^~~~~
s039407187
p00524
C++
#include <cstdio> #include <vector> using namespace std; #define long long Int typedef pair<Int, int> p; typedef pair<int, int> pp; int main(){ const int MAX_N = 100000; int N, M, X, H[MAX_N + 1]; int u, v, c; p d[MAX_N + 1]; vector<pp> V[MAX_N + 1]; bool updated; int to, cost, height; scanf("%d%d%d", &N, &M, &X); for(int i = 1; i <= N; i++){ scanf("%d", H + i); } for(int i = 0; i < M; i++){ scanf("%d%d%d", &u, &v, &c); V[u].push_back(pp(v, c)); V[v].push_back(pp(u, c)); } updated = true; for(int i = 1; i <= N; i++){ d[i].first = -1; d[i].second = -1; } d[1].first = 0; d[1].second = X; while(updated){ updated = false; for(int i = 1; i <= N; i++){ if(V[i].empty() || d[i].first == -1 || d[i].second == -1) continue; for(int j = 0; j < V[i].size(); j++){ to = V[i][j].first; if(H[i] < V[i][j].second) continue; if(d[i].second - V[i][j].second >= 0){ if(d[i].second - V[i][j].second <= H[to]){ cost = V[i][j].second; height = d[i].second - V[i][j].second; } else{ cost = d[i].second - H[to]; height = H[to]; } } else{ cost = V[i][j].second + (V[i][j].second - d[i].second); height = 0; } if(to == N){ if(d[to].first == -1 || (d[i].first + cost) + (H[to] - height) < d[to].first + (H[to] - d[to].second)){ d[to].first = d[i].first + cost; d[to].second = height; updated = true; } } else{ if(d[to].first == -1 || d[i].first + cost < d[to].first){ d[to].first = d[i].first + cost; d[to].second = height; updated = true; } } } } } printf("%lld\n", (d[N].first == -1)? -1 : (d[N].first + (H[N] - d[N].second))); return 0; }
a.cc:6:14: error: 'Int' was not declared in this scope; did you mean 'int'? 6 | typedef pair<Int, int> p; | ^~~ | int a.cc:6:22: error: template argument 1 is invalid 6 | typedef pair<Int, int> p; | ^ a.cc: In function 'int main()': a.cc:30:22: error: request for member 'first' in 'd[i]', which is of non-class type 'p' {aka 'int'} 30 | d[i].first = -1; | ^~~~~ a.cc:31:22: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'} 31 | d[i].second = -1; | ^~~~~~ a.cc:33:14: error: request for member 'first' in 'd[1]', which is of non-class type 'p' {aka 'int'} 33 | d[1].first = 0; d[1].second = X; | ^~~~~ a.cc:33:30: error: request for member 'second' in 'd[1]', which is of non-class type 'p' {aka 'int'} 33 | d[1].first = 0; d[1].second = X; | ^~~~~~ a.cc:37:49: error: request for member 'first' in 'd[i]', which is of non-class type 'p' {aka 'int'} 37 | if(V[i].empty() || d[i].first == -1 || d[i].second == -1) continue; | ^~~~~ a.cc:37:69: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'} 37 | if(V[i].empty() || d[i].first == -1 || d[i].second == -1) continue; | ^~~~~~ a.cc:42:41: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'} 42 | if(d[i].second - V[i][j].second >= 0){ | ^~~~~~ a.cc:43:49: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'} 43 | if(d[i].second - V[i][j].second <= H[to]){ | ^~~~~~ a.cc:45:63: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'} 45 | height = d[i].second - V[i][j].second; | ^~~~~~ a.cc:48:61: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'} 48 | cost = d[i].second - H[to]; | ^~~~~~ a.cc:53:88: error: request for member 'second' in 'd[i]', which is of non-class type 'p' {aka 'int'} 53 | cost = V[i][j].second + (V[i][j].second - d[i].second); | ^~~~~~ a.cc:58:50: error: request for member 'first' in 'd[to]', which is of non-class type 'p' {aka 'int'} 58 | if(d[to].first == -1 || (d[i].first + cost) + (H[to] - height) < d[to].first + (H[to] - d[to].second)){ | ^~~~~ a.cc:58:71: error: request for member 'first' in 'd[i]', which is of non-class type 'p' {aka 'int'} 58 | if(d[to].first == -1 || (d[i].first + cost) + (H[to] - height) < d[to].first + (H[to] - d[to].second)){ | ^~~~~ a.cc:58:112: error: request for member 'first' in 'd[to]', which is of non-class type 'p' {aka 'int'} 58 | if(d[to].first == -1 || (d[i].first + cost) + (H[to] - height) < d[to].first + (H[to] - d[to].second)){ | ^~~~~ a.cc:58:135: error: request for member 'second' in 'd[to]', which is of non-class type 'p' {aka 'int'} 58 | if(d[to].first == -1 || (d[i].first + cost) + (H[to] - height) < d[to].first + (H[to] - d[to].second)){ | ^~~~~~ a.cc:59:55: error: request for member 'first' in 'd[to]', which is of non-class type 'p' {aka 'int'} 59 | d[to].first = d[i].first + cost; | ^~~~~ a.cc:59:68: error: request for member 'first' in 'd[i]', which is of non-class type 'p' {aka 'int'} 59 | d[to].first = d[i].first + cost; | ^~~~~ a.cc:60:55: error: request for member 'second' in 'd[to]', which is of non-class type 'p' {aka 'int'} 60 | d[to].second = height; | ^~~~~~ a.cc:65:50: error: request for member 'first' in 'd[to]', which is of non-class type 'p' {aka 'int'} 65 | if(d[to].first == -1 || d[i].first + cost < d[to].first){ | ^~~~~ a.cc:65:70: error: request for member 'first' in 'd[i]', which is of non-class type 'p' {aka 'int'} 65 | if(d[to].first == -1 || d[i].first + cost < d[to].first){ | ^~~~~ a.cc:65:91: error: request for member 'first' in 'd[to]', which is of non-class type 'p' {aka 'int'} 65 | if(d[to].first == -1 || d[i].first + cost < d[to].first){ | ^~~~~ a.cc:66:55: error: request for member 'first' in 'd[to]', which is of non-class type 'p' {aka 'int'} 66 | d[to].first = d[i].first + cost; | ^~~~~ a.cc:66:68: error: request for member 'first' in 'd[i]', which is of non-class type 'p' {aka 'int'} 66 | d[to].first = d[i].first + cost; | ^~~~~ a.cc:67:55: error: request for member 'second' in 'd[to]', which is of non-class type 'p' {aka 'int'} 67 | d[to].second = height; | ^~~~~~ a.cc:75:32: error: request for member 'first' in 'd[N]', which is of non-class type 'p' {aka 'int'} 75 | printf("%lld\n", (d[N].first == -1)? -1 : (d[N].first + (H[N] - d[N].second))); | ^~~~~ a.cc:75:57: error: request for member 'first' in 'd[N]', which is of non-class type 'p' {aka 'int'} 75 | printf("%lld\n", (d[N].first == -1)? -1 : (d[N].first + (H[N] - d[N].second))); | ^~~~~ a.cc:75:78: error: request for member 'second' in 'd[N]', which is of non-class type 'p' {aka 'int'} 75 | printf("%lld\n", (d[N].first == -1)? -1 : (d[N].first + (H[N] - d[N].second))); | ^~~~~~
s643339462
p00524
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pii pair<int,int> #define INF 1<<27 #define MAX using namespace std; int n,m,x,h[101010],d[101010]; vector<pii> G[101010]; void solve(){ cin>>n>>m>>x; FOR(i,n) cin>>h[i]; int a,b,t; FOR(i,m){ cin>>a>>b>>t; a--; b--; if(t<=h[a]) G[a].pb(mp(b,t)); if(t<=h[b]) G[b].pb(mp(a,t)); } dijkstra(0); if(d[n-1]>=INF){ cout<<"-1"<<endl; return; } cout<<d[n-1]+h[n-1]-x<<endl; } void dijkstra(int s){ priority_queue<ti,vector<ti>,greater<ti>> que; fill(d,d+n,INF); d[s]=0; que.push(mp(0,s)); while(!que.empty()){ pii p=que.top(); que.pop(); int v=p.second; if(d[v]<p.first) continue; int to,cost; FOR(i,G[v].size()){ to=G[v][i].first; cost=G[v][i].second; if(d[to]>d[v]+cost){ d[to]=d[v]+cost; que.push(mp(d[to],to)); } } } } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:29:2: error: 'dijkstra' was not declared in this scope 29 | dijkstra(0); | ^~~~~~~~ a.cc: In function 'void dijkstra(int)': a.cc:38:17: error: 'ti' was not declared in this scope; did you mean 'tm'? 38 | priority_queue<ti,vector<ti>,greater<ti>> que; | ^~ | tm a.cc:38:29: error: template argument 2 is invalid 38 | priority_queue<ti,vector<ti>,greater<ti>> que; | ^ a.cc:38:41: error: template argument 1 is invalid 38 | priority_queue<ti,vector<ti>,greater<ti>> que; | ^~ a.cc:38:41: error: template argument 2 is invalid a.cc:38:41: error: template argument 3 is invalid a.cc:41:6: error: request for member 'push' in 'que', which is of non-class type 'int' 41 | que.push(mp(0,s)); | ^~~~ a.cc:42:13: error: request for member 'empty' in 'que', which is of non-class type 'int' 42 | while(!que.empty()){ | ^~~~~ a.cc:43:13: error: request for member 'top' in 'que', which is of non-class type 'int' 43 | pii p=que.top(); que.pop(); | ^~~ a.cc:43:24: error: request for member 'pop' in 'que', which is of non-class type 'int' 43 | pii p=que.top(); que.pop(); | ^~~ a.cc:52:9: error: request for member 'push' in 'que', which is of non-class type 'int' 52 | que.push(mp(d[to],to)); | ^~~~
s152614058
p00524
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pii pair<int,int> #define INF 1<<27 #define MAX using namespace std; int n,m,x,h[101010],d[101010]; vector<pii> G[101010]; void solve(){ cin>>n>>m>>x; FOR(i,n) cin>>h[i]; int a,b,t; FOR(i,m){ cin>>a>>b>>t; a--; b--; if(t<=h[a]) G[a].pb(mp(b,t)); if(t<=h[b]) G[b].pb(mp(a,t)); } dijkstra(0); if(d[n-1]>=INF){ cout<<"-1"<<endl; return; } cout<<d[n-1]+h[n-1]-x<<endl; } void dijkstra(int s){ priority_queue<pii,vector<pii>,greater<pii>> que; fill(d,d+n,INF); d[s]=0; que.push(mp(0,s)); while(!que.empty()){ pii p=que.top(); que.pop(); int v=p.second; if(d[v]<p.first) continue; int to,cost; FOR(i,G[v].size()){ to=G[v][i].first; cost=G[v][i].second; if(d[to]>d[v]+cost){ d[to]=d[v]+cost; que.push(mp(d[to],to)); } } } } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:29:2: error: 'dijkstra' was not declared in this scope 29 | dijkstra(0); | ^~~~~~~~
s846847076
p00524
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pii pair<int,int> #define INF 1<<27 #define MAX using namespace std; int n,m,x,h[101010],d[101010]; vector<pii> G[101010]; void solve(){ cin>>n>>m>>x; FOR(i,n) cin>>h[i]; int a,b,t; FOR(i,m){ cin>>a>>b>>t; a--; b--; if(t<=h[a]) G[a].pb(mp(b,t)); if(t<=h[b]) G[b].pb(mp(a,t)); } dijkstra(0); if(d[n-1]>=INF){ cout<<"-1"<<endl; return; } cout<<d[n-1]+h[n-1]-x<<endl; } void dijkstra(int s){ priority_queue<pii,vector<pii>,greater<pii>> que; fill(d,d+n,INF); d[s]=0; que.push(mp(0,s)); while(!que.empty()){ pii p=que.top(); que.pop(); int v=p.second; if(d[v]<p.first) continue; int to,cost; FOR(i,G[v].size()){ to=G[v][i].first; cost=G[v][i].second; if(d[to]>d[v]+cost){ d[to]=d[v]+cost; que.push(mp(d[to],to)); } } } } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:29:2: error: 'dijkstra' was not declared in this scope 29 | dijkstra(0); | ^~~~~~~~
s645823316
p00524
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, int> pl; typedef pair<ll, pl> pll; #define fir first #define sec second.first; #define thr second.second; #define INF (1ll << 60) int n,m; ll h[100800],dist[100800],ah[100800]; vector<pl> g[100800]; void dijkstra(ll height){ int i,from,to; ll hi,d,l,nw; pll tmp; priority_queue<pll, vector<pll>, greater<pll> > pq; fill(dist,dist+n,INF); fill(ah,ah+n,0ll); dist[0] = 0ll; ah[i] = x; pq.push(pll(dist[0],pl(height,0))); while(!pq.empty()){ tmp = pq.top(); pq.pop(); from = tmp.thr; hi = tmp.sec; d = tmp.fir; for(i=(g[from].size()-1); i>=0; i--){ to = g[from][i].second; l = g[from][i].first; if(l<=hi){ nw = d+l; if(dist[to]>=nw && h[to] >= hi-l){ if(dist[to]==nw){ ah[to] = max(ah[to],hi-l); }else{ ah[to] = hi-l; } dist[to] = nw; pq.push(pll(dist[to],pl(ah[to],to))); }else if(dist[to]>=nw){ nw += hi-l-h[to]; if(dist[to]>nw){ dist[to] = nw; ah[to] = h[to]; pq.push(pll(dist[to],pl(ah[to],to))); }else if(dist[to]==nw){ dist[to] = nw; ah[to] = max(ah[to],h[to]); pq.push(pll(dist[to],pl(ah[to],to))); } } }else if(l<=h[from]){ nw = d+l-hi+l; if(dist[to]>=nw){ if(dist[to]!=nw){ ah[to] = 0ll; } dist[to] = nw; pq.push(pll(dist[to],pl(ah[to],to))); } } } } } int main(void){ int i,a,b; ll x,t; cin >> n >> m >> x; for(i=0; i<n; i++){ cin >> h[i]; } for(i=0; i<m; i++){ cin >> a >> b >> t; a--; b--; g[a].push_back(pl(t,b)); g[b].push_back(pl(t,a)); } dijkstra(x); if(dist[n-1]==INF){ dist[n-1] = -1; }else{ dist[n-1] += h[n-1] - ah[n-1]; } cout << dist[n-1] << endl; return 0; }
a.cc: In function 'void dijkstra(ll)': a.cc:26:17: error: 'x' was not declared in this scope 26 | ah[i] = x; | ^
s241711838
p00524
C++
#include <iostream> using namespace std; int main() { int n,m,mn=0,a[300001],b[300001]; int ain,binp; long long int h[100001],t[300001],mt[100001],mh[100001],tin,x,t2,h2; bool check_tree[100001]; cin >> n >> m >> x; for(int i=1;i<=n;i++){ cin >> h[i]; mt[i]=-1; check_tree[i]=false; } for(int i=1;i<=m;i++){ cin >> ain >> binp >> tin; if(h[ain]>=tin){ a[mn]=ain; b[mn]=binp; t[mn]=tin; mn++; } if(h[binp]>=tin){ a[mn]=binp; b[mn]=ain; t[mn]=tin; mn++; } } check_tree[1]=true; mt[1]=0; mh[1]=x; bool f=true; while(f){ f=false; for(int i=1;i<=n;i++){ if(check_tree[i]){ for(int j=0;j<mn;j++){ if(a[j]==i){ if(h[b[j]]<mh[i]-t[j]){ t2=mt[i]+mh[i]-h[b[j]]; h2=h[b[j]]; }else{ if(mh[i]<t[j]){ t2=mt[i]+t[j]*2-mh[i]; h2=0; }else{ t2=mt[i]+t[j]; h2=mh[i]-t[j]; } } if(mt[b[j]]==-1 || mt[b[j]]-mh[b[j]]>t2-h2*"" || (mt[b[j]]-mh[b[j]]*2==t2-h2 && mh[b[j]]<h2)){ f=true; check_tree[b[j]]=true; mt[b[j]]=t2; mh[b[j]]=h2; } } } check_tree[i]=false; } } } if(mt[n]==-1){ cout << -1 << endl; }else{ cout << mt[n]+h[n]-mh[n] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:52:91: error: invalid operands of types 'long long int' and 'const char [1]' to binary 'operator*' 52 | if(mt[b[j]]==-1 || mt[b[j]]-mh[b[j]]>t2-h2*"" || (mt[b[j]]-mh[b[j]]*2==t2-h2 && mh[b[j]]<h2)){ | ~~^~~ | | | | | const char [1] | long long int
s299610559
p00524
C++
#include <iostream> using namespace std; int main() { int n,m,mm=0,b[600001],first_a[100001],last_a[100001],next_a[600001],a_in,b_in; long long int x,h[100001],tt[600001],mh[100001],mt[100001],t2,h2,t_in; bool check_a[100001],f=true; cin >> n >> m >> x; for(int i=1;i<=n;i++){ cin >> h[i]; first_a[i]=-1; last_a[i]=-1; mt[i]=-1; check_a[i]=false; } for(int i=0;i<m;i++){ cin >> a_in >> b_in >> t_in; if(h[a_in]>=t_in){ b[mm]=b_in; tt[mm]=t_in; next_a[mm]=-1; if(last_a[a_in]==-1){ first_a[a_in]=mm; }else{ next_a[last_a[a_in]]=mm; } last_a[a_in]=mm; mm++; } if(h[b_in]>=t_in){ b[mm]=a_in; tt[mm]=t_in; next_a[mm]=-1; if(last_a[b_in]==-1){ first_a[b_in]=mm; }else{ next_a[last_a[b_in]]=mm; } last_a[b_in]=mm; mm++; } } check_a[1]=true; mt[1]=0; mh[1]=x; while(f){ f=false; for(int i=1;i<=n;i++){ if(check_a[i]){ check_a[i]=false; int j=first_a[i]; while(j!=-1){ if(mh[i]>h[b[j]]+t[j]){ t2=mt[i]+mh[i]-h[b[j]]; h2=h[b[j]]; }else{ if(mh[i]<t[j]){ t2=mt[i]+t[j]*2-mh[i]; h2=0; }else{ t2=mt[i]+t[j]; h2=mh[i]-t[j]; } } if(mt[b[j]]==-1 || mt[b[j]]-mh[b[j]]>t2-h2 || (mt[b[j]]-mh[b[j]]==t2-h2 && mh[b[j]]<h2)){ mt[b[j]]=t2; mh[b[j]]=h2; check_a[b[j]]=true; f=true; } j=next_a[j]; } } } } if(mt[n]==-1){ cout << -1 << endl; }else{ cout << mt[n]+h[n]-mh[n] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:53:58: error: 't' was not declared in this scope 53 | if(mh[i]>h[b[j]]+t[j]){ | ^
s392903290
p00524
C++
#include<iostream> #include<queue> #include<algorithm> #include<string> #include<vector> #include<cstdio> using namespace std; #define N 100000 #define M 300000 #define HT 1000000000 #define INF 2e18 #define int long long #define MP(i, j) make_pair((i), (j)) typedef pair<int, int> P; int n, m, x, ans = INF, tree[N + 1]; vector<P> g[N + 1]; int flag[N + 1] = {}; priority_queue<S> pq; struct S { int to, fr, ti, nh; S(int i_fr, int i_to, int i_ti, int i_nh) : to(i_to), fr(i_fr), ti(i_ti), nh(i_nh) {} bool operator < (const S & s)const { if(ti != s.ti) return ti > s.ti; } }; void dijkstra(int sta) { for (int i = 0; i < g[1].size(); i++) { if (tree[1] >= g[1][i].second) { if (sta >= g[1][i].second) { if (sta > g[1][i].second + tree[g[1][i].first]) { pq.push({ 1, g[1][i].first, sta - tree[g[1][i].first], tree[g[1][i].first] }); } else { pq.push({ 1, g[1][i].first, g[1][i].second, sta - g[1][i].second }); } } else { if (abs(sta - g[1][i].second) <= tree[1]) pq.push({ 1, g[1][i].first, abs(sta - g[1][i].second) + g[1][i].second, 0 }); } } } while (!pq.empty()) { S s = pq.top(); pq.pop(); if (flag[s.to] && flag[s.to] < s.ti) continue; flag[s.to] = s.ti; if (s.to == n) { ans = min(ans, tree[n] - s.nh + flag[s.to]); break; } for (int i = 0; i < g[s.to].size(); i++) { if (tree[s.to] >= g[s.to][i].second) { if (s.nh >= g[s.to][i].second) { if (s.nh > g[s.to][i].second + tree[g[s.to][i].first]) { pq.push({ s.to, g[s.to][i].first, s.nh - tree[g[s.to][i].first] + s.ti, tree[g[s.to][i].first] }); } else { pq.push({ s.to, g[s.to][i].first, g[s.to][i].second + s.ti, s.nh - g[s.to][i].second }); } } else { if (g[s.to][i].second - s.nh <= tree[s.to]) pq.push({ s.to, g[s.to][i].first, g[s.to][i].second - s.nh+ g[s.to][i].second + s.ti, 0 }); } } } } } signed main() { scanf("%lld%lld%lld", &n, &m, &x); for (int i = 1; i <= n; i++) scanf("%lld", tree + i); for (int i = 0; i < m; i++) { int a, b, c; scanf("%lld%lld%lld", &a, &b, &c); g[a].push_back(MP(b, c)); g[b].push_back(MP(a, c)); } dijkstra(x); if (ans != INF) cout << ans << endl; else cout << -1 << endl; }
a.cc:18:16: error: 'S' was not declared in this scope 18 | priority_queue<S> pq; | ^ a.cc:18:17: error: template argument 1 is invalid 18 | priority_queue<S> pq; | ^ a.cc:18:17: error: template argument 2 is invalid a.cc:18:17: error: template argument 3 is invalid a.cc: In function 'void dijkstra(long long int)': a.cc:33:44: error: request for member 'push' in 'pq', which is of non-class type 'int' 33 | pq.push({ 1, g[1][i].first, sta - tree[g[1][i].first], tree[g[1][i].first] }); | ^~~~ a.cc:36:44: error: request for member 'push' in 'pq', which is of non-class type 'int' 36 | pq.push({ 1, g[1][i].first, g[1][i].second, sta - g[1][i].second }); | ^~~~ a.cc:41:44: error: request for member 'push' in 'pq', which is of non-class type 'int' 41 | pq.push({ 1, g[1][i].first, abs(sta - g[1][i].second) + g[1][i].second, 0 }); | ^~~~ a.cc:45:20: error: request for member 'empty' in 'pq', which is of non-class type 'int' 45 | while (!pq.empty()) { | ^~~~~ a.cc:46:26: error: request for member 'top' in 'pq', which is of non-class type 'int' 46 | S s = pq.top(); | ^~~ a.cc:47:20: error: request for member 'pop' in 'pq', which is of non-class type 'int' 47 | pq.pop(); | ^~~ a.cc:58:52: error: request for member 'push' in 'pq', which is of non-class type 'int' 58 | pq.push({ s.to, g[s.to][i].first, s.nh - tree[g[s.to][i].first] + s.ti, tree[g[s.to][i].first] }); | ^~~~ a.cc:61:52: error: request for member 'push' in 'pq', which is of non-class type 'int' 61 | pq.push({ s.to, g[s.to][i].first, g[s.to][i].second + s.ti, s.nh - g[s.to][i].second }); | ^~~~ a.cc:66:52: error: request for member 'push' in 'pq', which is of non-class type 'int' 66 | pq.push({ s.to, g[s.to][i].first, g[s.to][i].second - s.nh+ g[s.to][i].second + s.ti, 0 }); | ^~~~
s033668292
p00524
C++
#include<bits/stdc++.h> #define int long long #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef pair<int, int>P; typedef long long ll; struct st { int p, h; ll c; }; bool operator<(st a, st b) { return a.c > b.c; } int h[100000], cnt[100000], s[100000]; unordered_map<int, ll>d[100000]; vector<P>E[100000]; bool b[100000]; int main() { int n, m, x; scanf("%lld%lld%lld", &n, &m, &x); rep(i, n)scanf("%lld", &h[i]); rep(i, m) { int a, b, t; scanf("%lld%lld%lld", &a, &b, &t); a--; b--; if (t <= h[a])E[a].push_back(P(t, b)); if (t <= h[b])E[b].push_back(P(t, a)); } priority_queue<st>que; d[0][x] = 0; que.push({ 0,x,0 }); while (!que.empty()) { st s = que.top(); que.pop(); if (d[s.p][s.h] != s.c)continue; for (P u : E[s.p]) { if (b[u.second])continue; if (u.first > h[s.p])continue; int t = 0, k = s.h - u.first; if (k < 0)t = 0 - k, k = 0; if (k > h[u.second])t = k - h[u.second], k = h[u.second]; if ((d[u.second].find(k) == d[u.second].end()) || (d[u.second][k] > s.c + u.first + t)) { d[u.second][k] = s.c + u.first + t; que.push({ u.second,k,d[u.second][k] }); } } } ll Min = LLONG_MAX; for (auto p : d[n - 1]) { Min = min(Min, p.second + h[n - 1] - p.first); } if (Min == LLONG_MAX)puts("-1"); else printf("%lld\n", Min); }
cc1plus: error: '::main' must return 'int'
s514890708
p00524
C++
#include<bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef pair<int, int>P; typedef long long ll; struct st { int p, h; ll c; }; bool operator<(st a, st b) { return a.c > b.c; } int h[100000], s[100000]; ll d[100000][1000]; vector<P>E[100000]; int main() { int n, m, x; scanf("%d%d%d", &n, &m, &x); rep(i, n)scanf("%d", &h[i]); rep(i, m) { int a, b, t; scanf("%d%d%d", &a, &b, &t); a--; b--; if (t <= h[a])E[a].push_back(P(t, b)); if (t <= h[b])E[b].push_back(P(t, a)); } priority_queue<st>que; d[0][0] = 0; que.push({ 0,x,0 }); while (!que.empty()) { st s = que.top(); que.pop(); if (s.c < 0)abort(); if (d[s.p][s.h] != s.c)continue; for (P u : E[s.p]) { int t = 0, k = s.h - u.first; if (k < 0)t = 0 - k, k = 0; if (k > h[u.second])t = k - h[u.second], k = h[u.second]; if (d[u.second][k] > s.c + u.first + t) { d[u.second][k] = s.c + u.first + t; que.push({ u.second,k,d[u.second][k] }); } } } ll Min = LLONG_MAX; for (auto p : d[n - 1]) { Min = min(Min, p.second + h[n - 1] - p.first); } if (Min == LLONG_MAX)puts("-1"); else printf("%lld\n", Min); }
a.cc: In function 'int main()': a.cc:41:34: error: request for member 'second' in 'p', which is of non-class type 'long long int' 41 | Min = min(Min, p.second + h[n - 1] - p.first); | ^~~~~~ a.cc:41:56: error: request for member 'first' in 'p', which is of non-class type 'long long int' 41 | Min = min(Min, p.second + h[n - 1] - p.first); | ^~~~~
s850583485
p00524
C++
#include <iostream> #include <vector> #include <queue> #define INF 1e+18 #define int long long using namespace std; struct edge{ int to,cost; }; typedef pair<int,int> P; signed main(){ int n,m,x,h[100000]; int d[100000]; vector<edge> G[100000]; cin >> n >> m >> x; for(int i = 0;i < n;i++) { cin >> h[i]; d[i] = INF; } d[0] = 0; for(int i = 0;i < m;i++){ int a,b,c; cin >> a >> b >> c; if(h[a - 1] >= c) G[a - 1].push_back({b - 1,c}); if(h[b - 1] >= c) G[b - 1].push_back({a - 1,c}); } priority_queue<P,vector<P>,greater<P> > que; que.push(P(0,0)); while(!que.empty()){ P p = que.top();que.pop(); int v = p.second,nowh = x - d[v]; if(d[v] < p.first) continue; for(int i = 0;i < G[v].size();i++){ edge e = G[v][i]; if(h[e.to] + e.cost < nowh){ if(x - h[e.to] < d[e.to]){ d[e.to] = x - h[e.to]; que.push(P(d[e.to],e.to)); } } else if(nowh > 0 && nowh < e.cost){ if(d[v] + e.cost - nowh + e.cost < d[e.to]){ d[e.to] = d[v] + e.cost - nowh + e.cost; que.push(P(d[e.to],e.to)); } }else if(nowh >= e.cost){ if(d[v] + e.cost < d[e.to]){ d[e.to] = d[v] + e.cost; que.push(P(d[e.to],e.to)); } } else{ if(d[v] + e.cost * 2 < d[e.to]){ d[e.to] = d[v] + e.cost * 2; que.push(P(d[e.to],e.to)); } } } } if(d[n - 1] == INF) cout << -1 << endl; else cout << d[n - 1] + h[n - 1] - max(0,x - d[n - 1]) << endl; return 0; }
a.cc: In function 'int main()': a.cc:61:47: error: no matching function for call to 'max(int, long long int)' 61 | else cout << d[n - 1] + h[n - 1] - max(0,x - d[n - 1]) << endl; | ~~~^~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/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:47: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 61 | else cout << d[n - 1] + h[n - 1] - max(0,x - d[n - 1]) << endl; | ~~~^~~~~~~~~~~~~~~~ /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
s457171080
p00524
C++
#include <stdio.h> #include <vector> #include <utility> #include <queue> #include <bitset> using namespace std; typedef pair<int,long long int> pi; typedef pair<long long int,pi> plpi; #define F first #define S second #define PB push_back const int N=1e5+10; const long long int INF=1LL<<60; int main(){ int n,m,l,r; long long int ans=INF,dis[N],d,h[N],x; bitset<N>went; queue<plpi>q; priority_queue<plpi,vector<plpi>,greater<plpi>>pq; plpi nxt; vector<pi> graph[N]; scanf("%d%d%lld",&n,&m,&x); for(int i=1;i<=n;i++){ scanf("%lld",&h[i]); dis[i]=INF; } while(m--){ scanf("%d%d%lld",&l,&r,&d); if(h[l]-d>=0)graph[l].PB({r,d}); if(h[r]-d>=0)graph[r].PB({l,d}); } went.reset(); pq.push({0LL,{1,x}}); while(!pq.empty()){ nxt=pq.top(); pq.pop(); if(nxt.F>=ans)continue; if(nxt.S.F==n){ ans=min(ans,nxt.F+h[n]-nxt.S.S); break; } else if(nxt.S.S==0){ if(!went[nxt.S.F]&&dis[nxt.S.F]>=nxt.F){ went[nxt.S.F]=true; for(pi i:graph[nxt.S.F])if(nxt.F+i.S*2<dis[i.F]){ dis[i.F]=nxt.F+i.S*2; pq.push({nxt.F+i.S*2,{i.F,0}}); } } } else if(!went[nxt.S.F]){ for(pi i:graph[nxt.S.F])if({ if(nxt.S.S-i.S<0){ if(dis[i.F]>nxt.F-nxt.S.S+i.S*2){ dis[i.F]=nxt.F-nxt.S.S+i.S*2; pq.push({nxt.F-nxt.S.S+i.S*2,{i.F,0}}); } } else if(nxt.S.S-i.S>h[i.F]){ if(dis[i.F]>nxt.F+nxt.S.S-h[i.F]*2){ dis[i.F]=min(dis[i.F],nxt.F+nxt.S.S); pq.push({nxt.F+nxt.S.S-h[i.F],{i.F,h[i.F]}}); } } else { if(dis[i.F]>nxt.F+i.S*2-nxt.S.S){ dis[i.F]=min(dis[i.F],nxt.S.S+nxt.F); pq.push({nxt.F+i.S,{i.F,nxt.S.S-i.S}}); } } } } } if(ans==INF)printf("-1\n"); else printf("%lld\n",ans); }
a.cc: In function 'int main()': a.cc:52:40: error: expected primary-expression before '{' token 52 | for(pi i:graph[nxt.S.F])if({ | ^ a.cc:52:40: error: expected ')' before '{' token 52 | for(pi i:graph[nxt.S.F])if({ | ~^ | ) a.cc:72:9: error: expected primary-expression before '}' token 72 | } | ^
s926830248
p00524
C++
#include <stdio.h> #include <vector> #include <utility> #include <queue> #include <bitset> using namespace std; typedef pair<int,long long int> pi; typedef pair<long long int,pi> plpi; #define F first #define S second #define PB push_back const int N=1e5+10; const long long int INF=1LL<<60; int main(){ int n,m,l,r; long long int ans=INF,dis[N],d,h[N],x; bitset<N>went; queue<plpi>q; priority_queue<plpi,vector<plpi>,greater<plpi>>pq; plpi nxt; vector<pi> graph[N]; scanf("%d%d%lld",&n,&m,&x); for(int i=1;i<=n;i++){ scanf("%lld",&h[i]); dis[i]=INF; } while(m--){ scanf("%d%d%lld",&l,&r,&d); if(h[l]-d>=0)graph[l].PB({r,d}); if(h[r]-d>=0)graph[r].PB({l,d}); } went.reset(); pq.push({0LL,{1,x}}); while(!pq.empty()){ nxt=pq.top(); pq.pop(); if(nxt.F>=ans)continue; if(nxt.S.F==n){ ans=min(ans,nxt.F+h[n]-nxt.S.S); break; } else if(nxt.S.S==0){ if(!went[nxt.S.F]&&dis[nxt.S.F]>=nxt.F){ went[nxt.S.F]=true; for(pi i:graph[nxt.S.F])if(nxt.F+i.S*2<dis[i.F]){ dis[i.F]=nxt.F+i.S*2; pq.push({nxt.F+i.S*2,{i.F,0}}); } } } else if(!went[nxt.S.F]){ for(pi i:graph[nxt.S.F]) if(nxt.S.S-i.S<0){ if(dis[i.F]>nxt.F-nxt.S.S+i.S*2){ dis[i.F]=nxt.F-nxt.S.S+i.S*2; pq.push({nxt.F-nxt.S.S+i.S*2,{i.F,0}}); } } else if(nxt.S.S-i.S>h[i.F]){ if(dis[i.F]>nxt.F+nxt.S.S-h[i.F]*2){ dis[i.F]=min(dis[i.F],nxt.F+nxt.S.S); pq.push({nxt.F+nxt.S.S-h[i.F],{i.F,h[i.F]}}); } } else { if(dis[i.F]>nxt.F+i.S*2-nxt.S.S){ dis[i.F]=min(dis[i.F],nxt.S.S+nxt.F); pq.push({nxt.F+i.S,{i.F,nxt.S.S-i.S}}); } } } } } if(ans==INF)printf("-1\n"); else printf("%lld\n",ans); }
a.cc:74:5: error: expected unqualified-id before 'if' 74 | if(ans==INF)printf("-1\n"); | ^~ a.cc:75:5: error: expected unqualified-id before 'else' 75 | else printf("%lld\n",ans); | ^~~~ a.cc:76:1: error: expected declaration before '}' token 76 | } | ^
s226976536
p00524
C++
#include <stdio.h> #include <vector> #include <utility> #include <queue> #include <bitset> using namespace std; typedef pair<int,long long int> pi; typedef pair<long long int,pi> plpi; #define F first #define S second #define PB push_back const int N=1e5+10; const long long int INF=1LL<<60; int main(){ int n,m,l,r; long long int ans=INF,dis[N],d,h[N],x; bitset<N>went; queue<plpi>q; priority_queue<plpi,vector<plpi>,greater<plpi>>pq; plpi nxt; vector<pi> graph[N]; scanf("%d%d%lld",&n,&m,&x); for(int i=1;i<=n;i++){ scanf("%lld",&h[i]); dis[i]=INF; } while(m--){ scanf("%d%d%lld",&l,&r,&d); if(h[l]-d>=0)graph[l].PB({r,d}); if(h[r]-d>=0)graph[r].PB({l,d}); } went.reset(); pq.push({0LL,{1,x}}); while(!pq.empty()){ nxt=pq.top(); pq.pop(); if(nxt.F>=ans)continue; if(nxt.S.F==n){ ans=min(ans,nxt.F+h[n]-nxt.S.S); break; } else if(nxt.S.S==0){ if(!went[nxt.S.F]&&dis[nxt.S.F]>=nxt.F){ went[nxt.S.F]=true; for(pi i:graph[nxt.S.F])if(nxt.F+i.S*2<dis[i.F]){ dis[i.F]=nxt.F+i.S*2; pq.push({nxt.F+i.S*2,{i.F,0}}); } } } else if(!went[nxt.S.F]){ went[nxt.S.F]=true; for(pi i:graph[nxt.S.F])if({ if(nxt.S.S-i.S<0){ if(dis[i.F]>nxt.F-nxt.S.S+i.S*2){ dis[i.F]=nxt.F-nxt.S.S+i.S*2; pq.push({nxt.F-nxt.S.S+i.S*2,{i.F,0}}); } } else if(nxt.S.S-i.S>h[i.F]){ if(dis[i.F]>nxt.F+nxt.S.S-h[i.F]*2){ dis[i.F]=min(dis[i.F],nxt.F+nxt.S.S); pq.push({nxt.F+nxt.S.S-h[i.F],{i.F,h[i.F]}}); } } else { if(dis[i.F]>nxt.F+i.S*2-nxt.S.S){ dis[i.F]=min(dis[i.F],nxt.S.S+nxt.F); pq.push({nxt.F+i.S,{i.F,nxt.S.S-i.S}}); } } } } } if(ans==INF)printf("-1\n"); else printf("%lld\n",ans); }
a.cc: In function 'int main()': a.cc:53:40: error: expected primary-expression before '{' token 53 | for(pi i:graph[nxt.S.F])if({ | ^ a.cc:53:40: error: expected ')' before '{' token 53 | for(pi i:graph[nxt.S.F])if({ | ~^ | ) a.cc:73:9: error: expected primary-expression before '}' token 73 | } | ^
s825056959
p00525
C++
#pragma comment(linker, "/STACK:36777216") //#pragma GCC optimize ("O2") #define LOCAL //#include "testlib.h" #include <functional> #include <algorithm> #include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <numeric> #include <cstring> #include <climits> #include <cassert> #include <complex> #include <cstdio> #include <string> #include <vector> #include <bitset> #include <queue> #include <stack> #include <cmath> #include <ctime> #include <list> #include <set> #include <map> //#include <tr1/unordered_set> //#include <tr1/unordered_map> //#include <array> using namespace std; #define REP(i, n) for (int i=0;i<n;++i) #define FOR(i, a, b) for (int i=a;i<b;++i) #define DWN(i, b, a) for (int i=b-1;i>=a;--i) #define REP_1(i, n) for (int i=1;i<=n;++i) #define FOR_1(i, a, b) for (int i=a;i<=b;++i) #define DWN_1(i, b, a) for (int i=b;i>=a;--i) #define REP_C(i, n) for (int n____=n,i=0;i<n____;++i) #define FOR_C(i, a, b) for (int b____=b,i=a;i<b____;++i) #define DWN_C(i, b, a) for (int a____=a,i=b-1;i>=a____;--i) #define REP_N(i, n) for (i=0;i<n;++i) #define FOR_N(i, a, b) for (i=a;i<b;++i) #define DWN_N(i, b, a) for (i=b-1;i>=a;--i) #define REP_1_C(i, n) for (int n____=n,i=1;i<=n____;++i) #define FOR_1_C(i, a, b) for (int b____=b,i=a;i<=b____;++i) #define DWN_1_C(i, b, a) for (int a____=a,i=b;i>=a____;--i) #define REP_1_N(i, n) for (i=1;i<=n;++i) #define FOR_1_N(i, a, b) for (i=a;i<=b;++i) #define DWN_1_N(i, b, a) for (i=b;i>=a;--i) #define REP_C_N(i, n) for (int n____=(i=0,n);i<n____;++i) #define FOR_C_N(i, a, b) for (int b____=(i=0,b);i<b____;++i) #define DWN_C_N(i, b, a) for (int a____=(i=b-1,a);i>=a____;--i) #define REP_1_C_N(i, n) for (int n____=(i=1,n);i<=n____;++i) #define FOR_1_C_N(i, a, b) for (int b____=(i=a,b);i<=b____;++i) #define DWN_1_C_N(i, b, a) for (int a____=(i=b,a);i>=a____;--i) #define ECH(it, A) for (__typeof((A).begin()) it=(A).begin(); it != (A).end(); ++it) #define rECH(it, A) for (__typeof((A).rbegin()) it=(A).rbegin(); it != (A).rend(); ++it) #define REP_S(i, str) for (char*i=str;*i;++i) #define REP_L(i, hd, suc) for (int i=hd;i;i=suc[i]) #define REP_G(i, u) REP_L(i,hd[u],suc) #define REP_SS(x, s) for (int x=s;x;x=(x-1)&s) #define DO(n) for ( int ____n = n; ____n-->0; ) #define REP_2(i, j, n, m) REP(i, n) REP(j, m) #define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m) #define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l) #define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l) #define REP_4(i, j, k, ii, n, m, l, nn) REP(i, n) REP(j, m) REP(k, l) REP(ii, nn) #define REP_4_1(i, j, k, ii, n, m, l, nn) REP_1(i, n) REP_1(j, m) REP_1(k, l) REP_1(ii, nn) #define ALL(A) A.begin(), A.end() #define LLA(A) A.rbegin(), A.rend() #define CPY(A, B) memcpy(A, B, sizeof(A)) #define INS(A, P, B) A.insert(A.begin() + P, B) #define ERS(A, P) A.erase(A.begin() + P) #define LBD(A, x) (lower_bound(ALL(A), x) - A.begin()) #define UBD(A, x) (upper_bound(ALL(A), x) - A.begin()) #define CTN(T, x) (T.find(x) != T.end()) #define SZ(A) int((A).size()) #define PB push_back #define MP(A, B) make_pair(A, B) #define PTT pair<T, T> #define Ts *this #define rTs return Ts #define fi first #define se second #define re real() #define im imag() #define Rush for(int ____T=RD(); ____T--;) #define Display(A, n, m) { \ REP(i, n){ \ REP(j, m-1) cout << A[i][j] << " "; \ cout << A[i][m-1] << endl; \ } \ } #define Display_1(A, n, m) { \ REP_1(i, n){ \ REP_1(j, m-1) cout << A[i][j] << " "; \ cout << A[i][m] << endl; \ } \ } typedef long long LL; //typedef long double DB; typedef double DB; typedef unsigned uint; typedef unsigned long long uLL; typedef vector<int> VI; typedef vector<char> VC; typedef vector<string> VS; typedef vector<LL> VL; typedef vector<DB> VF; typedef set<int> SI; typedef set<string> SS; typedef map<int, int> MII; typedef map<string, int> MSI; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef vector<PII> VII; typedef vector<VI> VVI; typedef vector<VII> VVII; template<class T> inline T& RD(T &); template<class T> inline void OT(const T &); //inline int RD(){int x; return RD(x);} inline LL RD(){LL x; return RD(x);} inline DB& RF(DB &); inline DB RF(){DB x; return RF(x);} inline char* RS(char *s); inline char& RC(char &c); inline char RC(); inline char& RC(char &c){scanf(" %c", &c); return c;} inline char RC(){char c; return RC(c);} //inline char& RC(char &c){c = getchar(); return c;} //inline char RC(){return getchar();} template<class T> inline T& RDD(T &); inline LL RDD(){LL x; return RDD(x);} template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;} template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;} template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;} template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;} template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;} template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);} template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);} template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);} template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);} inline char& RC(char &a, char &b){RC(a), RC(b); return a;} inline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;} inline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;} inline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;} inline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;} inline void RS(char *s1, char *s2){RS(s1), RS(s2);} inline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);} template<class T0,class T1>inline T0& RDD(T0&a, T1&b){RDD(a),RDD(b); return a;} template<class T0,class T1,class T2>inline T1& RDD(T0&a, T1&b, T2&c){RDD(a),RDD(b),RDD(c); return a;} template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));} template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));} template<class T> inline void CLR(T &A){A.clear();} template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);} template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);} template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);} template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);} template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);} template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);} template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);} template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);} template<class T> inline void CLR(priority_queue<T, vector<T>, less<T> > &Q){while (!Q.empty()) Q.pop();} template<class T> inline void CLR(priority_queue<T, vector<T>, greater<T> > &Q){while (!Q.empty()) Q.pop();} template<class T> inline void CLR(stack<T> &S){while (!S.empty()) S.pop();} template<class T> inline void CLR(queue<T> &Q){while (!Q.empty()) Q.pop();} template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);} template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);} template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);} template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);} template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);} template<class T> inline bool EPT(T &a){return a.empty();} template<class T> inline T& SRT(T &A){sort(ALL(A)); return A;} template<class T, class C> inline T& SRT(T &A, C B){sort(ALL(A), B); return A;} template<class T> inline T& RVS(T &A){reverse(ALL(A)); return A;} template<class T> inline T& UNQQ(T &A){A.resize(unique(ALL(A))-A.begin());return A;} template<class T> inline T& UNQ(T &A){SRT(A);return UNQQ(A);} //} /** Constant List .. **/ //{ const int MOD = int(1e9) + 7; const int INF = 0x3f3f3f3f; const LL INFF = 0x3f3f3f3f3f3f3f3fLL; const DB EPS = 1e-9; const DB OO = 1e20; const DB PI = acos(-1.0); //M_PI; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; //} /** Add On .. **/ //{ // <<= '0. Nichi Joo ., //{ template<class T> inline bool checkMin(T &a,const T b){return b < a ? a = b, 1 : 0;} template<class T> inline bool checkMax(T &a,const T b){return a < b ? a = b, 1 : 0;} template <class T, class C> inline bool checkUpd(T& a, const T b, C c){return c(b,a) ? a = b, 1 : 0;} template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);} template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);} template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));} template<class T> inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));} template<class T> inline T min(T a, T b, T c, T d, T e){return min(min(min(a,b),min(c,d)),e);} template<class T> inline T max(T a, T b, T c, T d, T e){return max(max(max(a,b),max(c,d)),e);} template<class T> inline T sqr(T a){return a*a;} template<class T> inline T cub(T a){return a*a*a;} template<class T> inline T ceil(T x, T y){return (x - 1) / y + 1;} template<class T> T abs(T x){return x>0?x:-x;} inline int sgn(DB x){return x < -EPS ? -1 : x > EPS;} inline int sgn(DB x, DB y){return sgn(x - y);} inline DB cos(DB a, DB b, DB c){return (sqr(a)+sqr(b)-sqr(c))/(2*a*b);} inline DB cot(DB x){return 1./tan(x);}; inline DB sec(DB x){return 1./cos(x);}; inline DB csc(DB x){return 1./sin(x);}; //} //} /** I/O Accelerator Interface .. **/ //{ #define g (c=getchar()) #define d isdigit(g) #define p x=x*10+c-'0' #define n x=x*10+'0'-c #define pp l/=10,p #define nn l/=10,n template<class T> inline T& RD(T &x){ char c;while(!d);x=c-'0';while(d)p; return x; } template<class T> inline T& RDD(T &x){ char c;while(g,c!='-'&&!isdigit(c)); if (c=='-'){x='0'-g;while(d)n;} else{x=c-'0';while(d)p;} return x; } inline DB& RF(DB &x){ //scanf("%lf", &x); char c;while(g,c!='-'&&c!='.'&&!isdigit(c)); if(c=='-')if(g=='.'){x=0;DB l=1;while(d)nn;x*=l;} else{x='0'-c;while(d)n;if(c=='.'){DB l=1;while(d)nn;x*=l;}} else if(c=='.'){x=0;DB l=1;while(d)pp;x*=l;} else{x=c-'0';while(d)p;if(c=='.'){DB l=1;while(d)pp;x*=l;}} return x; } #undef nn #undef pp #undef n #undef p #undef d #undef g inline char* RS(char *s){ //gets(s); scanf("%s", s); return s; } LL last_ans; int Case; template<class T> inline void OT(const T &x){ //printf("Case #%d: ", ++Case); //printf("%lld\n", x); //printf("%.9f\n", x); //printf("%d\n", x); cout << x << endl; //last_ans = x; } //}/* .................................................................................................................................. */ const int MAXN = 100020; struct seg_tree { static const int DEPTH = 19; static const int SIZE = 1<<DEPTH; int bit[1<<(DEPTH+1)]; int renew[1<<(DEPTH+1)]; seg_tree() { } void init() { for(int i=0;i<2*SIZE;i++) bit[i] = renew[i] = 0; } void add(int p, int v) { p += SIZE; while(p){ bit[p] += v; p >>= 1; } } int query(int l, int r) { l += SIZE; r += SIZE; int ret = 0; while(l < r){ if(l&1) ret += bit[l++]; if(r&1) ret += bit[--r]; l >>= 1; r >>= 1; } return ret; } void set_renew(int l, int r) { l += SIZE; r += SIZE; while(l < r){ if(l&1) renew[l++] = 1; if(r&1) renew[--r] = 1; l >>= 1; r >>= 1; } } bool is_renew(int p) { p += SIZE; while(p){ if(renew[p]) return true; p >>= 1; } return false; } void unset_renew(int p) { p += SIZE; for(int i=DEPTH-1;i>0;i--){ if(renew[p >> i]){ renew[p >> i] = 0; renew[(p>>i)*2] = renew[(p>>i)*2+1] = 1; } } renew[p] = 0; } }; struct action { int pos, act, left, right; action(int p, int a, int l, int r) { pos = p; act = a; left = l; right = r; } }; inline bool operator<(const action& a, const action& b) { return a.pos < b.pos || (a.pos == b.pos && a.act < b.act); } int W, H, N; int x1[MAXN], y1[MAXN], x2[MAXN], y2[MAXN]; vector<int> uf; seg_tree seg; int target[MAXN*2]; int root(int p) { return (uf[p] < 0) ? p : (uf[p] = root(uf[p])); } bool join(int p, int q) { p = root(p); q = root(q); if(p==q) return false; if(uf[p] < uf[q]) swap(p, q); uf[p] = uf[q]; uf[q] = p; return true; } void adjust(int p) { if(seg.is_renew(p)){ uf.push_back(-1); seg.unset_renew(p); target[p] = uf.size() - 1; } } int main() { #ifndef ONLINE_JUDGE //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); #endif scanf("%d%d%d", &W, &H, &N); for(int i=0;i<N;i++){ scanf("%d%d%d%d", x1+i, y1+i, x2+i, y2+i); if(x1[i] > x2[i]) swap(x1[i], x2[i]); if(y1[i] > y2[i]) swap(y1[i], y2[i]); } for(int i=0;i<2*N;i++) target[i] = -1; x1[N ] = 0; y1[N ] = 0; x2[N ] = W; y2[N ] = 0; x1[N+1] = 0; y1[N+1] = 0; x2[N+1] = 0; y2[N+1] = H; x1[N+2] = W; y1[N+2] = 0; x2[N+2] = W; y2[N+2] = H; x1[N+3] = 0; y1[N+3] = H; x2[N+3] = W; y2[N+3] = H; N += 4; vector<int> xs; for(int i=0;i<N;i++){ xs.push_back(x1[i]); xs.push_back(x2[i]); } xs.push_back(-1); sort(xs.begin(), xs.end()); xs.erase(unique(xs.begin(), xs.end()), xs.end()); for(int i=0;i<N;i++){ x1[i] = lower_bound(xs.begin(), xs.end(), x1[i]) - xs.begin(); x2[i] = lower_bound(xs.begin(), xs.end(), x2[i]) - xs.begin(); } set<int> S; S.insert(0); target[0] = 0; uf.push_back(-1); vector<action> A; for(int i=0;i<N;i++){ if(x1[i] == x2[i]){ A.push_back(action(y1[i], 0, x1[i], -1)); A.push_back(action(y2[i], 2, x1[i], -1)); }else{ A.push_back(action(y1[i], 1, x1[i], x2[i])); } } sort(A.begin(), A.end()); long long ret = 0; for(int i=0;i<A.size();i++){ action V = A[i]; if(V.act == 0){ int lf = *--S.lower_bound(V.left); adjust(lf); adjust(V.left); target[V.left] = target[lf]; S.insert(V.left); seg.add(V.left, 1); }else if(V.act == 1){ int count = seg.query(V.left, V.right+1); if(count < 2) continue; ret += count - 1; seg.set_renew(V.left, *--S.upper_bound(V.right)); }else if(V.act == 2){ int lf = *--S.lower_bound(V.left); adjust(lf); adjust(V.left); if(join(target[lf], target[V.left])) --ret; S.erase(V.left); seg.add(V.left, -1); } //cout << V.act << " " << ret << endl; } printf("%lld\n", ret); return 0; }
a.cc:399:22: error: 'int y1 [100020]' redeclared as different kind of entity 399 | int x1[MAXN], y1[MAXN], x2[MAXN], y2[MAXN]; | ^ 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/functional:48, from a.cc:5: /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:444:43: warning: pointer to a function used in arithmetic [-Wpointer-arith] 444 | scanf("%d%d%d%d", x1+i, y1+i, x2+i, y2+i); | ~~^~ a.cc:446:24: warning: pointer to a function used in arithmetic [-Wpointer-arith] 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ^ a.cc:446:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~~~^~~~~~~ a.cc:446:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ^ a.cc:446:39: error: no matching function for call to 'swap(double (&)(double) noexcept, int&)' 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:7: /usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ^~~~ /usr/include/c++/14/bits/exception_ptr.h:229:25: note: no known conversion for argument 1 from 'double(double) noexcept' to 'std::__exception_ptr::exception_ptr&' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ~~~~~~~~~~~~~~~^~~~~ In file included from a.cc:9: /usr/include/c++/14/sstream:1204:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_stringbuf<_CharT, _Traits, _Alloc>&, basic_stringbuf<_CharT, _Traits, _Alloc>&)' 1204 | swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1204:5: note: template argument deduction/substitution failed: a.cc:446:39: note: mismatched types 'std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>' and 'double(double) noexcept' 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/sstream:1212:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_istringstream<_CharT, _Traits, _Allocator>&, basic_istringstream<_CharT, _Traits, _Allocator>&)' 1212 | swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1212:5: note: template argument deduction/substitution failed: a.cc:446:39: note: mismatched types 'std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>' and 'double(double) noexcept' 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/sstream:1219:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_ostringstream<_CharT, _Traits, _Allocator>&, basic_ostringstream<_CharT, _Traits, _Allocator>&)' 1219 | swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1219:5: note: template argument deduction/substitution failed: a.cc:446:39: note: mismatched types 'std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>' and 'double(double) noexcept' 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/sstream:1226:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_stringstream<_CharT, _Traits, _Allocator>&, basic_stringstream<_CharT, _Traits, _Allocator>&)' 1226 | swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1226:5: note: template argument deduction/substitution failed: a.cc:446:39: note: mismatched types 'std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>' and 'double(double) noexcept' 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_function.h:60, from /usr/include/c++/14/functional:49: /usr/include/c++/14/bits/move.h:226:5: note: candidate: 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)' 226 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/14/bits/move.h:226:5: note: template argument deduction/substitution failed: a.cc:446:39: note: deduced conflicting types for parameter '_Tp' ('double(double) noexcept' and 'int') 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])' 250 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) | ^~~~ /usr/include/c++/14/bits/move.h:250:5: note: template argument deduction/substitution failed: a.cc:446:39: note: mismatched types '_Tp [_Nm]' and 'double(double) noexcept' 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/tuple:38, from /usr/include/c++/14/functional:53: /usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' 1089 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: template argument deduction/substitution failed: a.cc:446:39: note: mismatched types 'std::pair<_T1, _T2>' and 'double(double) noexcept' 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted) 1106 | swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: template argument deduction/substitution failed: a.cc:446:39: note: mismatched types 'std::pair<_T1, _T2>' and 'double(double) noexcept' 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' 2805 | swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y) | ^~~~ /usr/include/c++/14/tuple:2805:5: note: template argument deduction/substitution failed: a.cc:446:39: note: mismatched types 'std::tuple<_UTypes ...>' and 'double(double) noexcept' 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted) 2823 | swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete; | ^~~~ /usr/include/c++/14/tuple:2823:5: note: template argument deduction/substitution failed: a.cc:446:39: note: mismatched types 'std::tuple<_UTypes ...>' and 'double(double) noexcept' 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/functional:59: /usr/include/c++/14/bits/std_function.h:782:5: note: candidate: 'template<class _Res, class ... _Args> void std::swap(function<_Res(_ArgTypes ...)>&, function<_Res(_ArgTypes ...)>&)' 782 | swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y) noexcept | ^~~~ /usr/include/c++/14/bits/std_function.h:782:5: note: template argument deduction/substitution failed: a.cc:446:39: note: mismatched types 'std::function<_Res(_ArgTypes ...)>' and 'double(double) noexcept' 446 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63: /usr/include/c++/14/bits/unordered_map.h:2130:5: note: candidate: 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> void std::swap(unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&, unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&)' 2130 | swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, | ^~~~ /usr/include/c++/14/bits/unordered_map.h:2130:5: note: template argument deduction/substitution failed: a.cc:446:39: note: m
s500505044
p00525
C++
#pragma comment(linker, "/STACK:36777216") //#pragma GCC optimize ("O2") #define LOCAL //#include "testlib.h" #include<iostream> #include<cstdio> #include<algorithm> #include<set> #include<vector> //#include <tr1/unordered_set> //#include <tr1/unordered_map> //#include <array> using namespace std; #define REP(i, n) for (int i=0;i<n;++i) #define FOR(i, a, b) for (int i=a;i<b;++i) #define DWN(i, b, a) for (int i=b-1;i>=a;--i) #define REP_1(i, n) for (int i=1;i<=n;++i) #define FOR_1(i, a, b) for (int i=a;i<=b;++i) #define DWN_1(i, b, a) for (int i=b;i>=a;--i) #define REP_C(i, n) for (int n____=n,i=0;i<n____;++i) #define FOR_C(i, a, b) for (int b____=b,i=a;i<b____;++i) #define DWN_C(i, b, a) for (int a____=a,i=b-1;i>=a____;--i) #define REP_N(i, n) for (i=0;i<n;++i) #define FOR_N(i, a, b) for (i=a;i<b;++i) #define DWN_N(i, b, a) for (i=b-1;i>=a;--i) #define REP_1_C(i, n) for (int n____=n,i=1;i<=n____;++i) #define FOR_1_C(i, a, b) for (int b____=b,i=a;i<=b____;++i) #define DWN_1_C(i, b, a) for (int a____=a,i=b;i>=a____;--i) #define REP_1_N(i, n) for (i=1;i<=n;++i) #define FOR_1_N(i, a, b) for (i=a;i<=b;++i) #define DWN_1_N(i, b, a) for (i=b;i>=a;--i) #define REP_C_N(i, n) for (int n____=(i=0,n);i<n____;++i) #define FOR_C_N(i, a, b) for (int b____=(i=0,b);i<b____;++i) #define DWN_C_N(i, b, a) for (int a____=(i=b-1,a);i>=a____;--i) #define REP_1_C_N(i, n) for (int n____=(i=1,n);i<=n____;++i) #define FOR_1_C_N(i, a, b) for (int b____=(i=a,b);i<=b____;++i) #define DWN_1_C_N(i, b, a) for (int a____=(i=b,a);i>=a____;--i) #define ECH(it, A) for (__typeof((A).begin()) it=(A).begin(); it != (A).end(); ++it) #define rECH(it, A) for (__typeof((A).rbegin()) it=(A).rbegin(); it != (A).rend(); ++it) #define REP_S(i, str) for (char*i=str;*i;++i) #define REP_L(i, hd, suc) for (int i=hd;i;i=suc[i]) #define REP_G(i, u) REP_L(i,hd[u],suc) #define REP_SS(x, s) for (int x=s;x;x=(x-1)&s) #define DO(n) for ( int ____n = n; ____n-->0; ) #define REP_2(i, j, n, m) REP(i, n) REP(j, m) #define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m) #define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l) #define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l) #define REP_4(i, j, k, ii, n, m, l, nn) REP(i, n) REP(j, m) REP(k, l) REP(ii, nn) #define REP_4_1(i, j, k, ii, n, m, l, nn) REP_1(i, n) REP_1(j, m) REP_1(k, l) REP_1(ii, nn) #define ALL(A) A.begin(), A.end() #define LLA(A) A.rbegin(), A.rend() #define CPY(A, B) memcpy(A, B, sizeof(A)) #define INS(A, P, B) A.insert(A.begin() + P, B) #define ERS(A, P) A.erase(A.begin() + P) #define LBD(A, x) (lower_bound(ALL(A), x) - A.begin()) #define UBD(A, x) (upper_bound(ALL(A), x) - A.begin()) #define CTN(T, x) (T.find(x) != T.end()) #define SZ(A) int((A).size()) #define PB push_back #define MP(A, B) make_pair(A, B) #define PTT pair<T, T> #define Ts *this #define rTs return Ts #define fi first #define se second #define re real() #define im imag() #define Rush for(int ____T=RD(); ____T--;) #define Display(A, n, m) { \ REP(i, n){ \ REP(j, m-1) cout << A[i][j] << " "; \ cout << A[i][m-1] << endl; \ } \ } #define Display_1(A, n, m) { \ REP_1(i, n){ \ REP_1(j, m-1) cout << A[i][j] << " "; \ cout << A[i][m] << endl; \ } \ } typedef long long LL; //typedef long double DB; typedef double DB; typedef unsigned uint; typedef unsigned long long uLL; typedef vector<int> VI; template<class T> inline T& RD(T &); template<class T> inline void OT(const T &); //inline int RD(){int x; return RD(x);} inline LL RD(){LL x; return RD(x);} inline DB& RF(DB &); inline DB RF(){DB x; return RF(x);} inline char* RS(char *s); inline char& RC(char &c); inline char RC(); inline char& RC(char &c){scanf(" %c", &c); return c;} inline char RC(){char c; return RC(c);} //inline char& RC(char &c){c = getchar(); return c;} //inline char RC(){return getchar();} template<class T> inline T& RDD(T &); inline LL RDD(){LL x; return RDD(x);} template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;} template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;} template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;} template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;} template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;} template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);} template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);} template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);} template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);} inline char& RC(char &a, char &b){RC(a), RC(b); return a;} inline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;} inline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;} inline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;} inline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;} inline void RS(char *s1, char *s2){RS(s1), RS(s2);} inline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);} template<class T0,class T1>inline T0& RDD(T0&a, T1&b){RDD(a),RDD(b); return a;} template<class T0,class T1,class T2>inline T1& RDD(T0&a, T1&b, T2&c){RDD(a),RDD(b),RDD(c); return a;} template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));} template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));} template<class T> inline void CLR(T &A){A.clear();} template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);} template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);} template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);} template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);} template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);} template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);} template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);} template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);} template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);} template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);} template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);} template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);} template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);} template<class T> inline bool EPT(T &a){return a.empty();} template<class T> inline T& SRT(T &A){sort(ALL(A)); return A;} template<class T, class C> inline T& SRT(T &A, C B){sort(ALL(A), B); return A;} template<class T> inline T& RVS(T &A){reverse(ALL(A)); return A;} template<class T> inline T& UNQQ(T &A){A.resize(unique(ALL(A))-A.begin());return A;} template<class T> inline T& UNQ(T &A){SRT(A);return UNQQ(A);} //} /** Constant List .. **/ //{ const int MOD = int(1e9) + 7; const int INF = 0x3f3f3f3f; const LL INFF = 0x3f3f3f3f3f3f3f3fLL; const DB EPS = 1e-9; const DB OO = 1e20; const DB PI = acos(-1.0); //M_PI; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; //} /** Add On .. **/ //{ // <<= '0. Nichi Joo ., //{ template<class T> inline bool checkMin(T &a,const T b){return b < a ? a = b, 1 : 0;} template<class T> inline bool checkMax(T &a,const T b){return a < b ? a = b, 1 : 0;} template <class T, class C> inline bool checkUpd(T& a, const T b, C c){return c(b,a) ? a = b, 1 : 0;} template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);} template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);} template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));} template<class T> inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));} template<class T> inline T min(T a, T b, T c, T d, T e){return min(min(min(a,b),min(c,d)),e);} template<class T> inline T max(T a, T b, T c, T d, T e){return max(max(max(a,b),max(c,d)),e);} template<class T> inline T sqr(T a){return a*a;} template<class T> inline T cub(T a){return a*a*a;} template<class T> inline T ceil(T x, T y){return (x - 1) / y + 1;} template<class T> T abs(T x){return x>0?x:-x;} inline int sgn(DB x){return x < -EPS ? -1 : x > EPS;} inline int sgn(DB x, DB y){return sgn(x - y);} inline DB cos(DB a, DB b, DB c){return (sqr(a)+sqr(b)-sqr(c))/(2*a*b);} inline DB cot(DB x){return 1./tan(x);}; inline DB sec(DB x){return 1./cos(x);}; inline DB csc(DB x){return 1./sin(x);}; //} //} /** I/O Accelerator Interface .. **/ //{ #define g (c=getchar()) #define d isdigit(g) #define p x=x*10+c-'0' #define n x=x*10+'0'-c #define pp l/=10,p #define nn l/=10,n template<class T> inline T& RD(T &x){ char c;while(!d);x=c-'0';while(d)p; return x; } template<class T> inline T& RDD(T &x){ char c;while(g,c!='-'&&!isdigit(c)); if (c=='-'){x='0'-g;while(d)n;} else{x=c-'0';while(d)p;} return x; } inline DB& RF(DB &x){ //scanf("%lf", &x); char c;while(g,c!='-'&&c!='.'&&!isdigit(c)); if(c=='-')if(g=='.'){x=0;DB l=1;while(d)nn;x*=l;} else{x='0'-c;while(d)n;if(c=='.'){DB l=1;while(d)nn;x*=l;}} else if(c=='.'){x=0;DB l=1;while(d)pp;x*=l;} else{x=c-'0';while(d)p;if(c=='.'){DB l=1;while(d)pp;x*=l;}} return x; } #undef nn #undef pp #undef n #undef p #undef d #undef g inline char* RS(char *s){ //gets(s); scanf("%s", s); return s; } LL last_ans; int Case; template<class T> inline void OT(const T &x){ //printf("Case #%d: ", ++Case); //printf("%lld\n", x); //printf("%.9f\n", x); //printf("%d\n", x); cout << x << endl; //last_ans = x; } //}/* .................................................................................................................................. */ const int MAXN = 100020; struct seg_tree { static const int DEPTH = 19; static const int SIZE = 1<<DEPTH; int bit[1<<(DEPTH+1)]; int renew[1<<(DEPTH+1)]; seg_tree() { } void init() { for(int i=0;i<2*SIZE;i++) bit[i] = renew[i] = 0; } void add(int p, int v) { p += SIZE; while(p){ bit[p] += v; p >>= 1; } } int query(int l, int r) { l += SIZE; r += SIZE; int ret = 0; while(l < r){ if(l&1) ret += bit[l++]; if(r&1) ret += bit[--r]; l >>= 1; r >>= 1; } return ret; } void set_renew(int l, int r) { l += SIZE; r += SIZE; while(l < r){ if(l&1) renew[l++] = 1; if(r&1) renew[--r] = 1; l >>= 1; r >>= 1; } } bool is_renew(int p) { p += SIZE; while(p){ if(renew[p]) return true; p >>= 1; } return false; } void unset_renew(int p) { p += SIZE; for(int i=DEPTH-1;i>0;i--){ if(renew[p >> i]){ renew[p >> i] = 0; renew[(p>>i)*2] = renew[(p>>i)*2+1] = 1; } } renew[p] = 0; } }; struct action { int pos, act, left, right; action(int p, int a, int l, int r) { pos = p; act = a; left = l; right = r; } }; inline bool operator<(const action& a, const action& b) { return a.pos < b.pos || (a.pos == b.pos && a.act < b.act); } int W, H, N; int x1[MAXN], y1[MAXN], x2[MAXN], y2[MAXN]; vector<int> uf; seg_tree seg; int target[MAXN*2]; int root(int p) { return (uf[p] < 0) ? p : (uf[p] = root(uf[p])); } bool join(int p, int q) { p = root(p); q = root(q); if(p==q) return false; if(uf[p] < uf[q]) swap(p, q); uf[p] = uf[q]; uf[q] = p; return true; } void adjust(int p) { if(seg.is_renew(p)){ uf.push_back(-1); seg.unset_renew(p); target[p] = uf.size() - 1; } } int main() { #ifndef ONLINE_JUDGE //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); #endif scanf("%d%d%d", &W, &H, &N); for(int i=0;i<N;i++){ scanf("%d%d%d%d", x1+i, y1+i, x2+i, y2+i); if(x1[i] > x2[i]) swap(x1[i], x2[i]); if(y1[i] > y2[i]) swap(y1[i], y2[i]); } for(int i=0;i<2*N;i++) target[i] = -1; x1[N ] = 0; y1[N ] = 0; x2[N ] = W; y2[N ] = 0; x1[N+1] = 0; y1[N+1] = 0; x2[N+1] = 0; y2[N+1] = H; x1[N+2] = W; y1[N+2] = 0; x2[N+2] = W; y2[N+2] = H; x1[N+3] = 0; y1[N+3] = H; x2[N+3] = W; y2[N+3] = H; N += 4; vector<int> xs; for(int i=0;i<N;i++){ xs.push_back(x1[i]); xs.push_back(x2[i]); } xs.push_back(-1); sort(xs.begin(), xs.end()); xs.erase(unique(xs.begin(), xs.end()), xs.end()); for(int i=0;i<N;i++){ x1[i] = lower_bound(xs.begin(), xs.end(), x1[i]) - xs.begin(); x2[i] = lower_bound(xs.begin(), xs.end(), x2[i]) - xs.begin(); } set<int> S; S.insert(0); target[0] = 0; uf.push_back(-1); vector<action> A; for(int i=0;i<N;i++){ if(x1[i] == x2[i]){ A.push_back(action(y1[i], 0, x1[i], -1)); A.push_back(action(y2[i], 2, x1[i], -1)); }else{ A.push_back(action(y1[i], 1, x1[i], x2[i])); } } sort(A.begin(), A.end()); long long ret = 0; for(int i=0;i<A.size();i++){ action V = A[i]; if(V.act == 0){ int lf = *--S.lower_bound(V.left); adjust(lf); adjust(V.left); target[V.left] = target[lf]; S.insert(V.left); seg.add(V.left, 1); }else if(V.act == 1){ int count = seg.query(V.left, V.right+1); if(count < 2) continue; ret += count - 1; seg.set_renew(V.left, *--S.upper_bound(V.right)); }else if(V.act == 2){ int lf = *--S.lower_bound(V.left); adjust(lf); adjust(V.left); if(join(target[lf], target[V.left])) --ret; S.erase(V.left); seg.add(V.left, -1); } //cout << V.act << " " << ret << endl; } printf("%lld\n", ret); return 0; }
a.cc:187:15: error: 'acos' was not declared in this scope 187 | const DB PI = acos(-1.0); //M_PI; | ^~~~ a.cc: In function 'DB cot(DB)': a.cc:214:31: error: 'tan' was not declared in this scope 214 | inline DB cot(DB x){return 1./tan(x);}; | ^~~ a.cc: In function 'DB sec(DB)': a.cc:215:34: error: too few arguments to function 'DB cos(DB, DB, DB)' 215 | inline DB sec(DB x){return 1./cos(x);}; | ~~~^~~ a.cc:213:11: note: declared here 213 | inline DB cos(DB a, DB b, DB c){return (sqr(a)+sqr(b)-sqr(c))/(2*a*b);} | ^~~ a.cc: In function 'DB csc(DB)': a.cc:216:31: error: 'sin' was not declared in this scope; did you mean 'sgn'? 216 | inline DB csc(DB x){return 1./sin(x);}; | ^~~ | sgn a.cc: At global scope: a.cc:367:15: warning: built-in function 'y1' declared as non-function [-Wbuiltin-declaration-mismatch] 367 | int x1[MAXN], y1[MAXN], x2[MAXN], y2[MAXN]; | ^~
s840620400
p00525
C++
#pragma comment(linker, "/STACK:36777216") //#pragma GCC optimize ("O2") #define LOCAL //#include "testlib.h" #include<iostream> #include<cstdio> #include<algorithm> #include<set> #include<vector> //#include <tr1/unordered_set> //#include <tr1/unordered_map> //#include <array> using namespace std; #define REP(i, n) for (int i=0;i<n;++i) #define FOR(i, a, b) for (int i=a;i<b;++i) #define DWN(i, b, a) for (int i=b-1;i>=a;--i) #define REP_1(i, n) for (int i=1;i<=n;++i) #define FOR_1(i, a, b) for (int i=a;i<=b;++i) #define DWN_1(i, b, a) for (int i=b;i>=a;--i) #define REP_C(i, n) for (int n____=n,i=0;i<n____;++i) #define FOR_C(i, a, b) for (int b____=b,i=a;i<b____;++i) #define DWN_C(i, b, a) for (int a____=a,i=b-1;i>=a____;--i) #define REP_N(i, n) for (i=0;i<n;++i) #define FOR_N(i, a, b) for (i=a;i<b;++i) #define DWN_N(i, b, a) for (i=b-1;i>=a;--i) #define REP_1_C(i, n) for (int n____=n,i=1;i<=n____;++i) #define FOR_1_C(i, a, b) for (int b____=b,i=a;i<=b____;++i) #define DWN_1_C(i, b, a) for (int a____=a,i=b;i>=a____;--i) #define REP_1_N(i, n) for (i=1;i<=n;++i) #define FOR_1_N(i, a, b) for (i=a;i<=b;++i) #define DWN_1_N(i, b, a) for (i=b;i>=a;--i) #define REP_C_N(i, n) for (int n____=(i=0,n);i<n____;++i) #define FOR_C_N(i, a, b) for (int b____=(i=0,b);i<b____;++i) #define DWN_C_N(i, b, a) for (int a____=(i=b-1,a);i>=a____;--i) #define REP_1_C_N(i, n) for (int n____=(i=1,n);i<=n____;++i) #define FOR_1_C_N(i, a, b) for (int b____=(i=a,b);i<=b____;++i) #define DWN_1_C_N(i, b, a) for (int a____=(i=b,a);i>=a____;--i) #define ECH(it, A) for (__typeof((A).begin()) it=(A).begin(); it != (A).end(); ++it) #define rECH(it, A) for (__typeof((A).rbegin()) it=(A).rbegin(); it != (A).rend(); ++it) #define REP_S(i, str) for (char*i=str;*i;++i) #define REP_L(i, hd, suc) for (int i=hd;i;i=suc[i]) #define REP_G(i, u) REP_L(i,hd[u],suc) #define REP_SS(x, s) for (int x=s;x;x=(x-1)&s) #define DO(n) for ( int ____n = n; ____n-->0; ) #define REP_2(i, j, n, m) REP(i, n) REP(j, m) #define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m) #define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l) #define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l) #define REP_4(i, j, k, ii, n, m, l, nn) REP(i, n) REP(j, m) REP(k, l) REP(ii, nn) #define REP_4_1(i, j, k, ii, n, m, l, nn) REP_1(i, n) REP_1(j, m) REP_1(k, l) REP_1(ii, nn) #define ALL(A) A.begin(), A.end() #define LLA(A) A.rbegin(), A.rend() #define CPY(A, B) memcpy(A, B, sizeof(A)) #define INS(A, P, B) A.insert(A.begin() + P, B) #define ERS(A, P) A.erase(A.begin() + P) #define LBD(A, x) (lower_bound(ALL(A), x) - A.begin()) #define UBD(A, x) (upper_bound(ALL(A), x) - A.begin()) #define CTN(T, x) (T.find(x) != T.end()) #define SZ(A) int((A).size()) #define PB push_back #define MP(A, B) make_pair(A, B) #define PTT pair<T, T> #define Ts *this #define rTs return Ts #define fi first #define se second #define re real() #define im imag() #define Rush for(int ____T=RD(); ____T--;) #define Display(A, n, m) { \ REP(i, n){ \ REP(j, m-1) cout << A[i][j] << " "; \ cout << A[i][m-1] << endl; \ } \ } #define Display_1(A, n, m) { \ REP_1(i, n){ \ REP_1(j, m-1) cout << A[i][j] << " "; \ cout << A[i][m] << endl; \ } \ } typedef long long LL; //typedef long double DB; typedef double DB; typedef unsigned uint; typedef unsigned long long uLL; typedef vector<int> VI; template<class T> inline T& RD(T &); template<class T> inline void OT(const T &); //inline int RD(){int x; return RD(x);} inline LL RD(){LL x; return RD(x);} inline DB& RF(DB &); inline DB RF(){DB x; return RF(x);} inline char* RS(char *s); inline char& RC(char &c); inline char RC(); inline char& RC(char &c){scanf(" %c", &c); return c;} inline char RC(){char c; return RC(c);} //inline char& RC(char &c){c = getchar(); return c;} //inline char RC(){return getchar();} template<class T> inline T& RDD(T &); inline LL RDD(){LL x; return RDD(x);} template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;} template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;} template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;} template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;} template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;} template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);} template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);} template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);} template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);} inline char& RC(char &a, char &b){RC(a), RC(b); return a;} inline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;} inline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;} inline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;} inline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;} inline void RS(char *s1, char *s2){RS(s1), RS(s2);} inline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);} template<class T0,class T1>inline T0& RDD(T0&a, T1&b){RDD(a),RDD(b); return a;} template<class T0,class T1,class T2>inline T1& RDD(T0&a, T1&b, T2&c){RDD(a),RDD(b),RDD(c); return a;} template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));} template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));} template<class T> inline void CLR(T &A){A.clear();} template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);} template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);} template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);} template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);} template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);} template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);} template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);} template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);} template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);} template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);} template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);} template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);} template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);} template<class T> inline bool EPT(T &a){return a.empty();} template<class T> inline T& SRT(T &A){sort(ALL(A)); return A;} template<class T, class C> inline T& SRT(T &A, C B){sort(ALL(A), B); return A;} template<class T> inline T& RVS(T &A){reverse(ALL(A)); return A;} template<class T> inline T& UNQQ(T &A){A.resize(unique(ALL(A))-A.begin());return A;} template<class T> inline T& UNQ(T &A){SRT(A);return UNQQ(A);} //} /** Constant List .. **/ //{ const int MOD = int(1e9) + 7; const int INF = 0x3f3f3f3f; const LL INFF = 0x3f3f3f3f3f3f3f3fLL; const DB EPS = 1e-9; const DB OO = 1e20; const DB PI = acos(-1.0); //M_PI; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; //} /** Add On .. **/ //{ // <<= '0. Nichi Joo ., //{ template<class T> inline bool checkMin(T &a,const T b){return b < a ? a = b, 1 : 0;} template<class T> inline bool checkMax(T &a,const T b){return a < b ? a = b, 1 : 0;} template <class T, class C> inline bool checkUpd(T& a, const T b, C c){return c(b,a) ? a = b, 1 : 0;} template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);} template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);} template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));} template<class T> inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));} template<class T> inline T min(T a, T b, T c, T d, T e){return min(min(min(a,b),min(c,d)),e);} template<class T> inline T max(T a, T b, T c, T d, T e){return max(max(max(a,b),max(c,d)),e);} template<class T> inline T sqr(T a){return a*a;} template<class T> inline T cub(T a){return a*a*a;} template<class T> inline T ceil(T x, T y){return (x - 1) / y + 1;} template<class T> T abs(T x){return x>0?x:-x;} inline int sgn(DB x){return x < -EPS ? -1 : x > EPS;} inline int sgn(DB x, DB y){return sgn(x - y);} inline DB cos(DB a, DB b, DB c){return (sqr(a)+sqr(b)-sqr(c))/(2*a*b);} inline DB cot(DB x){return 1./tan(x);}; inline DB sec(DB x){return 1./cos(x);}; inline DB csc(DB x){return 1./sin(x);}; //} //} /** I/O Accelerator Interface .. **/ //{ #define g (c=getchar()) #define d isdigit(g) #define p x=x*10+c-'0' #define n x=x*10+'0'-c #define pp l/=10,p #define nn l/=10,n template<class T> inline T& RD(T &x){ char c;while(!d);x=c-'0';while(d)p; return x; } template<class T> inline T& RDD(T &x){ char c;while(g,c!='-'&&!isdigit(c)); if (c=='-'){x='0'-g;while(d)n;} else{x=c-'0';while(d)p;} return x; } inline DB& RF(DB &x){ //scanf("%lf", &x); char c;while(g,c!='-'&&c!='.'&&!isdigit(c)); if(c=='-')if(g=='.'){x=0;DB l=1;while(d)nn;x*=l;} else{x='0'-c;while(d)n;if(c=='.'){DB l=1;while(d)nn;x*=l;}} else if(c=='.'){x=0;DB l=1;while(d)pp;x*=l;} else{x=c-'0';while(d)p;if(c=='.'){DB l=1;while(d)pp;x*=l;}} return x; } #undef nn #undef pp #undef n #undef p #undef d #undef g inline char* RS(char *s){ //gets(s); scanf("%s", s); return s; } LL last_ans; int Case; template<class T> inline void OT(const T &x){ //printf("Case #%d: ", ++Case); //printf("%lld\n", x); //printf("%.9f\n", x); //printf("%d\n", x); cout << x << endl; //last_ans = x; } //}/* .................................................................................................................................. */ const int MAXN = 100020; struct seg_tree { static const int DEPTH = 19; static const int SIZE = 1<<DEPTH; int bit[1<<(DEPTH+1)]; int renew[1<<(DEPTH+1)]; seg_tree() { } void init() { for(int i=0;i<2*SIZE;i++) bit[i] = renew[i] = 0; } void add(int p, int v) { p += SIZE; while(p){ bit[p] += v; p >>= 1; } } int query(int l, int r) { l += SIZE; r += SIZE; int ret = 0; while(l < r){ if(l&1) ret += bit[l++]; if(r&1) ret += bit[--r]; l >>= 1; r >>= 1; } return ret; } void set_renew(int l, int r) { l += SIZE; r += SIZE; while(l < r){ if(l&1) renew[l++] = 1; if(r&1) renew[--r] = 1; l >>= 1; r >>= 1; } } bool is_renew(int p) { p += SIZE; while(p){ if(renew[p]) return true; p >>= 1; } return false; } void unset_renew(int p) { p += SIZE; for(int i=DEPTH-1;i>0;i--){ if(renew[p >> i]){ renew[p >> i] = 0; renew[(p>>i)*2] = renew[(p>>i)*2+1] = 1; } } renew[p] = 0; } }; struct action { int pos, act, left, right; action(int p, int a, int l, int r) { pos = p; act = a; left = l; right = r; } }; inline bool operator<(const action& a, const action& b) { return a.pos < b.pos || (a.pos == b.pos && a.act < b.act); } int W, H, N; int x1[MAXN], y1[MAXN], x2[MAXN], y2[MAXN]; vector<int> uf; seg_tree seg; int target[MAXN*2]; int root(int p) { return (uf[p] < 0) ? p : (uf[p] = root(uf[p])); } bool join(int p, int q) { p = root(p); q = root(q); if(p==q) return false; if(uf[p] < uf[q]) swap(p, q); uf[p] = uf[q]; uf[q] = p; return true; } void adjust(int p) { if(seg.is_renew(p)){ uf.push_back(-1); seg.unset_renew(p); target[p] = uf.size() - 1; } } int main() { #ifndef ONLINE_JUDGE //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); #endif scanf("%d%d%d", &W, &H, &N); for(int i=0;i<N;i++){ scanf("%d%d%d%d", x1+i, y1+i, x2+i, y2+i); if(x1[i] > x2[i]) swap(x1[i], x2[i]); if(y1[i] > y2[i]) swap(y1[i], y2[i]); } for(int i=0;i<2*N;i++) target[i] = -1; x1[N ] = 0; y1[N ] = 0; x2[N ] = W; y2[N ] = 0; x1[N+1] = 0; y1[N+1] = 0; x2[N+1] = 0; y2[N+1] = H; x1[N+2] = W; y1[N+2] = 0; x2[N+2] = W; y2[N+2] = H; x1[N+3] = 0; y1[N+3] = H; x2[N+3] = W; y2[N+3] = H; N += 4; vector<int> xs; for(int i=0;i<N;i++){ xs.push_back(x1[i]); xs.push_back(x2[i]); } xs.push_back(-1); sort(xs.begin(), xs.end()); xs.erase(unique(xs.begin(), xs.end()), xs.end()); for(int i=0;i<N;i++){ x1[i] = lower_bound(xs.begin(), xs.end(), x1[i]) - xs.begin(); x2[i] = lower_bound(xs.begin(), xs.end(), x2[i]) - xs.begin(); } set<int> S; S.insert(0); target[0] = 0; uf.push_back(-1); vector<action> A; for(int i=0;i<N;i++){ if(x1[i] == x2[i]){ A.push_back(action(y1[i], 0, x1[i], -1)); A.push_back(action(y2[i], 2, x1[i], -1)); }else{ A.push_back(action(y1[i], 1, x1[i], x2[i])); } } sort(A.begin(), A.end()); long long ret = 0; for(int i=0;i<A.size();i++){ action V = A[i]; if(V.act == 0){ int lf = *--S.lower_bound(V.left); adjust(lf); adjust(V.left); target[V.left] = target[lf]; S.insert(V.left); seg.add(V.left, 1); }else if(V.act == 1){ int count = seg.query(V.left, V.right+1); if(count < 2) continue; ret += count - 1; seg.set_renew(V.left, *--S.upper_bound(V.right)); }else if(V.act == 2){ int lf = *--S.lower_bound(V.left); adjust(lf); adjust(V.left); if(join(target[lf], target[V.left])) --ret; S.erase(V.left); seg.add(V.left, -1); } //cout << V.act << " " << ret << endl; } printf("%lld\n", ret); return 0; }
a.cc:187:15: error: 'acos' was not declared in this scope 187 | const DB PI = acos(-1.0); //M_PI; | ^~~~ a.cc: In function 'DB cot(DB)': a.cc:214:31: error: 'tan' was not declared in this scope 214 | inline DB cot(DB x){return 1./tan(x);}; | ^~~ a.cc: In function 'DB sec(DB)': a.cc:215:34: error: too few arguments to function 'DB cos(DB, DB, DB)' 215 | inline DB sec(DB x){return 1./cos(x);}; | ~~~^~~ a.cc:213:11: note: declared here 213 | inline DB cos(DB a, DB b, DB c){return (sqr(a)+sqr(b)-sqr(c))/(2*a*b);} | ^~~ a.cc: In function 'DB csc(DB)': a.cc:216:31: error: 'sin' was not declared in this scope; did you mean 'sgn'? 216 | inline DB csc(DB x){return 1./sin(x);}; | ^~~ | sgn a.cc: At global scope: a.cc:367:15: warning: built-in function 'y1' declared as non-function [-Wbuiltin-declaration-mismatch] 367 | int x1[MAXN], y1[MAXN], x2[MAXN], y2[MAXN]; | ^~
s130808646
p00525
C++
#pragma comment(linker, "/STACK:36777216") //#pragma GCC optimize ("O2") #define LOCAL //#include "testlib.h" #include<iostream> #include<cstdio> #include<algorithm> #include<set> #include<vector> #include<cmath> //#include <tr1/unordered_set> //#include <tr1/unordered_map> //#include <array> using namespace std; #define REP(i, n) for (int i=0;i<n;++i) #define FOR(i, a, b) for (int i=a;i<b;++i) #define DWN(i, b, a) for (int i=b-1;i>=a;--i) #define REP_1(i, n) for (int i=1;i<=n;++i) #define FOR_1(i, a, b) for (int i=a;i<=b;++i) #define DWN_1(i, b, a) for (int i=b;i>=a;--i) #define REP_C(i, n) for (int n____=n,i=0;i<n____;++i) #define FOR_C(i, a, b) for (int b____=b,i=a;i<b____;++i) #define DWN_C(i, b, a) for (int a____=a,i=b-1;i>=a____;--i) #define REP_N(i, n) for (i=0;i<n;++i) #define FOR_N(i, a, b) for (i=a;i<b;++i) #define DWN_N(i, b, a) for (i=b-1;i>=a;--i) #define REP_1_C(i, n) for (int n____=n,i=1;i<=n____;++i) #define FOR_1_C(i, a, b) for (int b____=b,i=a;i<=b____;++i) #define DWN_1_C(i, b, a) for (int a____=a,i=b;i>=a____;--i) #define REP_1_N(i, n) for (i=1;i<=n;++i) #define FOR_1_N(i, a, b) for (i=a;i<=b;++i) #define DWN_1_N(i, b, a) for (i=b;i>=a;--i) #define REP_C_N(i, n) for (int n____=(i=0,n);i<n____;++i) #define FOR_C_N(i, a, b) for (int b____=(i=0,b);i<b____;++i) #define DWN_C_N(i, b, a) for (int a____=(i=b-1,a);i>=a____;--i) #define REP_1_C_N(i, n) for (int n____=(i=1,n);i<=n____;++i) #define FOR_1_C_N(i, a, b) for (int b____=(i=a,b);i<=b____;++i) #define DWN_1_C_N(i, b, a) for (int a____=(i=b,a);i>=a____;--i) #define ECH(it, A) for (__typeof((A).begin()) it=(A).begin(); it != (A).end(); ++it) #define rECH(it, A) for (__typeof((A).rbegin()) it=(A).rbegin(); it != (A).rend(); ++it) #define REP_S(i, str) for (char*i=str;*i;++i) #define REP_L(i, hd, suc) for (int i=hd;i;i=suc[i]) #define REP_G(i, u) REP_L(i,hd[u],suc) #define REP_SS(x, s) for (int x=s;x;x=(x-1)&s) #define DO(n) for ( int ____n = n; ____n-->0; ) #define REP_2(i, j, n, m) REP(i, n) REP(j, m) #define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m) #define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l) #define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l) #define REP_4(i, j, k, ii, n, m, l, nn) REP(i, n) REP(j, m) REP(k, l) REP(ii, nn) #define REP_4_1(i, j, k, ii, n, m, l, nn) REP_1(i, n) REP_1(j, m) REP_1(k, l) REP_1(ii, nn) #define ALL(A) A.begin(), A.end() #define LLA(A) A.rbegin(), A.rend() #define CPY(A, B) memcpy(A, B, sizeof(A)) #define INS(A, P, B) A.insert(A.begin() + P, B) #define ERS(A, P) A.erase(A.begin() + P) #define LBD(A, x) (lower_bound(ALL(A), x) - A.begin()) #define UBD(A, x) (upper_bound(ALL(A), x) - A.begin()) #define CTN(T, x) (T.find(x) != T.end()) #define SZ(A) int((A).size()) #define PB push_back #define MP(A, B) make_pair(A, B) #define PTT pair<T, T> #define Ts *this #define rTs return Ts #define fi first #define se second #define re real() #define im imag() #define Rush for(int ____T=RD(); ____T--;) #define Display(A, n, m) { \ REP(i, n){ \ REP(j, m-1) cout << A[i][j] << " "; \ cout << A[i][m-1] << endl; \ } \ } #define Display_1(A, n, m) { \ REP_1(i, n){ \ REP_1(j, m-1) cout << A[i][j] << " "; \ cout << A[i][m] << endl; \ } \ } typedef long long LL; //typedef long double DB; typedef double DB; typedef unsigned uint; typedef unsigned long long uLL; typedef vector<int> VI; template<class T> inline T& RD(T &); template<class T> inline void OT(const T &); //inline int RD(){int x; return RD(x);} inline LL RD(){LL x; return RD(x);} inline DB& RF(DB &); inline DB RF(){DB x; return RF(x);} inline char* RS(char *s); inline char& RC(char &c); inline char RC(); inline char& RC(char &c){scanf(" %c", &c); return c;} inline char RC(){char c; return RC(c);} //inline char& RC(char &c){c = getchar(); return c;} //inline char RC(){return getchar();} template<class T> inline T& RDD(T &); inline LL RDD(){LL x; return RDD(x);} template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;} template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;} template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;} template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;} template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;} template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);} template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);} template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);} template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);} inline char& RC(char &a, char &b){RC(a), RC(b); return a;} inline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;} inline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;} inline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;} inline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;} inline void RS(char *s1, char *s2){RS(s1), RS(s2);} inline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);} template<class T0,class T1>inline T0& RDD(T0&a, T1&b){RDD(a),RDD(b); return a;} template<class T0,class T1,class T2>inline T1& RDD(T0&a, T1&b, T2&c){RDD(a),RDD(b),RDD(c); return a;} template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));} template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));} template<class T> inline void CLR(T &A){A.clear();} template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);} template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);} template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);} template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);} template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);} template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);} template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);} template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);} template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);} template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);} template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);} template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);} template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);} template<class T> inline bool EPT(T &a){return a.empty();} template<class T> inline T& SRT(T &A){sort(ALL(A)); return A;} template<class T, class C> inline T& SRT(T &A, C B){sort(ALL(A), B); return A;} template<class T> inline T& RVS(T &A){reverse(ALL(A)); return A;} template<class T> inline T& UNQQ(T &A){A.resize(unique(ALL(A))-A.begin());return A;} template<class T> inline T& UNQ(T &A){SRT(A);return UNQQ(A);} //} /** Constant List .. **/ //{ const int MOD = int(1e9) + 7; const int INF = 0x3f3f3f3f; const LL INFF = 0x3f3f3f3f3f3f3f3fLL; const DB EPS = 1e-9; const DB OO = 1e20; const DB PI = acos(-1.0); //M_PI; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; //} /** Add On .. **/ //{ // <<= '0. Nichi Joo ., //{ template<class T> inline bool checkMin(T &a,const T b){return b < a ? a = b, 1 : 0;} template<class T> inline bool checkMax(T &a,const T b){return a < b ? a = b, 1 : 0;} template <class T, class C> inline bool checkUpd(T& a, const T b, C c){return c(b,a) ? a = b, 1 : 0;} template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);} template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);} template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));} template<class T> inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));} template<class T> inline T min(T a, T b, T c, T d, T e){return min(min(min(a,b),min(c,d)),e);} template<class T> inline T max(T a, T b, T c, T d, T e){return max(max(max(a,b),max(c,d)),e);} template<class T> inline T sqr(T a){return a*a;} template<class T> inline T cub(T a){return a*a*a;} template<class T> inline T ceil(T x, T y){return (x - 1) / y + 1;} template<class T> T abs(T x){return x>0?x:-x;} inline int sgn(DB x){return x < -EPS ? -1 : x > EPS;} inline int sgn(DB x, DB y){return sgn(x - y);} inline DB cos(DB a, DB b, DB c){return (sqr(a)+sqr(b)-sqr(c))/(2*a*b);} inline DB cot(DB x){return 1./tan(x);}; inline DB sec(DB x){return 1./cos(x);}; inline DB csc(DB x){return 1./sin(x);}; //} //} /** I/O Accelerator Interface .. **/ //{ #define g (c=getchar()) #define d isdigit(g) #define p x=x*10+c-'0' #define n x=x*10+'0'-c #define pp l/=10,p #define nn l/=10,n template<class T> inline T& RD(T &x){ char c;while(!d);x=c-'0';while(d)p; return x; } template<class T> inline T& RDD(T &x){ char c;while(g,c!='-'&&!isdigit(c)); if (c=='-'){x='0'-g;while(d)n;} else{x=c-'0';while(d)p;} return x; } inline DB& RF(DB &x){ //scanf("%lf", &x); char c;while(g,c!='-'&&c!='.'&&!isdigit(c)); if(c=='-')if(g=='.'){x=0;DB l=1;while(d)nn;x*=l;} else{x='0'-c;while(d)n;if(c=='.'){DB l=1;while(d)nn;x*=l;}} else if(c=='.'){x=0;DB l=1;while(d)pp;x*=l;} else{x=c-'0';while(d)p;if(c=='.'){DB l=1;while(d)pp;x*=l;}} return x; } #undef nn #undef pp #undef n #undef p #undef d #undef g inline char* RS(char *s){ //gets(s); scanf("%s", s); return s; } LL last_ans; int Case; template<class T> inline void OT(const T &x){ //printf("Case #%d: ", ++Case); //printf("%lld\n", x); //printf("%.9f\n", x); //printf("%d\n", x); cout << x << endl; //last_ans = x; } //}/* .................................................................................................................................. */ const int MAXN = 100020; struct seg_tree { static const int DEPTH = 19; static const int SIZE = 1<<DEPTH; int bit[1<<(DEPTH+1)]; int renew[1<<(DEPTH+1)]; seg_tree() { } void init() { for(int i=0;i<2*SIZE;i++) bit[i] = renew[i] = 0; } void add(int p, int v) { p += SIZE; while(p){ bit[p] += v; p >>= 1; } } int query(int l, int r) { l += SIZE; r += SIZE; int ret = 0; while(l < r){ if(l&1) ret += bit[l++]; if(r&1) ret += bit[--r]; l >>= 1; r >>= 1; } return ret; } void set_renew(int l, int r) { l += SIZE; r += SIZE; while(l < r){ if(l&1) renew[l++] = 1; if(r&1) renew[--r] = 1; l >>= 1; r >>= 1; } } bool is_renew(int p) { p += SIZE; while(p){ if(renew[p]) return true; p >>= 1; } return false; } void unset_renew(int p) { p += SIZE; for(int i=DEPTH-1;i>0;i--){ if(renew[p >> i]){ renew[p >> i] = 0; renew[(p>>i)*2] = renew[(p>>i)*2+1] = 1; } } renew[p] = 0; } }; struct action { int pos, act, left, right; action(int p, int a, int l, int r) { pos = p; act = a; left = l; right = r; } }; inline bool operator<(const action& a, const action& b) { return a.pos < b.pos || (a.pos == b.pos && a.act < b.act); } int W, H, N; int x1[MAXN], y1[MAXN], x2[MAXN], y2[MAXN]; vector<int> uf; seg_tree seg; int target[MAXN*2]; int root(int p) { return (uf[p] < 0) ? p : (uf[p] = root(uf[p])); } bool join(int p, int q) { p = root(p); q = root(q); if(p==q) return false; if(uf[p] < uf[q]) swap(p, q); uf[p] = uf[q]; uf[q] = p; return true; } void adjust(int p) { if(seg.is_renew(p)){ uf.push_back(-1); seg.unset_renew(p); target[p] = uf.size() - 1; } } int main() { #ifndef ONLINE_JUDGE //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); #endif scanf("%d%d%d", &W, &H, &N); for(int i=0;i<N;i++){ scanf("%d%d%d%d", x1+i, y1+i, x2+i, y2+i); if(x1[i] > x2[i]) swap(x1[i], x2[i]); if(y1[i] > y2[i]) swap(y1[i], y2[i]); } for(int i=0;i<2*N;i++) target[i] = -1; x1[N ] = 0; y1[N ] = 0; x2[N ] = W; y2[N ] = 0; x1[N+1] = 0; y1[N+1] = 0; x2[N+1] = 0; y2[N+1] = H; x1[N+2] = W; y1[N+2] = 0; x2[N+2] = W; y2[N+2] = H; x1[N+3] = 0; y1[N+3] = H; x2[N+3] = W; y2[N+3] = H; N += 4; vector<int> xs; for(int i=0;i<N;i++){ xs.push_back(x1[i]); xs.push_back(x2[i]); } xs.push_back(-1); sort(xs.begin(), xs.end()); xs.erase(unique(xs.begin(), xs.end()), xs.end()); for(int i=0;i<N;i++){ x1[i] = lower_bound(xs.begin(), xs.end(), x1[i]) - xs.begin(); x2[i] = lower_bound(xs.begin(), xs.end(), x2[i]) - xs.begin(); } set<int> S; S.insert(0); target[0] = 0; uf.push_back(-1); vector<action> A; for(int i=0;i<N;i++){ if(x1[i] == x2[i]){ A.push_back(action(y1[i], 0, x1[i], -1)); A.push_back(action(y2[i], 2, x1[i], -1)); }else{ A.push_back(action(y1[i], 1, x1[i], x2[i])); } } sort(A.begin(), A.end()); long long ret = 0; for(int i=0;i<A.size();i++){ action V = A[i]; if(V.act == 0){ int lf = *--S.lower_bound(V.left); adjust(lf); adjust(V.left); target[V.left] = target[lf]; S.insert(V.left); seg.add(V.left, 1); }else if(V.act == 1){ int count = seg.query(V.left, V.right+1); if(count < 2) continue; ret += count - 1; seg.set_renew(V.left, *--S.upper_bound(V.right)); }else if(V.act == 2){ int lf = *--S.lower_bound(V.left); adjust(lf); adjust(V.left); if(join(target[lf], target[V.left])) --ret; S.erase(V.left); seg.add(V.left, -1); } //cout << V.act << " " << ret << endl; } printf("%lld\n", ret); return 0; }
a.cc:367:22: error: 'int y1 [100020]' redeclared as different kind of entity 367 | int x1[MAXN], y1[MAXN], x2[MAXN], y2[MAXN]; | ^ 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/requires_hosted.h:31, from /usr/include/c++/14/iostream:38, from a.cc:6: /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:412:43: warning: pointer to a function used in arithmetic [-Wpointer-arith] 412 | scanf("%d%d%d%d", x1+i, y1+i, x2+i, y2+i); | ~~^~ a.cc:414:24: warning: pointer to a function used in arithmetic [-Wpointer-arith] 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ^ a.cc:414:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~~~^~~~~~~ a.cc:414:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ^ a.cc:414:39: error: no matching function for call to 'swap(double (&)(double) noexcept, int&)' 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41: /usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ^~~~ /usr/include/c++/14/bits/exception_ptr.h:229:25: note: no known conversion for argument 1 from 'double(double) noexcept' to 'std::__exception_ptr::exception_ptr&' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ~~~~~~~~~~~~~~~^~~~~ In file included from /usr/include/c++/14/bits/exception_ptr.h:41: /usr/include/c++/14/bits/move.h:226:5: note: candidate: 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)' 226 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/14/bits/move.h:226:5: note: template argument deduction/substitution failed: a.cc:414:39: note: deduced conflicting types for parameter '_Tp' ('double(double) noexcept' and 'int') 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])' 250 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) | ^~~~ /usr/include/c++/14/bits/move.h:250:5: note: template argument deduction/substitution failed: a.cc:414:39: note: mismatched types '_Tp [_Nm]' and 'double(double) noexcept' 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' 1089 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: template argument deduction/substitution failed: a.cc:414:39: note: mismatched types 'std::pair<_T1, _T2>' and 'double(double) noexcept' 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted) 1106 | swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: template argument deduction/substitution failed: a.cc:414:39: note: mismatched types 'std::pair<_T1, _T2>' and 'double(double) noexcept' 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4039 | swap(basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~ /usr/include/c++/14/bits/basic_string.h:4039:5: note: template argument deduction/substitution failed: a.cc:414:39: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'double(double) noexcept' 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' 2805 | swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y) | ^~~~ /usr/include/c++/14/tuple:2805:5: note: template argument deduction/substitution failed: a.cc:414:39: note: mismatched types 'std::tuple<_UTypes ...>' and 'double(double) noexcept' 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted) 2823 | swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete; | ^~~~ /usr/include/c++/14/tuple:2823:5: note: template argument deduction/substitution failed: a.cc:414:39: note: mismatched types 'std::tuple<_UTypes ...>' and 'double(double) noexcept' 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/set:62, from a.cc:9: /usr/include/c++/14/bits/stl_tree.h:1675:5: note: candidate: 'template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> void std::swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)' 1675 | swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, | ^~~~ /usr/include/c++/14/bits/stl_tree.h:1675:5: note: template argument deduction/substitution failed: a.cc:414:39: note: mismatched types 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>' and 'double(double) noexcept' 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/set:63: /usr/include/c++/14/bits/stl_set.h:1061:5: note: candidate: 'template<class _Key, class _Compare, class _Alloc> void std::swap(set<_Key, _Compare, _Allocator>&, set<_Key, _Compare, _Allocator>&)' 1061 | swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y) | ^~~~ /usr/include/c++/14/bits/stl_set.h:1061:5: note: template argument deduction/substitution failed: a.cc:414:39: note: mismatched types 'std::set<_Key, _Compare, _Allocator>' and 'double(double) noexcept' 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/set:64: /usr/include/c++/14/bits/stl_multiset.h:1047:5: note: candidate: 'template<class _Key, class _Compare, class _Alloc> void std::swap(multiset<_Key, _Compare, _Allocator>&, multiset<_Key, _Compare, _Allocator>&)' 1047 | swap(multiset<_Key, _Compare, _Alloc>& __x, | ^~~~ /usr/include/c++/14/bits/stl_multiset.h:1047:5: note: template argument deduction/substitution failed: a.cc:414:39: note: mismatched types 'std::multiset<_Key, _Compare, _Allocator>' and 'double(double) noexcept' 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:66, from a.cc:10: /usr/include/c++/14/bits/stl_vector.h:2122:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(vector<_Tp, _Alloc>&, vector<_Tp, _Alloc>&)' 2122 | swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y) | ^~~~ /usr/include/c++/14/bits/stl_vector.h:2122:5: note: template argument deduction/substitution failed: a.cc:414:39: note: mismatched types 'std::vector<_Tp, _Alloc>' and 'double(double) noexcept' 414 | if(y1[i] > y2[i]) swap(y1[i], y2[i]); | ~~~~^~~~~~~~~~~~~~ a.cc:418:28: warning: pointer to a function used in arithmetic [-Wpointer-arith] 418 | x1[N ] = 0; y1[N ] = 0; x2[N ] = W; y2[N ] = 0; |
s067371496
p00525
C++
#pragma comment(linker, "/STACK:36777216") //#pragma GCC optimize ("O2") #define LOCAL //#include "testlib.h" #include<iostream> #include<cstdio> #include<algorithm> #include<set> #include<vector> //#include <tr1/unordered_set> //#include <tr1/unordered_map> //#include <array> using namespace std; #define REP(i, n) for (int i=0;i<n;++i) #define FOR(i, a, b) for (int i=a;i<b;++i) #define DWN(i, b, a) for (int i=b-1;i>=a;--i) #define REP_1(i, n) for (int i=1;i<=n;++i) #define FOR_1(i, a, b) for (int i=a;i<=b;++i) #define DWN_1(i, b, a) for (int i=b;i>=a;--i) #define REP_C(i, n) for (int n____=n,i=0;i<n____;++i) #define FOR_C(i, a, b) for (int b____=b,i=a;i<b____;++i) #define DWN_C(i, b, a) for (int a____=a,i=b-1;i>=a____;--i) #define REP_N(i, n) for (i=0;i<n;++i) #define FOR_N(i, a, b) for (i=a;i<b;++i) #define DWN_N(i, b, a) for (i=b-1;i>=a;--i) #define REP_1_C(i, n) for (int n____=n,i=1;i<=n____;++i) #define FOR_1_C(i, a, b) for (int b____=b,i=a;i<=b____;++i) #define DWN_1_C(i, b, a) for (int a____=a,i=b;i>=a____;--i) #define REP_1_N(i, n) for (i=1;i<=n;++i) #define FOR_1_N(i, a, b) for (i=a;i<=b;++i) #define DWN_1_N(i, b, a) for (i=b;i>=a;--i) #define REP_C_N(i, n) for (int n____=(i=0,n);i<n____;++i) #define FOR_C_N(i, a, b) for (int b____=(i=0,b);i<b____;++i) #define DWN_C_N(i, b, a) for (int a____=(i=b-1,a);i>=a____;--i) #define REP_1_C_N(i, n) for (int n____=(i=1,n);i<=n____;++i) #define FOR_1_C_N(i, a, b) for (int b____=(i=a,b);i<=b____;++i) #define DWN_1_C_N(i, b, a) for (int a____=(i=b,a);i>=a____;--i) #define ECH(it, A) for (__typeof((A).begin()) it=(A).begin(); it != (A).end(); ++it) #define rECH(it, A) for (__typeof((A).rbegin()) it=(A).rbegin(); it != (A).rend(); ++it) #define REP_S(i, str) for (char*i=str;*i;++i) #define REP_L(i, hd, suc) for (int i=hd;i;i=suc[i]) #define REP_G(i, u) REP_L(i,hd[u],suc) #define REP_SS(x, s) for (int x=s;x;x=(x-1)&s) #define DO(n) for ( int ____n = n; ____n-->0; ) #define REP_2(i, j, n, m) REP(i, n) REP(j, m) #define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m) #define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l) #define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l) #define REP_4(i, j, k, ii, n, m, l, nn) REP(i, n) REP(j, m) REP(k, l) REP(ii, nn) #define REP_4_1(i, j, k, ii, n, m, l, nn) REP_1(i, n) REP_1(j, m) REP_1(k, l) REP_1(ii, nn) #define ALL(A) A.begin(), A.end() #define LLA(A) A.rbegin(), A.rend() #define CPY(A, B) memcpy(A, B, sizeof(A)) #define INS(A, P, B) A.insert(A.begin() + P, B) #define ERS(A, P) A.erase(A.begin() + P) #define LBD(A, x) (lower_bound(ALL(A), x) - A.begin()) #define UBD(A, x) (upper_bound(ALL(A), x) - A.begin()) #define CTN(T, x) (T.find(x) != T.end()) #define SZ(A) int((A).size()) #define PB push_back #define MP(A, B) make_pair(A, B) #define PTT pair<T, T> #define Ts *this #define rTs return Ts #define fi first #define se second #define re real() #define im imag() #define Rush for(int ____T=RD(); ____T--;) #define Display(A, n, m) { \ REP(i, n){ \ REP(j, m-1) cout << A[i][j] << " "; \ cout << A[i][m-1] << endl; \ } \ } #define Display_1(A, n, m) { \ REP_1(i, n){ \ REP_1(j, m-1) cout << A[i][j] << " "; \ cout << A[i][m] << endl; \ } \ } typedef long long LL; //typedef long double DB; typedef double DB; typedef unsigned uint; typedef unsigned long long uLL; typedef vector<int> VI; template<class T> inline T& RD(T &); template<class T> inline void OT(const T &); //inline int RD(){int x; return RD(x);} inline LL RD(){LL x; return RD(x);} inline DB& RF(DB &); inline DB RF(){DB x; return RF(x);} inline char* RS(char *s); inline char& RC(char &c); inline char RC(); inline char& RC(char &c){scanf(" %c", &c); return c;} inline char RC(){char c; return RC(c);} //inline char& RC(char &c){c = getchar(); return c;} //inline char RC(){return getchar();} template<class T> inline T& RDD(T &); inline LL RDD(){LL x; return RDD(x);} template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;} template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;} template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;} template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;} template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;} template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);} template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);} template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);} template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);} inline char& RC(char &a, char &b){RC(a), RC(b); return a;} inline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;} inline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;} inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;} inline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;} inline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;} inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;} inline void RS(char *s1, char *s2){RS(s1), RS(s2);} inline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);} template<class T0,class T1>inline T0& RDD(T0&a, T1&b){RDD(a),RDD(b); return a;} template<class T0,class T1,class T2>inline T1& RDD(T0&a, T1&b, T2&c){RDD(a),RDD(b),RDD(c); return a;} template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));} template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));} template<class T> inline void CLR(T &A){A.clear();} template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);} template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);} template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);} template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);} template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);} template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);} template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);} template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);} template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);} template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);} template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);} template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);} template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);} template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);} template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);} template<class T> inline bool EPT(T &a){return a.empty();} template<class T> inline T& SRT(T &A){sort(ALL(A)); return A;} template<class T, class C> inline T& SRT(T &A, C B){sort(ALL(A), B); return A;} template<class T> inline T& RVS(T &A){reverse(ALL(A)); return A;} template<class T> inline T& UNQQ(T &A){A.resize(unique(ALL(A))-A.begin());return A;} template<class T> inline T& UNQ(T &A){SRT(A);return UNQQ(A);} //} /** Constant List .. **/ //{ const int MOD = int(1e9) + 7; const int INF = 0x3f3f3f3f; const LL INFF = 0x3f3f3f3f3f3f3f3fLL; const DB EPS = 1e-9; const DB OO = 1e20; const DB PI = acos(-1.0); //M_PI; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; //} /** Add On .. **/ //{ // <<= '0. Nichi Joo ., //{ template<class T> inline bool checkMin(T &a,const T b){return b < a ? a = b, 1 : 0;} template<class T> inline bool checkMax(T &a,const T b){return a < b ? a = b, 1 : 0;} template <class T, class C> inline bool checkUpd(T& a, const T b, C c){return c(b,a) ? a = b, 1 : 0;} template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);} template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);} template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));} template<class T> inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));} template<class T> inline T min(T a, T b, T c, T d, T e){return min(min(min(a,b),min(c,d)),e);} template<class T> inline T max(T a, T b, T c, T d, T e){return max(max(max(a,b),max(c,d)),e);} template<class T> inline T sqr(T a){return a*a;} template<class T> inline T cub(T a){return a*a*a;} template<class T> inline T ceil(T x, T y){return (x - 1) / y + 1;} template<class T> T abs(T x){return x>0?x:-x;} inline int sgn(DB x){return x < -EPS ? -1 : x > EPS;} inline int sgn(DB x, DB y){return sgn(x - y);} //} //} /** I/O Accelerator Interface .. **/ //{ #define g (c=getchar()) #define d isdigit(g) #define p x=x*10+c-'0' #define n x=x*10+'0'-c #define pp l/=10,p #define nn l/=10,n template<class T> inline T& RD(T &x){ char c;while(!d);x=c-'0';while(d)p; return x; } template<class T> inline T& RDD(T &x){ char c;while(g,c!='-'&&!isdigit(c)); if (c=='-'){x='0'-g;while(d)n;} else{x=c-'0';while(d)p;} return x; } inline DB& RF(DB &x){ //scanf("%lf", &x); char c;while(g,c!='-'&&c!='.'&&!isdigit(c)); if(c=='-')if(g=='.'){x=0;DB l=1;while(d)nn;x*=l;} else{x='0'-c;while(d)n;if(c=='.'){DB l=1;while(d)nn;x*=l;}} else if(c=='.'){x=0;DB l=1;while(d)pp;x*=l;} else{x=c-'0';while(d)p;if(c=='.'){DB l=1;while(d)pp;x*=l;}} return x; } #undef nn #undef pp #undef n #undef p #undef d #undef g inline char* RS(char *s){ //gets(s); scanf("%s", s); return s; } LL last_ans; int Case; template<class T> inline void OT(const T &x){ //printf("Case #%d: ", ++Case); //printf("%lld\n", x); //printf("%.9f\n", x); //printf("%d\n", x); cout << x << endl; //last_ans = x; } //}/* .................................................................................................................................. */ const int MAXN = 100020; struct seg_tree { static const int DEPTH = 19; static const int SIZE = 1<<DEPTH; int bit[1<<(DEPTH+1)]; int renew[1<<(DEPTH+1)]; seg_tree() { } void init() { for(int i=0;i<2*SIZE;i++) bit[i] = renew[i] = 0; } void add(int p, int v) { p += SIZE; while(p){ bit[p] += v; p >>= 1; } } int query(int l, int r) { l += SIZE; r += SIZE; int ret = 0; while(l < r){ if(l&1) ret += bit[l++]; if(r&1) ret += bit[--r]; l >>= 1; r >>= 1; } return ret; } void set_renew(int l, int r) { l += SIZE; r += SIZE; while(l < r){ if(l&1) renew[l++] = 1; if(r&1) renew[--r] = 1; l >>= 1; r >>= 1; } } bool is_renew(int p) { p += SIZE; while(p){ if(renew[p]) return true; p >>= 1; } return false; } void unset_renew(int p) { p += SIZE; for(int i=DEPTH-1;i>0;i--){ if(renew[p >> i]){ renew[p >> i] = 0; renew[(p>>i)*2] = renew[(p>>i)*2+1] = 1; } } renew[p] = 0; } }; struct action { int pos, act, left, right; action(int p, int a, int l, int r) { pos = p; act = a; left = l; right = r; } }; inline bool operator<(const action& a, const action& b) { return a.pos < b.pos || (a.pos == b.pos && a.act < b.act); } int W, H, N; int x1[MAXN], y1[MAXN], x2[MAXN], y2[MAXN]; vector<int> uf; seg_tree seg; int target[MAXN*2]; int root(int p) { return (uf[p] < 0) ? p : (uf[p] = root(uf[p])); } bool join(int p, int q) { p = root(p); q = root(q); if(p==q) return false; if(uf[p] < uf[q]) swap(p, q); uf[p] = uf[q]; uf[q] = p; return true; } void adjust(int p) { if(seg.is_renew(p)){ uf.push_back(-1); seg.unset_renew(p); target[p] = uf.size() - 1; } } int main() { #ifndef ONLINE_JUDGE //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); #endif scanf("%d%d%d", &W, &H, &N); for(int i=0;i<N;i++){ scanf("%d%d%d%d", x1+i, y1+i, x2+i, y2+i); if(x1[i] > x2[i]) swap(x1[i], x2[i]); if(y1[i] > y2[i]) swap(y1[i], y2[i]); } for(int i=0;i<2*N;i++) target[i] = -1; x1[N ] = 0; y1[N ] = 0; x2[N ] = W; y2[N ] = 0; x1[N+1] = 0; y1[N+1] = 0; x2[N+1] = 0; y2[N+1] = H; x1[N+2] = W; y1[N+2] = 0; x2[N+2] = W; y2[N+2] = H; x1[N+3] = 0; y1[N+3] = H; x2[N+3] = W; y2[N+3] = H; N += 4; vector<int> xs; for(int i=0;i<N;i++){ xs.push_back(x1[i]); xs.push_back(x2[i]); } xs.push_back(-1); sort(xs.begin(), xs.end()); xs.erase(unique(xs.begin(), xs.end()), xs.end()); for(int i=0;i<N;i++){ x1[i] = lower_bound(xs.begin(), xs.end(), x1[i]) - xs.begin(); x2[i] = lower_bound(xs.begin(), xs.end(), x2[i]) - xs.begin(); } set<int> S; S.insert(0); target[0] = 0; uf.push_back(-1); vector<action> A; for(int i=0;i<N;i++){ if(x1[i] == x2[i]){ A.push_back(action(y1[i], 0, x1[i], -1)); A.push_back(action(y2[i], 2, x1[i], -1)); }else{ A.push_back(action(y1[i], 1, x1[i], x2[i])); } } sort(A.begin(), A.end()); long long ret = 0; for(int i=0;i<A.size();i++){ action V = A[i]; if(V.act == 0){ int lf = *--S.lower_bound(V.left); adjust(lf); adjust(V.left); target[V.left] = target[lf]; S.insert(V.left); seg.add(V.left, 1); }else if(V.act == 1){ int count = seg.query(V.left, V.right+1); if(count < 2) continue; ret += count - 1; seg.set_renew(V.left, *--S.upper_bound(V.right)); }else if(V.act == 2){ int lf = *--S.lower_bound(V.left); adjust(lf); adjust(V.left); if(join(target[lf], target[V.left])) --ret; S.erase(V.left); seg.add(V.left, -1); } //cout << V.act << " " << ret << endl; } printf("%lld\n", ret); return 0; }
a.cc:186:15: error: 'acos' was not declared in this scope 186 | const DB PI = acos(-1.0); //M_PI; | ^~~~ a.cc:360:15: warning: built-in function 'y1' declared as non-function [-Wbuiltin-declaration-mismatch] 360 | int x1[MAXN], y1[MAXN], x2[MAXN], y2[MAXN]; | ^~
s457388517
p00525
C++
#include <windows.h> int WorkSize(void) { typedef struct { DWORD cb; DWORD PageFaultCount; SIZE_T PeakWorkingSetSize; SIZE_T WorkingSetSize; SIZE_T QuotaPeakPagedPoolUsage; SIZE_T QuotaPagedPoolUsage; SIZE_T QuotaPeakNonPagedPoolUsage; SIZE_T QuotaNonPagedPoolUsage; SIZE_T PagefileUsage; SIZE_T PeakPagefileUsage; } info_t; typedef BOOL(WINAPI*func_t)(HANDLE,info_t*,DWORD); static func_t func; static enum { FIRST,OK,ERR } flag; static HANDLE proc; info_t info; HINSTANCE dll; if (flag==FIRST) { if ((dll=LoadLibraryA("psapi"))==0) { flag=ERR; return 0; } func=(func_t)GetProcAddress(dll,"GetProcessMemoryInfo"); if (func==0) { flag=ERR; return 0; } proc=GetCurrentProcess(); flag=OK; } if (flag==ERR) return 0; func(proc,&info,sizeof info); return(int)info.WorkingSetSize; } #include<vector> #include<unordered_map> #include<algorithm> class Compression { public: Compression(const std::vector<int>& list) : value_(list) { std::sort(begin(value_), end(value_)); value_.erase(std::unique(begin(value_), end(value_)), end(value_)); for(int i = 0; i < value_.size(); ++i) index_[value_[i]] = i; } int size() const {return value_.size();} int index(const int v) const {return index_.at(v);} int operator[](const int i) const {return value_.at(i);} private: std::unordered_map<int, int> index_; std::vector<int> value_; }; #include<unordered_map> #include<utility> template<typename T> class UnionFind { public: void unite(const T& a, const T& b) { T x = find(a), y = find(b); if(rank_[x] < rank_[y]) std::swap(x, y); parent_[y] = x; if(rank_[x] == rank_[y]) rank_[x] += 1; } const T find(const T& x) { if(!parent_.count(x)) { rank_[x] = 1; return parent_[x] = x; } return (parent_[x] == x) ? x : (parent_[x] = find(parent_[x])); } private: std::unordered_map<T, T> parent_; std::unordered_map<T, int> rank_; }; #include<bits/stdc++.h> using namespace std; // [left, right) struct Node { int id, left, right; Node(int x) : id(2e9), left(x), right(2e9) {} Node(int i, int l, int r) : id(i), left(l), right(r) {} bool operator<(const Node& n) const { if(left != n.left) return left < n.left; if(right != n.right) return right < n.right; return id < n.id; } }; class SegmentTree { public: SegmentTree(int n) : size_(1) { while(size_ < n) size_ <<= 1; root_ = new Node(); } void add(int a, int b, int v) {add(a, b + 1, v, root_, 0, size_);} int find(int x) {return find(x, root_, 0, size_);} private: struct Node { int value; int lazy; Node *l_child, *r_child; }; inline void push(Node *n) { if(not n->l_child) n->l_child = new Node(); if(not n->r_child) n->r_child = new Node(); if(n->lazy) { n->l_child->lazy += n->lazy; n->r_child->lazy += n->lazy; n->value += n->lazy; n->lazy = 0; } } void add(int a, int b, int v, Node *n, int l, int r) { push(n); if(b <= l || r <= a) return; if(a <= l && r <= b) {n->lazy = v; return;}; auto m = (l + r) / 2; add(a, b, v, n->l_child, l, m); add(a, b, v, n->r_child, m, r); } int find(int x, Node *n, int l, int r) { push(n); if(x == l && x == r - 1) return n->value; auto m = (l + r) / 2; if(x < m) return find(x, n->l_child, l, m); else return find(x, n->r_child, m, r); } Node *root_; int size_; }; int main() { enum Type {Y_IN, X, Y_OUT}; struct Event {int y; Type type; int x1, x2;}; int W, H, N; cin >> W >> H >> N; list<Event> event; for(auto i = 0; i < N; ++i) { int A, B, C, D; cin >> A >> B >> C >> D; if(B == D) event.push_back({B, X, A, C}); else { event.push_back({B, Y_IN, A, C}); event.push_back({D, Y_OUT, A, C}); } } event.push_back({0, X, 0, W}); event.push_back({0, Y_IN, 0, 0}); event.push_back({0, Y_IN, W, W}); event.push_back({H, Y_OUT, 0, 0}); event.push_back({H, Y_OUT, W, W}); event.push_back({H, X, 0, W}); event.sort([](auto l, auto r) { if(l.y != r.y) return l.y < r.y; if(l.type != r.type) return l.type < r.type; if(l.x1 != r.x1) return l.x1 < r.x1; return l.x2 < r.x2; }); W += 3; for(auto& q: event) {++q.x1; ++q.x2;} vector<int> x = {W}; for(auto& q: event) { x.emplace_back(q.x1); x.emplace_back(q.x2); } Compression cx(x); for(auto& q: event) {q.x1 = cx.index(q.x1); q.x2 = cx.index(q.x2);} SegmentTree flag(cx.index(W)); UnionFind<int> group; int id = 0; set<Node> node; node.emplace(id, 0, cx.index(W)); while(!event.empty()) { // for(auto i:node)cout<<i.id<<"("<<group.find(i.id)<<")"<<": "<<i.left<<" to "<<i.right<<endl; // for(auto i=0;i<W;++i)cout<<" "<<flag.find(i);cout<<endl;cout<<endl; auto q = event.front(); event.pop_front(); if(q.type == Y_IN) { // cout<<"split: "<<q.y<<" "<<q.x1<<" "<<q.x2<<endl; auto n = node.upper_bound(q.x1); --n; if(n->right == q.x1) continue; auto f = flag.find(n->left); flag.add(n->left, n->right - 1, -f); auto i = f ? id + f : n->id; id += f + 1; group.unite(i, id); node.emplace(i, n->left, q.x1); node.emplace(id, q.x1, n->right); node.erase(n); } else if(q.type == Y_OUT) { // cout<<"merge: "<<q.y<<" "<<q.x1<<" "<<q.x2<<endl; auto l = node.upper_bound(q.x1); --l; if(q.x1 != l->left) continue; auto r = l--; auto fl = flag.find(l->left); auto fr = flag.find(r->left); flag.add(l->left, l->right - 1, -fl); flag.add(r->left, r->right - 1, -fr); if(fl==0 && fr==0) group.unite(l->id, r->id); else if(fl==0) group.unite(l->id, id + fr); else if(fr==0) group.unite(id + fl, r->id); else group.unite(id + fl, id + fl + fr); if(fl==0 && fr==0) node.emplace(l->id, l->left, r->right); else node.emplace(id += fl + fr, l->left, r->right); node.erase(l); node.erase(r); } else { // cout<<"separate: "<<q.y<<" "<<q.x1<<" "<<q.x2<<endl; auto l = node.upper_bound(q.x1); auto r = node.upper_bound(q.x2); --l; --r; if(l->left != q.x1) ++l; if(r->right != q.x2) --r; if(l == end(node)) continue; if(r->right <= l->left) continue; flag.add(l->left, r->right - 1, 1); } } // for(auto i:node)cout<<i.id<<"("<<group.find(i.id)<<")"<<": "<<i.left<<" to "<<i.right<<endl; // for(auto i=0;i<W;++i)cout<<" "<<flag.find(i);cout<<endl;cout<<endl; set<int> res; for(auto i = 0; i <= id; ++i) res.emplace(group.find(i)); cout << res.size() - 1 << endl; }
a.cc:1:10: fatal error: windows.h: No such file or directory 1 | #include <windows.h> | ^~~~~~~~~~~ compilation terminated.
s591383143
p00525
C++
#include <bits/stdc++.h> using namespace std; struct Line { int x1, y1, x2, y2; Line (int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {} }; struct Query { int l, r, id; Query (int l, int r, int id) : l(l), r(r), id(id) {} void dbg() { cout << "Query " << l << ' ' << r << ' ' << id << '\n'; } }; struct Update { int p, t, id; Update (int p, int t, int id) : p(p), t(t), id(id) {} void dbg() { cout << "Update " << p << ' ' << t << ' ' << id << '\n'; } }; const int N = 100005; int w, h, n; int it[2][8 * N]; int go[2][40 * N]; int pos[40 * N]; bool visit[40 * N]; int cnt, cntv, cnte, cntc; vector<Line> a; vector<int> vx, vy, G[N]; vector<Update> update[N * 2]; vector<Query> query[N * 2]; void addEdge(int u, int v) { //cout << u << ' ' << v << '\n'; G[u].push_back(v), G[v].push_back(u); } void add(int x, int y) { if (y == 32) cout << x << '\n'; if (pos[x]) addEdge(pos[x], y); if (visit[x]) return; visit[x] = 1; for (int i = 0; i < 2; ++i) { if (!go[i][x]) continue; add(go[i][x], y); } } void upd(int i, int l, int r, int p, int t, int id) { it[0][i] += t, it[1][i] = ++cnt; if (!it[0][i]) it[1][i] = 0; if (l == r) { if (t) pos[it[1][i]] = id; return; } int mid = (l + r) >> 1; if (p <= mid) upd(i << 1, l, mid, p, t, id); else upd(i << 1 | 1, mid + 1, r, p, t, id); go[0][it[1][i]] = it[1][i << 1], go[1][it[1][i]] = it[1][i << 1 | 1]; } int get(int i, int l, int r, int u, int v, int id) { if (l > v || u > r) return 0; if (u <= l && r <= v) { if (it[1][i]) { add(it[1][i], id), pos[it[1][i]] = id; } return it[0][i]; } int mid = (l + r) >> 1; return get(i << 1, l, mid, u, v, id) + get(i << 1 | 1, mid + 1, r, u, v, id); } void dfs(int u) { visit[u] = 1; for (auto v : G[u]) { if (!visit[v]) dfs(v); } } void addLine(int x1, int y1, int x2, int y2) { a.push_back(Line(x1, y1, x2, y2)); vx.push_back(x1), vx.push_back(x2); vy.push_back(y1), vy.push_back(y2); } int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); ios::sync_with_stdio(false); cin >> w >> h >> n; addLine(0, 0, 0, h); addLine(0, h, w, h); addLine(w, 0, w, h); addLine(0, 0, w, 0); for (int i = 0; i < n; ++i) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; addLine(x1, y1, x2, y2); } n += 4, cntv = n * 2, cnte = cnt = n; sort(vx.begin(), vx.end()), sort(vy.begin(), vy.end()); for (int i = 0; i < n; ++i) { a[i].x1 = lower_bound(vx.begin(), vx.end(), a[i].x1) - vx.begin(); a[i].y1 = lower_bound(vy.begin(), vy.end(), a[i].y1) - vy.begin(); a[i].x2 = lower_bound(vx.begin(), vx.end(), a[i].x2) - vx.begin(); a[i].y2 = lower_bound(vy.begin(), vy.end(), a[i].y2) - vy.begin(); if (a[i].y1 == a[i].y2) { update[a[i].x1].push_back(Update(a[i].y1, 1, i + 1)); update[a[i].x2 + 1].push_back(Update(a[i].y2, -1, i + 1)); } else { query[a[i].x1].push_back(Query(a[i].y1, a[i].y2, i + 1)); } } for (int i = 0; i < n * 2; ++i) { for (auto j : update[i]) { if (j.t == -1) { //j.dbg(); upd(1, 0, n * 2, j.p, j.t, j.id); } } for (auto j : update[i]) { if (j.t == 1) { //j.dbg(); upd(1, 0, n * 2, j.p, j.t, j.id); } } for (auto j : query[i]) { //j.dbg(); int tmp = get(1, 0, n * 2, j.l, j.r, j.id); cntv += tmp, cnte += tmp * 2; } } memset(visit, 0, sizeof(visit)); for (int i = 1; i <= n; ++i) { if (!visit[i]) dfs(i), cntc++; } //cout << "End " << cntc << ' ' << cntv << ' ' << cnte << '\n'; cout << cntc - cntv + cnte; }
a.cc: In function 'void add(int, int)': a.cc:53:9: error: reference to 'visit' is ambiguous 53 | if (visit[x]) return; visit[x] = 1; | ^~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80, from a.cc:1: /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~ a.cc:53:27: error: reference to 'visit' is ambiguous 53 | if (visit[x]) return; visit[x] = 1; | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~ a.cc: In function 'void dfs(int)': a.cc:85:5: error: reference to 'visit' is ambiguous 85 | visit[u] = 1; | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~ a.cc:87:14: error: reference to 'visit' is ambiguous 87 | if (!visit[v]) dfs(v); | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~ a.cc: In function 'int main()': a.cc:152:12: error: reference to 'visit' is ambiguous 152 | memset(visit, 0, sizeof(visit)); | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~ a.cc:152:29: error: reference to 'visit' is ambiguous 152 | memset(visit, 0, sizeof(visit)); | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~ a.cc:154:14: error: reference to 'visit' is ambiguous 154 | if (!visit[i]) dfs(i), cntc++; | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~
s284336431
p00525
C++
#include <bits/stdc++.h> using namespace std; struct Line { int x1, y1, x2, y2; Line (int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {} }; struct Query { int l, r, id; Query (int l, int r, int id) : l(l), r(r), id(id) {} void dbg() { cout << "Query " << l << ' ' << r << ' ' << id << '\n'; } }; struct Update { int p, t, id; Update (int p, int t, int id) : p(p), t(t), id(id) {} void dbg() { cout << "Update " << p << ' ' << t << ' ' << id << '\n'; } }; const int N = 100005; int w, h, n; int it[2][8 * N]; int go[2][40 * N]; int pos[40 * N]; bool visit[40 * N]; int cnt, cntv, cnte, cntc; vector<Line> a; vector<int> vx, vy, G[N]; vector<Update> update[N * 2]; vector<Query> query[N * 2]; void addEdge(int u, int v) { //cout << u << ' ' << v << '\n'; G[u].push_back(v), G[v].push_back(u); } void add(int x, int y) { if (pos[x]) addEdge(pos[x], y); if (visit[x]) return; visit[x] = 1; for (int i = 0; i < 2; ++i) { if (!go[i][x]) continue; add(go[i][x], y); } } void upd(int i, int l, int r, int p, int t, int id) { it[0][i] += t, it[1][i] = ++cnt; if (!it[0][i]) it[1][i] = 0; if (l == r) { if (t == 1) pos[it[1][i]] = id; return; } int mid = (l + r) >> 1; if (p <= mid) upd(i << 1, l, mid, p, t, id); else upd(i << 1 | 1, mid + 1, r, p, t, id); go[0][it[1][i]] = it[1][i << 1], go[1][it[1][i]] = it[1][i << 1 | 1]; } int get(int i, int l, int r, int u, int v, int id) { if (l > v || u > r) return 0; if (u <= l && r <= v) { if (it[1][i]) { add(it[1][i], id), pos[it[1][i]] = id; } return it[0][i]; } int mid = (l + r) >> 1; return get(i << 1, l, mid, u, v, id) + get(i << 1 | 1, mid + 1, r, u, v, id); } void dfs(int u) { visit[u] = 1; for (auto v : G[u]) { if (!visit[v]) dfs(v); } } void addLine(int x1, int y1, int x2, int y2) { a.push_back(Line(x1, y1, x2, y2)); vx.push_back(x1), vx.push_back(x2); vy.push_back(y1), vy.push_back(y2); } int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); ios::sync_with_stdio(false); cin >> w >> h >> n; addLine(0, 0, 0, h); addLine(0, h, w, h); addLine(w, 0, w, h); addLine(0, 0, w, 0); for (int i = 0; i < n; ++i) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; addLine(x1, y1, x2, y2); } n += 4, cntv = n * 2, cnte = cnt = n; sort(vx.begin(), vx.end()), sort(vy.begin(), vy.end()); for (int i = 0; i < n; ++i) { a[i].x1 = lower_bound(vx.begin(), vx.end(), a[i].x1) - vx.begin(); a[i].y1 = lower_bound(vy.begin(), vy.end(), a[i].y1) - vy.begin(); a[i].x2 = lower_bound(vx.begin(), vx.end(), a[i].x2) - vx.begin(); a[i].y2 = lower_bound(vy.begin(), vy.end(), a[i].y2) - vy.begin(); if (a[i].y1 == a[i].y2) { update[a[i].x1].push_back(Update(a[i].y1, 1, i + 1)); update[a[i].x2 + 1].push_back(Update(a[i].y2, -1, i + 1)); } else { query[a[i].x1].push_back(Query(a[i].y1, a[i].y2, i + 1)); } } for (int i = 0; i < n * 2; ++i) { for (auto j : update[i]) { if (j.t == -1) { //j.dbg(); upd(1, 0, n * 2, j.p, j.t, j.id); } } for (auto j : update[i]) { if (j.t == 1) { //j.dbg(); upd(1, 0, n * 2, j.p, j.t, j.id); } } for (auto j : query[i]) { //j.dbg(); int tmp = get(1, 0, n * 2, j.l, j.r, j.id); cntv += tmp, cnte += tmp * 2; } } memset(visit, 0, sizeof(visit)); for (int i = 1; i <= n; ++i) { if (!visit[i]) dfs(i), cntc++; } //cout << "End " << cntc << ' ' << cntv << ' ' << cnte << '\n'; cout << cntc - cntv + cnte << '\n'; }
a.cc: In function 'void add(int, int)': a.cc:52:9: error: reference to 'visit' is ambiguous 52 | if (visit[x]) return; visit[x] = 1; | ^~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80, from a.cc:1: /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~ a.cc:52:27: error: reference to 'visit' is ambiguous 52 | if (visit[x]) return; visit[x] = 1; | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~ a.cc: In function 'void dfs(int)': a.cc:84:5: error: reference to 'visit' is ambiguous 84 | visit[u] = 1; | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~ a.cc:86:14: error: reference to 'visit' is ambiguous 86 | if (!visit[v]) dfs(v); | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~ a.cc: In function 'int main()': a.cc:151:12: error: reference to 'visit' is ambiguous 151 | memset(visit, 0, sizeof(visit)); | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~ a.cc:151:29: error: reference to 'visit' is ambiguous 151 | memset(visit, 0, sizeof(visit)); | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~ a.cc:153:14: error: reference to 'visit' is ambiguous 153 | if (!visit[i]) dfs(i), cntc++; | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:38:6: note: 'bool visit [4000200]' 38 | bool visit[40 * N]; | ^~~~~
s946342147
p00526
C++
#include<iostream> #define MAX_N 100000 int N; int a[MAX_N]; //??¶??? int p[MAX_N]; //?????????, a[i] = a[i + 1]??????i???????´? int p_tail; //p????????????????´? int main() { scanf("%d", &N); p[0] = -1; p_tail = 0; for (int i = 0; i < N; i++) { scanf("%d", &a[i]); if(i > 0 && a[i] == a[i - 1]) { p[tail + 1] = i - 1; p_tail++; } } p[p_tail + 1] = N - 1; p_tail++; //a[i + 3] - a[i]????????§????????§?????????????????¢??? if(p_tail < 2) { printf("%d\n", N); } else { int ans = 0; for(int i = 0; i <= p_tail - 3; i++) { if(ans < a[i + 3] - a[i]) { ans = a[i + 3] - a[i]; } } printf("%d\n", ans); } return 0; }
a.cc: In function 'int main()': a.cc:17:9: error: 'tail' was not declared in this scope; did you mean 'p_tail'? 17 | p[tail + 1] = i - 1; | ^~~~ | p_tail
s074090576
p00526
C++
#include <iostream> #include <string> #include <sstream> #include <algorithm> #include <vector> #include <utility> #include <functional> #include <stack> #include <queue> #include <map> #include <set> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <deque> #include <ctime> using namespace std; #define rep(i,n) REP(i,0,n) #define REP(i,s,e) for(int i=(s); i<(int)(e); i++) #define pb push_back #define mp make_pair #define all(r) (r).begin(),(r).end() #define rall(r) (r).rbegin(),(r).rend() #define fi first #define se second #define println(X) cout<<X<<endl; #define DBG(X) cout<<#X<<" : "<<X<<endl; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef vector<ll> vl; typedef vector<vl> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; const ll MOD = 1e9 + 7; double EPS = 1e-8; const double PI = acos(-1); int a[100010]; int main(){ int n; cin>>n; rep(i, n) cin>>a[i]; vi s(n+1), t(1); for(int i = 1; i < n; i++){ if(a[i] != a[i-1]) s[i] = s[i-1]+1; else t.pb(i); } if(t.size()==1) ans = n; t.pb(n); int ans = 2; for(int i = 0; i + 1 < t.size(); i++){ int tmp = t[i+1]-t[i]; //cout<<" "<<i<<" "<<tmp; if(i + 2 < t.size()) tmp += t[i+2]-t[i+1]; if(i + 3 < t.size()) tmp += t[i+3]-t[i+2]; //cout<<" "<<tmp<<endl; ans = max(tmp, ans); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:57:25: error: 'ans' was not declared in this scope; did you mean 'abs'? 57 | if(t.size()==1) ans = n; | ^~~ | abs
s145561649
p00526
C++
//============================================================================ // Name : AOJ.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> using namespace std; int main() { int N; int D[100000]; int R=0; cin>N; for(int i=0;i<N;i++){ cin>>D[i]; } int a1,a2,a3; for(int i=1;i<N;i++){ if(D[i]==D[i-1]){ R=max(R,a3); a3=a2+1; a2=a1+1; a1=1; } if(D[i]!=D[i-1]){ a1+=1; a2+=1; a3+=1; } } R=max(R,a1); R=max(R,a2); R=max(R,a3); cout<<R<<endl; return 0; }
a.cc: In function 'int main()': a.cc:16:12: error: no match for 'operator>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int') 16 | cin>N; | ~~~^~ | | | | | int | std::istream {aka std::basic_istream<char>} a.cc:16:12: note: candidate: 'operator>(int, int)' (built-in) 16 | cin>N; | ~~~^~ a.cc:16:12: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:9: /usr/include/c++/14/bits/stl_iterator.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 462 | operator>(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 16 | cin>N; | ^ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 507 | operator>(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 16 | cin>N; | ^ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1714 | operator>(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 16 | cin>N; | ^ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1774 | operator>(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 16 | cin>N; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>' 16 | cin>N; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:695:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 695 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:695:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 16 | cin>N; | ^ /usr/include/c++/14/string_view:702:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 702 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:702:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 16 | cin>N; | ^ /usr/include/c++/14/string_view:710:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 710 | operator> (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:710:5: note: template argument deduction/substitution failed: a.cc:16:13: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 16 | cin>N; | ^ /usr/include/c++/14/bits/basic_string.h:3915:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3915 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3915:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 16 | cin>N; | ^ /usr/include/c++/14/bits/basic_string.h:3929:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3929 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3929:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 16 | cin>N; | ^ /usr/include/c++/14/bits/basic_string.h:3942:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3942 | operator>(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3942:5: note: template argument deduction/substitution failed: a.cc:16:13: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>' 16 | cin>N; | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2619:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator>(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2619 | operator>(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2619:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>' 16 | cin>N; | ^
s725730202
p00526
C++
//============================================================================ // Name : AOJ.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> using namespace std; int main() { int N; int D[100000]; int R=0; cin>N; for(int i=0;i<N;i++){ cin>>D[i]; } int a1=1,a2=1,a3=1; for(int i=1;i<N;i++){ if(D[i]==D[i-1]){ R=max(R,a3); a3=a2+1; a2=a1+1; a1=1; } if(D[i]!=D[i-1]){ a1+=1; a2+=1; a3+=1; } } R=max(R,a1); R=max(R,a2); R=max(R,a3); cout<<R<<endl; return 0; }
a.cc: In function 'int main()': a.cc:16:12: error: no match for 'operator>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int') 16 | cin>N; | ~~~^~ | | | | | int | std::istream {aka std::basic_istream<char>} a.cc:16:12: note: candidate: 'operator>(int, int)' (built-in) 16 | cin>N; | ~~~^~ a.cc:16:12: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:9: /usr/include/c++/14/bits/stl_iterator.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 462 | operator>(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 16 | cin>N; | ^ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 507 | operator>(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 16 | cin>N; | ^ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1714 | operator>(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 16 | cin>N; | ^ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1774 | operator>(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 16 | cin>N; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>' 16 | cin>N; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:695:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 695 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:695:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 16 | cin>N; | ^ /usr/include/c++/14/string_view:702:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 702 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:702:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 16 | cin>N; | ^ /usr/include/c++/14/string_view:710:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 710 | operator> (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:710:5: note: template argument deduction/substitution failed: a.cc:16:13: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 16 | cin>N; | ^ /usr/include/c++/14/bits/basic_string.h:3915:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3915 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3915:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 16 | cin>N; | ^ /usr/include/c++/14/bits/basic_string.h:3929:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3929 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3929:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 16 | cin>N; | ^ /usr/include/c++/14/bits/basic_string.h:3942:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3942 | operator>(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3942:5: note: template argument deduction/substitution failed: a.cc:16:13: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>' 16 | cin>N; | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2619:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator>(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2619 | operator>(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2619:5: note: template argument deduction/substitution failed: a.cc:16:13: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>' 16 | cin>N; | ^
s781845444
p00527
C++
#include<iostream> #include<cstdio> #include<math.h> #include<algorithm> using namespace std; int N,M; char S[2001],T[2001]; int dp[2000][2000][2]; int main() { cin >> N >> M; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { dp[i][j][1] = -INT_MAX; dp[i][j][0] = 0; } } scanf("%s", S + 1); scanf("%s", T + 1); int MAX = 0; for (int s = 0; s < N; s++) { for (int t = 0; t < M; t++) { if (s < N&&S[s + 1] == 'I') { dp[s + 1][t][1] = max(dp[s + 1][t][1], dp[s][t][0] + 1); MAX = max(MAX, dp[s+1][t][1]); } if (t < M&&T[t + 1] == 'I') { dp[s][t + 1][1] = max(dp[s][t + 1][1], dp[s][t][0] + 1); MAX = max(MAX, dp[s][t+1][1]); } if (s < N&&S[s + 1] == 'O') { dp[s + 1][t][0] = max(dp[s + 1][t][0], dp[s][t][1] + 1); MAX = max(MAX, dp[s+1][t][0]); } if (t < M&&T[t + 1] == 'O') { dp[s][t + 1][0] = max(dp[s][t + 1][0], dp[s][t][1] + 1); MAX = max(MAX, dp[s][t+1][0]); } } } cout << MAX - ((MAX + 1) % 2) << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:40: error: 'INT_MAX' was not declared in this scope 14 | dp[i][j][1] = -INT_MAX; | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include<algorithm> +++ |+#include <climits> 5 | using namespace std;
s522032311
p00527
C++
#include<iostream> #include<cstdio> #include<math.h> #include<algorithm> using namespace std; int N,M; char S[2001],T[2001]; int dp[2000][2000][2]; int main() { cin >> N >> M; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { dp[i][j][1] = -INT_MAX; dp[i][j][0] = 0; } } scanf("%s", S + 1); scanf("%s", T + 1); int MAX = 0; for (int s = 0; s < N; s++) { for (int t = 0; t < M; t++) { if (s < N&&S[s + 1] == 'I') { dp[s + 1][t][1] = max(dp[s + 1][t][1], dp[s][t][0] + 1); MAX = max(MAX, dp[s+1][t][1]); } if (t < M&&T[t + 1] == 'I') { dp[s][t + 1][1] = max(dp[s][t + 1][1], dp[s][t][0] + 1); MAX = max(MAX, dp[s][t+1][1]); } if (s < N&&S[s + 1] == 'O') { dp[s + 1][t][0] = max(dp[s + 1][t][0], dp[s][t][1] + 1); //MAX = max(MAX, dp[s+1][t][0]); } if (t < M&&T[t + 1] == 'O') { dp[s][t + 1][0] = max(dp[s][t + 1][0], dp[s][t][1] + 1); //MAX = max(MAX, dp[s][t+1][0]); } } } cout << MAX << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:40: error: 'INT_MAX' was not declared in this scope 14 | dp[i][j][1] = -INT_MAX; | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include<algorithm> +++ |+#include <climits> 5 | using namespace std;
s522317126
p00527
C++
#include<iostream> #include<algorithm> using namespace std; int s[2000]; int t[2000]; int main(){ char hoge; int m,n; cin>>m>>n; for(int i=0;i<m;i++){ cin>>hoge; if(hoge=='I'){s[i]=1;} else{s[i]=0;} } for(int i=0;i<n;i++){ cin>>hoge; if(hoge=='I'){t[i]=1;} else{t[i]=0;} } int ans=0; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ bool loop = true; int ci=i; int cj=j; int cans=0; while(loop==true){ if(s[ci]!=1 and t[cj]!=1){loop=false;} else{ if(s[ci]==1 and t[cj]==0){ ci++; cans++; } else if(s[ci]==0 and t[cj]==1){ cj++; cans++; } else if(s[ci]==0 and t[si]==0){loop = false;} else{ if(ci+1<n and s[ci+1]==0){ ci++; cans++; } else if(cj+1<n){ cj++; cans++; } else{loop=false;} } if(ci+1<n and s[ci]==0 and t[cj]==1){ ci++; cans++; } else if(cj+1<n and s[ci]==1 and t[cj]==0){ cj++; cans++; } else if(s[ci]==1 and t[cj]==1){loop=false;} else{ if(ci+1<n and s[ci+1]==1){ ci++; cans++; } else if(cj+1<n){ cj++; cans++; } else{loop=false;} } } } ans=max(ans,cans); } } if(ans%2==0){ans--;} cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:43:64: error: 'si' was not declared in this scope; did you mean 'ci'? 43 | else if(s[ci]==0 and t[si]==0){loop = false;} | ^~ | ci
s370963346
p00527
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pii pair<int,int> #define INF 1<<29 #define MAX using namespace std; int n,m,dp[2020][2020]; string s,t; int dfs(int o,int d){ if(dp[o][d]>=0) return dp[o][d]; int ma=0; if((n+m-o-d)&1){ if(o&&s[o-1]=='O') ma=max(ma,dfs(o-1,d)+1); if(d&&t[d-1]=='O') ma=max(ma,dfs(o,d-1)+1); } else{ if(o&&s[o-1]=='I') ma=max(ma,dfs(o-1,d)+1); if(d&&t[d-1]=='I') ma=max(ma,dfs(o,d-1)+1); } return dp[o][d]=ma; } void solve(){ cin>>n>>m; cin>>s; cin>>t; FOR(i,n+1) FOR(j,m+1) dp[i][j]=-1; dfs(n,m); int ma=0; FOR(i,n+1){ FOR(j,m+1){ if((n+m-o-d)&1) ma=max(ma,dp[i][j]); } } cout<<ma<<endl; } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:42:12: error: 'o' was not declared in this scope 42 | if((n+m-o-d)&1) ma=max(ma,dp[i][j]); | ^ a.cc:42:14: error: 'd' was not declared in this scope 42 | if((n+m-o-d)&1) ma=max(ma,dp[i][j]); | ^
s797696922
p00527
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pii pair<int,int> #define INF 1<<29 #define MAX using namespace std; int n,m,dp[2020][2020]; string s,t; int dfs(int o,int d){ if(dp[o][d]>=0) return dp[o][d]; int ma=0; if((n+m-o-d)&1){ if(o&&s[o-1]=='O') ma=max(ma,dfs(o-1,d)+1); if(d&&t[d-1]=='O') ma=max(ma,dfs(o,d-1)+1); } else{ if(o&&s[o-1]=='I') ma=max(ma,dfs(o-1,d)+1); if(d&&t[d-1]=='I') ma=max(ma,dfs(o,d-1)+1); } return dp[o][d]=ma; } void solve(){ cin>>n>>m; cin>>s; cin>>t; FOR(i,n+1) FOR(j,m+1) dp[i][j]=-1; int p=dfs(n,m); if(p&1) cout<<p<<endl; else if(p) cout<<p-1<<endl; else cout<<0<<end; } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:41:14: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>') 41 | else cout<<0<<end; | ~~~~~~~^~~~~ In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:1: /usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'} 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]' 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int' 174 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int' 178 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool' 182 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int' 97 | operator<<(short __n) | ~~~~~~^~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int' 189 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int' 111 | operator<<(int __n) | ~~~~^~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int' 200 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int' 211 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int' 215 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double' 231 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float' 235 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double' 243 | operator<<(long double __f) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 301 | operator<<(const void* __p) | ^~~~~~~~ /usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*' 301 | operator<<(const void* __p) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]' 306 | oper
s491230082
p00527
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pii pair<int,int> #define INF 1<<29 #define MAX using namespace std; int n,m,dp[2020][2020]; string s,t; int dfs(int o,int d){ if(dp[o][d]>=0) return dp[o][d]; int ma=0; if((n+m-o-d)&1){ if(o&&s[o-1]=='O') ma=max(ma,dfs(o-1,d)+1); if(d&&t[d-1]=='O') ma=max(ma,dfs(o,d-1)+1); } else{ if(o&&s[o-1]=='I') ma=max(ma,dfs(o-1,d)+1); if(d&&t[d-1]=='I') ma=max(ma,dfs(o,d-1)+1); } return dp[o][d]=ma; } void solve(){ cin>>n>>m; cin>>s; cin>>t; FOR(i,n+1) FOR(j,m+1) dp[i][j]=-1; int p=dfs(n,m); if(!p||(p&1)){ cout<<p<<endl; return; } p--; else cout<<p<<endl; } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:44:2: error: 'else' without a previous 'if' 44 | else cout<<p<<endl; | ^~~~
s658834579
p00527
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pii pair<int,int> #define INF 1<<29 #define MAX using namespace std; int n,m,dp[2020][2020][2]; string s,t; int dfs(int o,int d,int odd){ if(dp[o][d][odd]>=0) return dp[o][d][odd]; int ma=0; if(odd){ if(o<n&&s[o]=='O') ma=max(ma,dfs(o+1,d,odd^1)+1); if(d<m&&t[d]=='O') ma=max(ma,dfs(o,d+1,odd^1)+1); } else{ if(o<n&&s[o]!='O') ma=max(ma,dfs(o+1,d,odd^1)+1); if(d<m&&t[d]!='O') ma=max(ma,dfs(o,d+1,odd^1)+1); } if(o<n) ma=max(ma,max(dfs(o+1,d,odd)); if(d<n) ma=max(ma,max(dfs(o,d+1,odd)); return dp[o][d][odd]=ma; } void solve(){ cin>>n>>m; cin>>s; cin>>t; FOR(i,n+1) FOR(j,m+1) FOR(k,2) dp[i][j][k]=-1; int p=dfs(0,0,0); if(!p||(p&1)) cout<<p<<endl; else cout<<p-1<<endl; } int main(){ solve(); return 0; }
a.cc: In function 'int dfs(int, int, int)': a.cc:30:23: error: no matching function for call to 'max(int)' 30 | if(o<n) ma=max(ma,max(dfs(o+1,d,odd)); | ~~~^~~~~~~~~~~~~~~~ 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: candidate expects 2 arguments, 1 provided /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, 1 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: template argument deduction/substitution failed: a.cc:30:23: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 30 | if(o<n) ma=max(ma,max(dfs(o+1,d,odd)); | ~~~^~~~~~~~~~~~~~~~ /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: candidate expects 2 arguments, 1 provided a.cc:31:23: error: no matching function for call to 'max(int)' 31 | if(d<n) ma=max(ma,max(dfs(o,d+1,odd)); | ~~~^~~~~~~~~~~~~~~~ /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: candidate expects 2 arguments, 1 provided /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, 1 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: template argument deduction/substitution failed: a.cc:31:23: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 31 | if(d<n) ma=max(ma,max(dfs(o,d+1,odd)); | ~~~^~~~~~~~~~~~~~~~ /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: candidate expects 2 arguments, 1 provided
s809477572
p00527
C++
#include <stdio.h> #include <algorithm> using namespace std; char s[2001], t[2001]; int dp[2001][2001][2]; int m, n; int main() { scanf("%d %d", &m, &n); scanf("%s", s); scanf("%s", t); int ans = 0; memset(dp, 0, sizeof(dp)); for (int i = m; i >= 0; --i) { for (int j = n; j >= 0; --j) { dp[i][j][0] = max((s[i] == 'O') ? dp[i + 1][j][1] + 1 : 0, (t[j] == 'O') ? dp[i][j + 1][1] + 1 : 0); dp[i][j][1] = max((s[i] == 'I') ? dp[i + 1][j][0] + 1 : 0, (t[j] == 'I') ? dp[i][j + 1][0] + 1 : 0); if (s[i] == 'I' || t[i] == 'I') { dp[i][j][0] = max(dp[i][j][0], 1); dp[i][j][1] = max(dp[i][j][1], 1); } ans = max(dp[i][j][0], ans); ans = max(dp[i][j][1], ans); } } printf("%d\n", (ans - 1) / 2 * 2 + 1); return 0; }
a.cc: In function 'int main()': a.cc:17:9: error: 'memset' was not declared in this scope 17 | memset(dp, 0, sizeof(dp)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <algorithm> +++ |+#include <cstring> 4 |
s902376812
p00527
C++
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define INF (1<<29) char s[2001], t[2001]; int n, m; int dp[2001][2001][2]; int dfs(int is, int it, bool I) { if (dp[is][it][I] != INF) return dp[is][it][I]; int res = 0; if (is < m) { if (s[is] == 'I' && !I) res = max(res, dfs(is + 1, it, true) + 1); if (s[is] == 'O' && I) res = max(res, dfs(is + 1, it, false) + 1); } if (it < n) { if (t[it] == 'I' && !I) res = max(res, dfs(is, it + 1, true) + 1); if (t[it] == 'O' && I) res = max(res, dfs(is, it + 1, false) + 1); } return dp[is][it][I?1:0] = res; } int main() { cin >> m >> n; cin >> s >> t; fill(dp[0][0], dp[m][0], INF);a int ans = 0; REP(i, m) REP(j, n) { int res = dfs(i, j, false); if (res % 2 == 1) ans = max(ans, res); } cout << ans << endl; return 0; } /* dp[i][j][k] = -1; if (s[i] == 'I') dp[i + 1][j][1] = 1; if (t[i] == 'I') dp[i][j + 1][1] = 1; dp[0][0][0] = 0; dp[i][j][k] = S??????i????????\???, T??????j??????????????§??????????????¨??£?????????k(I:1,O:0)?????¨??????????????????????????§ if (s[i] == 'I') dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][0] + 1); else dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][1] + 1); if (t[i] == 'O') dp[i][j + 1][0] = max(dp[i][j + 1][0], dp[i][j][1] + 1); else dp[i][j + 1][1] = max(dp[i][j + 1][1], dp[i][j][0] + 1); ans : max(dp[i][j][1]) */
a.cc: In function 'int main()': a.cc:35:39: error: 'a' was not declared in this scope 35 | fill(dp[0][0], dp[m][0], INF);a | ^ a.cc:40:35: error: 'ans' was not declared in this scope; did you mean 'abs'? 40 | if (res % 2 == 1) ans = max(ans, res); | ^~~ | abs a.cc:43:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 43 | cout << ans << endl; | ^~~ | abs
s567011718
p00527
C++
#include <iostream> #include <algorithm> constexpr int MAX=2001; int n,m; int dp[MAX][MAX][2]; bool S[MAX],T[MAX]; int main() { std::cin>>n>>m; char ch; for(int i=1;i<=n;++i){ std::cin>>ch; if(ch=='I') S[i]=1; } for(int j=1;j<=m;++j){ std::cin>>ch; if(ch=='I') T[i]=1; } for(int i=1;i<=n;++i){ if(S[i]) dp[i][0][1]=1; } for(int i=1;i<=m;++i){ if(T[i]) dp[0][i][1]=1; } for(int i=1;i<=n;++i){ for(int j=1;j<=m;++j){ for(int k=0;k<2;++k){ if(S[i]==k) dp[i][j][k]=dp[i-1][j][!k]+1; if(T[i]==k) dp[i][j][k]=std::max(dp[i][j][k], dp[i][j-1][!k])+1; } } } int ans=0; for(int i=0;i<=n;++i){ for(int j=0;j<=m;++j) ans=std::max(ans,dp[i][j][1]); } std::cout<<ans<<std::endl; return 0; }
a.cc: In function 'int main()': a.cc:23:27: error: 'i' was not declared in this scope 23 | T[i]=1; | ^
s151511388
p00527
C++
#include <iomanip> #include <utility> #include <algorithm> #include <type_traits> #include <set> #include <string> #include <iostream> #include <fstream> #include <cassert> #include <memory> #include <unordered_set> #include <unordered_map> #include <map> #include <queue> #include <vector> #include <array> #include <chrono> #include <random> #include <forward_list> #include <iomanip> #include <functional> #include <iostream> #include <stdio.h> #include <string.h> #include <sstream> #include <numeric> using namespace std; #define MFOR(i,end) for(size_t i = 0, end_##i = (end); i < end_##i; ++i) size_t M, N; char S[2500]; char T[2500]; enum class Mode_T : int8_t { none = 0, I, O }; int dp[2010][2010][3]; int func(int spos, int tpos, Mode_T last) { if (S[spos] == '\0' && T[tpos] == '\0') { return -2010 * 2010 * 3; } if (dp[spos][tpos][(int8_t)last] != -1) { return dp[spos][tpos][(int8_t)last]; } int max = -2010* 2010*3; if (last == Mode_T::none) { if (S[spos] == 'I') { max = std::max(max, 1 + std::max(0, func(spos + 1, tpos, Mode_T::I))); } if (S[spos] != '\0')max = std::max(max, 0 + func(spos + 1, tpos, Mode_T::none)); if (T[tpos] == 'I') { max = std::max(max, 1 + std::max(0, func(spos, tpos + 1, Mode_T::I))); } if (T[tpos] != '\0')max = std::max(max, 0 + func(spos, tpos + 1, Mode_T::none)); } else if (last == Mode_T::I) { if (S[spos] == 'O') { max = std::max(max, 1 + func(spos + 1, tpos, Mode_T::O)); } if (T[tpos] == 'O') { max = std::max(max, 1 + func(spos, tpos + 1, Mode_T::O)); } } else if (last == Mode_T::O) { if (S[spos] == 'I') { max = std::max(max, 1 + std::max(0, func(spos + 1, tpos, Mode_T::I))); } if (T[tpos] == 'I') { max = std::max(max, 1 + std::max(0, func(spos, tpos + 1, Mode_T::I))); } } return dp[spos][tpos][(int8_t)last] = max; }
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s022023211
p00527
C++
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; } int dp[2005][2005][2]; int main() { int m, n; cin >> m >> n; vector<int> s(m + 1); s[m] = 0; rep(i, m) { char c; cin >> c; s[i] = c == 'I'; } vector<int> t(n + 1); rep(i, n) { char c; cin >> c; t[i] = c == 'I'; } t[n] = 0; int ans = 0; rep(i, m + 1) rep(j, n + 1) { maxup(dp[i + 1][j][0], (dp[i][j][1] + 1) * !!dp[i][j][1] * !s[i]); maxup(dp[i][j + 1][0], (dp[i][j][1] + 1) * !!dp[i][j][1] * !t[j]); maxup(dp[i + 1][j][1], (dp[i][j][0] + 1) * s[i]); maxup(dp[i][j + 1][1], (dp[i][j][0] + 1) * t[j]); maxup(ans, dp[i + 1][j][1]); maxup(ans, dp[i][j + 1][1]); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:30:42: error: cannot bind rvalue reference of type 'const int&&' to lvalue of type 'int' 30 | maxup(ans, dp[i + 1][j][1]); | ~~~~~~~~~~~~~~^ a.cc:4:48: note: initializing argument 2 of 'bool maxup(T&, const T&&) [with T = int]' 4 | template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; } | ~~~~~~~~~~^ a.cc:31:42: error: cannot bind rvalue reference of type 'const int&&' to lvalue of type 'int' 31 | maxup(ans, dp[i][j + 1][1]); | ~~~~~~~~~~~~~~^ a.cc:4:48: note: initializing argument 2 of 'bool maxup(T&, const T&&) [with T = int]' 4 | template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; } | ~~~~~~~~~~^ a.cc: In function 'bool maxup(T&, const T&&) [with T = int]': a.cc:4:89: warning: control reaches end of non-void function [-Wreturn-type] 4 | template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; } | ^
s581016554
p00527
C++
#include<iostream> #include<string> #include<cmath> #include<queue> #include<map> #include<set> #include<list> #include<iomanip> #include<vector> #include<functional> #include<algorithm> #include<cstdio> using namespace std; typedef long long ll; ll n,m; bool a[2000],b[2000]; ll dp[2000][2000][2]; map<bool, int>o; ll solve(ll i,ll j,bool s){ ll sum=0; if(i!=n&&a[i]==!s){ if(dp[i+1][j][o[!s]]!=-1){ sum=1+dp[i+1][j][o[!s]]; } else sum=1+(dp[i+1][j][o[!s]]=solve(i+1,j,!s)); l=true; } if(j!=m&&b[j]==!s){ if(dp[i][j+1][!s]!=-1){ sum=max(sum,1+dp[i][j+1][o[!s]]); } else sum=max(sum,1+(dp[i][j+1][o[!s]]=solve(i,j+1,!s))); } return sum; } int main() { while(cin>>n>>m){ string u1,u2; cin>>u1>>u2; for(ll i=n-1;i>=0;i--){ if(u1[i]=='I') a[n-i]=true; else a[n-i]=false; } for(ll i=m-1;i>=0;i--){ if(u2[i]=='I') b[m-i]=true; else b[m-i]=false; } for(ll i=0;i<n;i++){ for(ll j=0;j<m;j++){ dp[i][j][0]=-1; dp[i][j][1]=-1; } } o.insert(map<bool, int>::value_type(true,0)); o.insert(map<bool, int>::value_type(false,1)); cout<<solve(0,0,false)<<endl; } }
a.cc: In function 'll solve(ll, ll, bool)': a.cc:26:17: error: 'l' was not declared in this scope 26 | l=true; | ^
s840730863
p00528
C++
#include<cstdio> #include<algorithm> #include<vector> #include<queue> #include<cmath> #include<string.h> using namespace std; #define F first #define S second #define INF 0x7f7f7f7f typedef long long LL; typedef pair<LL, LL> P; struct edge { LL to, cost,sw; }; vector<edge> g[200001]; LL d[200001][2]; bool flag[200001] = { 0 }; pair<pair<LL,LL>,int> xy[200001]; pair<pair<LL,LL>,int> yx[200001]; int main(){ int m, n, k; scanf("%d%d%d", &m, &n, &k); LL x, y; for (int i = 1; i <= k; i++) { scanf("%lld%lld", &x, &y); xy[i] = make_pair(make_pair(x, y),i); yx[i] = make_pair(make_pair(y, x),i); } memset(d, 0x7f, sizeof(d)); //memset(flag, false, sizeof(flag)); d[0][0] = 0; xy[0] = make_pair(make_pair(1, 1),0);yx[0] = make_pair(make_pair(1, 1),0); xy[k + 1] = make_pair(make_pair(m, n),k + 1); yx[k + 1] = make_pair(make_pair(n, m), k + 1); sort(xy, xy + k + 1); sort(yx, yx + k + 1); for (int i = 0; i <= k; i++) { edge t; if (xy[i + 1].F.F == xy[i].F.F) { t.to = xy[i+1].S; t.cost = abs(xy[i].F.S - xy[i + 1].F.S); t.sw = 0; g[xy[i].S].push_back(t); } if (yx[i + 1].F.F == yx[i].F.F) { t.to = yx[i+1].S; t.cost = abs(yx[i].F.S - yx[i + 1].F.S); t.sw = 1; g[yx[i].S].push_back(t); } if (xy[i - 1].F.F == xy[i].F.F) { t.to = xy[i - 1].S; t.cost = abs(xy[i].F.S - xy[i - 1].F.S); t.sw = 0; g[xy[i].S].push_back(t); } if (yx[i - 1].F.F == yx[i].F.F) { t.to = yx[i - 1].S; t.cost = abs(yx[i].F.S - yx[i - 1].F.S); t.sw = 1; g[yx[i].S].push_back(t); } } priority_queue<int, vector<int>, greater<int> >q; q.push(0); int bef = -1; while (!q.empty()) { int i = q.top; q.pop(); if (bef == i) continue; flag[i] = true; for (int j = 0; j < g[i].size(); j++) { if (!flag[g[i][j].to]) { d[g[i][j].to][1 - g[i][j].sw] = min(d[i][g[i][j].sw] + g[i][j].cost + 1, d[g[i][j].to][1 - g[i][j].sw]); d[g[i][j].to][g[i][j].sw] = min(d[i][g[i][j].sw] + g[i][j].cost, d[g[i][j].to][g[i][j].sw]); q.push(g[i][j].to); } } bef = i; } printf("%lld\n", min(d[k + 1][0], d[k + 1][1]) == INF ? -1: min(d[k + 1][0], d[k + 1][1])); }
a.cc: In function 'int main()': a.cc:62:27: error: cannot convert 'std::priority_queue<int, std::vector<int>, std::greater<int> >::top' from type 'const __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type& (std::priority_queue<int, std::vector<int>, std::greater<int> >::)() const' {aka 'const int& (std::priority_queue<int, std::vector<int>, std::greater<int> >::)() const'} to type 'int' 62 | int i = q.top; q.pop(); | ^~~
s758184423
p00528
C++
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s648478300
p00528
C++
#include<bits/stdc++.h> using namespace std; typedef long long int64; typedef pair< int64, int > Pi; const int64 INF = 1LL << 60; struct edge { int to, cost; }; vector< edge > graph[400004]; int64 min_cost[400004]; int H, W, K; vector< Pi > X[100001], Y[100001]; int64 Dijkstra() { fill_n(min_cost, 400004, INF); priority_queue< Pi, vector< Pi >, greater< Pi > > Que; min_cost[K - 2] = 0; Que.push(Pi(0, K - 2)); while(!Que.empty()) { Pi p = Que.top(); Que.pop(); if(min_cost[p.second] < p.first) continue; if(p.second == K - 1) return(p.first); for(int i = 0; i < graph[p.second].size(); i++) { const e = graph[p.second][i]; int64 next = p.first + e.cost; if(min_cost[e.to] > next) { min_cost[e.to] = next; Que.push(Pi(next, e.to)); } } } return(-1); } int main() { cin >> W >> H >> K; for(int i = 0; i < K; i++) { int x, y; cin >> x >> y; X[x].push_back(Pi(y, i)); Y[y].push_back(Pi(x, i)); } X[1].push_back(Pi(1, K)); Y[1].push_back(Pi(1, K)); X[W].push_back(Pi(H, K + 1)); Y[H].push_back(Pi(W, K + 1)); K += 2; for(int i = 0; i < 100001; i++) { sort(X[i].begin(), X[i].end()); sort(Y[i].begin(), Y[i].end()); for(int j = 1; j < X[i].size(); ++j) { const Pi &prev = X[i][j - 1], &curr = X[i][j]; graph[prev.second].push_back((edge){curr.second, abs(prev.first - curr.first)}); graph[curr.second].push_back((edge){prev.second, abs(prev.first - curr.first)}); } for(int j = 1; j < Y[i].size(); ++j) { const Pi &prev = Y[i][j - 1], &curr = Y[i][j]; graph[prev.second + K].push_back((edge){curr.second + K, abs(prev.first - curr.first)}); graph[curr.second + K].push_back((edge){prev.second + K, abs(prev.first - curr.first)}); } } for(int i = 0; i < K - 2; i++) { graph[i].push_back((edge){i + K, 1}); graph[i + K].push_back((edge){i, 1}); } graph[K - 1 + K].push_back((edge){K - 1, 0}); cout << Dijkstra() << endl; }
a.cc: In function 'int64 Dijkstra()': a.cc:25:13: error: 'e' does not name a type 25 | const e = graph[p.second][i]; | ^ a.cc:26:30: error: 'e' was not declared in this scope 26 | int64 next = p.first + e.cost; | ^ a.cc: In function 'int main()': a.cc:60:59: warning: narrowing conversion of 'std::abs((((long long int)prev.std::pair<long long int, int>::first) - ((long long int)curr.std::pair<long long int, int>::first)))' from 'long long int' to 'int' [-Wnarrowing] 60 | graph[prev.second].push_back((edge){curr.second, abs(prev.first - curr.first)}); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:61:59: warning: narrowing conversion of 'std::abs((((long long int)prev.std::pair<long long int, int>::first) - ((long long int)curr.std::pair<long long int, int>::first)))' from 'long long int' to 'int' [-Wnarrowing] 61 | graph[curr.second].push_back((edge){prev.second, abs(prev.first - curr.first)}); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:65:67: warning: narrowing conversion of 'std::abs((((long long int)prev.std::pair<long long int, int>::first) - ((long long int)curr.std::pair<long long int, int>::first)))' from 'long long int' to 'int' [-Wnarrowing] 65 | graph[prev.second + K].push_back((edge){curr.second + K, abs(prev.first - curr.first)}); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:66:67: warning: narrowing conversion of 'std::abs((((long long int)prev.std::pair<long long int, int>::first) - ((long long int)curr.std::pair<long long int, int>::first)))' from 'long long int' to 'int' [-Wnarrowing] 66 | graph[curr.second + K].push_back((edge){prev.second + K, abs(prev.first - curr.first)}); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~