submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s513949830 | p00518 | Java | import java.io.*;
import java.util.Arrays;
class Main{
static final PrintWriter out=new PrintWriter(System.out);
static final int MOD=10007;
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] pic=new int[n];
line=br.readLine();
for(int i=0;i<n;i++) pic[i]=bit(line.charAt(i));
int[][] dp=new int[n][1<<3];
for(int i=0;i<1<<3;i++){
if((i>>(1<<0)&1)&&(i>>pic[0]&1)) dp[0][i]=1;
}
for(int i=1;i<n;i++){
for(int j=0;j<(1<<3);j++){
for(int k=0;k<(1<<3);k++){
if((j>>pic[i]&1==0)&&(k>>pic[i]&1==0)) dp[i][k]+=dp[i-1][j];
if((!j>>pic[i]&1==0)&&(k>>pic[i]&1==0)&&(j&k!=0)) dp[i][k]+=dp[i-1][j];
dp[i][k]%=MOD;
}
}
}
int ans=0;
for(int i=1;i<=7;i++) ans+=dp[n-1][i];
out.println(ans%MOD);
out.flush();
}
}
public static int bit(char c){
if(c=='J') return 1<<0;
else if(c=='O') return 1<<1;
else return 1<<2;
}
} | Main.java:19: error: bad operand types for binary operator '&&'
if((i>>(1<<0)&1)&&(i>>pic[0]&1)) dp[0][i]=1;
^
first type: int
second type: int
Main.java:24: error: bad operand types for binary operator '&'
if((j>>pic[i]&1==0)&&(k>>pic[i]&1==0)) dp[i][k]+=dp[i-1][j];
^
first type: int
second type: boolean
Main.java:24: error: bad operand types for binary operator '&'
if((j>>pic[i]&1==0)&&(k>>pic[i]&1==0)) dp[i][k]+=dp[i-1][j];
^
first type: int
second type: boolean
Main.java:25: error: bad operand type int for unary operator '!'
if((!j>>pic[i]&1==0)&&(k>>pic[i]&1==0)&&(j&k!=0)) dp[i][k]+=dp[i-1][j];
^
Main.java:25: error: bad operand types for binary operator '&'
if((!j>>pic[i]&1==0)&&(k>>pic[i]&1==0)&&(j&k!=0)) dp[i][k]+=dp[i-1][j];
^
first type: int
second type: boolean
Main.java:25: error: bad operand types for binary operator '&'
if((!j>>pic[i]&1==0)&&(k>>pic[i]&1==0)&&(j&k!=0)) dp[i][k]+=dp[i-1][j];
^
first type: int
second type: boolean
6 errors
|
s346062529 | p00518 | Java | import java.io.*;
import java.util.Arrays;
class Main{
static final PrintWriter out=new PrintWriter(System.out);
static final int MOD=10007;
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] pic=new int[n];
line=br.readLine();
for(int i=0;i<n;i++) pic[i]=bit(line.charAt(i));
int[][] dp=new int[n][1<<3];
for(int i=0;i<1<<3;i++){
if((i>>(1<<0)&1)==0&&(i>>pic[0]&1)==0) dp[0][i]=1;
}
for(int i=1;i<n;i++){
for(int j=0;j<(1<<3);j++){
for(int k=0;k<(1<<3);k++){
if((j>>pic[i]&1)==0&&(k>>pic[i]&1)==0) dp[i][k]+=dp[i-1][j];
if((!j>>pic[i]&1)==0&&(k>>pic[i]&1)==0&&(j&k)!=0) dp[i][k]+=dp[i-1][j];
dp[i][k]%=MOD;
}
}
}
int ans=0;
for(int i=1;i<1<<3;i++) ans+=dp[n-1][i];
out.println(ans%MOD);
out.flush();
}
}
public static int bit(char c){
if(c=='J') return 1<<0;
else if(c=='O') return 1<<1;
else return 1<<2;
}
} | Main.java:25: error: bad operand type int for unary operator '!'
if((!j>>pic[i]&1)==0&&(k>>pic[i]&1)==0&&(j&k)!=0) dp[i][k]+=dp[i-1][j];
^
1 error
|
s285128873 | p00518 | Java | ?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.io.*;
import java.util.Arrays;
class Main{
static final PrintWriter out=new PrintWriter(System.out);
static final int MOD=10007;
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] pic=new int[n];
line=br.readLine();
for(int i=0;i<n;i++) pic[i]=bit(line.charAt(i));
int[][] dp=new int[n][1<<3];
for(int i=0;i<1<<3;i++){
if((i&(1<<0))==0&&(i&pic[0])==0) dp[0][i]=1;
}
for(int i=1;i<n;i++){
for(int j=1;j<(1<<3);j++){
for(int k=1;k<(1<<3);k++){
if((k&pic[0])==0){
if((j&pic[i])==0) dp[i][k]+=dp[i-1][j];
if((j&pic[i])!=0&&(j&k)==0) dp[i][k]+=dp[i-1][j];
dp[i][k]%=MOD;
}
}
}
}
int ans=0;
for(int i=1;i<1<<3;i++) ans+=dp[n-1][i];
out.println(ans%MOD);
out.flush();
}
}
public static int bit(char c){
if(c=='J') return 1<<0;
else if(c=='O') return 1<<1;
else return 1<<2;
}
} | Main.java:1: error: class, interface, enum, or record expected
?
^
Main.java:45: error: class, interface, enum, or record expected
import java.util.Arrays;
^
2 errors
|
s289858860 | p00518 | Java | import java.io.*;
import java.util.Scanner;
public class AOJ0595{
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
int n = sc.nextInt();
String str = input.readLine();
char[] kanrisya = str.toCharArray();
int[] kanri = new int[n + 1];
int[][] bunki = new int[n + 1][7];
int ans = 0;
for(int i = 0; i <= n; i++){
if(i == 0) kanri[i] = 1;
else {
if(kanrisya[i - 1] == 'J') kanri[i] = 1;
else if(kanrisya[i - 1] == 'O') kanri[i] = 2;
else if(kanrisya[i - 1] == 'I') kanri[i] = 3;
else ;
}
}
for(int i = 0; i <= n; i++){
for(int j = 0; j < 7; j++){
if(i == 0 && j == 0) bunki[i][j] = 1;
else bunki[i][j] = 0;
}
}
for(int i = 1; i <= n; i++){
if(kanri[i] == 1){
bunki[i][0] = bunki[i-1][0]+bunki[i-1][3]+bunki[i-1][4]+bunki[i-1][6];
bunki[i][3] = bunki[i-1][0]+bunki[i-1][1]+bunki[i-1][3]+bunki[i-1][4]+bunki[i-1][5]+bunki[i-1][6];
bunki[i][4] = bunki[i-1][0]+bunki[i-1][2]+bunki[i-1][3]+bunki[i-1][4]+bunki[i-1][5]+bunki[i-1][6];
bunki[i][6] = bunki[i-1][0]+bunki[i-1][1]+bunki[i-1][2]+bunki[i-1][3]+bunki[i-1][4]+bunki[i-1][5]+bunki[i-1][6];
}
else if(kanri[i] == 2){
bunki[i][1] = bunki[i-1][1]+bunki[i-1][3]+bunki[i-1][5]+bunki[i-1][6];
bunki[i][3] = bunki[i-1][0]+bunki[i-1][1]+bunki[i-1][3]+bunki[i-1][4]+bunki[i-1][5]+bunki[i-1][6];
bunki[i][5] = bunki[i-1][1]+bunki[i-1][2]+bunki[i-1][3]+bunki[i-1][4]+bunki[i-1][5]+bunki[i-1][6];
bunki[i][6] = bunki[i-1][0]+bunki[i-1][1]+bunki[i-1][2]+bunki[i-1][3]+bunki[i-1][4]+bunki[i-1][5]+bunki[i-1][6];
}
else{
bunki[i][2] = bunki[i-1][2]+bunki[i-1][4]+bunki[i-1][5]+bunki[i-1][6];
bunki[i][4] = bunki[i-1][0]+bunki[i-1][2]+bunki[i-1][3]+bunki[i-1][4]+bunki[i-1][5]+bunki[i-1][6];
bunki[i][5] = bunki[i-1][1]+bunki[i-1][2]+bunki[i-1][3]+bunki[i-1][4]+bunki[i-1][5]+bunki[i-1][6];
bunki[i][6] = bunki[i-1][0]+bunki[i-1][1]+bunki[i-1][2]+bunki[i-1][3]+bunki[i-1][4]+bunki[i-1][5]+bunki[i-1][6];
}
for(int k = 0; k < 7; k++){
bunki[i][k] %= 10007;
}
}
for(int i = 0; i < 7; i++){
ans += bunki[n][i];
ans %= 10007;
}
System.out.println(ans);
return;
}
} | Main.java:4: error: class AOJ0595 is public, should be declared in a file named AOJ0595.java
public class AOJ0595{
^
1 error
|
s501364343 | p00518 | Java | import java.io.*;
import java.util.Scanner;
public class AOJ0595 {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
int n = sc.nextInt();
String str = input.readLine();
char[] kanrisya = new char[n + 1];
kanrisya = str.toCharArray();
int[] kanri = new int[n + 1];
int[][] bunki = new int[n + 1][7];
int ans = 0;
for (int i = 0; i <= n; i++) {
if (i == 0)
kanri[i] = 1;
else {
if (kanrisya[i - 1] == 'J')
kanri[i] = 1;
else if (kanrisya[i - 1] == 'O')
kanri[i] = 2;
else
kanri[i] = 3;
}
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j < 7; j++) {
if (i == 0 && j == 0)
bunki[i][j] = 1;
else
bunki[i][j] = 0;
}
}
for (int i = 1; i <= n; i++) {
if (kanri[i] == 1) {
bunki[i][0] = bunki[i - 1][0] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][6];
bunki[i][3] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][4] = bunki[i - 1][0] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][6] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
} else if (kanri[i] == 2) {
bunki[i][1] = bunki[i - 1][1] + bunki[i - 1][3] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][3] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][5] = bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][6] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
} else {
bunki[i][2] = bunki[i - 1][2] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][4] = bunki[i - 1][0] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][5] = bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][6] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
}
for (int k = 0; k < 7; k++) {
bunki[i][k] %= 10007;
}
}
for (int i = 0; i < 7; i++) {
ans += bunki[n][i];
}
ans %= 10007;
System.out.println(ans);
return;
}
} | Main.java:4: error: class AOJ0595 is public, should be declared in a file named AOJ0595.java
public class AOJ0595 {
^
1 error
|
s873078189 | p00518 | Java | import java.util.Scanner;
public class AOJ0595 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String str = sc.next();
char[] kanrisya = new char[n + 1];
kanrisya = str.toCharArray();
int[] kanri = new int[n + 1];
int[][] bunki = new int[n + 1][7];
int ans = 0;
for (int i = 0; i <= n; i++) {
if (i == 0)
kanri[i] = 1;
else {
if (kanrisya[i - 1] == 'J')
kanri[i] = 1;
else if (kanrisya[i - 1] == 'O')
kanri[i] = 2;
else
kanri[i] = 3;
}
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j < 7; j++) {
if (i == 0 && j == 0)
bunki[i][j] = 1;
else
bunki[i][j] = 0;
}
}
for (int i = 1; i <= n; i++) {
if (kanri[i] == 1) {
bunki[i][0] = bunki[i - 1][0] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][6];
bunki[i][3] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][4] = bunki[i - 1][0] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][6] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
} else if (kanri[i] == 2) {
bunki[i][1] = bunki[i - 1][1] + bunki[i - 1][3] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][3] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][5] = bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][6] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
} else {
bunki[i][2] = bunki[i - 1][2] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][4] = bunki[i - 1][0] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][5] = bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
bunki[i][6] = bunki[i - 1][0] + bunki[i - 1][1] + bunki[i - 1][2] + bunki[i - 1][3] + bunki[i - 1][4] + bunki[i - 1][5] + bunki[i - 1][6];
}
for (int k = 0; k < 7; k++) {
bunki[i][k] %= 10007;
}
}
for (int i = 0; i < 7; i++) {
ans += bunki[n][i];
}
ans %= 10007;
System.out.println(ans);
return;
}
} | Main.java:3: error: class AOJ0595 is public, should be declared in a file named AOJ0595.java
public class AOJ0595 {
^
1 error
|
s403890731 | p00518 | C | #include <bits/stdc++.h>
using namespace std;
const int MOD = 10007;
int dp[1024][8];
int joi(char c)
{
if (c == 'J') return 4;
else if (c == 'O') return 2;
return 1;
}
int main()
{
int n;
char key[1024] = {0};
scanf("%d", &n);
scanf("%s", key);
int first = joi(*key);
for (int i = 1; i < 8; i++){
if ((i | first | 4) != i) continue;
dp[1][i] = 1;
}
int last = 4;
for (int i = 2; key[i - 1] != 0; i++){
int today = joi(key[i - 1]);
for (int j = 0; j < 8; j++){
if ((j | today) != j) continue;
for (int k = 0; k < 8; k++){
if ((j & k) == 0) continue;
dp[i][j] = (dp[i][j] + dp[i - 1][k]) % MOD;
}
}
last = today;
}
int sum = 0;
for (int i = 0; i < 8; i++){
sum = (sum + dp[n][i]) % MOD;
}
printf("%d\n", sum);
return 0;
} | main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
1 | #include <bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s714788223 | p00518 | C | #define r(i,n) for(int i=0;i<n;i++)
int a[999][8],n,t,d[99];char s[999];main(){scanf("%d%s",&n,s);a[0][1]=d[79]=1;d[73]=2;r(i,n)r(j,8)r(k,8)if(j&k&&k>>d[s[i]]&1)a[i+1][k]+=a[i][j]%10007;r(i,8)t+=a[n][i];printf("%d\n",t%10007);} | main.c:2:37: error: return type defaults to 'int' [-Wimplicit-int]
2 | int a[999][8],n,t,d[99];char s[999];main(){scanf("%d%s",&n,s);a[0][1]=d[79]=1;d[73]=2;r(i,n)r(j,8)r(k,8)if(j&k&&k>>d[s[i]]&1)a[i+1][k]+=a[i][j]%10007;r(i,8)t+=a[n][i];printf("%d\n",t%10007);}
| ^~~~
main.c: In function 'main':
main.c:2:44: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
2 | int a[999][8],n,t,d[99];char s[999];main(){scanf("%d%s",&n,s);a[0][1]=d[79]=1;d[73]=2;r(i,n)r(j,8)r(k,8)if(j&k&&k>>d[s[i]]&1)a[i+1][k]+=a[i][j]%10007;r(i,8)t+=a[n][i];printf("%d\n",t%10007);}
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | #define r(i,n) for(int i=0;i<n;i++)
main.c:2:44: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
2 | int a[999][8],n,t,d[99];char s[999];main(){scanf("%d%s",&n,s);a[0][1]=d[79]=1;d[73]=2;r(i,n)r(j,8)r(k,8)if(j&k&&k>>d[s[i]]&1)a[i+1][k]+=a[i][j]%10007;r(i,8)t+=a[n][i];printf("%d\n",t%10007);}
| ^~~~~
main.c:2:44: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:2:168: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
2 | int a[999][8],n,t,d[99];char s[999];main(){scanf("%d%s",&n,s);a[0][1]=d[79]=1;d[73]=2;r(i,n)r(j,8)r(k,8)if(j&k&&k>>d[s[i]]&1)a[i+1][k]+=a[i][j]%10007;r(i,8)t+=a[n][i];printf("%d\n",t%10007);}
| ^~~~~~
main.c:2:168: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:2:168: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:2:168: note: include '<stdio.h>' or provide a declaration of 'printf'
|
s138130786 | p00518 | C | int a[1999][9],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;fprintf(stderr,"%d\n",u);for(j=8;j--;){for(k=8;k--;)if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;z+=a[n][j];}}printf("%d\n",z%10007);} | main.c:1:28: error: return type defaults to 'int' [-Wimplicit-int]
1 | int a[1999][9],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;fprintf(stderr,"%d\n",u);for(j=8;j--;){for(k=8;k--;)if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;z+=a[n][j];}}printf("%d\n",z%10007);}
| ^~~~
main.c: In function 'main':
main.c:1:35: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
1 | int a[1999][9],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;fprintf(stderr,"%d\n",u);for(j=8;j--;){for(k=8;k--;)if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;z+=a[n][j];}}printf("%d\n",z%10007);}
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | int a[1999][9],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;fprintf(stderr,"%d\n",u);for(j=8;j--;){for(k=8;k--;)if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;z+=a[n][j];}}printf("%d\n",z%10007);}
main.c:1:35: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
1 | int a[1999][9],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;fprintf(stderr,"%d\n",u);for(j=8;j--;){for(k=8;k--;)if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;z+=a[n][j];}}printf("%d\n",z%10007);}
| ^~~~~
main.c:1:35: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:1:80: error: implicit declaration of function 'getchar' [-Wimplicit-function-declaration]
1 | int a[1999][9],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;fprintf(stderr,"%d\n",u);for(j=8;j--;){for(k=8;k--;)if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;z+=a[n][j];}}printf("%d\n",z%10007);}
| ^~~~~~~
main.c:1:80: note: 'getchar' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
main.c:1:94: error: implicit declaration of function 'fprintf' [-Wimplicit-function-declaration]
1 | int a[1999][9],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;fprintf(stderr,"%d\n",u);for(j=8;j--;){for(k=8;k--;)if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;z+=a[n][j];}}printf("%d\n",z%10007);}
| ^~~~~~~
main.c:1:94: note: include '<stdio.h>' or provide a declaration of 'fprintf'
main.c:1:94: warning: incompatible implicit declaration of built-in function 'fprintf' [-Wbuiltin-declaration-mismatch]
main.c:1:94: note: include '<stdio.h>' or provide a declaration of 'fprintf'
main.c:1:102: error: 'stderr' undeclared (first use in this function)
1 | int a[1999][9],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;fprintf(stderr,"%d\n",u);for(j=8;j--;){for(k=8;k--;)if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;z+=a[n][j];}}printf("%d\n",z%10007);}
| ^~~~~~
main.c:1:102: note: 'stderr' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
main.c:1:102: note: each undeclared identifier is reported only once for each function it appears in
main.c:1:199: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
1 | int a[1999][9],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;fprintf(stderr,"%d\n",u);for(j=8;j--;){for(k=8;k--;)if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;z+=a[n][j];}}printf("%d\n",z%10007);}
| ^~~~~~
main.c:1:199: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:1:199: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:1:199: note: include '<stdio.h>' or provide a declaration of 'printf'
|
s105823035 | p00518 | C++ | #include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int dp[1001][8];
memset(dp, 0, sizeof(dp));
int n, i, i2, i3,k;
char sc[1000];
cin >> n >> sc;
for (i = 0; i < n; i++){
if (sc[i] == 'J')k = 1;
else if (sc[i] == 'O')k = 2;
else if (sc[i] == 'I')k = 4;
for (i2 = 1; i2 < 8; i2++){
for (i3 = 1; i3 < 8; i3++){
if ((i2&i3) > 0 && (i2&k) == k&&i != 0){
dp[i][i2] = (dp[i][i2] + dp[i - 1][i3]) % 10007;
}
else if (i==0&&(i2&1)==1&&(i2&k)==k){
dp[0][i2] = 1;
}
}
}
}
int sum = 0;
for (i = 0; i < 8; i++){
sum = (sum+dp[n - 1][i])%10007;
}
cout << sum <<endl;
} | a.cc: In function 'int main()':
a.cc:8:9: error: 'memset' was not declared in this scope
8 | 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 | using namespace std;
|
s730299608 | p00518 | C++ | #include<stdio.h>
#include<iostream>
#include<algorithm>
#include<memory>
using namespace std;
int main()
{
int dp[1001][8];
memset(dp, 0, sizeof(dp));
int n, i, i2, i3,k;
char sc[1001];
cin >> n >> sc;
for (i = 0; i < n; i++){
if (sc[i] == 'J')k = 1;
else if (sc[i] == 'O')k = 2;
else if (sc[i] == 'I')k = 4;
for (i2 = 1; i2 < 8; i2++){
for (i3 = 1; i3 < 8; i3++){
if ((i2&i3) > 0 && (i2&k) == k&&i != 0){
dp[i][i2] = (dp[i][i2] + dp[i - 1][i3]) % 10007;
}
else if (i==0&&(i2&1)==1&&(i2&k)==k){
dp[0][i2] = 1;
}
}
}
}
int sum = 0;
for (i = 0; i < 8; i++){
sum = (sum+dp[n - 1][i])%10007;
}
cout << sum <<endl;
} | a.cc: In function 'int main()':
a.cc:10:9: error: 'memset' was not declared in this scope
10 | memset(dp, 0, sizeof(dp));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include<memory>
+++ |+#include <cstring>
5 | using namespace std;
|
s170238292 | p00518 | C++ | d | a.cc:1:1: error: 'd' does not name a type
1 | d
| ^
|
s513510214 | p00518 | C++ | #include<iostream>
using namespace std;
int dp[1005][9];
int check(char a){
switch(a){
case 'J':
return 1;
case 'O':
return 2;
case 'I':
return 4;
default:
return 0;
}
}
int main(){
unsigned long long n,ans;
string s;
cin>>n>>s;
memset(dp,0,sizeof(dp));
dp[0][1]=1;
char pre='J';
for(int i=1;i<=s.length();i++){
char now=s[i-1];
int p=check(pre);
int n=check(now);
for(int k=0;k<8;k++){
for(int j=0;j<8;j++){
if(((k&p)&&(j&n)&&(j&k))!=0){
dp[i][j]+=dp[i-1][k];
dp[i][j]%=10007;
}
}
}
pre=now;
}
for(int i=0;i<8;i++)
ans+=dp[s.length()][i];
cout<<ans%10007<<endl;
} | a.cc: In function 'int main()':
a.cc:20:5: error: 'memset' was not declared in this scope
20 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include<iostream>
+++ |+#include <cstring>
2 | using namespace std;
|
s521019561 | p00518 | C++ | #include<iostream>
#include<stdlib.h>
using namespace std;
int dp[1005][9];
int check(char a){
switch(a){
case 'J':
return 1;
case 'O':
return 2;
case 'I':
return 4;
default:
return 0;
}
}
int main(){
unsigned long long n,ans;
string s;
cin>>n>>s;
memset(dp,0,sizeof(dp));
dp[0][1]=1;
char pre='J';
for(int i=1;i<=s.length();i++){
char now=s[i-1];
int p=check(pre);
int n=check(now);
for(int k=0;k<8;k++){
for(int j=0;j<8;j++){
if(((k&p)&&(j&n)&&(j&k))!=0){
dp[i][j]+=dp[i-1][k];
dp[i][j]%=10007;
}
}
}
pre=now;
}
for(int i=0;i<8;i++)
ans+=dp[s.length()][i];
cout<<ans%10007<<endl;
} | a.cc: In function 'int main()':
a.cc:21:5: error: 'memset' was not declared in this scope
21 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<stdlib.h>
+++ |+#include <cstring>
3 | using namespace std;
|
s066567135 | p00518 | C++ | #include<iostream>
#include<stdlib.h>
using namespace std;
int dp[1005][9];
int check(char a){
switch(a){
case 'J':
return 1;
case 'O':
return 2;
case 'I':
return 4;
default:
return 0;
}
}
int main(){
unsigned long long n,ans;
string s;
cin>>n>>s;
memset(dp,0,sizeof(dp));
dp[0][1]=1;
char pre='J';
for(int i=1;i<=s.length();i++){
char now=s[i-1];
int p=check(pre);
int n=check(now);
for(int k=0;k<8;k++){
for(int j=0;j<8;j++){
if(((k&p)&&(j&n)&&(j&k))!=0){
dp[i][j]+=dp[i-1][k];
dp[i][j]%=10007;
}
}
}
pre=now;
}
for(int i=0;i<8;i++)
ans+=dp[s.length()][i];
cout<<(ans%10007)<<endl;
} | a.cc: In function 'int main()':
a.cc:21:5: error: 'memset' was not declared in this scope
21 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<stdlib.h>
+++ |+#include <cstring>
3 | using namespace std;
|
s478607092 | p00518 | C++ | #include<iostream>
#include<string>
using namespace std;
#define MOD 10007
int main(){
int x[1001][3][2][2][2];
int k[1001];
int l[3];
memset(x,0,sizeof(x));
x[0][0][1][0][0]=1;
k[0]=0;
int m,sum=0;
string S;
cin>>m;
cin>>S;
for(int i=0;i<m;i++){
if(S[i]=='J'){
k[i+1]=0;
}
else if(S[i]=='O'){
k[i+1]=1;
}
else{
k[i+1]=2;
}
}
for(int i=1;i<=m;i++){
if(k[i]==0){
for(int j=0;j<2;j++){
for(int n=0;n<2;n++){
for(int o=0;o<2;o++){
for(int p=0;p<2;p++){
for(int q=0;q<2;q++){
if(((o==1) || (j==1 && p==1)) || (n==1 && q==1)){
x[i][k[i]][1][j][n] += x[i-1][k[i-1]][o][p][q];
}
}
}
}
}
}
}
if(k[i]==1){
for(int j=0;j<2;j++){
for(int n=0;n<2;n++){
for(int o=0;o<2;o++){
for(int p=0;p<2;p++){
for(int q=0;q<2;q++){
if(((j==1 && o==1) || (p==1)) || (n==1 && q==1)){
x[i][k[i]][j][1][n] += x[i-1][k[i-1]][o][p][q];
}
}
}
}
}
}
}
if(k[i]==2){
for(int j=0;j<2;j++){
for(int n=0;n<2;n++){
for(int o=0;o<2;o++){
for(int p=0;p<2;p++){
for(int q=0;q<2;q++){
if(((j==1 && o==1) || (n==1 && p==1)) || (q==1)){
x[i][k[i]][j][n][1] += x[i-1][k[i-1]][o][p][q];
}
}
}
}
}
}
}
for(int o=0;o<2;o++){
for(int p=0;p<2;p++){
for(int q=0;q<2;q++){
x[i][k[i]][o][p][q] %= MOD;
}
}
}
}
for(int i=0;i<2;i++){
for(int j=0;j<2;j++){
for(int n=0;n<2;n++){
sum += x[m][k[m]][i][j][n];
}
}
}
cout<<sum%MOD<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:11:9: error: 'memset' was not declared in this scope
11 | memset(x,0,sizeof(x));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include<iostream>
+++ |+#include <cstring>
2 | #include<string>
|
s301844799 | p00518 | C++ | #include <iostream>
#include <string>
using namespace std;
const int MOD = 10007;
int joi(char c)
{
if(c=='J') return 1;
if(c=='O') return 2;
return 4;
}
int main()
{
int dp[8][1000]={};
int n;
string s;
cin >> n;
cin >> s;
for(int j=0;j<8;j++)
if(joi(s[i])&j) dp[j][0]=1;
for(int i=1;i<n;i++)
for(int j=0;j<8;j++)
for(int k=0;k<8;k++)
{
if((joi(s[i])&j)&&(j&k))
{
dp[j][i]=(dp[j][i]+dp[k][i-1])%MOD;
}
}
int res=0;
for(int i=0;i<8;i++)
res = (res+dp[i][n-1])%MOD;
cout << res << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:23:26: error: 'i' was not declared in this scope
23 | if(joi(s[i])&j) dp[j][0]=1;
| ^
|
s764550570 | p00518 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int dp[1001][8];
int can[8][7]={0,0,0,0,0,0,0,1,3,5,7,0,0,0,2,3,6,7,0,0,0,1,2,3,5,6,7,0,4,5,6,7,0,0,0,1,3,4,5,6,7,0,2,3,4,5,6,7,0,1,2,3,4,5,6,7};
int not[3][4]={0,1,2,3,0,1,4,5,0,2,4,6};
int main(){
int n;
char z;
cin>>n>>z;
for(int i=0;i<n;i++){
for(int j=0;j<8;j++){
dp[i][j]=0;
}
}
int set;
if(z=='J')set=0;
if(z=='O')set=1;
if(z=='I')set=2;
for(int i=4;i<8;i++){
bool ok=true;
for(int j=0;j<4;j++){
if(not[set][j]==i){
ok=false;
}
}
if(ok){
dp[0][i]=1;
}
}
for(int i=1;i<n;i++){
cin>>z;
if(z=='J')set=0;
if(z=='O')set=1;
if(z=='I')set=2;
for(int j=0;j<8;j++){
for(int k=0;k<8;k++){
bool ok=false;
for(int r=0;r<7;r++){
if(can[k][r]==j){
ok=true;
}
}
for(int r=0;r<4;r++){
if(not[set][r]==j){
ok=false;
}
}
if(ok){
dp[i][j]+=dp[i-1][k];
}
}
dp[i][j]%=10007;
}
}
int ans=0;
for(int i=0;i<8;i++){
ans+=dp[n-1][i];
}
cout<<ans%10007<<endl;
return 0;
} | a.cc:6:5: error: expected unqualified-id before 'not' token
6 | int not[3][4]={0,1,2,3,0,1,4,5,0,2,4,6};
| ^~~
a.cc: In lambda function:
a.cc:23:36: error: expected '{' before '[' token
23 | if(not[set][j]==i){
| ^
a.cc: In function 'int main()':
a.cc:23:36: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
a.cc: In lambda function:
a.cc:45:52: error: expected '{' before '[' token
45 | if(not[set][r]==j){
| ^
a.cc: In function 'int main()':
a.cc:45:52: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
|
s918366280 | p00518 | C++ | #include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
typedef long long int lli;
typedef pair<int,int> P;
#define F first
#define S second
const int INF=1000000000;
long long int dp[1001][2][2][2];
int main(){
for(int i=0; i<1001; ++i){
for(int j=0; j<2; ++j){
for(int k=0; k<2; ++k){
for(int l=0; l<2; ++l){
dp[i][j][k][l]=0;
}
}
}
}
int N;
cin >> N;
string str;
cin >> str;
if(str[0]=='J'){
for(int i=0;i<2; ++i){
for(int j=0; j<2; ++j){
dp[1][1][i][j]=1;
}
}
} else if(str[0]=='O'){
for(int i=0; i<2; ++i){
dp[1][1][1][i]=1;
}
} else if(str[0]=='I'){
for(int i=0; i<2; ++i){
dp[1][1][i][1]=1;
}
}
for(int i=2; i<=N; ++i){
if(str[i-1]=='J'){
dp[i][1][0][0]+=(dp[i-1][1][0][0]+dp[i-1][1][1][0]+dp[i-1][1][0][1]+dp[i-1][1][1][1])%10007;
dp[i][1][1][0]+=(dp[i-1][1][0][0]+dp[i-1][0][1][0]+dp[i-1][1][1][0]+dp[i-1][1][0][1]+dp[i-1][0][1][1]+dp[i-1][1][1][1])%10007;
dp[i][1][0][1]+=(dp[i-1][1][0][0]+dp[i-1][0][0][1]+dp[i-1][1][1][0]+dp[i-1][1][0][1]+dp[i-1][0][1][1]+dp[i-1][1][1][1])%10007;
dp[i][1][1][1]+=(dp[i-1][1][0][0]+dp[i-1][0][1][0]+dp[i-1][0][0][1]+dp[i-1][1][1][0]+dp[i-1][1][0][1]+dp[i-1][0][1][1]+dp[i-1][1][1][1])%10007;
} else if(str[i-1]=='O'){
dp[i][0][1][0]+=(dp[i-1][0][1][0]+dp[i-1][1][1][0]+dp[i-1][0][1][1]+dp[i-1][1][1][1])%10007;
dp[i][1][1][0]+=(dp[i-1][1][0][0]+dp[i-1][0][1][0]+dp[i-1][1][1][0]+dp[i-1][1][0][1]+dp[i-1][0][1][1]+dp[i-1][1][1][1])%10007;
dp[i][0][1][1]+=(dp[i-1][0][1][0]+dp[i-1][0][0][1]+dp[i-1][1][1][0]+dp[i-1][1][0][1]+dp[i-1][0][1][1]+dp[i-1][1][1][1])%10007;
dp[i][1][1][1]+=(dp[i-1][1][0][0]+dp[i-1][0][1][0]+dp[i-1][0][0][1]+dp[i-1][1][1][0]+dp[i-1][1][0][1]+dp[i-1][0][1][1]+dp[i-1][1][1][1])%10007;
} else if(str[i-1]=='I'){
dp[i][0][0][1]+=(dp[i-1][0][0][1]+dp[i-1][1][0][1]+dp[i-1][0][1][1]+dp[i-1][1][1][1])%10007;
dp[i][1][0][1]+=(dp[i-1][1][0][0]+dp[i-1][0][0][1]+dp[i-1][1][1][0]+dp[i-1][1][0][1]+dp[i-1][0][1][1]+dp[i-1][1][1][1])%10007;
dp[i][0][1][1]+=(dp[i-1][0][1][0]+dp[i-1][0][0][1]+dp[i-1][1][1][0]+dp[i-1][1][0][1]+dp[i-1][0][1][1]+dp[i-1][1][1][1])%10007;
dp[i][1][1][1]+=(dp[i-1][1][0][0]+dp[i-1][0][1][0]+dp[i-1][0][0][1]+dp[i-1][1][1][0]+dp[i-1][1][0][1]+dp[i-1][0][1][1]+dp[i-1][1][1][1])%10007;
}
}
long long int ans=0;
for(int i=0; i<2; ++i){
for(int j=0; j<2; ++j){
for(int k=0; k<2; ++k){
ans+=dp[N][i][j][k]%10007;
}
}
}
cout << ans%10007 << "\n";
return 0; | a.cc: In function 'int main()':
a.cc:79:18: error: expected '}' at end of input
79 | return 0;
| ^
a.cc:22:11: note: to match this '{'
22 | int main(){
| ^
|
s680591753 | p00518 | C++ | #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
int a[1010][8],n,t,d[90];char s[1010];main(){scanf("%d%s",&n,s);a[0][1]=d[79]=1;d[73]=2;r(i,n)r(j,8)r(k,8)if(j&k&&k>>d[s+i]&1)(a[i+1][k]+=a[i][j])%=10007;r(i,8)t+=a[n][i];printf("%d\n",t%10007);} | a.cc:3:39: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
3 | int a[1010][8],n,t,d[90];char s[1010];main(){scanf("%d%s",&n,s);a[0][1]=d[79]=1;d[73]=2;r(i,n)r(j,8)r(k,8)if(j&k&&k>>d[s+i]&1)(a[i+1][k]+=a[i][j])%=10007;r(i,8)t+=a[n][i];printf("%d\n",t%10007);}
| ^~~~
a.cc: In function 'int main()':
a.cc:3:119: error: invalid types 'int [90][char*]' for array subscript
3 | int a[1010][8],n,t,d[90];char s[1010];main(){scanf("%d%s",&n,s);a[0][1]=d[79]=1;d[73]=2;r(i,n)r(j,8)r(k,8)if(j&k&&k>>d[s+i]&1)(a[i+1][k]+=a[i][j])%=10007;r(i,8)t+=a[n][i];printf("%d\n",t%10007);}
| ^
|
s603147897 | p00518 | C++ | #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
int a[1010][8],n,t,d[90];char s[1010];main(){scanf("%d%s",&n,s);a[0][1]=d[79]=1;d[73]=2;r(i,n)r(j,8)r(k,8)if(j&k&&k>>d[s+i]&1)(a[i+1][k]+=a[i][j])%=10007;r(i,8)t+=a[n][i];printf("%d\n",t%10007);} | a.cc:3:39: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
3 | int a[1010][8],n,t,d[90];char s[1010];main(){scanf("%d%s",&n,s);a[0][1]=d[79]=1;d[73]=2;r(i,n)r(j,8)r(k,8)if(j&k&&k>>d[s+i]&1)(a[i+1][k]+=a[i][j])%=10007;r(i,8)t+=a[n][i];printf("%d\n",t%10007);}
| ^~~~
a.cc: In function 'int main()':
a.cc:3:119: error: invalid types 'int [90][char*]' for array subscript
3 | int a[1010][8],n,t,d[90];char s[1010];main(){scanf("%d%s",&n,s);a[0][1]=d[79]=1;d[73]=2;r(i,n)r(j,8)r(k,8)if(j&k&&k>>d[s+i]&1)(a[i+1][k]+=a[i][j])%=10007;r(i,8)t+=a[n][i];printf("%d\n",t%10007);}
| ^
|
s447146496 | p00518 | C++ | int a[999][8],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;j=8;while(j--){k=8;while(k--){if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;}z+=a[n][j];}}printf("%d\n",z%10007);} | a.cc:1:27: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
1 | int a[999][8],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;j=8;while(j--){k=8;while(k--){if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;}z+=a[n][j];}}printf("%d\n",z%10007);}
| ^~~~
a.cc: In function 'int main()':
a.cc:1:34: error: 'scanf' was not declared in this scope
1 | int a[999][8],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;j=8;while(j--){k=8;while(k--){if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;}z+=a[n][j];}}printf("%d\n",z%10007);}
| ^~~~~
a.cc:1:79: error: 'getchar' was not declared in this scope
1 | int a[999][8],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;j=8;while(j--){k=8;while(k--){if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;}z+=a[n][j];}}printf("%d\n",z%10007);}
| ^~~~~~~
a.cc:1:1: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | int a[999][8],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;j=8;while(j--){k=8;while(k--){if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;}z+=a[n][j];}}printf("%d\n",z%10007);}
a.cc:1:177: error: 'printf' was not declared in this scope
1 | int a[999][8],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;j=8;while(j--){k=8;while(k--){if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;}z+=a[n][j];}}printf("%d\n",z%10007);}
| ^~~~~~
a.cc:1:177: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
|
s170043572 | p00518 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cmath>
#include <deque>
#include <set>
#define rep_(v, f, l) for (auto v = (f); v != (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, o) rep_(v, o.begin(), o.end())
using namespace std;
typedef long long int lint;
const int MOD = 10007;
template<typename T> inline bool in(T& x){ return cin >> x; }
template<typename T> inline T in(){T x; cin >> x; return x; }
int main()
{
int N;
string need;
in(N), in(need);
int joi_map[255];
joi_map['J'] = 1;
joi_map['O'] = 2;
joi_map['I'] = 4;
int dp[N + 1][8];
rep(i, N + 1) rep(j, 8) dp[i][j] = 0;
dp[0][1] = 1;
rep_(i, 1, N + 1)
rep(j, 8)
rep(k, 8)
if ((j & joi_map[need[i]]) && (j & k))
(dp[i][j] += dp[i - 1][k]) %= MOD;
int ans = 0;
rep(i, 8)
(ans += dp[N][i]) %= MOD;
printf("%d\n", ans);
return (0);
} | a.cc: In instantiation of 'bool in(T&) [with T = int]':
a.cc:32:4: required from here
32 | in(N), in(need);
| ~~^~~
a.cc:24:58: error: cannot convert 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'bool' in return
24 | template<typename T> inline bool in(T& x){ return cin >> x; }
| ^
In file included from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/basic_ios.h:121:16: note: explicit conversion function was not considered
121 | explicit operator bool() const
| ^~~~~~~~
a.cc: In instantiation of 'bool in(T&) [with T = std::__cxx11::basic_string<char>]':
a.cc:32:11: required from here
32 | in(N), in(need);
| ~~^~~~~~
a.cc:24:58: error: cannot convert 'std::basic_istream<char>' to 'bool' in return
24 | template<typename T> inline bool in(T& x){ return cin >> x; }
| ^
/usr/include/c++/14/bits/basic_ios.h:121:16: note: explicit conversion function was not considered
121 | explicit operator bool() const
| ^~~~~~~~
|
s948460949 | p00519 | Java | import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.PriorityQueue;
class Main{
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;
public static class Edge{
int to;
int cost;
public Edge(int to){
this.to=to;
}
public Edge(int to,int cost){
this.to=to; this.cost=cost;
}
}
public static class Pair{
int x;
int y;
public Pair(int x,int y){
this.x=x; this.y=y;
}
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{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line.split(" ")[0]);
int k=Integer.parseInt(line.split(" ")[1]);
int[] c=new int[n];
int[] d=new int[n];
int[] dist=new int[n];
boolean[] visited=new boolean[n];
boolean[][] cg=new boolean[n][n];
MyArrayList[] array=new MyArrayList[n];
for(int i=0;i<n;i++){
line=br.readLine();
c[i]=Integer.parseInt(line.split(" ")[0]);
d[i]=Integer.parseInt(line.split(" ")[1]);
array[i]=new MyArrayList();
}
MyArrayList[] carray=array.clone();
for(int i=0;i<k;i++){
line=br.readLine();
int a=Integer.parseInt(line.split(" ")[0]);
int b=Integer.parseInt(line.split(" ")[1]);
array[a-1].add(new Edge(b-1));
array[b-1].add(new Edge(a-1));
}
for(int i=0;i<n;i++) bfs(i,d[i],visited,cg,array);
for(int i=0;i<n;i++){
for(int j=0;j<n&&j!=i;j++){
if(cg[i][j]) carray[i].add(new Edge(j,c[i]));
}
}
dijkstra(dist,carray);
out.println(dist[n-1]);
out.flush();
}
}
public static void bfs(int s,int t,boolean[] visited,boolean[][] cg,MyArrayList[] array){
Arrays.fill(visited,false);
ArrayList<Edge> list;
Deque<Pair> que=new ArrayDeque<Pair>();
que.offerLast(new Pair(s,t));
while(!que.isEmpty()){
Pair p=que.pollFirst();
int ns=p.x;
int nt=p.y;
list=array[ns];
if(nt>=0||list.size()==0) continue;
visited[ns]=true;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(!visited[e.to]) que.offerLast(new Pair(e.to,nt-1));
}
}
}
public static void dijkstra(int[] dist,MyArrayList[] array){
PriorityQueue<Pair> pque=new PriorityQueue<Pair>(10,Pair.DISTANCE_ORDER);
Arrays.fill(dist,INF);
dist[0]=0;
pque.offer(new Pair(0,0));
while(!pque.isEmpty()){
Pair p=pque.poll();
int v=p.y;
ArrayList<Edge> list=array[v];
if(dist[v]<p.x||list.size()==0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(d[e.to]>d[v]+e.cost){
d[e.to]=d[v]+e.cost;
pque.offer(new Pair(d[e.to],e.to));
}
}
}
}
} | Main.java:116: error: reached end of file while parsing
}
^
1 error
|
s944836977 | p00519 | Java | import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.PriorityQueue;
class Main{
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;
public static class Edge{
int to;
int cost;
public Edge(int to){
this.to=to;
}
public Edge(int to,int cost){
this.to=to; this.cost=cost;
}
}
public static class Pair{
int x;
int y;
public Pair(int x,int y){
this.x=x; this.y=y;
}
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{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line.split(" ")[0]);
int k=Integer.parseInt(line.split(" ")[1]);
int[] c=new int[n];
int[] d=new int[n];
int[] dist=new int[n];
boolean[] visited=new boolean[n];
boolean[][] cg=new boolean[n][n];
MyArrayList[] array=new MyArrayList[n];
for(int i=0;i<n;i++){
line=br.readLine();
c[i]=Integer.parseInt(line.split(" ")[0]);
d[i]=Integer.parseInt(line.split(" ")[1]);
array[i]=new MyArrayList();
}
MyArrayList[] carray=array.clone();
for(int i=0;i<k;i++){
line=br.readLine();
int a=Integer.parseInt(line.split(" ")[0]);
int b=Integer.parseInt(line.split(" ")[1]);
array[a-1].add(new Edge(b-1));
array[b-1].add(new Edge(a-1));
}
for(int i=0;i<n;i++) bfs(i,d[i],visited,cg,array);
for(int i=0;i<n;i++){
for(int j=0;j<n&&j!=i;j++){
if(cg[i][j]) carray[i].add(new Edge(j,c[i]));
}
}
dijkstra(dist,carray);
out.println(dist[n-1]);
out.flush();
}
}
public static void bfs(int s,int t,boolean[] visited,boolean[][] cg,MyArrayList[] array){
Arrays.fill(visited,false);
ArrayList<Edge> list;
Deque<Pair> que=new ArrayDeque<Pair>();
que.offerLast(new Pair(s,t));
while(!que.isEmpty()){
Pair p=que.pollFirst();
int ns=p.x;
int nt=p.y;
list=array[ns];
if(nt>=0||list.size()==0) continue;
visited[ns]=true;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(!visited[e.to]) que.offerLast(new Pair(e.to,nt-1));
}
}
}
public static void dijkstra(int[] dist,MyArrayList[] array){
PriorityQueue<Pair> pque=new PriorityQueue<Pair>(10,Pair.DISTANCE_ORDER);
Arrays.fill(dist,INF);
dist[0]=0;
pque.offer(new Pair(0,0));
while(!pque.isEmpty()){
Pair p=pque.poll();
int v=p.y;
ArrayList<Edge> list=array[v];
if(dist[v]<p.x||list.size()==0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(d[e.to]>d[v]+e.cost){
d[e.to]=d[v]+e.cost;
pque.offer(new Pair(d[e.to],e.to));
}
}
}
}
} | Main.java:57: error: non-static variable this cannot be referenced from a static context
array[i]=new MyArrayList();
^
Main.java:110: error: cannot find symbol
if(d[e.to]>d[v]+e.cost){
^
symbol: variable d
location: class Main
Main.java:110: error: cannot find symbol
if(d[e.to]>d[v]+e.cost){
^
symbol: variable d
location: class Main
Main.java:111: error: cannot find symbol
d[e.to]=d[v]+e.cost;
^
symbol: variable d
location: class Main
Main.java:111: error: cannot find symbol
d[e.to]=d[v]+e.cost;
^
symbol: variable d
location: class Main
Main.java:112: error: cannot find symbol
pque.offer(new Pair(d[e.to],e.to));
^
symbol: variable d
location: class Main
6 errors
|
s098926435 | p00519 | Java | import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.PriorityQueue;
class Main{
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;
public static class Edge{
int to;
int cost;
public Edge(int to){
this.to=to;
}
public Edge(int to,int cost){
this.to=to; this.cost=cost;
}
}
public static class Pair{
int x;
int y;
public Pair(int x,int y){
this.x=x; this.y=y;
}
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;
}
}
}
public static class MyArrayList extends ArrayList<Edge>{}
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line.split(" ")[0]);
int k=Integer.parseInt(line.split(" ")[1]);
int[] c=new int[n];
int[] d=new int[n];
int[] dist=new int[n];
boolean[][] cg=new boolean[n][n];
MyArrayList[] array=new MyArrayList[n];
for(int i=0;i<n;i++){
line=br.readLine();
c[i]=Integer.parseInt(line.split(" ")[0]);
d[i]=Integer.parseInt(line.split(" ")[1]);
array[i]=new MyArrayList();
}
MyArrayList[] carray=array.clone();
for(int i=0;i<k;i++){
line=br.readLine();
int a=Integer.parseInt(line.split(" ")[0]);
int b=Integer.parseInt(line.split(" ")[1]);
array[a-1].add(new Edge(b-1));
array[b-1].add(new Edge(a-1));
}
for(int i=0;i<n;i++) bfs(i,d[i],visited,cg,array);
for(int i=0;i<n;i++){
for(int j=0;j<n&&j!=i;j++){
if(cg[i][j]) carray[i].add(new Edge(j,c[i]));
}
}
dijkstra(dist,carray);
out.println(dist[n-1]);
out.flush();
}
}
public static void bfs(int s,int t,boolean[][] cg,MyArrayList[] array){
Arrays.fill(visited,false);
ArrayList<Edge> list;
Deque<Pair> que=new ArrayDeque<Pair>();
que.offerLast(new Pair(s,t));
while(!que.isEmpty()){
Pair p=que.pollFirst();
int ns=p.x;
int nt=p.y;
list=array[ns];
if(nt<=0||list.size()==0) continue;
cg[s][ns]=true;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(!cg[s][e.to]) que.offerLast(new Pair(e.to,nt-1));
}
}
}
public static void dijkstra(int[] dist,MyArrayList[] array){
PriorityQueue<Pair> pque=new PriorityQueue<Pair>(10,Pair.DISTANCE_ORDER);
Arrays.fill(dist,INF);
dist[0]=0;
pque.offer(new Pair(0,0));
while(!pque.isEmpty()){
Pair p=pque.poll();
int v=p.y;
ArrayList<Edge> list=array[v];
if(dist[v]<p.x||list.size()==0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(dist[e.to]>dist[v]+e.cost){
dist[e.to]=dist[v]+e.cost;
pque.offer(new Pair(dist[e.to],e.to));
}
}
}
}
} | Main.java:66: error: cannot find symbol
for(int i=0;i<n;i++) bfs(i,d[i],visited,cg,array);
^
symbol: variable visited
location: class Main
Main.java:79: error: cannot find symbol
Arrays.fill(visited,false);
^
symbol: variable visited
location: class Main
2 errors
|
s124890440 | p00519 | Java | import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.PriorityQueue;
class Main{
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
public static class Edge{
int to;
int cost;
public Edge(int to){
this.to=to; cost=0;
}
public Edge(int to,int cost){
this.to=to; this.cost=cost;
}
}
public static class Pair{
int x;
int y;
public Pair(int x,int y){
this.x=x; this.y=y;
}
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;
}
}
}
public static class MyArrayList extends ArrayList<Edge>{}
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line.split(" ")[0]);
int k=Integer.parseInt(line.split(" ")[1]);
int[] c=new int[n];
int[] d=new int[n];
int[] dist=new int[n];
boolean[][] cg=new boolean[n][n];
MyArrayList[] array=new MyArrayList[n];
for(int i=0;i<n;i++){
line=br.readLine();
c[i]=Integer.parseInt(line.split(" ")[0]);
d[i]=Integer.parseInt(line.split(" ")[1]);
array[i]=new MyArrayList();
}
MyArrayList carray=array.clone();
for(int i=0;i<k;i++){
line=br.readLine();
int a=Integer.parseInt(line.split(" ")[0]);
int b=Integer.parseInt(line.split(" ")[1]);
array[a-1].add(new Edge(b-1));
array[b-1].add(new Edge(a-1));
}
for(int i=0;i<n;i++) bfs(i,d[i],cg,array);
for(int i=0;i<n;i++){
for(int j=0;j<n&&j!=i;j++){
if(cg[i][j]) carray[i].add(new Edge(j,c[i]));
}
}
dijkstra(dist,carray);
out.println(dist[n-1]);
out.flush();
}
}
public static void bfs(int s,int t,boolean[][] cg,MyArrayList[] array){
ArrayList<Edge> list;
Deque<Pair> que=new ArrayDeque<Pair>();
que.offerLast(new Pair(s,t));
while(!que.isEmpty()){
Pair p=que.pollFirst();
int ns=p.x;
cg[s][ns]=true;
list=array[ns];
if(p.y<=0||list.size()==0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
que.offerLast(new Pair(e.to,p.y-1));
}
}
}
public static void dijkstra(int[] dist,MyArrayList[] array){
PriorityQueue<Pair> pque=new PriorityQueue<Pair>(10,Pair.DISTANCE_ORDER);
Arrays.fill(dist,INF);
dist[0]=0;
pque.offer(new Pair(0,0));
while(!pque.isEmpty()){
Pair p=pque.poll();
int v=p.y;
ArrayList<Edge> list=array[v];
if(dist[v]<p.x||list.size()==0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(dist[e.to]>dist[v]+e.cost){
dist[e.to]=dist[v]+e.cost;
pque.offer(new Pair(dist[e.to],e.to));
}
}
}
}
} | Main.java:58: error: incompatible types: MyArrayList[] cannot be converted to MyArrayList
MyArrayList carray=array.clone();
^
Main.java:69: error: array required, but MyArrayList found
if(cg[i][j]) carray[i].add(new Edge(j,c[i]));
^
Main.java:72: error: incompatible types: MyArrayList cannot be converted to MyArrayList[]
dijkstra(dist,carray);
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
3 errors
|
s519773697 | p00519 | Java | import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.PriorityQueue;
class Main{
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
public static class Edge{
int to;
int cost;
public Edge(int to){
this.to=to; cost=0;
}
public Edge(int to,int cost){
this.to=to; this.cost=cost;
}
}
public static class Pair{
int x;
int y;
public Pair(int 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;
}
}
}
public static class MyArrayList extends ArrayList<Edge>{}
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line.split(" ")[0]);
int k=Integer.parseInt(line.split(" ")[1]);
int[] c=new int[n];
int[] d=new int[n];
int[] dist=new int[n];
boolean[][] cg=new boolean[n][n];
MyArrayList[] array=new MyArrayList[n];
for(int i=0;i<n;i++){
line=br.readLine();
c[i]=Integer.parseInt(line.split(" ")[0]);
d[i]=Integer.parseInt(line.split(" ")[1]);
array[i]=new MyArrayList();
}
MyArrayList[] carray=array.clone();
for(int i=0;i<k;i++){
line=br.readLine();
int a=Integer.parseInt(line.split(" ")[0]);
int b=Integer.parseInt(line.split(" ")[1]);
array[a-1].add(new Edge(b-1));
array[b-1].add(new Edge(a-1));
}
for(int i=0;i<n;i++) bfs(i,d[i],cg,array);
for(int i=0;i<n;i++){
for(int j=0;j<n&&j!=i;j++){
if(cg[i][j]) carray[i].add(new Edge(j,c[i]));
}
}
dijkstra(dist,carray);
out.println(dist[n-1]);
}
out.flush();
}
public static void bfs(int s,int t,boolean[][] cg,MyArrayList[] array){
ArrayList<Edge> list;
Deque<Pair> que=new ArrayDeque<Pair>();
que.offerLast(new Pair(s,t));
while(!que.isEmpty()&&){
Pair p=que.pollFirst();
int ns=p.x;
cg[s][ns]=true;
list=array[ns];
if(p.y<=0||list.size()==0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(!cg[s][e.to]) que.offerLast(new Pair(e.to,p.y-1));
}
}
}
public static void dijkstra(int[] dist,MyArrayList[] array){
PriorityQueue<Pair> pque=new PriorityQueue<Pair>(1,Pair.DISTANCE_ORDER);
Arrays.fill(dist,INF);
dist[0]=0;
pque.offer(new Pair(0,0));
while(!pque.isEmpty()dist[dist.length-1]!=INF){
Pair p=pque.poll();
int v=p.y;
ArrayList<Edge> list=array[v];
if(dist[v]<p.x||list.size()==0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(dist[e.to]>dist[v]+e.cost){
dist[e.to]=dist[v]+e.cost;
pque.offer(new Pair(dist[e.to],e.to));
}
}
}
}
} | Main.java:82: error: illegal start of expression
while(!que.isEmpty()&&){
^
Main.java:100: error: ')' expected
while(!pque.isEmpty()dist[dist.length-1]!=INF){
^
Main.java:100: error: not a statement
while(!pque.isEmpty()dist[dist.length-1]!=INF){
^
Main.java:100: error: ';' expected
while(!pque.isEmpty()dist[dist.length-1]!=INF){
^
4 errors
|
s615570985 | p00519 | Java | import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
class Main{
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
public static class Edge{
int to;
int cost;
public Edge(int to){
this.to=to; cost=0;
}
public Edge(int to,int cost){
this.to=to; this.cost=cost;
}
}
public static class Pair{
int x;
int y;
public Pair(int 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;
}
}
}
public static class MyArrayList extends ArrayList<Edge>{}
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int n=Integer.parseInt(line.split(" ")[0]);
int k=Integer.parseInt(line.split(" ")[1]);
int[] c=new int[n];
int[] r=new int[n];
int[] dist=new int[n];
boolean[][] visited=new boolean[n][n];
MyArrayList[] array=new MyArrayList[n];
for(int i=0;i<n;i++){
st=new StringTokenizer(br.readLine());
c[i]=Integer.parseInt(st.nextToken());
r[i]=Integer.parseInt(st.nextToken());
array[i]=new MyArrayList();
}
MyArrayList[] carray=array.clone();
for(int i=0;i<k;i++){
st=new StringTokenizer(br.readLine());
int a=Integer.parseInt(st.nextToken())-1;
int b=Integer.parseInt(st.nextToken())-1;
array[a].add(new Edge(b));
array[b].add(new Edge(a));
}
for(int i=0;i<n;i++){
bfs(i,r[i],visited,array);
for(int j=0;j<n&&j!=i;j++){
if(visited[i][j]) carray[i].add(new Edge(j,c[i]));
}
}
dijkstra(dist,carray);
out.println(dist[n-1]);
out.flush();
}
public static void bfs(int s,int t,boolean[][] visited,MyArrayList[] array){
Arrays.fill(visited[s],false);
Deque<Pair> que=new ArrayDeque<Pair>();
que.offerLast(new Pair(s,t));
while(!que.isEmpty()){
Pair p=que.pollFirst();
int ns=p.x;
if(visited[s][ns]) continue;
visited[s][ns]=true;
ArrayList<Edge> list=array[ns];
if(p.y<=0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(visited[s][e.to]) continue;
que.offerLast(new Pair(e.to,p.y-1));
}
}
}
public static void dijkstra(int[] dist,MyArrayList[] array){
PriorityQueue<Pair> pque=new PriorityQueue<Pair>(1,Pair.DISTANCE_ORDER);
Arrays.fill(dist,INF);
dist[0]=0;
pque.offer(new Pair(0,0));
while(!pque.isEmpty()){
Pair p=pque.poll();
int v=p.y;
ArrayList<Edge> list=array[v];
if(dist[v]<p.x||list.size()==0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(dist[e.to]>dist[v]+e.cost){
dist[e.to]=dist[v]+e.cost;
pque.offer(new Pair(dist[e.to],e.to));
}
}
}
}
} | Main.java:45: error: cannot find symbol
int n=Integer.parseInt(line.split(" ")[0]);
^
symbol: variable line
location: class Main
Main.java:46: error: cannot find symbol
int k=Integer.parseInt(line.split(" ")[1]);
^
symbol: variable line
location: class Main
2 errors
|
s922123101 | p00519 | Java | import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
class Main{
static final int INF=Integer.MAX_VALUE;
public static class Edge{
int to;
int cost;
public Edge(int to){
this.to=to; cost=0;
}
public Edge(int to,int cost){
this.to=to; this.cost=cost;
}
}
public static class Pair{
int x;
int y;
public Pair(int 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;
}
}
}
public static class MyArrayList extends ArrayList<Edge>{}
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int n=Integer.parseInt(line.split(" ")[0]);
int k=Integer.parseInt(line.split(" ")[1]);
int[] c=new int[n];
int[] r=new int[n];
int[] dist=new int[n];
boolean[][] visited=new boolean[n][n];
MyArrayList[] array=new MyArrayList[n];
for(int i=0;i<n;i++){
st=new StringTokenizer(br.readLine());
c[i]=Integer.parseInt(st.nextToken());
r[i]=Integer.parseInt(st.nextToken());
array[i]=new MyArrayList();
}
MyArrayList[] carray=array.clone();
for(int i=0;i<k;i++){
st=new StringTokenizer(br.readLine());
int a=Integer.parseInt(st.nextToken())-1;
int b=Integer.parseInt(st.nextToken())-1;
array[a].add(new Edge(b));
array[b].add(new Edge(a));
}
for(int i=0;i<n;i++){
bfs(i,r[i],visited,array);
for(int j=0;j<n&&j!=i;j++){
if(visited[i][j]) carray[i].add(new Edge(j,c[i]));
}
}
dijkstra(dist,carray);
System.out.println(dist[n-1]);
}
public static void bfs(int s,int t,boolean[][] visited,MyArrayList[] array){
Arrays.fill(visited[s],false);
Deque<Pair> que=new ArrayDeque<Pair>();
que.offerLast(new Pair(s,t));
while(!que.isEmpty()){
Pair p=que.pollFirst();
int ns=p.x;
if(visited[s][ns]) continue;
visited[s][ns]=true;
ArrayList<Edge> list=array[ns];
if(p.y<=0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(visited[s][e.to]) continue;
que.offerLast(new Pair(e.to,p.y-1));
}
}
}
public static void dijkstra(int[] dist,MyArrayList[] array){
PriorityQueue<Pair> pque=new PriorityQueue<Pair>(1,Pair.DISTANCE_ORDER);
Arrays.fill(dist,INF);
dist[0]=0;
pque.offer(new Pair(0,0));
while(!pque.isEmpty()){
Pair p=pque.poll();
int v=p.y;
ArrayList<Edge> list=array[v];
if(dist[v]<p.x||list.size()==0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(dist[e.to]>dist[v]+e.cost){
dist[e.to]=dist[v]+e.cost;
pque.offer(new Pair(dist[e.to],e.to));
}
}
}
}
} | Main.java:44: error: cannot find symbol
int n=Integer.parseInt(line.split(" ")[0]);
^
symbol: variable line
location: class Main
Main.java:45: error: cannot find symbol
int k=Integer.parseInt(line.split(" ")[1]);
^
symbol: variable line
location: class Main
2 errors
|
s622325537 | p00519 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
struct T{
int v,r;
};
struct S{
int v,c,r;
bool operator<(S s)const{
return c>s.c;
}
};
int N,K;
int C[5001],R[5001];
vector<int> G[5001];
int main(){
cin>>N>>K;
for(int i=1;i<=N;i++){
cin>>C[i]>>R[i];
}
while(K--){
int A,B;
cin>>A>>B;
G[A].push_back(B);
G[B].push_back(A);
}
priority_queue<S> que;
que.push({1,0,0});
static bool mem[5001][5001];
for(;;){
S cs=que.top();
if(cs.v==N)break;
que.pop();
if(mem[cs.v][cs.r]++)continue;
que.push({cs.v,cs.c+C[cs.v],R[cs.v]});
if(cs.r){
for(auto e:H[cs.v]){
que.push({e,cs.c+C[cs.v],cs.r-1});
}
}
}
cout<<que.top().c<<endl;
} | a.cc: In function 'int main()':
a.cc:41:22: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
41 | if(mem[cs.v][cs.r]++)continue;
| ~~~~~~~~~~~~~~^
a.cc:44:18: error: 'H' was not declared in this scope
44 | for(auto e:H[cs.v]){
| ^
a.cc:45:17: error: no matching function for call to 'std::priority_queue<S>::push(<brace-enclosed initializer list>)'
45 | que.push({e,cs.c+C[cs.v],cs.r-1});
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
from a.cc:4:
/usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = S; _Sequence = std::vector<S, std::allocator<S> >; _Compare = std::less<S>; value_type = S]'
736 | push(const value_type& __x)
| ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<S>::value_type&' {aka 'const S&'}
736 | push(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = S; _Sequence = std::vector<S, std::allocator<S> >; _Compare = std::less<S>; value_type = S]'
744 | push(value_type&& __x)
| ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:25: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<S>::value_type&&' {aka 'S&&'}
744 | push(value_type&& __x)
| ~~~~~~~~~~~~~^~~
|
s007580507 | p00519 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cmath>
#include <deque>
#include <set>
#include <climits>
#define rep_(v, f, l) for (auto v = (f); v != (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, o) rep_(v, o.begin(), o.end())
const long long INF = LLONG_MAX;
using namespace std;
typedef long long int lint;
template<typename T> inline bool in(T& x){ return cin >> x; }
template<typename T> inline T in(){T x; cin >> x; return x; }
typedef long long int Weight;
struct Edge {
int src, dst;
Weight weight;
Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
bool operator < (const Edge &e, const Edge &f) {
return e.weight != f.weight ? e.weight > f.weight :
e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void shortestPath(const Graph &g, int s, vector<Weight> &dist, vector<int> &prev){
int n = g.size();
dist.assign(n, INF); dist[s] = 0;
prev.assign(n, -1);
priority_queue<Edge> Q;
for (Q.push(Edge(-2, s, 0)); !Q.empty();){
Edge e = Q.top(); Q.pop();
if (prev[e.dst] != -1) continue;
prev[e.dst] = e.src;
lep(f, g[e.dst]){
if (dist[f->dst] > e.weight + f->weight){
dist[f->dst] = e.weight + f->weight;
Q.push(Edge(f->src, f->dst, e.weight + f->weight));
}
}
}
}
struct Taxi {
int val, len;
Taxi(int val, int len) : val(val), len(len) {}
};
void dfs(const Graph& g, Graph& G, int s, int d, int val, int len, int *vis)
{
if (len == -1) return;
if (vis[d]) return;
vis[d] = 1;
if (s != d){
G[s].push_back(Edge(s, d, val));
}
lep(e, g[d]){
dfs(g, G, s, e->dst, val, len - 1, vis);
}
vis[d] = 0;
}
int main()
{
int N, K;
in(N), in(K);
vector<Taxi> taxi;
rep(i, N){
int val, len;
in(val), in(len);
taxi.push_back(Taxi(val, len));
}
Graph g(N), G(N);
rep(i, K){
int from, to;
in(from), in(to);
from--, to--;
g[from].push_back(Edge(from, to, 0));
g[to].push_back(Edge(to, from, 0));
}
vector<Weight> w;
vector<int> prev;
int vis[N] = {0};
rep(i, N){
dfs(g, G, i, i, taxi[i].val, taxi[i].len, vis);
memset(vis, 0, sizeof(vis));
}
shortestPath(G, 0, w, prev);
printf("%lld\n", w[N - 1]);
return (0);
} | a.cc: In instantiation of 'bool in(T&) [with T = int]':
a.cc:80:4: required from here
80 | in(N), in(K);
| ~~^~~
a.cc:25:58: error: cannot convert 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'bool' in return
25 | template<typename T> inline bool in(T& x){ return cin >> x; }
| ^
In file included from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/basic_ios.h:121:16: note: explicit conversion function was not considered
121 | explicit operator bool() const
| ^~~~~~~~
|
s035867956 | p00519 | C++ | import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
class Main{
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
public static class Edge{
int to;
int cost;
public Edge(int to){
this.to=to; cost=0;
}
public Edge(int to,int cost){
this.to=to; this.cost=cost;
}
}
public static class Pair{
int x;
int y;
public Pair(int 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;
}
}
}
public static class MyArrayList extends ArrayList<Edge>{}
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line.split(" ")[0]);
int k=Integer.parseInt(line.split(" ")[1]);
int[] c=new int[n];
int[] d=new int[n];
int[] dist=new int[n];
boolean[][] visited=new boolean[n][n];
MyArrayList[] array=new MyArrayList[n];
for(int i=0;i<n;i++){
st=new StringTokenizer(br.readLine());
c[i]=Integer.parseInt(st.nextToken());
d[i]=Integer.parseInt(st.nextToken());
array[i]=new MyArrayList();
}
MyArrayList[] carray=array.clone();
for(int i=0;i<k;i++){
st=new StringTokenizer(br.readLine());
int a=Integer.parseInt(st.nextToken())-1;
int b=Integer.parseInt(st.nextToken())-1;
array[a].add(new Edge(b));
array[b].add(new Edge(a));
}
for(int i=0;i<n;i++) bfs(i,d[i],visited,array);
for(int i=0;i<n;i++){
for(int j=0;j<n&&j!=i;j++){
if(visited[i][j]) carray[i].add(new Edge(j,c[i]));
}
}
dijkstra(dist,carray);
out.println(dist[n-1]);
}
out.flush();
}
public static void bfs(int s,int t,boolean[][] visited,MyArrayList[] array){
Arrays.fill(visited[s],false);
Deque<Pair> que=new ArrayDeque<Pair>();
que.offerLast(new Pair(s,t));
while(!que.isEmpty()){
Pair p=que.pollFirst();
int ns=p.x;
visited[s][ns]=true;
ArrayList<Edge> list=array[ns];
if(p.y<=0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(!visited[s][e.to]) que.offerLast(new Pair(e.to,p.y-1));
}
}
}
public static void dijkstra(int[] dist,MyArrayList[] array){
PriorityQueue<Pair> pque=new PriorityQueue<Pair>(1,Pair.DISTANCE_ORDER);
Arrays.fill(dist,INF);
dist[0]=0;
pque.offer(new Pair(0,0));
while(!pque.isEmpty()){
Pair p=pque.poll();
int v=p.y;
ArrayList<Edge> list=array[v];
if(dist[v]<p.x||list.size()==0) continue;
for(int i=0;i<list.size();i++){
Edge e=list.get(i);
if(dist[e.to]>dist[v]+e.cost){
dist[e.to]=dist[v]+e.cost;
pque.offer(new Pair(dist[e.to],e.to));
}
}
}
}
} | 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:2:1: error: 'import' does not name a type
2 | import java.util.ArrayDeque;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.util.ArrayList;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.util.Arrays;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.util.Comparator;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
6 | import java.util.Deque;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
7 | import java.util.PriorityQueue;
| ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: 'import' does not name a type
8 | import java.util.StringTokenizer;
| ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:12:8: error: 'final' does not name a type
12 | static final PrintWriter out=new PrintWriter(System.out);
| ^~~~~
a.cc:13:8: error: 'final' does not name a type
13 | static final int INF=Integer.MAX_VALUE;
| ^~~~~
a.cc:15:7: error: expected ':' before 'static'
15 | public static class Edge{
| ^~~~~~~
| :
a.cc:18:7: error: expected ':' before 'Edge'
18 | public Edge(int to){
| ^~~~~
| :
a.cc:21:7: error: expected ':' before 'Edge'
21 | public Edge(int to,int cost){
| ^~~~~
| :
a.cc:24:2: error: expected ';' after class definition
24 | }
| ^
| ;
a.cc:15:8: error: a storage class can only be specified for objects and functions
15 | public static class Edge{
| ^~~~~~
a.cc:26:7: error: expected ':' before 'static'
26 | public static class Pair{
| ^~~~~~~
| :
a.cc:29:7: error: expected ':' before 'Pair'
29 | public Pair(int x,int y){
| ^~~~~
| :
a.cc:32:7: error: expected ':' before 'static'
32 | public static final Comparator<Pair> DISTANCE_ORDER=new Comp();
| ^~~~~~~
| :
a.cc:32:15: error: 'final' does not name a type
32 | public static final Comparator<Pair> DISTANCE_ORDER=new Comp();
| ^~~~~
a.cc:33:8: error: expected ':' before 'static'
33 | private static class Comp implements Comparator<Pair>{
| ^~~~~~~
| :
a.cc:33:27: error: expected ';' at end of member declaration
33 | private static class Comp implements Comparator<Pair>{
| ^~~~~~~~~~
| ;
a.cc:33:38: error: 'Comparator' does not name a type
33 | private static class Comp implements Comparator<Pair>{
| ^~~~~~~~~~
a.cc:38:2: error: expected ';' after class definition
38 | }
| ^
| ;
a.cc:26:8: error: a storage class can only be specified for objects and functions
26 | public static class Pair{
| ^~~~~~
a.cc:40:7: error: expected ':' before 'static'
40 | public static class MyArrayList extends ArrayList<Edge>{}
| ^~~~~~~
| :
a.cc:40:33: error: expected ';' at end of member declaration
40 | public static class MyArrayList extends ArrayList<Edge>{}
| ^~~~~~~
| ;
a.cc:40:41: error: 'ArrayList' does not name a type; did you mean 'MyArrayList'?
40 | public static class MyArrayList extends ArrayList<Edge>{}
| ^~~~~~~~~
| MyArrayList
a.cc:42:7: error: expected ':' before 'static'
42 | public static void main(String[] args) throws IOException{
| ^~~~~~~
| :
a.cc:42:25: error: 'String' has not been declared
42 | public static void main(String[] args) throws IOException{
| ^~~~~~
a.cc:42:34: error: expected ',' or '...' before 'args'
42 | public static void main(String[] args) throws IOException{
| ^~~~
a.cc:42:38: error: expected ';' at end of member declaration
42 | public static void main(String[] args) throws IOException{
| ^
| ;
a.cc:42:40: error: 'throws' does not name a type
42 | public static void main(String[] args) throws IOException{
| ^~~~~~
a.cc:80:7: error: expected ':' before 'static'
80 | public static void bfs(int s,int t,boolean[][] visited,MyArrayList[] array){
| ^~~~~~~
| :
a.cc:80:36: error: 'boolean' has not been declared
80 | public static void bfs(int s,int t,boolean[][] visited,MyArrayList[] array){
| ^~~~~~~
a.cc:80:46: error: multidimensional array must have bounds for all dimensions except the first
80 | public static void bfs(int s,int t,boolean[][] visited,MyArrayList[] array){
| ^
a.cc:80:48: error: expected ',' or '...' before 'visited'
80 | public static void bfs(int s,int t,boolean[][] visited,MyArrayList[] array){
| ^~~~~~~
a.cc:97:7: error: expected ':' before 'static'
97 | public static void dijkstra(int[] dist,MyArrayList[] array){
| ^~~~~~~
| :
a.cc:97:35: error: expected ',' or '...' before 'dist'
97 | public static void dijkstra(int[] dist,MyArrayList[] array){
| ^~~~
a.cc:116:2: error: expected ';' after class definition
116 | }
| ^
| ;
a.cc: In constructor 'Main::Edge::Edge(int)':
a.cc:19:6: error: request for member 'to' in '(Main::Edge*)this', which is of pointer type 'Main::Edge*' (maybe you meant to use '->' ?)
19 | this.to=to; cost=0;
| ^~
a.cc: In constructor 'Main::Edge::Edge(int, int)':
a.cc:22:6: error: request for member 'to' in '(Main::Edge*)this', which is of pointer type 'Main::Edge*' (maybe you meant to use '->' ?)
22 | this.to=to; this.cost=cost;
| ^~
a.cc:22:18: error: request for member 'cost' in '(Main::Edge*)this', which is of pointer type 'Main::Edge*' (maybe you meant to use '->' ?)
22 | this.to=to; this.cost=cost;
| ^~~~
a.cc: In constructor 'Main::Pair::Pair(int, int)':
a.cc:30:6: error: request for member 'x' in '(Main::Pair*)this', which is of pointer type 'Main::Pair*' (maybe you meant to use '->' ?)
30 | this.x=x; this.y=y;
| ^
a.cc:30:16: error: request for member 'y' in '(Main::Pair*)this', which is of pointer type 'Main::Pair*' (maybe you meant to use '->' ?)
30 | this.x=x; this.y=y;
| ^
a.cc: In static member function 'static void Main::bfs(...)':
a.cc:81:1: error: 'Arrays' was not declared in this scope
81 | Arrays.fill(visited[s],false);
| ^~~~~~
a.cc:81:13: error: 'visited' was not declared in this scope
81 | Arrays.fill(visited[s],false);
| ^~~~~~~
a.cc:82:1: error: 'Deque' was not declared in this scope
82 | Deque<Pair> que=new ArrayDeque<Pair>();
| ^~~~~
a.cc:82:11: error: expected primary-expression before '>' token
82 | Deque<Pair> que=new ArrayDeque<Pair>();
| ^
a.cc:82:13: error: 'que' was not declared in this scope
82 | Deque<Pair> que=new ArrayDeque<Pair>();
| ^~~
a.cc:82:21: error: 'ArrayDeque' does not name a type
82 | Deque<Pair> que=new ArrayDeque<Pair>();
| ^~~~~~~~~~
a.cc:82:36: error: expected primary-expression before '>' token
82 | Deque<Pair> que=new ArrayDeque<Pair>();
| ^
a.cc:82:38: error: expected primary-expression before ')' token
82 | Deque<Pair> que=new ArrayDeque<Pair>();
| ^
a.cc:86:10: error: 'int Main::Pair::x' is private within this context
86 | int ns=p.x;
| ^
a.cc:27:5: note: declared private here
27 | int x;
| ^
a.cc:88:1: error: 'ArrayList' was not declared in this scope; did you mean 'MyArrayList'?
88 | ArrayList<Edge> list=array[ns];
| ^~~~~~~~~
| MyArrayList
a.cc:88:15: error: expected primary-expression before '>' token
88 | ArrayList<Edge> list=array[ns];
| ^
a.cc:88:17: error: 'list' was not declared in this scope
88 | ArrayList<Edge> list=array[ns];
| ^~~~
a.cc:88:22: error: 'array' was not declared in this scope
88 | ArrayList<Edge> list=array[ns];
| ^~~~~
a.cc:89:6: error: 'int Main::Pair::y' is private within this context
89 | if(p.y<=0) continue;
| ^
a.cc:28:5: note: declared private here
28 | int y;
| ^
a.cc:92:18: error: 'int Main::Edge::to' is private within this context
92 | if(!visited[s][e.to]) que.offerLast(new Pair(e.to,p.y-1));
| ^~
a.cc:16:5: note: declared private here
16 | int to;
| ^~
a.cc:92:48: error: 'int Main::Edge::to' is private within this context
92 | if(!visited[s][e.to]) que.offerLast(new Pair(e.to,p.y-1));
| ^~
a.cc:16:5: note: declared private here
16 | int to;
| ^~
a.cc:92:53: error: 'int Main::Pair::y' is private within this context
92 | if(!visited[s][e.to]) que.offerLast(new Pair(e.to,p.y-1));
| ^
a.cc:28:5: note: declared private here
28 | int y;
| ^
a.cc: In static member function 'static void Main::dijkstra(int*)':
a.cc:98:1: error: 'PriorityQueue' was not declared in this scope
98 | PriorityQueue<Pair> pque=new PriorityQueu |
s571838653 | p00519 | C++ | #include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define INF 999999999
vector<int> pass[6000];
int n,k;
int c[6000],r[6000];
int d[6000];
bool used[6000];
void dfs(int v,int u,int f,int end,bool visited[6000]){
if(visited[u])return ;
visited[u] = true;
d[u] = min(d[u],d[v]+c[v]);
if(f>=end)return ;
rep(i,pass[u].size()){
dfs(v,pass[u][i],f+1,end,visited);
}
}
int dijk(int s,int g){
rep(i,6000)d[i]=INF;
rep(i,6000)used[i]=false;
d[s]=0;
while(1){
int v=-1;
rep(u,n){
if(!used[u] && (v==-1||d[u]<d[v]))v=u;
}
if(v==-1)break;
used[v]=true;
rep(i,pass[v].size()){
bool visited[6000]={};
dfs( v,pass[v][i],1,r[v],visited );
}
}
return d[g];
}
int main(){
cin>>n>>k;
rep(i,n) cin>>c[i]>>r[i];
rep(i,k){
int a,b;
cin>>a>>b;
a--,b--;
pass[a].pb(b);
pass[b].pb(a);
}
cout<<dijk(0,n-1)<<endl;
} | a.cc: In function 'int main()':
a.cc:52:17: error: 'class std::vector<int>' has no member named 'pb'
52 | pass[a].pb(b);
| ^~
a.cc:53:17: error: 'class std::vector<int>' has no member named 'pb'
53 | pass[b].pb(a);
| ^~
|
s484158100 | p00519 | C++ | #include <queue>
#include <vector>
#include <utility>
#include <iostream>
using namespace std;
#define INF (1 << 30)
#define WHITE 0
#define GRAY 1
#define BLACK 2
int main()
{
int N, K, A, B;
cin >> N >> K;
vector<int> C(N + 1);
vector<int> R(N + 1);
vector<int> S(N + 1);
vector<int> D(N + 1);
vector<int> P(N + 1);
vector<vector<bool> > M1(N + 1, vector<bool>(N + 1, false));
vector<vector<int> > M2(N + 1, vector<int>(N + 1, INF));
for (int i = 1; i <= N; i++)
cin >> C[i] >> R[i];
for (int i = 1; i <= K; i++)
{
cin >> A >> B;
M1[A][B] = true;
M1[B][A] = true;
}
for (int i = 1; i <= N; i++)
{
if (R[i] < N - 1)
{
queue<pair<int, short> > que;
pair<int, short> start;
start.first = i;
start.second = (short)0;
que.push(start);
while (!que.empty() && que.front().second < R[i])
{
pair<int, short> p1 = que.front(); que.pop();
for (int j = 1; j <= N; j++)
{
if (M1[p1.first][j] == true && M2[i][j] == INF)
{
pair<int, short> p2;
p2.first = j;
p2.second = p1.second + (short)1;
que.push(p2);
M2[i][p2.first] = C[i];
}
}
}
}
else
{
for (int j = 1; j <= N; j++)
{
if (i != j)
{
M2[i][j] = C[i];
}
}
}
}
for (int i = 0; i < MAX_N; i++)
{
S[i] = WHITE; D[i] = INF; P[i] = INF;
}
D[1] = 0;
P[1] = -1;
while (true)
{
int mincost = INF;
int u = -1;
for (int i = 1; i <= N; i++)
{
if (S[i] != BLACK && D[i] < mincost)
{
mincost = D[i];
u = i;
}
}
if (mincost == INF) { break; }
S[u] = BLACK;
for (int v = 1; v <= N; v++)
{
if (S[v] != BLACK && M2[u][v] != INF)
{
if (D[u] + M2[u][v] < D[v])
{
D[v] = D[u] + M2[u][v];
P[v] = u;
S[u] = GRAY;
}
}
}
}
cout << D[N] << endl;
return 0;
}
// Time : O ( N ^ 2 ) | a.cc: In function 'int main()':
a.cc:84:29: error: 'MAX_N' was not declared in this scope
84 | for (int i = 0; i < MAX_N; i++)
| ^~~~~
|
s494513223 | p00519 | C++ | #include <iostream>
#include <vector>
#include <queue>
#include <climits>
using namespace std;
int n,k;
vector<int> c,r,result;
vector<bool> p, notv;
priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q;
void addRoute(int now, int remain, int cost){
notv[i] = false;
if(remain){
for(int i=0; i<n; i++){
if(p[now+i*n] && notv[i]){
if(result[i] > cost){
q.push(make_pair(cost,i));
}
addRoute(i, remain-1, cost);
}
}
}
}
int main(){
cin>>n>>k;
c.resize(n);
r.resize(n);
p.assign(n*n,false);
for(int i=0; i<n; i++){
cin>>c[i]>>r[i];
}
for(int i=0; i<k; i++){
int a,b;
cin>>a>>b;
p[(a-1)+n*(b-1)] = p[(b-1)+n*(a-1)] = true;
}
result.assign(n,INT_MAX);
q.push(make_pair(0,0));
for(;q.size();){
int cost = q.top().first;
int now = q.top().second;
q.pop();
if(cost < result[now]){
result[now] = cost;
notv.assign(n,true);
addRoute(now, r[now], c[now] + cost);
}
}
cout<<result[n-1]<<endl;
} | a.cc: In function 'void addRoute(int, int, int)':
a.cc:13:14: error: 'i' was not declared in this scope
13 | notv[i] = false;
| ^
|
s060161184 | p00519 | C++ | #include <iostream>
#include <queue>
#include <vector>
#include <set>
using namespace std;
const int INF = 1000000007;
class V
{
public:
V(){dj=INF;visited=false;}
unordered_set<int> graph;
unordered_set<int> graph2;
int cost;
int dj;
int num;
bool visited;
};
V v[5000];
int main()
{
int n, k;
cin >> n >> k;
v[0].dj=0;
for(int i=0;i<n;i++)
cin >> v[i].cost >> v[i].num;
for(int i=0;i<k;i++)
{
int a, b;
cin >> a >> b;
v[a-1].graph.insert(b-1);
v[b-1].graph.insert(a-1);
}
for(int i=0;i<n;i++)
{
queue< pair<int, int> > q;
q.push(pair<int, int>(i, v[i].num));
while(!q.empty())
{
pair<int, int> p = q.front();q.pop();
v[i].graph2.insert(p.first);
if(p.second)
{
for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
{
q.push(pair<int, int>((*it), p.second-1));
}
}
}
}
int now=0;
do
{
int mini = INF;
int nextSearch = -1;
v[now].visited=true;
for(int i=0;i<n;i++)
{
if((!v[i].visited)&&(v[now].graph2.find(i)!=v[now].graph2.end())&&(v[now].dj+v[now].cost<v[i].dj))
{
int n=v[now].dj+v[now].cost;
v[i].dj=n;
}
if((!v[i].visited)&&(v[i].dj<mini))
{
mini = v[i].dj;
nextSearch=i;
}
}
now = nextSearch;
}while (now != -1);
cout << v[n-1].dj << endl;
return 0;
} | a.cc:14:9: error: 'unordered_set' does not name a type
14 | unordered_set<int> graph;
| ^~~~~~~~~~~~~
a.cc:15:9: error: 'unordered_set' does not name a type
15 | unordered_set<int> graph2;
| ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:35:24: error: 'class V' has no member named 'graph'
35 | v[a-1].graph.insert(b-1);
| ^~~~~
a.cc:36:24: error: 'class V' has no member named 'graph'
36 | v[b-1].graph.insert(a-1);
| ^~~~~
a.cc:46:30: error: 'class V' has no member named 'graph2'
46 | v[i].graph2.insert(p.first);
| ^~~~~~
a.cc:49:70: error: 'class V' has no member named 'graph'
49 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^~~~~
a.cc:49:99: error: 'class V' has no member named 'graph'
49 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^~~~~
a.cc:65:53: error: 'class V' has no member named 'graph2'
65 | if((!v[i].visited)&&(v[now].graph2.find(i)!=v[now].graph2.end())&&(v[now].dj+v[now].cost<v[i].dj))
| ^~~~~~
a.cc:65:76: error: 'class V' has no member named 'graph2'
65 | if((!v[i].visited)&&(v[now].graph2.find(i)!=v[now].graph2.end())&&(v[now].dj+v[now].cost<v[i].dj))
| ^~~~~~
|
s798269146 | p00519 | C++ | #include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <unordered_set>
using namespace std;
const int INF = 1000000007;
class V
{
public:
V(){dj=INF;visited=false;}
unordered_set<int> graph;
unordered_set<int> graph2;
int cost;
int dj;
int num;
bool visited;
};
V v[5000];
int main()
{
int n, k;
cin >> n >> k;
v[0].dj=0;
for(int i=0;i<n;i++)
cin >> v[i].cost >> v[i].num;
for(int i=0;i<k;i++)
{
int a, b;
cin >> a >> b;
v[a-1].graph.insert(b-1);
v[b-1].graph.insert(a-1);
}
for(int i=0;i<n;i++)
{
queue< pair<int, int> > q;
q.push(pair<int, int>(i, v[i].num));
while(!q.empty())
{
pair<int, int> p = q.front();q.pop();
v[i].graph2.insert(p.first);
if(p.second)
{
for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
{
q.push(pair<int, int>((*it), p.second-1));
}
}
}
}
int now=0;
do
{
int mini = INF;
int nextSearch = -1;
v[now].visited=true;
for(int i=0;i<n;i++)
{
if((!v[i].visited)&&(v[now].graph2.find(i)!=v[now].graph2.end())&&(v[now].dj+v[now].cost<v[i].dj))
{
int n=v[now].dj+v[now].cost;
v[i].dj=n;
}
if((!v[i].visited)&&(v[i].dj<mini))
{
mini = v[i].dj;
nextSearch=i;
}
}
now = nextSearch;
}while (now != -1);
cout << v[n-1].dj << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:50:81: error: conversion from 'std::unordered_set<int>::iterator' {aka 'std::__detail::_Insert_base<int, int, std::allocator<int>, std::__detail::_Identity, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, true, true> >::iterator'} to non-scalar type 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} requested
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ~~~~~~~~~~~~~~~~~~~~~~^~
a.cc:50:86: error: no match for 'operator!=' (operand types are 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} and 'std::unordered_set<int>::iterator' {aka 'std::__detail::_Insert_base<int, int, std::allocator<int>, std::__detail::_Identity, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, true, true> >::iterator'})
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ~~^~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | std::unordered_set<int>::iterator {aka std::__detail::_Insert_base<int, int, std::allocator<int>, std::__detail::_Identity, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, true, true> >::iterator}
| std::set<int>::iterator {aka std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator}
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)'
197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::fpos<_StateT>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
In file included from /usr/include/c++/14/string:43,
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/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)'
243 | operator!=(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:243:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::allocator<_CharT>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
455 | operator!=(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
500 | operator!=(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1686 | operator!=(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1753 | operator!=(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
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:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::pair<_T1, _T2>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
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:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
651 | operator!=(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:651:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
/usr/include/c++/14/string_view:658: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> >)'
658 | operator!=(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:658:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
50 | for(set<int>::iterator it=v[p. |
s797511732 | p00519 | C++ | #include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <unordered_set>
using namespace std;
const int INF = 1000000007;
class V
{
public:
V(){dj=INF;visited=false;}
unordered_set<int> graph;
unordered_set<int> graph2;
int cost;
int dj;
int num;
bool visited;
};
V v[5000];
int main()
{
int n, k;
cin >> n >> k;
v[0].dj=0;
for(int i=0;i<n;i++)
cin >> v[i].cost >> v[i].num;
for(int i=0;i<k;i++)
{
int a, b;
cin >> a >> b;
v[a-1].graph.insert(b-1);
v[b-1].graph.insert(a-1);
}
for(int i=0;i<n;i++)
{
queue< pair<int, int> > q;
q.push(pair<int, int>(i, v[i].num));
while(!q.empty())
{
pair<int, int> p = q.front();q.pop();
v[i].graph2.insert(p.first);
if(p.second)
{
for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
{
q.push(pair<int, int>((*it), p.second-1));
}
}
}
}
int now=0;
do
{
int mini = INF;
int nextSearch = -1;
v[now].visited=true;
for(int i=0;i<n;i++)
{
if((!v[i].visited)&&(v[now].graph2.find(i)!=v[now].graph2.end())&&(v[now].dj+v[now].cost<v[i].dj))
{
int n=v[now].dj+v[now].cost;
v[i].dj=n;
}
if((!v[i].visited)&&(v[i].dj<mini))
{
mini = v[i].dj;
nextSearch=i;
}
}
now = nextSearch;
}while (now != -1);
cout << v[n-1].dj << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:50:81: error: conversion from 'std::unordered_set<int>::iterator' {aka 'std::__detail::_Insert_base<int, int, std::allocator<int>, std::__detail::_Identity, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, true, true> >::iterator'} to non-scalar type 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} requested
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ~~~~~~~~~~~~~~~~~~~~~~^~
a.cc:50:86: error: no match for 'operator!=' (operand types are 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} and 'std::unordered_set<int>::iterator' {aka 'std::__detail::_Insert_base<int, int, std::allocator<int>, std::__detail::_Identity, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, true, true> >::iterator'})
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ~~^~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | std::unordered_set<int>::iterator {aka std::__detail::_Insert_base<int, int, std::allocator<int>, std::__detail::_Identity, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, true, true> >::iterator}
| std::set<int>::iterator {aka std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator}
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)'
197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::fpos<_StateT>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
In file included from /usr/include/c++/14/string:43,
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/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)'
243 | operator!=(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:243:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::allocator<_CharT>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
455 | operator!=(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
500 | operator!=(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1686 | operator!=(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1753 | operator!=(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
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:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::pair<_T1, _T2>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
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:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
651 | operator!=(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:651:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
50 | for(set<int>::iterator it=v[p.first].graph.begin();it!=v[p.first].graph.end();it++)
| ^
/usr/include/c++/14/string_view:658: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> >)'
658 | operator!=(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:658:5: note: template argument deduction/substitution failed:
a.cc:50:109: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
50 | for(set<int>::iterator it=v[p. |
s218455372 | p00519 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
static const int INF = 1LL<<61;
static const int MAX_N = 5005;
struct S {
int to, c, r;
S(int p1, int p2, int p3) {
to = p1;
c = p2;
r = p3;
}
};
int C[MAX_N], R[MAX_N], d[MAX_N], n, k, visit[MAX_N];
vector<pii> G[MAX_N];
vector<int> tg[MAX_N];
void dijkstra() {
fill(d, d + MAX_N, INF);
d[1] = 0;
priority_queue<pii, vector<pii>, greater<pii>> q;
q.push(pii(0, 1));
while (q.size()) {
pii p = q.top();
q.pop();
int v = p.second;
if (d[v] < p.first) continue;
for (int i = 0; i < G[v].size(); ++i) {
pii e = G[v][i];
if (d[e.first] < e.second + p.first) continue;
d[e.first] = e.second + p.first;
q.push(pii(d[e.first], e.first));
}
}
cout << d[n] << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; ++i) {
cin >> C[i] >> R[i];
}
for (int i = 0; i < k; ++i) {
int a, b;
cin >> a >> b;
tg[a].PB(b);
tg[b].PB(a);
}
for (int i = 1; i <= n; ++i) {
memset(visit, 0, sizeof(visit));
visit[i] = true;
queue<S> q;
for (int j = 0; j < tg[i].size(); ++j) {
q.push(S(tg[i][j], C[i], R[i]));
}
while (q.size()) {
S s = q.front();
q.pop();
int v = s.to;
if (visit[v] || s.r == 0) continue;
G[i].PB(pii(v, s.c));
visit[v] = true;
for (int j = 0; j < tg[v].size(); ++j) {
q.push(S(tg[v][j], s.c, s.r - 1));
}
}
}
dijkstra();
return 0;
} | a.cc: In function 'int main()':
a.cc:69:14: error: reference to 'visit' is ambiguous
69 | memset(visit, 0, sizeof(visit));
| ^~~~~
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:23:41: note: 'long long int visit [5005]'
23 | int C[MAX_N], R[MAX_N], d[MAX_N], n, k, visit[MAX_N];
| ^~~~~
a.cc:69:31: error: reference to 'visit' is ambiguous
69 | 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:23:41: note: 'long long int visit [5005]'
23 | int C[MAX_N], R[MAX_N], d[MAX_N], n, k, visit[MAX_N];
| ^~~~~
a.cc:70:7: error: reference to 'visit' is ambiguous
70 | visit[i] = true;
| ^~~~~
/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:23:41: note: 'long long int visit [5005]'
23 | int C[MAX_N], R[MAX_N], d[MAX_N], n, k, visit[MAX_N];
| ^~~~~
a.cc:80:13: error: reference to 'visit' is ambiguous
80 | if (visit[v] || s.r == 0) continue;
| ^~~~~
/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:23:41: note: 'long long int visit [5005]'
23 | int C[MAX_N], R[MAX_N], d[MAX_N], n, k, visit[MAX_N];
| ^~~~~
a.cc:82:9: error: reference to 'visit' is ambiguous
82 | visit[v] = true;
| ^~~~~
/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:23:41: note: 'long long int visit [5005]'
23 | int C[MAX_N], R[MAX_N], d[MAX_N], n, k, visit[MAX_N];
| ^~~~~
|
s262018001 | p00519 | C++ | #include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int V, E, s, t, w[5003], r[5003], d[5003]; vector<int> G[5003], H[5003];
int main() {
scanf("%d%d", &V, &E);
for(int i = 0; i < V; i++) scanf("%d%d", &s, &t);
for(int i = 0; i < E; i++) {
scanf("%d%d", &s, &t); s--, t--;
G[s].push_back(t);
G[t].push_back(s);
}
for(int i = 0; i < V; i++) {
fill(d, d + V, -1); d[i] = 0; H[i].push_back(i);
queue<int> que; que.push(i);
while(!que.empty()) {
int u = que.front(); que.pop();
for(auto &e : G[u]) {
if(d[e] == -1) {
d[e] = d[u] + 1;
H[i].push_back(e);
if(d[e] != r[i]) que.push(e);
}
}
}
}
fill(d, d + V, 1999999999);
priority_queue<pair<int, int> > que2; que2.push(make_pair(0, 0));
while(!que.empty()){
int u = que.top().second; que.pop();
if(u == V - 1) { printf("%d\n", d[u]); break; }
for(auto &e : H[u]) {
if(d[e] > d[u] + w[u]) {
d[e] = d[u] + w[u];
que.push(make_pair(-d[e], e));
}
}
}
} | a.cc: In function 'int main()':
a.cc:31:16: error: 'que' was not declared in this scope; did you mean 'que2'?
31 | while(!que.empty()){
| ^~~
| que2
|
s618311206 | p00519 | C++ |
#include <stdio.h>
#include <vector>
#include <queue>
#include <functional>
#include <utility>
#define MAX_N 5000
using namespace std;
struct edge { int to, cost; };
vector<edge> graph[MAX_N];
vector<int> simpg[MAX_N];
bool bfsflag[MAX_N];
int dist[MAX_N];
int n, k;
int c[MAX_N], r[MAX_N];
using P = pair<int, int>;
void dijkstra(int start)
{
for (int a = 0; a < n; ++a)dist[a] = INT_MAX - 100000;
dist[start] = 0;
priority_queue<P, vector<P>, greater<P>>que;
que.push(P(0,start));
while (!que.empty())
{
P p = que.top(); que.pop();
if (dist[p.second] < p.first)continue;
for (edge e : graph[p.second])
{
if (dist[e.to] > dist[p.second] + e.cost)
{
dist[e.to] = dist[p.second] + e.cost;
que.push(P(dist[e.to],e.to));
}
}
}
}
int main()
{
scanf("%d %d", &n, &k);
for (int i = 0; i < n; ++i)
{
scanf("%d %d", &c[i], &r[i]);
}
for (int j = 0; j < k; ++j)
{
int a, b;
scanf("%d %d", &a, &b);
simpg[a - 1].push_back(b - 1);
simpg[b - 1].push_back(a - 1);
}
for (int i = 0; i < n; ++i)
{
memset(bfsflag,false,sizeof(bfsflag));
bfsflag[i] = true;
queue<int> bfs;
bfs.push(i);
for (int j = 0; j < r[i]; ++j)//?
{
if (bfs.empty())break;
int v = bfs.front(); bfs.pop();
for (int cv : simpg[v])
{
if (!bfsflag[cv])
{
bfsflag[cv] = true;
bfs.push(cv);
graph[i].push_back({ cv, c[i]});
}
}
}
}
dijkstra(0);
printf("%d\n", dist[n - 1]);
} | a.cc: In function 'void dijkstra(int)':
a.cc:25:46: error: 'INT_MAX' was not declared in this scope
25 | for (int a = 0; a < n; ++a)dist[a] = INT_MAX - 100000;
| ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
6 | #include <utility>
+++ |+#include <climits>
7 |
a.cc: In function 'int main()':
a.cc:61:17: error: 'memset' was not declared in this scope
61 | memset(bfsflag,false,sizeof(bfsflag));
| ^~~~~~
a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
6 | #include <utility>
+++ |+#include <cstring>
7 |
|
s093005435 | p00519 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;
int n, k; //????????° ???????????¬??°
int c[5010], r[5010]; //???????????£?¶???????????????????????????¬??°
vector<int> d[5010];//???????????£??\
int G[5010][5010];//r?????¶???????????????????????????????????£??\???????????§?¨????
int dist[5010]; //0->i??????????°??????????
bool used[5010]; //?????£??????????¨????
void dijkstra(int start){
rep(i, n) dist[i] = INF;//?????????
dist[start] = 0;
while(1){
int v = -1;
//???????????????????????????????????????????????¢???????°???????????????¢???
for (int u = 0; u < n; ++u){
if(!used[u] && (v == -1 || dist[u] < dist[v])) v = u;
}
//?????????????????¢???????°???????????????????v???
if(v == -1) break;
used[v] = true;//?????¨??????
for (int u = 0; u < n; ++u){
dist[u] = min(dist[u], dist[v] + G[v][u]);//??????????????£??\????????????G?????¨??§?????????
}
}
}
int main(void){
cin >> n >> k;
rep(i, n) cin >> c[i] >> r[i];
rep(i, k){
int a, b; cin >> a >> b;
a--; b--;
d[a].push_back(b);
d[b].push_back(a);
}
rep(i, 5010)rep(j, 5010) G[i][j] = INF;
//???????????¢?´¢?????¨?????????i???->j?????????????????¨?????§?????????????¨?????????????
for (int i = 0; i < n; ++i){
queue<pair<int, int> > q; q.push(make_pair(i, 0));//<???, ?????¬???>
int cnt = 0;
while(!q.empty()){
auto now = q.front(); q.pop();
if(now.second >= r[i]) continue;
for(auto j : d[now.first]){
q.push(make_pair(j, now.second + 1));
G[i][j] = c[i];//??£??\??????????????£????????????????¨????
}
}
}
dijkstra(0);
printf("%d\n", dist[n - 1]);
} | a.cc: In function 'void dijkstra(int)':
a.cc:31:58: error: 'G' was not declared in this scope
31 | dist[u] = min(dist[u], dist[v] + G[v][u]);//??????????????£??\????????????G?????¨??§?????????
| ^
a.cc: In function 'int main()':
a.cc:46:34: error: 'G' was not declared in this scope
46 | rep(i, 5010)rep(j, 5010) G[i][j] = INF;
| ^
a.cc:56:33: error: 'G' was not declared in this scope
56 | G[i][j] = c[i];//??£??\??????????????£????????????????¨????
| ^
|
s046865920 | p00519 | C++ | #include<iostream>
#include<queue>
#include<vector>
#include<map>
using namespace std;
bool used[5005];
int town[5005][2];//??????????????¢
vector<int> v1[5005];
vector<pair<int,int> > v2[5005];
queue<int> bfs;
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q1;
int main(){
int n,m;
int i,j,k,l;
int a,b,c;
cin>>n>>m;
for(i=0;i<n;i++){
cin>>town[i][0]>>town[i][1];
}
for(i=0;i<m;i++){
cin>>a>>b;
a--,b--;
v1[a].push_back(b);
v1[b].push_back(a);
}
for(i=0;i<n;i++){
for(j=0;j<v1[i].size();j++){
bfs.push(v1[i][j]);
}
used[i]=true;
for(j=0;j<town[i][1];j++){
c=bfs.size();
for(k=0;k<c;k++){//
a=bfs.front(),bfs.pop();
if(used[a])continue;
used[a]=true;
v2[i].push_back(make_pair(a,town[i][0]));
for(l=0;l<v1[a].size();l++){
if(used[v1[a][l]])continue;
bfs.push(v1[a][l]);
}
}
}
memset(used,false,sizeof(used));
while(!bfs.empty()){bfs.pop();}
}
q1.push(make_pair(0,0));
while(!q1.empty()){
a=q1.top().first,b=q1.top().second,q1.pop();
if(b==n-1)break;
if(used[b])continue;
used[b]=true;
for(i=0;i<v2[b].size();i++){
if(used[v2[b][i].first])continue;
q1.push(make_pair(v2[b][i].second+a,v2[b][i].first));
}
}
cout<<a<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:45:17: error: 'memset' was not declared in this scope
45 | memset(used,false,sizeof(used));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include<map>
+++ |+#include <cstring>
5 | using namespace std;
|
s716263300 | p00519 | C++ | #include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef int ll;
typedef pair<ll,ll> P;
typedef double db;
const ll INF = 0xfffffff;
ll n,k;
ll c[5000],r[5000];
ll d[5000];
ll a[10000],b[10000];
ll tmax[5000];
vector<ll> G[5000];
priority_queue<P,vector<P>,greater<P> > q;queue<P> q2;
int main()
{
scanf("%d%d",&n,&k);
for(ll i=0;i<n;i++) scanf("%d%d",&c[i],&r[i]);
for(ll i=0;i<k;i++){
scanf("%d%d",&a[i],&b[i]);
a[i]--;
b[i]--;
G[a[i]].push_back(b[i]);
G[b[i]].push_back(a[i]);
}
fill(d,d+n,INF);
d[0]=0;
tmax[0]=0;
q.push(P(d[0]+c[0],0));
while(!q.empty()){
P p=q.top();
q.pop();
if(d[p.second]+c[p.second]<p.first) continue;
q2.push(P(p.second,r[p.second]));
while(!q2.empty()){
P t=q2.front();
q2.pop();
if(d[t.first]>p.first){
d[t.first]=p.first;
tmax[t.first]=t.second;
q.push(P(d[t.first]+c[t.first],t.first));
}
if(t.second) for(ll i=0;i<G[x].size();++i) if(d[G[t.first][i]]>p.first||tmax[G[t.first][i]]<t.second-1) q2.push(P(G[t.first][i],t.second-1));
}
}
printf("%d\n",d[n-1]);
} | a.cc: In function 'int main()':
a.cc:51:53: error: 'x' was not declared in this scope
51 | if(t.second) for(ll i=0;i<G[x].size();++i) if(d[G[t.first][i]]>p.first||tmax[G[t.first][i]]<t.second-1) q2.push(P(G[t.first][i],t.second-1));
| ^
|
s656312753 | p00519 | C++ | #include <cstdio>
#include <stack>
#include <map>
#include <queue>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bitset>
#include <math.h>
#include <stdio.h>
#include <queue>
#define F first
#define S second
#define MP make_pair
#define INF 1e9
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;
typedef pair<P, P> PP;
inline int in() {
int temp = 0;
scanf("%d", &temp);
return temp;
}
int n = in(), k = in();
P taxi[5001];
vector<int> road[5001];
int town[5001];
priority_queue<P> pq;
bool flag[5001];
void bfs(int s, int mey)
{
memset(flag, 0, sizeof(flag));
queue<P> que;
mey -= taxi[s].S;
que.push(MP(s, 0));
flag[s] = true;
while (!que.empty()) {
P p = que.front();
que.pop();
if (p.S == taxi[s].F)
{
continue;
}
for (int i = 0; i < road[p.F].size(); i++)
{
if (!flag[road[p.F][i]])
{
if (town[road[p.F][i]] < mey)
{
town[road[p.F][i]] = mey;
pq.push(MP(mey, road[p.F][i]));
}
que.push(MP(road[p.F][i], p.S + 1));
flag[road[p.F][i]] = true;
}
}
}
}
void dijkstra()
{
pq.push(MP(0, 1));
while (!pq.empty())
{
P p = pq.top();
pq.pop();
bfs(p.S, p.F);
}
}
int main()
{
for (int i = 1; i <= n; i++)
{
taxi[i] = make_pair(in(), in());
}
for (int i = 0; i < k; i++)
{
int a = in(), b = in();
road[a].push_back(b);
road[b].push_back(a);
}
fill(town, town + 5001, -INF);
dijkstra();
cout << -town[n] << endl;
} | a.cc: In function 'void bfs(int, int)':
a.cc:37:9: error: 'memset' was not declared in this scope
37 | memset(flag, 0, sizeof(flag));
| ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
10 | #include <math.h>
+++ |+#include <cstring>
11 | #include <stdio.h>
|
s108969884 | p00519 | C++ | #include <queue>
#include <vector>
#include <iostream>
#include <functional>
using namespace std;
struct state {
int cost, pos, rem;
state() : cost(0), pos(0), rem(0) {};
state(int c, int p, int r) : cost(c), pos(p), rem(r) {};
};
bool operator<(const state& s1, const state& s2) {
return s1.cost < s2.cost;
}
bool operator>(const state& s1, const state& s2) {
return s1.cost > s2.cost;
}
int n, m, a, b;
int main() {
cin >> n >> m;
vector<int> c(n), t(n);
vector<vector<int> > G(n);
for (int i = 0; i < n; i++) cin >> c[i] >> t[i];
for (int i = 0; i < m; i++) {
cin >> a >> b; a--, b--;
G[a].push_back(b);
G[b].push_back(a);
}
priority_queue<state, vector<state>, greater<state> > que; que.push(state(c[0], 0, t[0]));
vector<vector<int> > dist(n, vector<int>(n + 1, 1999999999)); dist[0][t[0]] = c[0];
while (!que.empty()) {
state s = que.top(); que.pop();
for (int i : G[s.pos]) {
if (s.rem > 0) {
if (dist[i][s.rem - 1] > s.cost) {
dist[i][s.rem - 1] = s.cost;
que.push(state(s.cost, i, s.rem - 1));
}
}
if (dist[i][t[i]] > s.cost + c[i]) {
dist[i][t[i]] = s.cost + c[i];
que.push(state(s.cost + c[i], i, t[i]));
}
}
}
cout << *min_element(dist[n - 1].begin(), dist[n - 1].end());
return 0;
} | a.cc: In function 'int main()':
a.cc:45:18: error: 'min_element' was not declared in this scope
45 | cout << *min_element(dist[n - 1].begin(), dist[n - 1].end());
| ^~~~~~~~~~~
|
s580499364 | p00519 | C++ | #include <cstdio>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;
const int INF = 1 << 30;
int n, k;
int c[5001], r[5001], road[2], cost[5001];
vector<int> city[5001];
queue<int> que;
priority_queue<P, vector<P>, greater<P> > p_que;
void dfs(int v, int count){
if(count == 0)
return;
for(int i = 0; i < city[v].size(); i++){
if(flag[city[v][i]])
return;
que.push(city[v][i]);
dfs(city[v][i], count - 1);
}
}
void dijkstra(){
fill(cost, cost + n + 1, INF);
cost[1] = 0;
p_que.push(P(cost[1], 1));
while(!p_que.empty()){
P p = p_que.top();
p_que.pop();
int now = p.second;
if(cost[now] < p.first)
continue;
dfs(now, r[now]);
while(!que.empty()){
int next = que.front();
que.pop();
if(cost[next] > cost[now] + c[now]){
cost[next] = cost[now] + c[now];
p_que.push(P(cost[next], next));
}
}
flag[now] = 1;
}
}
int main(){
scanf("%d%d", &n, &k);
for(int i = 1; i <= n; i++)
scanf("%d%d", &c[i], &r[i]);
for(int i = 1; i <= k; i++){
scanf("%d%d", &road[0], &road[1]);
city[road[0]].push_back(road[1]);
city[road[1]].push_back(road[0]);
}
dijkstra();
printf("%d\n", cost[n]);
return 0;
} | a.cc: In function 'void dfs(int, int)':
a.cc:20:20: error: 'flag' was not declared in this scope
20 | if(flag[city[v][i]])
| ^~~~
a.cc: In function 'void dijkstra()':
a.cc:49:17: error: 'flag' was not declared in this scope
49 | flag[now] = 1;
| ^~~~
|
s417632728 | p00519 | C++ | #include <cstdio>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;
const int INF = 1 << 30;
int n, k;
int c[5001], r[5001], road[2], cost[5001];
bool flag[5001];
vector<int> city[5001];
queue<int> que;
priority_queue<P, vector<P>, greater<P> > p_que;
void dfs(int v, int count){
if(count == 0 || flag[v][i])
return;
for(int i = 0; i < city[v].size(); i++){
flag[city[v][i] = 1;
que.push(city[v][i]);
dfs(city[v][i], count - 1);
flag[city[v][i]] = 0;
}
}
void dijkstra(){
fill(cost, cost + n + 1, INF);
cost[1] = 0;
p_que.push(P(cost[1], 1));
while(!p_que.empty()){
P p = p_que.top();
p_que.pop();
int now = p.second;
if(cost[now] < p.first)
continue;
dfs(now, r[now]);
while(!que.empty()){
int next = que.front();
que.pop();
if(cost[next] > cost[now] + c[now]){
cost[next] = cost[now] + c[now];
p_que.push(P(cost[next], next));
}
}
}
}
int main(){
scanf("%d%d", &n, &k);
for(int i = 1; i <= n; i++)
scanf("%d%d", &c[i], &r[i]);
for(int i = 1; i <= k; i++){
scanf("%d%d", &road[0], &road[1]);
city[road[0]].push_back(road[1]);
city[road[1]].push_back(road[0]);
}
dijkstra();
printf("%d\n", cost[n]);
return 0;
} | a.cc: In function 'void dfs(int, int)':
a.cc:17:34: error: 'i' was not declared in this scope
17 | if(count == 0 || flag[v][i])
| ^
a.cc:21:36: error: expected ']' before ';' token
21 | flag[city[v][i] = 1;
| ^
| ]
|
s790290036 | p00519 | C++ | #include <cstdio>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;
const int INF = 1 << 30;
int n, k;
int c[5001], r[5001], road[2], cost[5001];
bool flag[5001];
vector<int> city[5001];
queue<int> que;
priority_queue<P, vector<P>, greater<P> > p_que;
void dfs(int v, int count){
if(count == 0)
return;
flag[city[v][i]] = 1;
for(int i = 0; i < city[v].size(); i++){
if(!flag[city[v][i]])
que.push(city[v][i]);
dfs(city[v][i], count - 1);
}
}
void dijkstra(){
fill(cost, cost + n + 1, INF);
cost[1] = 0;
p_que.push(P(cost[1], 1));
while(!p_que.empty()){
P p = p_que.top();
p_que.pop();
int now = p.second;
if(cost[now] < p.first)
continue;
dfs(now, r[now]);
while(!que.empty()){
int next = que.front();
que.pop();
if(cost[next] > cost[now] + c[now]){
cost[next] = cost[now] + c[now];
p_que.push(P(cost[next], next));
}
}
flag[now] = 1;
}
}
int main(){
scanf("%d%d", &n, &k);
for(int i = 1; i <= n; i++)
scanf("%d%d", &c[i], &r[i]);
for(int i = 1; i <= k; i++){
scanf("%d%d", &road[0], &road[1]);
city[road[0]].push_back(road[1]);
city[road[1]].push_back(road[0]);
}
dijkstra();
printf("%d\n", cost[n]);
return 0;
} | a.cc: In function 'void dfs(int, int)':
a.cc:19:22: error: 'i' was not declared in this scope
19 | flag[city[v][i]] = 1;
| ^
|
s702833679 | p00519 | C++ | #include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#define int long long
#define P pair<int,int>
using namespace std;
int cost[5000], idou[5000], mincost[5000];
vector<int>rinsetu[5000];
bool operator <(P a, P b) {
return a.first < b.first;
}
signed main()
{
int a, b;
cin >> a >> b;
fill(mincost + 1, mincost + a, LLONG_MAX / 3);
for (int c = 0; c<a; c++) { scanf("%lld%lld", &cost[c], &idou[c]); }
for (int d = 0; d<b; d++) {
int e, f;
scanf("%lld%lld", &e, &f);
e--; f--;
rinsetu[e].push_back(f);
rinsetu[f].push_back(e);
}
priority_queue <P>Q;
Q.push(P(0, 0));
while (Q.size()) {
P g = Q.top(); Q.pop();
if (mincost[g.first]<g.second)continue;
int h[5000];
memset(h, -1, sizeof(h));
h[g.first] = 0;
queue<P>que;
que.push(P(g.first, 0));
while (que.size()) {
P o = que.front(); que.pop();
if (o.second>idou[o.first])break;
for (int r = 0; r<rinsetu[o.first].size(); r++) {
if (h[rinsetu[o.first][r]] == -1) { que.push(P(rinsetu[o.first][r], o.second + 1)); h[rinsetu[o.first][r]] = o.second + 1; }
}
}
for (int i = 0; i<a; i++) {
if (h[i] <= idou[g.first] && mincost[i]>g.second + cost[g.first]) { mincost[i] = g.second + cost[g.first]; Q.push(P(i, mincost[i])); }
}
cout << mincost[a - 1] << endl;
}
} | a.cc: In function 'int main()':
a.cc:19:40: error: 'LLONG_MAX' was not declared in this scope
19 | fill(mincost + 1, mincost + a, LLONG_MAX / 3);
| ^~~~~~~~~
a.cc:6:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
5 | #include<algorithm>
+++ |+#include <climits>
6 | #define int long long
a.cc:34:17: error: 'memset' was not declared in this scope
34 | memset(h, -1, sizeof(h));
| ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
5 | #include<algorithm>
+++ |+#include <cstring>
6 | #define int long long
|
s338674420 | p00519 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<functional>
#include<queue>
using namespace std;
#define INF 1000000007
typedef pair<int, int> P;
struct edge{int to,cost;};
int d[5005];
P cst[5005];
bool used[5005];
vector<edge>graf[5005];
vector<edge>G[5005];
int main() {
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
cst[i] = P(a, b);
}
for (int i = 0; i < k; i++) {
int a, b;
cin >> a >> b;
graf[a-1].push_back({b-1,1});
}
for (int ia = 0; ia < n; ia++) {//bfs
queue<P>q;
fill(d,d+n,INF);
d[ia]=0;
Q.push(P(0,ia));
while(q.size()){
P p=q.front();
q.pop();
int v=p.second;
if(d[v]<p.first)continue;
for(int i=0;i<graf[v].size();i++){
edge e=graf[v][i];
if(d[e.to]>d[v]+e.cost;
q.push(P(d[e.to],e.to));
}
}
for(int i=0;i<n;i++){
if(i==ia){
G[ia].push_back({i,0});
continue;
}
if(d[i]<cst[ia].second)continue;
G[ia].push_back({i,cst[ia].first})
}
}
//dijkstra ElogV=36989
priority_queue<P,vector<P>,greater<P> >Q;
fill(d,d+n,INF);
d[0]=0;
Q.push(P(0,0));
while(Q.size()){
P p=Q.top();
Q.pop();
int v=p.second;
if(d[v]<p.first)continue;
for(int i=0;i<G[v].size();i++){
edge e=G[v][i];
if(d[e.to]>d[v]+e.cost){
d[e.to]=d[v]+e.cost;
Q.push(P(d[e.to],e.to));
}
}
}
cout << d[n - 1] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:37:8: error: 'Q' was not declared in this scope
37 | Q.push(P(0,ia));
| ^
a.cc:47:51: error: expected ')' before ';' token
47 | q.push(P(d[e.to],e.to));
| ^
| )
a.cc:46:30: note: to match this '('
46 | if(d[e.to]>d[v]+e.cost;
| ^
a.cc:47:34: error: could not convert 'q.std::queue<std::pair<int, int> >::push(std::pair<int, int>(d[e.edge::to], e.edge::to))' from 'void' to 'bool'
47 | q.push(P(d[e.to],e.to));
| ~~~~~~^~~~~~~~~~~~~~~~~
| |
| void
a.cc:56:59: error: expected ';' before '}' token
56 | G[ia].push_back({i,cst[ia].first})
| ^
| ;
57 | }
| ~
|
s062341291 | p00519 | C++ | #include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"
using namespace std;
const long long int MOD = 1000000007;
int N, K;
list<int>edge[5000];
list<int>can[5000];
queue<int>box;
priority_queue<long long int, vector<long long int>, greater<long long int>>Q;
int main() {
ios::sync_with_stdio(false);
cin >> N >> K;
vector<int>cost(N);
vector<int>far(N);
vector<int>dis(N, INT_MAX);
dis[0] = 0;
for (int i = 0; i < N; i++)cin >> cost[i] >> far[i];
for (int i = 0; i < K; i++) {
int a, b;
cin >> a >> b;
a--;
b--;
edge[a].push_back(b);
edge[b].push_back(a);
}
vector<int>move(N, INT_MAX);
Q.push(0);
while (!Q.empty()) {
int current = Q.top() % MOD;
int dist = Q.top() / MOD;
box.push(current);
for (int i = 0; i < N; i++)move[i] = INT_MAX;
move[current] = 0;
while (!box.empty()) {
for (auto j : edge[box.front()]) {
if (move[j] > move[box.front()] + 1) {
move[j] = move[box.front()] + 1;
box.push(j);
}
}
box.pop();
}
for (int j = 0; j < N; j++) {
if (move[j] && move[j] <= far[i])can[i].push_back(j);
}
for (auto i : can[current]) {
if (dis[i] > dist + cost[current]) {
dis[i] = dist + cost[current];
Q.push(dis[i] * MOD + i);
}
}
can[current].clear();
Q.pop();
}
cout << dis[N - 1] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:60:55: error: 'i' was not declared in this scope
60 | if (move[j] && move[j] <= far[i])can[i].push_back(j);
| ^
|
s321038357 | p00519 | C++ | #include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<map>
#include<functional>
using namespace std;
typedef long long int llint;
typedef bool izryt;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int big=1e9;
vector<vector<int>>time;
vector<pair<int,int>>taxi;//???????????????????????¨?????¢
vector<vector<int>>road;//????????????
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> que;
const int maxR=5000;//?????§???R ?????´?????§???15
int n,k;
void dfs(int ter,int cos,int met){//ter??? cos?????? met
int i,ok=1;
if(met<0){return;}
//cout<<"a2";
if(time[ter][met]<=cos){return;}//?????????
for(i=met;i>=0;i--){if(time[ter][i]<=cos){ok=0;break;}time[ter][i]=cos;}//??°??????
if(ok==1){que.push(mp(cos+taxi[ter].fir,ter));}
for(i=0;i<road[ter].size();i++){dfs(road[ter][i],cos,met-1);}
return;
}
int main(void){
cin>>n>>k;
int i,j,a,b;
//?????????????????????
time.res(n);
taxi.res(n);
road.res(n);
for(i=0;i<n;i++){time[i].res(maxR+1);for(j=0;j<=maxR;j++){time[i][j]=big;}}
for(i=0;i<n;i++){cin>>a>>b;taxi[i]=mp(a,b);}
for(i=0;i<k;i++){cin>>a>>b;a--;b--;road[a].pub(b);road[b].pub(a);}
que.push(mp(taxi[0].fir,0));//?????????0??????????????§
while(!que.empty()){
int town=que.top().sec;
int now=que.top().fir;
que.pop();
dfs(town,now,taxi[town].sec);
}
cout<<time[n-1][0]<<endl;
return 0;
} | a.cc:27:20: error: 'std::vector<std::vector<int> > time' redeclared as different kind of entity
27 | vector<vector<int>>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:6:
/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 'void dfs(int, int, int)':
a.cc:37:20: warning: pointer to a function used in arithmetic [-Wpointer-arith]
37 | if(time[ter][met]<=cos){return;}//?????????
| ^
a.cc:37:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
37 | if(time[ter][met]<=cos){return;}//?????????
| ^
a.cc:37:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
37 | if(time[ter][met]<=cos){return;}//?????????
| ~~~~~~~~~~~~~~^~~~~
a.cc:38:40: warning: pointer to a function used in arithmetic [-Wpointer-arith]
38 | for(i=met;i>=0;i--){if(time[ter][i]<=cos){ok=0;break;}time[ter][i]=cos;}//??°??????
| ^
a.cc:38:43: warning: pointer to a function used in arithmetic [-Wpointer-arith]
38 | for(i=met;i>=0;i--){if(time[ter][i]<=cos){ok=0;break;}time[ter][i]=cos;}//??°??????
| ^
a.cc:38:44: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
38 | for(i=met;i>=0;i--){if(time[ter][i]<=cos){ok=0;break;}time[ter][i]=cos;}//??°??????
| ~~~~~~~~~~~~^~~~~
a.cc:38:71: warning: pointer to a function used in arithmetic [-Wpointer-arith]
38 | for(i=met;i>=0;i--){if(time[ter][i]<=cos){ok=0;break;}time[ter][i]=cos;}//??°??????
| ^
a.cc:38:74: warning: pointer to a function used in arithmetic [-Wpointer-arith]
38 | for(i=met;i>=0;i--){if(time[ter][i]<=cos){ok=0;break;}time[ter][i]=cos;}//??°??????
| ^
a.cc:38:75: error: assignment of read-only location '*(time + (((sizetype)ter) + ((sizetype)i)))'
38 | for(i=met;i>=0;i--){if(time[ter][i]<=cos){ok=0;break;}time[ter][i]=cos;}//??°??????
| ~~~~~~~~~~~~^~~~
a.cc: In function 'int main()':
a.cc:23:13: error: request for member 'resize' in 'time', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
23 | #define res resize
| ^~~~~~
a.cc:47:14: note: in expansion of macro 'res'
47 | time.res(n);
| ^~~
a.cc:50:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
50 | for(i=0;i<n;i++){time[i].res(maxR+1);for(j=0;j<=maxR;j++){time[i][j]=big;}}
| ^
a.cc:23:13: error: request for member 'resize' in '*(time + ((sizetype)i))', which is of non-class type 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'}
23 | #define res resize
| ^~~~~~
a.cc:50:34: note: in expansion of macro 'res'
50 | for(i=0;i<n;i++){time[i].res(maxR+1);for(j=0;j<=maxR;j++){time[i][j]=big;}}
| ^~~
a.cc:50:73: warning: pointer to a function used in arithmetic [-Wpointer-arith]
50 | for(i=0;i<n;i++){time[i].res(maxR+1);for(j=0;j<=maxR;j++){time[i][j]=big;}}
| ^
a.cc:50:76: warning: pointer to a function used in arithmetic [-Wpointer-arith]
50 | for(i=0;i<n;i++){time[i].res(maxR+1);for(j=0;j<=maxR;j++){time[i][j]=big;}}
| ^
a.cc:50:77: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))'
50 | for(i=0;i<n;i++){time[i].res(maxR+1);for(j=0;j<=maxR;j++){time[i][j]=big;}}
| ~~~~~~~~~~^~~~
a.cc:60:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
60 | cout<<time[n-1][0]<<endl;
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:60:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
60 | cout<<time[n-1][0]<<endl;
| ^
|
s751363475 | p00519 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define F first
#define S second
#define MP make_pair
int N, K;
int c[5000], r[5000];
bool flag[5000];
int flag2[5000];
vector<int> G[5000], G2[5000];
priority_queue<P, vector<P>, greater<P> > pq;
void bfs(int s)
{
queue<P> que;
que.push(MP(s, 0));
memset(flag, 0, sizeof(flag));
flag[s] = true;
while(!que.empty())
{
P now = que.front();
que.pop();
if(now.S == r[s]) continue;
for(int i = 0; i < G[now.F].size(); ++i)
{
if(!flag[G[now.F][i]])
{
flag[G[now.F][i]] = true;
que.push(MP(G[now.F][i], now.S + 1));
G2[s].push_back(G[now.F][i]);
}
}
}
}
void dijkstra(int s)
{
pq.push(MP(0, 0));
while(!pq.empty())
{
P now = pq.top();
pq.pop();
for(int i = 0; i < G2[now.S].size(); ++i)
{
if(flag2[G2[now.S][i]] > now.F + c[now.S])
{
flag2[G2[now.S][i]] = now.F + c[now.S];
pq.push(MP(now.F + c[now.S], G2[now.S][i]));
}
}
}
}
int main()
{
cin >> N >> K;
for(int i = 0; i < N; ++i)
scnaf("%d%d", c + i, r + i);
for(int i = 0; i < K; ++i)
{
int in1, in2;
scanf("%d%d", &in1, &in2);
--in1; --in2;
G[in1].push_back(in2);
G[in2].push_back(in1);
}
fill(flag2 + 1, flag2 + N, INT_MAX);
for(int i = 0; i < N; ++i)
bfs(i);
dijkstra(0);
cout << flag2[N - 1] << endl;
} | a.cc: In function 'int main()':
a.cc:56:17: error: 'scnaf' was not declared in this scope; did you mean 'scanf'?
56 | scnaf("%d%d", c + i, r + i);
| ^~~~~
| scanf
|
s653703145 | p00519 | C++ | #include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define INF 900000000
using namespace std;
int n, k, c[5010], r[5010], cost[5010];
vector<int> road[5010];
vector<pair<int, int>> adj[5010];
bool done[5010];
void dfs (int dep, int lim, int num)
{
done[lim]=true;
if (dep>r[lim]) return;
else
{
for (vector<int>::iterator itr=road[num].begin(); itr!=road[num].end(); itr++;)
{
int u=*itr;
if (!done[u])
{
done[u]=true;
adj[lim].push_back({u, c[lim]});
dfs(dep+1, lim, u);
}
}
}
}
int dijkstra ()
{
//memset(done, false, sizeof(done));
for (int i=0; i<5010; i++) cost[i]=INF;
cost[1]=0;
priority_queue<pair<int, int>> que;
que.push({0,1});
while (!que.empty())
{
int a=que.top().second;
que.pop();
/*if (done[a]) continue;
done[a]=true;*/
for (vector<pair<int,int>>::iterator u=adj[a].begin(); u!=adj[a].end(); u++;)
{
int b=u->first, w=u->second;
if (cost[b]>cost[a]+w)
{
cost[b]=cost[a]+w;
que.push({-cost[b], b});
}
}
}
return cost[n];
}
int main()
{
int a,b;
cin>>n>>k;
for (int i=1; i<=n; i++ ) cin>>c[i]>>r[i];
for (int i=1; i<=k; i++)
{
cin>>a>>b;
road[a].push_back(b);
road[b].push_back(a);
}
for (int i=1; i<=n; i++)
{
memset(done, false, sizeof(done));
dfs(1, i, i);
}
cout<<dijkstra()<<'\n';
return 0;
}
| a.cc:24:1: error: extended character is not valid in an identifier
24 | if (!done[u])
| ^
a.cc:24:1: error: extended character is not valid in an identifier
a.cc:24:1: error: extended character is not valid in an identifier
a.cc:24:1: error: extended character is not valid in an identifier
a.cc:24:1: error: extended character is not valid in an identifier
a.cc:24:1: error: extended character is not valid in an identifier
a.cc: In function 'void dfs(int, int, int)':
a.cc:21:86: error: expected ')' before ';' token
21 | for (vector<int>::iterator itr=road[num].begin(); itr!=road[num].end(); itr++;)
| ~ ^
| )
a.cc:21:87: error: expected primary-expression before ')' token
21 | for (vector<int>::iterator itr=road[num].begin(); itr!=road[num].end(); itr++;)
| ^
a.cc: In function 'int dijkstra()':
a.cc:47:84: error: expected ')' before ';' token
47 | for (vector<pair<int,int>>::iterator u=adj[a].begin(); u!=adj[a].end(); u++;)
| ~ ^
| )
a.cc:47:85: error: expected primary-expression before ')' token
47 | for (vector<pair<int,int>>::iterator u=adj[a].begin(); u!=adj[a].end(); u++;)
| ^
|
s431410552 | p00519 | C++ | #include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define INF 900000000
using namespace std;
int n, k, c[5010], r[5010], cost[5010];
vector<int> road[5010];
vector<pair<int, int>> adj[5010];
bool done[5010];
void dfs (int dep, int lim, int num)
{
done[lim]=true;
if (dep>r[lim]) return;
else
{
for (vector<int>::iterator itr=road[num].begin(); itr!=road[num].end(); itr++)
{
int u=*itr;
if (!done[u])
{
done[u]=true;
adj[lim].push_back({u, c[lim]});
dfs(dep+1, lim, u);
}
}
}
}
int dijkstra ()
{
//memset(done, false, sizeof(done));
for (int i=0; i<5010; i++) cost[i]=INF;
cost[1]=0;
priority_queue<pair<int, int>> que;
que.push({0,1});
while (!que.empty())
{
int a=que.top().second;
que.pop();
/*if (done[a]) continue;
done[a]=true;*/
for (vector<pair<int,int>>::iterator u=adj[a].begin(); u!=adj[a].end(); u++)
{
int b=u->first, w=u->second;
if (cost[b]>cost[a]+w)
{
cost[b]=cost[a]+w;
que.push({-cost[b], b});
}
}
}
return cost[n];
}
int main()
{
int a,b;
cin>>n>>k;
for (int i=1; i<=n; i++ ) cin>>c[i]>>r[i];
for (int i=1; i<=k; i++)
{
cin>>a>>b;
road[a].push_back(b);
road[b].push_back(a);
}
for (int i=1; i<=n; i++)
{
memset(done, false, sizeof(done));
dfs(1, i, i);
}
cout<<dijkstra()<<'\n';
return 0;
}
| a.cc:24:1: error: extended character is not valid in an identifier
24 | if (!done[u])
| ^
a.cc:24:1: error: extended character is not valid in an identifier
a.cc:24:1: error: extended character is not valid in an identifier
a.cc:24:1: error: extended character is not valid in an identifier
a.cc:24:1: error: extended character is not valid in an identifier
a.cc:24:1: error: extended character is not valid in an identifier
a.cc: In function 'void dfs(int, int, int)':
a.cc:24:1: error: '\U00003000\U00003000\U00003000\U00003000\U00003000\U00003000' was not declared in this scope
24 | if (!done[u])
| ^~~~~~~~~~~~
|
s995249590 | p00519 | C++ | #include<iostream>
#include<queue>
#include<vector>
#include<cstdio>
using namespace std;
struct P{int c,r;};
struct State{
int t;
int pos, remain;
bool operator < (const State& st) const {
return t > st.t;
}
};
const int MAX = 5001;
const int INF = (1<<25);
int T[MAX][MAX];
vector<int> Edge[MAX];
P price[MAX];
int N,K;
void input(){
scanf("%d %d",&N,&K);
for(int i = 0; i < N; i++) scanf("%d %d",&price[i].c, &price[i].r);
for(int i = 0; i < K; i++){
int a,b;
scanf("%d %d",&a, &b);
a--;b--;
Edge[a].push_back(b);
Edge[b].push_back(a);
}
}
void solve(){
//fill(T[0], T[0]+MAX*MAX, INF);
memset(T, -1, sizeof(T));
T[0][0] = 0;
priority_queue<State> Q;
Q.push((State){0,0,0});
while(!Q.empty()){
const State now = Q.top();
Q.pop();
if(now.t > T[now.pos][now.remain]) continue;
if(now.remain > 0){
for(int i = 0; i < (int)Edge[now.pos].size(); i++){
State nex = now;
nex.pos = Edge[now.pos][i];
nex.remain--;
if(T[nex.pos][nex.remain] == -1 || T[nex.pos][nex.remain] > nex.t){
T[nex.pos][nex.remain] = nex.t;
Q.push(nex);
}
}
}
State nex = now;
nex.t += price[now.pos].c;
nex.remain = price[now.pos].r;
if(T[nex.pos][nex.remain] == -1 || T[nex.pos][nex.remain] > nex.t){
T[nex.pos][nex.remain] = nex.t;
Q.push(nex);
}
}
int ans = INF;
for(int i = 0; i < MAX; i++)
if(T[N-1][i] >= 0) ans = min(ans,T[N-1][i]);
printf("%d\n",ans);
}
int main(){
input();
solve();
return 0;
} | a.cc: In function 'void solve()':
a.cc:38:3: error: 'memset' was not declared in this scope
38 | memset(T, -1, sizeof(T));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include<cstdio>
+++ |+#include <cstring>
5 |
|
s337999716 | p00520 | C++ | #include <iostream>
#include <algorithm>
int32_t N;
int32_t D[120];
int32_t A[120];
int32_t dp[100][0X80];
struct R_print {
template<typename T>
T operator=(T&& v) {
std::cout << v << ')' << '\n'; return std::forward<T>(v);
}
};
//i??\?????????????????¨???????????§???eatable_flag???i????????????i??????7???(???????????????)???
int32_t func(int l_pos, uint8_t eatable_flag)
{
if (N <= l_pos) { return 0; }
eatable_flag &= 0X7F;
if (N <= l_pos + 7) {
uint16_t mask = 0;
for (int i = l_pos + 1; i < N; ++i) {
mask <<= 1; mask |= 1;
}
eatable_flag &= mask;
}
#ifdef DEBUG
auto PARAM_PRINT = [&]() {
std::cout << '(' << l_pos << ',';
for (int i = 7 - 1; i >= 0; --i) {
std::cout << ((eatable_flag & (1 << i)) ? '1' : '0');
}
std::cout << ','; };
#define RETURN PARAM_PRINT(); return R_print{}=
#else
#define RETURN return
#endif
if (-1 != dp[l_pos][eatable_flag]) { return dp[l_pos][eatable_flag]; }
auto eat = [l_pos, eatable_flag](int pos) {
auto index = l_pos + pos + 1;
int32_t v = 0;
for (int i = -7; i <= 7; ++i) {
auto rindex = index + i;
if (rindex < 0 || N < rindex) { continue; }
if (rindex < l_pos) {
if (index <= rindex + D[rindex]) {
v += A[rindex];
}
}
if (l_pos < rindex) {//0 < pos + 1 + i
auto bit = pos + i;
if (
(bit < 7) &&
(
((eatable_flag & (1 << bit)) == 0) &&
(rindex - D[rindex] <= index && index <= rindex + D[rindex])
)
) {
v += A[rindex];
}
}
}
return v;
};
int32_t res = 0;
for (int i = 0; i < 7; ++i) {
if (eatable_flag & (1 << i)) {
//l_pos??\???????£???????
res = std::max(res, eat(i) + func(l_pos, eatable_flag & ~(1 << i)));
}
}
//l_pos????£???????
auto nf = eatable_flag;
int count = 0;
while ((nf & 1) != 1) {
++count;
nf |= 0X80; nf >>= 1;
}
++count;
nf |= 0X80; nf >>= 1;
res = std::max(res, eat(-1) + func(l_pos + count, nf));
RETURN dp[l_pos][eatable_flag] = res;
}
int main()
{
for (auto& a : dp)for (auto& i : a) { i = -1; }
std::cin >> N;
for (int i = 0; i < N; ++i) {
std::cin >> D[i];
}
for (int i = 0; i < N; ++i) {
std::cin >> A[i];
}
std::cout << func(0, 0X7FFF) << std::endl;
} | a.cc:17:25: error: 'uint8_t' has not been declared
17 | int32_t func(int l_pos, uint8_t eatable_flag)
| ^~~~~~~
a.cc: In function 'int32_t func(int, int)':
a.cc:22:17: error: 'uint16_t' was not declared in this scope
22 | uint16_t mask = 0;
| ^~~~~~~~
a.cc:3:1: note: 'uint16_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
2 | #include <algorithm>
+++ |+#include <cstdint>
3 |
a.cc:24:25: error: 'mask' was not declared in this scope
24 | mask <<= 1; mask |= 1;
| ^~~~
a.cc:26:33: error: 'mask' was not declared in this scope
26 | eatable_flag &= mask;
| ^~~~
|
s100841246 | p00520 | C++ | #include <iostream>
#include <algorithm>
int32_t N;
int32_t D[120];
int32_t A[120];
int32_t dp[100][0X80];
struct R_print {
template<typename T>
T operator=(T&& v) {
std::cout << v << ')' << '\n'; return std::forward<T>(v);
}
};
//i??\??????????????????¨????????????§???eatable_flag???i????????????i??????7???(???????????????)???
int32_t func(int l_pos, uint8_t eatable_flag)
{
if (N <= l_pos) { return 0; }
eatable_flag &= 0X7F;
if (N <= l_pos + 7) {
uint16_t mask = 0;
for (int i = l_pos + 1; i < N; ++i) {
mask <<= 1; mask |= 1;
}
eatable_flag &= mask;
}
#ifdef DEBUG
auto PARAM_PRINT = [&]() {
std::cout << '(' << l_pos << ',';
for (int i = 7 - 1; i >= 0; --i) {
std::cout << ((eatable_flag & (1 << i)) ? '1' : '0');
}
std::cout << ','; };
#define RETURN PARAM_PRINT(); return R_print{}=
#else
#define RETURN return
#endif
if (-1 != dp[l_pos][eatable_flag]) { return dp[l_pos][eatable_flag]; }
auto eat = [l_pos, eatable_flag](int pos) {
auto index = l_pos + pos + 1;
int32_t v = 0;
for (int i = -7; i <= 7; ++i) {
auto rindex = index + i;
if (rindex < 0 || N < rindex) { continue; }
if (rindex < l_pos) {
if (index <= rindex + D[rindex]) {
v += A[rindex];
}
}
if (l_pos < rindex) {//0 < pos + 1 + i
auto bit = pos + i;
if (
(bit < 7) &&
(
((eatable_flag & (1 << bit)) == 0) &&
(rindex - D[rindex] <= index && index <= rindex + D[rindex])
)
) {
v += A[rindex];
}
}
}
return v;
};
int32_t res = 0;
for (int i = 0; i < 7; ++i) {
if (eatable_flag & (1 << i)) {
//l_pos??\????????£???????
res = std::max(res, eat(i) + func(l_pos, eatable_flag & ~(1 << i)));
}
}
//l_pos?????£???????
auto nf = eatable_flag;
int count = 0;
while ((nf & 1) != 1) {
++count;
nf |= 0X80; nf >>= 1;
}
++count;
nf |= 0X80; nf >>= 1;
res = std::max(res, eat(-1) + func(l_pos + count, nf));
RETURN dp[l_pos][eatable_flag] = res;
}
int main()
{
for (auto& a : dp)for (auto& i : a) { i = -1; }
std::cin >> N;
for (int i = 0; i < N; ++i) {
std::cin >> D[i];
}
for (int i = 0; i < N; ++i) {
std::cin >> A[i];
}
std::cout << func(0, 0X7FFF) << std::endl;
} | a.cc:17:25: error: 'uint8_t' has not been declared
17 | int32_t func(int l_pos, uint8_t eatable_flag)
| ^~~~~~~
a.cc: In function 'int32_t func(int, int)':
a.cc:22:9: error: 'uint16_t' was not declared in this scope
22 | uint16_t mask = 0;
| ^~~~~~~~
a.cc:3:1: note: 'uint16_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
2 | #include <algorithm>
+++ |+#include <cstdint>
3 |
a.cc:24:13: error: 'mask' was not declared in this scope
24 | mask <<= 1; mask |= 1;
| ^~~~
a.cc:26:25: error: 'mask' was not declared in this scope
26 | eatable_flag &= mask;
| ^~~~
|
s362881656 | p00520 | C++ | #include <stdio.h>
#include <tchar.h>
#include<set>
#include<deque>
#include<queue>
#include<map>
#include<string>
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<33);
const llint ban = (big<<20);
int main(void){
//di max7
int i,j,N,M,a,ans;
vector<int> per={1,2,3,4,5,6,7};
vector<int>pera={1,2,3,4,5,6,7};
vector<int> perg={1,2,3,4,5,6,7,8};
vector<int> di={7,7,7,7,7,7,7};
vector<int> ai={10000,10000,10000,10000,10000,10000,10000};
vector<int>stz[5041];
map<vector<int>,int> zts;
static int dp[114][5140]={0};
i=0;
do {
stz[i]=per;
zts[per]=i;
i++;
} while(std::next_permutation(per.begin(),per.end()));
scanf_s("%d",&N);
for(i=0;i<N;i++){
scanf_s("%d",&a);
di.pub(a);
}
for(i=0;i<N;i++){
scanf_s("%d",&a);
ai.pub(a);
}
for(i=0;i<7;i++){per[i]=i+1;}
dp[6][zts[per]]=210000;
for(i=7;i<N+7;i++){
for(j=0;j<8;j++){
perg[j]=j+1;
}
do {
for(j=0;j<7;j++){
if(perg[j]>perg[7]){ per[j]=perg[j]-1; } else{ per[j]=perg[j]; }
}//per??????????????????
for(j=0;j<7;j++){
if(perg[j+1]>perg[0]){ pera[j]=perg[j+1]-1; } else{ pera[j]=perg[j+1]; }
}//pera??????????????°??????
ans=dp[i-1][zts[per]];
for(j=0;j<7;j++){
if(perg[j]<perg[7]&&di[i-7+j]>=7-j){
ans+=ai[i-7+j];
}
if(perg[j]>perg[7]&&di[i]>=7-j){
ans+=ai[i];
}
}
dp[i][zts[pera]]=max(dp[i][zts[pera]],ans);
} while(std::next_permutation(perg.begin(),perg.end()));
}
ans=0;
for(i=0;i<5040;i++){
ans=max(ans,dp[N+6][i]);
}
for(i=7;i>0;i--){
if(N<i){ ans+=10000*(8-i); }
}
printf("%d",ans-490000);
return 0;
} | a.cc:2:10: fatal error: tchar.h: No such file or directory
2 | #include <tchar.h>
| ^~~~~~~~~
compilation terminated.
|
s958154202 | p00520 | C++ | #include <stdio.h>
//#include <tchar.h>
#include<set>
#include<deque>
#include<queue>
#include<map>
#include<string>
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<33);
const llint ban = (big<<20);
int main(void){
//di max7
int i,j,N,M,a,ans;
vector<int> per={1,2,3,4,5,6,7};
vector<int>pera={1,2,3,4,5,6,7};
vector<int> perg={1,2,3,4,5,6,7,8};
vector<int> di={7,7,7,7,7,7,7};
vector<int> ai={10000,10000,10000,10000,10000,10000,10000};
vector<int>stz[5041];
map<vector<int>,int> zts;
static int dp[114][5140]={0};
i=0;
do {
stz[i]=per;
zts[per]=i;
i++;
} while(std::next_permutation(per.begin(),per.end()));
scanf_s("%d",&N);
for(i=0;i<N;i++){
scanf_s("%d",&a);
di.pub(a);
}
for(i=0;i<N;i++){
scanf_s("%d",&a);
ai.pub(a);
}
for(i=0;i<7;i++){per[i]=i+1;}
dp[6][zts[per]]=210000;
for(i=7;i<N+7;i++){
for(j=0;j<8;j++){
perg[j]=j+1;
}
do {
for(j=0;j<7;j++){
if(perg[j]>perg[7]){ per[j]=perg[j]-1; } else{ per[j]=perg[j]; }
}//per??????????????????
for(j=0;j<7;j++){
if(perg[j+1]>perg[0]){ pera[j]=perg[j+1]-1; } else{ pera[j]=perg[j+1]; }
}//pera??????????????°??????
ans=dp[i-1][zts[per]];
for(j=0;j<7;j++){
if(perg[j]<perg[7]&&di[i-7+j]>=7-j){
ans+=ai[i-7+j];
}
if(perg[j]>perg[7]&&di[i]>=7-j){
ans+=ai[i];
}
}
dp[i][zts[pera]]=max(dp[i][zts[pera]],ans);
} while(std::next_permutation(perg.begin(),perg.end()));
}
ans=0;
for(i=0;i<5040;i++){
ans=max(ans,dp[N+6][i]);
}
for(i=7;i>0;i--){
if(N<i){ ans+=10000*(8-i); }
}
printf("%d",ans-490000);
return 0;
} | a.cc: In function 'int main()':
a.cc:42:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
42 | scanf_s("%d",&N);
| ^~~~~~~
| scanf
|
s959487757 | p00521 | 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.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
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 m,n;
static char[][] flag;
static char[][] emblem;
static final char JOI={'J','O','I'};
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
m=ir.nextInt();
n=ir.nextInt();
flag=ir.makeCharMap(m,n);
emblem=ir.makeCharMap(2,2);
int ans=numOfEmblems();
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
for(int k=0;k<3;k++){
if(flag[i][j]!=JOI[k]){
char c=flag[i][j];
flag[i][j]=JOI[k];
ans=Math.max(ans,numOfEmblems());
flag[i][j]=c;
}
}
}
}
out.println(ans);
out.flush();
}
public staitc int numOfEmblem(){
int cnt=0;
for(int i=0;i<m-1;i++){
for(int j=0;j<n-1;j++){
if(flag[i][j]==emblem[0][0]&&flag[i][j+1]==emblem[0][1]&&flag[i+1][j]==emblem[1][0]&&flag[i+1][j+1]==emblem[1][1]) cnt++;
}
}
return cnt;
}
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;
}
}
public char[][] makeCharMap(int m,int n){
char[][] map=new char[m][n];
for(int i=0;i<m;i++) map[i]=ir.next().toCharArray();
}
} | Main.java:50: error: <identifier> expected
public staitc int numOfEmblem(){
^
1 error
|
s401743298 | p00521 | 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.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
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 m,n;
static char[][] flag;
static char[][] emblem;
static final char JOI={'J','O','I'};
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
m=ir.nextInt();
n=ir.nextInt();
flag=ir.makeCharMap(m,n);
emblem=ir.makeCharMap(2,2);
int ans=numOfEmblems();
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
for(int k=0;k<3;k++){
if(flag[i][j]!=JOI[k]){
char c=flag[i][j];
flag[i][j]=JOI[k];
ans=Math.max(ans,numOfEmblems());
flag[i][j]=c;
}
}
}
}
out.println(ans);
out.flush();
}
public static int numOfEmblem(){
int cnt=0;
for(int i=0;i<m-1;i++){
for(int j=0;j<n-1;j++){
if(flag[i][j]==emblem[0][0]&&flag[i][j+1]==emblem[0][1]&&flag[i+1][j]==emblem[1][0]&&flag[i+1][j+1]==emblem[1][1]) cnt++;
}
}
return cnt;
}
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;
}
}
public char[][] makeCharMap(int m,int n){
char[][] map=new char[m][n];
for(int i=0;i<m;i++) map[i]=ir.next().toCharArray();
}
} | Main.java:25: error: illegal initializer for char
static final char JOI={'J','O','I'};
^
Main.java:31: error: cannot find symbol
flag=ir.makeCharMap(m,n);
^
symbol: method makeCharMap(int,int)
location: variable ir of type InputReader
Main.java:32: error: cannot find symbol
emblem=ir.makeCharMap(2,2);
^
symbol: method makeCharMap(int,int)
location: variable ir of type InputReader
Main.java:33: error: cannot find symbol
int ans=numOfEmblems();
^
symbol: method numOfEmblems()
location: class Main
Main.java:37: error: array required, but char found
if(flag[i][j]!=JOI[k]){
^
Main.java:39: error: array required, but char found
flag[i][j]=JOI[k];
^
Main.java:40: error: cannot find symbol
ans=Math.max(ans,numOfEmblems());
^
symbol: method numOfEmblems()
location: class Main
Main.java:141: error: cannot find symbol
for(int i=0;i<m;i++) map[i]=ir.next().toCharArray();
^
symbol: variable ir
location: class Main
8 errors
|
s366626825 | p00521 | 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.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
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 m,n;
static char[][] flag;
static char[][] emblem;
static final char[] JOI={'J','O','I'};
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
m=ir.nextInt();
n=ir.nextInt();
flag=ir.makeCharMap(m,n);
emblem=ir.makeCharMap(2,2);
int ans=numOfEmblems();
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
for(int k=0;k<3;k++){
if(flag[i][j]!=JOI[k]){
char c=flag[i][j];
flag[i][j]=JOI[k];
ans=Math.max(ans,numOfEmblems());
flag[i][j]=c;
}
}
}
}
out.println(ans);
out.flush();
}
public static int numOfEmblem(){
int cnt=0;
for(int i=0;i<m-1;i++){
for(int j=0;j<n-1;j++){
if(flag[i][j]==emblem[0][0]&&flag[i][j+1]==emblem[0][1]&&flag[i+1][j]==emblem[1][0]&&flag[i+1][j+1]==emblem[1][1]) cnt++;
}
}
return cnt;
}
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;
}
}
public char[][] makeCharMap(int m,int n){
char[][] map=new char[m][n];
for(int i=0;i<m;i++) map[i]=next().toCharArray();
}
} | Main.java:31: error: cannot find symbol
flag=ir.makeCharMap(m,n);
^
symbol: method makeCharMap(int,int)
location: variable ir of type InputReader
Main.java:32: error: cannot find symbol
emblem=ir.makeCharMap(2,2);
^
symbol: method makeCharMap(int,int)
location: variable ir of type InputReader
Main.java:33: error: cannot find symbol
int ans=numOfEmblems();
^
symbol: method numOfEmblems()
location: class Main
Main.java:40: error: cannot find symbol
ans=Math.max(ans,numOfEmblems());
^
symbol: method numOfEmblems()
location: class Main
Main.java:141: error: cannot find symbol
for(int i=0;i<m;i++) map[i]=next().toCharArray();
^
symbol: method next()
location: class Main
5 errors
|
s217133916 | p00521 | 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.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
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 m,n;
static char[][] flag;
static char[][] emblem;
static final char[] JOI={'J','O','I'};
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
m=ir.nextInt();
n=ir.nextInt();
flag=ir.makeCharMap(m,n);
emblem=ir.makeCharMap(2,2);
char[][] count=new char[m][n];
int ans=0;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
count[i][j]=_count(i-1,j-1)+_count(i,j-1)+_count(i,j)+_count(i-1,j);
sum+=count[i][j];
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
for(int k=0;k<3;k++){
if(flag[i][j]!=JOI[k]){
char c=flag[i][j];
int cnt=sum-(4*_count(i-1,j-1)+4*_count(i-1,j)+4*_count(i,j-1)+4*_count(i,j));
flag[i][j]=JOI[k];
ans+=4*_count(i-1,j-1)+4*_count(i-1,j)+4*_count(i,j-1)+4*_count(i,j);
ans=Math.max(cnt,ans);
flag[i][j]=c;
}
}
}
}
out.println(ans/4);
out.flush();
}
public static int _count(int x,int y){
if(x<0||y<0||x>=m||y>=n) return 0;
if(flag[x][y]==emblem[0][0]&&flag[x+1][y]==emblem[1][0]&&flag[x][y+1]==emblem[0][1]&&flag[x+1][y+1]==emblem[1][1]) return 1;
}
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;
}
public char[][] makeCharMap(int m,int n){
char[][] map=new char[m][n];
for(int i=0;i<m;i++) map[i]=next().toCharArray();
return map;
}
}
} | Main.java:37: error: incompatible types: possible lossy conversion from int to char
count[i][j]=_count(i-1,j-1)+_count(i,j-1)+_count(i,j)+_count(i-1,j);
^
Main.java:38: error: cannot find symbol
sum+=count[i][j];
^
symbol: variable sum
location: class Main
Main.java:46: error: cannot find symbol
int cnt=sum-(4*_count(i-1,j-1)+4*_count(i-1,j)+4*_count(i,j-1)+4*_count(i,j));
^
symbol: variable sum
location: class Main
3 errors
|
s727789532 | p00521 | 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.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
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 m,n;
static char[][] flag;
static char[][] emblem;
static final char[] JOI={'J','O','I'};
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
m=ir.nextInt();
n=ir.nextInt();
flag=ir.makeCharMap(m,n);
emblem=ir.makeCharMap(2,2);
int ans=0;
int[][] count=new int[m][n];
for(int i=0;i<m;i++) for(int j=0;j<n;j++)count[i][j]=_count(i,j);
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
int t=count[i-1][j-1]+count[i][j-1]+count[i][j]+count[i-1][j];
sum+=t;
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
for(int k=0;k<3;k++){
if(flag[i][j]!=JOI[k]){
char c=flag[i][j];
int cnt=sum-4*(count[i-1][j-1]+count[i][j-1]+count[i][j]+count[i-1][j]);
flag[i][j]=JOI[k];
ans+=4*_count(i-1,j-1)+4*_count(i-1,j)+4*_count(i,j-1)+4*_count(i,j);
ans=Math.max(cnt,ans);
flag[i][j]=c;
}
}
}
}
out.println(ans/4);
out.flush();
}
public static int _count(int x,int y){
if(x<0||y<0||x>=m||y>=n) return 0;
if(flag[x][y]==emblem[0][0]&&flag[x+1][y]==emblem[1][0]&&flag[x][y+1]==emblem[0][1]&&flag[x+1][y+1]==emblem[1][1]) return 1;
}
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;
}
public char[][] makeCharMap(int m,int n){
char[][] map=new char[m][n];
for(int i=0;i<m;i++) map[i]=next().toCharArray();
return map;
}
}
} | Main.java:39: error: cannot find symbol
sum+=t;
^
symbol: variable sum
location: class Main
Main.java:47: error: cannot find symbol
int cnt=sum-4*(count[i-1][j-1]+count[i][j-1]+count[i][j]+count[i-1][j]);
^
symbol: variable sum
location: class Main
2 errors
|
s375467680 | p00521 | 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.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
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 m,n;
static char[][] flag;
static char[][] emblem;
static final char[] JOI={'J','O','I'};
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
m=ir.nextInt();
n=ir.nextInt();
flag=ir.makeCharMap(m,n);
emblem=ir.makeCharMap(2,2);
int ans=0,sum=0;
int[][] count=new int[m][n];
for(int i=0;i<m;i++) for(int j=0;j<n;j++)count[i][j]=_count(i,j);
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
int t=count[i-1][j-1]+count[i][j-1]+count[i][j]+count[i-1][j];
sum+=t;
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
for(int k=0;k<3;k++){
if(flag[i][j]!=JOI[k]){
char c=flag[i][j];
int cnt=sum-4*(count[i-1][j-1]+count[i][j-1]+count[i][j]+count[i-1][j]);
flag[i][j]=JOI[k];
ans+=4*_count(i-1,j-1)+4*_count(i-1,j)+4*_count(i,j-1)+4*_count(i,j);
ans=Math.max(cnt,ans);
flag[i][j]=c;
}
}
}
}
out.println(ans/4);
out.flush();
}
public static int _count(int x,int y){
if(x<0||y<0||x>=m||y>=n) return 0;
if(flag[x][y]==emblem[0][0]&&flag[x+1][y]==emblem[1][0]&&flag[x][y+1]==emblem[0][1]&&flag[x+1][y+1]==emblem[1][1]) return 1;
}
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;
}
public char[][] makeCharMap(int m,int n){
char[][] map=new char[m][n];
for(int i=0;i<m;i++) map[i]=next().toCharArray();
return map;
}
}
} | Main.java:63: error: missing return statement
}
^
1 error
|
s453888129 | p00521 | 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.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
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 m,n;
static char[][] flag;
static char[][] emblem;
static final char[] JOI={'J','O','I'};
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
m=ir.nextInt();
n=ir.nextInt();
flag=ir.makeCharMap(m,n);
emblem=ir.makeCharMap(2,2);
int ans=0,sum=0;
int[][] count=new int[m][n];
for(int i=0;i<m;i++) for(int j=0;j<n;j++)count[i][j]=_count(i,j);
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
int t=0;
if(i!=0&&j!=0) t+=count[i-1][j-1];
if(i!=0) t+=count[i-1][j];
if(j!=0) t+=count[i][j-1];
t+=count[i][j];
sum+=t;
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
for(int k=0;k<3;k++){
if(flag[i][j]!=JOI[k]){
char c=flag[i][j];
int t=sum;
if(i!=0&&j!=0) t-=4*count[i-1][j-1];
if(i!=0) t-=4*count[i-1][j];
if(j!=0) t-=4*count[i][j-1];
t-=4*count[i][j];
flag[i][j]=JOI[k];
ans+=4*_count(i-1,j-1)+4*_count(i-1,j)+4*_count(i,j-1)+4*_count(i,j);
ans=Math.max(cnt,ans);
flag[i][j]=c;
}
}
}
}
out.println(ans/4);
out.flush();
}
public static int _count(int x,int y){
if(x<0||y<0||x>=m-1||y>=n-1) return 0;
if(flag[x][y]==emblem[0][0]&&flag[x+1][y]==emblem[1][0]&&flag[x][y+1]==emblem[0][1]&&flag[x+1][y+1]==emblem[1][1]) return 1;
return 0;
}
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;
}
public char[][] makeCharMap(int m,int n){
char[][] map=new char[m][n];
for(int i=0;i<m;i++) map[i]=next().toCharArray();
return map;
}
}
} | Main.java:58: error: cannot find symbol
ans=Math.max(cnt,ans);
^
symbol: variable cnt
location: class Main
1 error
|
s725013589 | p00521 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int n, m;
char c[1080][1080];
int cnt[1080][1080];
int ans[2][2], anss, res;
int main(){
cin >> m >> n;
for(int i = 1;i <= m;i++)
for(int j = 1;j <= n;j++)
cin >> c[i][j];
for(int i = 0;i < 2;i++)
for(int j = 0;j < 2;j++)
cin >> ans[i][j];
for(int i = 1;i <= m;i++)
for(int j = 1;j <= n;j++){
cnt[i][j] = 1;
for(int k = 0;k < 2;k++)
for(int l = 0;l < 2;l++)
if(c[i + k][j + l] != ans[k][l])cnt[i][j] = 0;
res += cnt[i][j];
}
int anss = res;
for(int i = 1;i <= m;i++){
for(int j = 1;j <= n;j++){
int last = c[i][j];
int tres;
c[i][j] = 'J';
tres = res;
for(int k = i - 1;k <= i;k++)
for(int l = j - 1;l <= j;l++){
int tmp = 1;
for(int o = 0;o < 2;o++)
for(int p = 0;p > 2;p++)
if(c[k + o][l + p] != ans[o][p]tmp = 0;
tres += tmp - cnt[k][l];
}
anss = max(anss, tres);
c[i][j] = 'O';
tres = res;
for(int k = i - 1;k <= i;k++)
for(int l = j - 1;l <= j;l++){
int tmp = 1;
for(int o = 0;o < 2;o++)
for(int p = 0;p > 2;p++)
if(c[k + o][l + p] != ans[o][p]tmp = 0;
tres += tmp - cnt[k][l];
}
anss = max(anss, tres);
c[i][j] = 'I';
tres = res;
for(int k = i - 1;k <= i;k++)
for(int l = j - 1;l <= j;l++){
int tmp = 1;
for(int o = 0;o < 2;o++)
for(int p = 0;p > 2;p++)
if(c[k + o][l + p] != ans[o][p]tmp = 0;
tres += tmp - cnt[k][l];
}
anss = max(anss, tres);
c[i][j] = last;
}
}
cout << anss << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:40:88: error: expected ';' before 'tmp'
40 | if(c[k + o][l + p] != ans[o][p]tmp = 0;
| ^~~
| ;
a.cc:41:64: error: expected ')' before ';' token
41 | tres += tmp - cnt[k][l];
| ^
| )
a.cc:40:59: note: to match this '('
40 | if(c[k + o][l + p] != ans[o][p]tmp = 0;
| ^
a.cc:51:88: error: expected ';' before 'tmp'
51 | if(c[k + o][l + p] != ans[o][p]tmp = 0;
| ^~~
| ;
a.cc:52:64: error: expected ')' before ';' token
52 | tres += tmp - cnt[k][l];
| ^
| )
a.cc:51:59: note: to match this '('
51 | if(c[k + o][l + p] != ans[o][p]tmp = 0;
| ^
a.cc:63:88: error: expected ';' before 'tmp'
63 | if(c[k + o][l + p] != ans[o][p]tmp = 0;
| ^~~
| ;
a.cc:64:64: error: expected ')' before ';' token
64 | tres += tmp - cnt[k][l];
| ^
| )
a.cc:63:59: note: to match this '('
63 | if(c[k + o][l + p] != ans[o][p]tmp = 0;
| ^
|
s004075532 | p00521 | C++ | #include<stdio.h>
char new[1001][1001];
int i,j,k;
int main(void)
{
char old[5];
char joi[3]={'J','O','I'};
int m,n;
int cnt,c,max;
c=0;
cnt=0;
max=0;
scanf("%d %d",&m,&n);
for(i=0;i<m;i++){
for(j=0;j<n;j++){
scanf(" %c",&new[i][j]);
}
}
for(i=0;i<4;i++){
scanf(" %c",&old[i]);
}
for(i=0;i<m-1;i++){
for(j=0;j<n-1;j++){
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
cnt++;
}
else if(new[i][j]=='J'){
new[i][j]=joi[1];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
c=0;
new[i][j]=joi[2];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
}
else if(new[i][j]=='O'){
new[i][j]=joi[0];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
c=0;
new[i][j]=joi[2];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
}
else if(new[i][j]=='I'){
new[i][j]=joi[0];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
c=0;
new[i][j]=joi[1];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
}
}
}
printf("%d\n",cnt+max);
return 0;
} | a.cc:2:6: error: expected unqualified-id before 'new'
2 | char new[1001][1001];
| ^~~
a.cc: In function 'int main()':
a.cc:17:41: error: expected type-specifier before '[' token
17 | scanf(" %c",&new[i][j]);
| ^
a.cc:25:31: error: expected type-specifier before '[' token
25 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:25:31: error: expected ')' before '[' token
25 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:28:36: error: expected type-specifier before '[' token
28 | else if(new[i][j]=='J'){
| ^
a.cc:28:36: error: expected ')' before '[' token
28 | else if(new[i][j]=='J'){
| ~ ^
| )
a.cc:29:36: error: expected type-specifier before '[' token
29 | new[i][j]=joi[1];
| ^
a.cc:30:39: error: expected type-specifier before '[' token
30 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:30:39: error: expected ')' before '[' token
30 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:33:39: error: expected type-specifier before '[' token
33 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:33:39: error: expected ')' before '[' token
33 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:36:39: error: expected type-specifier before '[' token
36 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:36:39: error: expected ')' before '[' token
36 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:39:39: error: expected type-specifier before '[' token
39 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:39:39: error: expected ')' before '[' token
39 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ~ ^
| )
a.cc:46:36: error: expected type-specifier before '[' token
46 | new[i][j]=joi[2];
| ^
a.cc:47:39: error: expected type-specifier before '[' token
47 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:47:39: error: expected ')' before '[' token
47 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:50:39: error: expected type-specifier before '[' token
50 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:50:39: error: expected ')' before '[' token
50 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:53:39: error: expected type-specifier before '[' token
53 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:53:39: error: expected ')' before '[' token
53 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:56:39: error: expected type-specifier before '[' token
56 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:56:39: error: expected ')' before '[' token
56 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ~ ^
| )
a.cc:63:36: error: expected type-specifier before '[' token
63 | else if(new[i][j]=='O'){
| ^
a.cc:63:36: error: expected ')' before '[' token
63 | else if(new[i][j]=='O'){
| ~ ^
| )
a.cc:64:36: error: expected type-specifier before '[' token
64 | new[i][j]=joi[0];
| ^
a.cc:65:39: error: expected type-specifier before '[' token
65 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:65:39: error: expected ')' before '[' token
65 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:68:39: error: expected type-specifier before '[' token
68 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:68:39: error: expected ')' before '[' token
68 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:71:39: error: expected type-specifier before '[' token
71 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:71:39: error: expected ')' before '[' token
71 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:74:39: error: expected type-specifier before '[' token
74 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:74:39: error: expected ')' before '[' token
74 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ~ ^
| )
a.cc:81:36: error: expected type-specifier before '[' token
81 | new[i][j]=joi[2];
| ^
a.cc:82:39: error: expected type-specifier before '[' token
82 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:82:39: error: expected ')' before '[' token
82 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:85:39: error: expected type-specifier before '[' token
85 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:85:39: error: expected ')' before '[' token
85 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:88:39: error: expected type-specifier before '[' token
88 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:88:39: error: expected ')' before '[' token
88 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:91:39: error: expected type-specifier before '[' token
91 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:91:39: error: expected ')' bef |
s483880272 | p00521 | C++ | #include<stdio.h>
char new[1001][1001];
int i,j,k;
int main(void)
{
char old[5];
char joi[3]={'J','O','I'};
int m,n;
long long int cnt,c,max;
c=0;
cnt=0;
max=0;
scanf("%d %d",&m,&n);
for(i=0;i<m;i++){
for(j=0;j<n;j++){
scanf(" %c",&new[i][j]);
}
}
for(i=0;i<4;i++){
scanf(" %c",&old[i]);
}
for(i=0;i<m-1;i++){
for(j=0;j<n-1;j++){
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
cnt++;
}
else if(new[i][j]=='J'){
new[i][j]=joi[1];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
c=0;
new[i][j]=joi[2];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
}
else if(new[i][j]=='O'){
new[i][j]=joi[0];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
c=0;
new[i][j]=joi[2];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
}
else if(new[i][j]=='I'){
new[i][j]=joi[0];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
c=0;
new[i][j]=joi[1];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
}
}
}
printf("%lld\n",cnt+max);
return 0;
} | a.cc:2:6: error: expected unqualified-id before 'new'
2 | char new[1001][1001];
| ^~~
a.cc: In function 'int main()':
a.cc:17:41: error: expected type-specifier before '[' token
17 | scanf(" %c",&new[i][j]);
| ^
a.cc:25:31: error: expected type-specifier before '[' token
25 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:25:31: error: expected ')' before '[' token
25 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:28:36: error: expected type-specifier before '[' token
28 | else if(new[i][j]=='J'){
| ^
a.cc:28:36: error: expected ')' before '[' token
28 | else if(new[i][j]=='J'){
| ~ ^
| )
a.cc:29:36: error: expected type-specifier before '[' token
29 | new[i][j]=joi[1];
| ^
a.cc:30:39: error: expected type-specifier before '[' token
30 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:30:39: error: expected ')' before '[' token
30 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:33:39: error: expected type-specifier before '[' token
33 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:33:39: error: expected ')' before '[' token
33 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:36:39: error: expected type-specifier before '[' token
36 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:36:39: error: expected ')' before '[' token
36 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:39:39: error: expected type-specifier before '[' token
39 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:39:39: error: expected ')' before '[' token
39 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ~ ^
| )
a.cc:46:36: error: expected type-specifier before '[' token
46 | new[i][j]=joi[2];
| ^
a.cc:47:39: error: expected type-specifier before '[' token
47 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:47:39: error: expected ')' before '[' token
47 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:50:39: error: expected type-specifier before '[' token
50 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:50:39: error: expected ')' before '[' token
50 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:53:39: error: expected type-specifier before '[' token
53 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:53:39: error: expected ')' before '[' token
53 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:56:39: error: expected type-specifier before '[' token
56 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:56:39: error: expected ')' before '[' token
56 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ~ ^
| )
a.cc:63:36: error: expected type-specifier before '[' token
63 | else if(new[i][j]=='O'){
| ^
a.cc:63:36: error: expected ')' before '[' token
63 | else if(new[i][j]=='O'){
| ~ ^
| )
a.cc:64:36: error: expected type-specifier before '[' token
64 | new[i][j]=joi[0];
| ^
a.cc:65:39: error: expected type-specifier before '[' token
65 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:65:39: error: expected ')' before '[' token
65 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:68:39: error: expected type-specifier before '[' token
68 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:68:39: error: expected ')' before '[' token
68 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:71:39: error: expected type-specifier before '[' token
71 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:71:39: error: expected ')' before '[' token
71 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:74:39: error: expected type-specifier before '[' token
74 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:74:39: error: expected ')' before '[' token
74 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ~ ^
| )
a.cc:81:36: error: expected type-specifier before '[' token
81 | new[i][j]=joi[2];
| ^
a.cc:82:39: error: expected type-specifier before '[' token
82 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:82:39: error: expected ')' before '[' token
82 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:85:39: error: expected type-specifier before '[' token
85 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:85:39: error: expected ')' before '[' token
85 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:88:39: error: expected type-specifier before '[' token
88 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:88:39: error: expected ')' before '[' token
88 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:91:39: error: expected type-specifier before '[' token
91 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:91:39: error: expected ')' bef |
s584311919 | p00521 | C++ | #include<stdio.h>
char new[1001][1001];
int i,j,k;
int main(void)
{
char old[5];
char joi[3]={'J','O','I'};
int m,n;
int cnt,c,max;
c=0;
cnt=0;
max=0;
scanf("%d %d",&m,&n);
for(i=0;i<m;i++){
for(j=0;j<n;j++){
scanf(" %c",&new[i][j]);
}
}
for(i=0;i<4;i++){
scanf(" %c",&old[i]);
}
for(i=0;i<m;i++){
for(j=0;j<n;j++){
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
cnt++;
}
else if(new[i][j]=='J'){
new[i][j]=joi[1];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
c=0;
new[i][j]=joi[2];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
}
else if(new[i][j]=='O'){
new[i][j]=joi[0];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
c=0;
new[i][j]=joi[2];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
}
else if(new[i][j]=='I'){
new[i][j]=joi[0];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
c=0;
new[i][j]=joi[1];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
}
}
}
printf("%d\n",cnt+max);
return 0;
} | a.cc:2:6: error: expected unqualified-id before 'new'
2 | char new[1001][1001];
| ^~~
a.cc: In function 'int main()':
a.cc:17:41: error: expected type-specifier before '[' token
17 | scanf(" %c",&new[i][j]);
| ^
a.cc:25:31: error: expected type-specifier before '[' token
25 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:25:31: error: expected ')' before '[' token
25 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:28:36: error: expected type-specifier before '[' token
28 | else if(new[i][j]=='J'){
| ^
a.cc:28:36: error: expected ')' before '[' token
28 | else if(new[i][j]=='J'){
| ~ ^
| )
a.cc:29:36: error: expected type-specifier before '[' token
29 | new[i][j]=joi[1];
| ^
a.cc:30:39: error: expected type-specifier before '[' token
30 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:30:39: error: expected ')' before '[' token
30 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:33:39: error: expected type-specifier before '[' token
33 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:33:39: error: expected ')' before '[' token
33 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:36:39: error: expected type-specifier before '[' token
36 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:36:39: error: expected ')' before '[' token
36 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:39:39: error: expected type-specifier before '[' token
39 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:39:39: error: expected ')' before '[' token
39 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ~ ^
| )
a.cc:46:36: error: expected type-specifier before '[' token
46 | new[i][j]=joi[2];
| ^
a.cc:47:39: error: expected type-specifier before '[' token
47 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:47:39: error: expected ')' before '[' token
47 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:50:39: error: expected type-specifier before '[' token
50 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:50:39: error: expected ')' before '[' token
50 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:53:39: error: expected type-specifier before '[' token
53 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:53:39: error: expected ')' before '[' token
53 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:56:39: error: expected type-specifier before '[' token
56 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:56:39: error: expected ')' before '[' token
56 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ~ ^
| )
a.cc:63:36: error: expected type-specifier before '[' token
63 | else if(new[i][j]=='O'){
| ^
a.cc:63:36: error: expected ')' before '[' token
63 | else if(new[i][j]=='O'){
| ~ ^
| )
a.cc:64:36: error: expected type-specifier before '[' token
64 | new[i][j]=joi[0];
| ^
a.cc:65:39: error: expected type-specifier before '[' token
65 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:65:39: error: expected ')' before '[' token
65 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:68:39: error: expected type-specifier before '[' token
68 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:68:39: error: expected ')' before '[' token
68 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:71:39: error: expected type-specifier before '[' token
71 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:71:39: error: expected ')' before '[' token
71 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:74:39: error: expected type-specifier before '[' token
74 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:74:39: error: expected ')' before '[' token
74 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ~ ^
| )
a.cc:81:36: error: expected type-specifier before '[' token
81 | new[i][j]=joi[2];
| ^
a.cc:82:39: error: expected type-specifier before '[' token
82 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:82:39: error: expected ')' before '[' token
82 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:85:39: error: expected type-specifier before '[' token
85 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:85:39: error: expected ')' before '[' token
85 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:88:39: error: expected type-specifier before '[' token
88 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:88:39: error: expected ')' before '[' token
88 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:91:39: error: expected type-specifier before '[' token
91 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:91:39: error: expected ')' bef |
s009208158 | p00521 | C++ | #include<stdio.h>
char new[1002][1002];
int i,j,k;
int main(void)
{
char old[5];
char joi[3]={'J','O','I'};
int m,n;
int cnt,c,max;
c=0;
cnt=0;
max=0;
scanf("%d %d",&m,&n);
for(i=0;i<m;i++){
for(j=0;j<n;j++){
scanf(" %c",&new[i][j]);
}
}
for(i=0;i<4;i++){
scanf(" %c",&old[i]);
}
for(i=0;i<m;i++){
for(j=0;j<n;j++){
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
cnt++;
}
else if(new[i][j]=='J'){
new[i][j]=joi[1];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
c=0;
new[i][j]=joi[2];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
}
else if(new[i][j]=='O'){
new[i][j]=joi[0];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
c=0;
new[i][j]=joi[2];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
}
else if(new[i][j]=='I'){
new[i][j]=joi[0];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
c=0;
new[i][j]=joi[1];
if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
c++;
}
if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
c++;
}
if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
c++;
}
if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
c++;
}
if(c>max){
max=c;
}
}
}
}
printf("%d\n",cnt+max);
return 0;
} | a.cc:2:6: error: expected unqualified-id before 'new'
2 | char new[1002][1002];
| ^~~
a.cc: In function 'int main()':
a.cc:17:41: error: expected type-specifier before '[' token
17 | scanf(" %c",&new[i][j]);
| ^
a.cc:25:31: error: expected type-specifier before '[' token
25 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:25:31: error: expected ')' before '[' token
25 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:28:36: error: expected type-specifier before '[' token
28 | else if(new[i][j]=='J'){
| ^
a.cc:28:36: error: expected ')' before '[' token
28 | else if(new[i][j]=='J'){
| ~ ^
| )
a.cc:29:36: error: expected type-specifier before '[' token
29 | new[i][j]=joi[1];
| ^
a.cc:30:39: error: expected type-specifier before '[' token
30 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:30:39: error: expected ')' before '[' token
30 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:33:39: error: expected type-specifier before '[' token
33 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:33:39: error: expected ')' before '[' token
33 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:36:39: error: expected type-specifier before '[' token
36 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:36:39: error: expected ')' before '[' token
36 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:39:39: error: expected type-specifier before '[' token
39 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:39:39: error: expected ')' before '[' token
39 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ~ ^
| )
a.cc:46:36: error: expected type-specifier before '[' token
46 | new[i][j]=joi[2];
| ^
a.cc:47:39: error: expected type-specifier before '[' token
47 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:47:39: error: expected ')' before '[' token
47 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:50:39: error: expected type-specifier before '[' token
50 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:50:39: error: expected ')' before '[' token
50 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:53:39: error: expected type-specifier before '[' token
53 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:53:39: error: expected ')' before '[' token
53 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:56:39: error: expected type-specifier before '[' token
56 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:56:39: error: expected ')' before '[' token
56 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ~ ^
| )
a.cc:63:36: error: expected type-specifier before '[' token
63 | else if(new[i][j]=='O'){
| ^
a.cc:63:36: error: expected ')' before '[' token
63 | else if(new[i][j]=='O'){
| ~ ^
| )
a.cc:64:36: error: expected type-specifier before '[' token
64 | new[i][j]=joi[0];
| ^
a.cc:65:39: error: expected type-specifier before '[' token
65 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:65:39: error: expected ')' before '[' token
65 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:68:39: error: expected type-specifier before '[' token
68 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:68:39: error: expected ')' before '[' token
68 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:71:39: error: expected type-specifier before '[' token
71 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:71:39: error: expected ')' before '[' token
71 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:74:39: error: expected type-specifier before '[' token
74 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:74:39: error: expected ')' before '[' token
74 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ~ ^
| )
a.cc:81:36: error: expected type-specifier before '[' token
81 | new[i][j]=joi[2];
| ^
a.cc:82:39: error: expected type-specifier before '[' token
82 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ^
a.cc:82:39: error: expected ')' before '[' token
82 | if(new[i][j]==old[0] && new[i][j+1]==old[1] && new[i+1][j]==old[2] && new[i+1][j+1]==old[3]){
| ~ ^
| )
a.cc:85:39: error: expected type-specifier before '[' token
85 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ^
a.cc:85:39: error: expected ')' before '[' token
85 | if(new[i][j-1]==old[0] && new[i][j]==old[1] && new[i-1][j-1]==old[2] && new[i-1][j]==old[3]){
| ~ ^
| )
a.cc:88:39: error: expected type-specifier before '[' token
88 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ^
a.cc:88:39: error: expected ')' before '[' token
88 | if(new[i+1][j-1]==old[0] && new[i+1][j]==old[1] && new[i][j-1]==old[2] && new[i][j]==old[3]){
| ~ ^
| )
a.cc:91:39: error: expected type-specifier before '[' token
91 | if(new[i+1][j]==old[0] && new[i+1][j+1]==old[1] && new[i][j]==old[2] && new[i][j+1]==old[3]){
| ^
a.cc:91:39: error: expected ')' bef |
s113263564 | p00521 | C++ | #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
const int MAX_M = 1000, MAX_N = 1000;
int M, N;
string flag[MAX_M];
string Emb[2];
int table[MAX_M][MAX_N];
int res, plus, n;
bool lu(int i, int j){ return flag[i][j] == Emb[0][0]; }
bool ru(int i, int j){ return flag[i][j + 1] == Emb[0][1]; }
bool ld(int i, int j){ return flag[i + 1][j] == Emb[1][0]; }
bool rd(int i, int j){ return flag[i + 1][j + 1] == Emb[1][1]; }
int main(){
for(int i = 0; i < MAX_M; i++){
for(int j = 0; j < MAX_N; j++){
table[i][j] = 0;
}
}
cin >> M >> N;
for(int i = 0; i < M; i++){
cin >> flag[i];
}
for(int i = 0; i < 2; i++){
cin >> Emb[i];
}
res = 0;
for(int i = 0; i < M - 1; i++){
for(int j = 0; j < N - 1; j++){
if(lu(i, j) && ru(i, j) && ld(i, j) && rd(i, j)) res++;
else{
if(ru(i, j) && ld(i, j) && rd(i, j)) table[i][j] = 1;
else if(lu(i, j) && ld(i, j) && rd(i, j)) table[i][j] = 2;
else if(lu(i, j) && ru(i, j) && rd(i, j)) table[i][j] = 3;
else if(lu(i, j) && ru(i, j) && ld(i, j)) table[i][j] = 4;
else table[i][j] = -1;
}
}
}
plus = 0;
for(int i = 0; i < M - 1; i++){
for(int j = 0; j < N - 1; j++){
n = 0;
if(table[i][j] == 0 || table[i][j] == -1) continue;
if(table[i][j] == 1) n = 1;
else if(table[i][j] == 2){
if(j < N - 2 && table[i][j + 1] == 1) n = 2;
else n = 1;
}
else if(table[i][j] == 3){
if(i < M - 2 && table[i + 1][j] == 1) n = 2;
else n = 1;
}
else{
n = 1;
if(i < M - 2 && j < N - 2){
if(table[i][j + 1] == 3) n++;
if(table[i + 1][j] == 2) n++;
if(table[i + 1][j + 1] == 1) n++;
}
else if(i < M - 2){
if(table[i + 1][j] == 2) n++;
}
else if(j < N - 2){
if(table[i][j + 1] == 3) n++;
}
}
plus = max(plus, n);
}
}
cout << res + plus << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:47:9: error: reference to 'plus' is ambiguous
47 | plus = 0;
| ^~~~
In file included from /usr/include/c++/14/string:49,
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_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:11:10: note: 'int plus'
11 | int res, plus, n;
| ^~~~
a.cc:76:25: error: reference to 'plus' is ambiguous
76 | plus = max(plus, n);
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:11:10: note: 'int plus'
11 | int res, plus, n;
| ^~~~
a.cc:76:36: error: reference to 'plus' is ambiguous
76 | plus = max(plus, n);
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:11:10: note: 'int plus'
11 | int res, plus, n;
| ^~~~
a.cc:80:23: error: reference to 'plus' is ambiguous
80 | cout << res + plus << endl;
| ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
160 | struct plus;
| ^~~~
a.cc:11:10: note: 'int plus'
11 | int res, plus, n;
| ^~~~
|
s008283098 | p00521 | C++ | #include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const string JOI = "JOI";
int main()
{
int H, W;
scanf("%d", &H);
scanf("%d", &W);
vector<string> D(H);
for (int i = 0; i < H; i++)
{
cin >> D[i];
}
string C1, C2; cin >> C1 >> C2;
int sum = 0;
for (int i = 0; i < H - 1; i++)
{
for (int j = 0; j < W - 1; j++)
{
string R1 = D[i].substr(j, 2);
string R2 = D[i + 1].substr(j, 2);
if (R1 == C1 && R2 == C2)
{
sum++;
}
}
}
int diff, ret = sum;
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
diff = 0; char prevch = D[i][j];
for (int k = 0; k < 3; k++)
{
if (JOI[k] != prevch)
{
if (i != 0 && j != 0)
{
D[i][j] = JOI[k];
string R1 = D[i - 1].substr(j - 1, 2);
string R2 = D[i].substr(j - 1, 2);
diff += (R1 == C1 && R2 == C2 ? 1 : 0);
D[i][j] = prevch;
string R1 = D[i - 1].substr(j - 1, 2);
string R2 = D[i].substr(j - 1, 2);
diff -= (R1 == C1 && R2 == C2 ? 1 : 0);
}
if (i != 0 && j + 1 != W)
{
D[i][j] = JOI[k];
string R1 = D[i - 1].substr(j, 2);
string R2 = D[i].substr(j, 2);
diff += (R1 == C1 && R2 == C2 ? 1 : 0);
D[i][j] = prevch;
string R1 = D[i - 1].substr(j, 2);
string R2 = D[i].substr(j, 2);
diff -= (R1 == C1 && R2 == C2 ? 1 : 0);
}
if (i + 1 != H && j != 0)
{
D[i][j] = JOI[k];
string R1 = D[i].substr(j - 1, 2);
string R2 = D[i + 1].substr(j - 1, 2);
diff += (R1 == C1 && R2 == C2 ? 1 : 0);
D[i][j] = prevch;
string R1 = D[i].substr(j - 1, 2);
string R2 = D[i + 1].substr(j - 1, 2);
diff -= (R1 == C1 && R2 == C2 ? 1 : 0);
}
if (i + 1 != H && j + 1 != W)
{
D[i][j] = JOI[k];
string R1 = D[i].substr(j, 2);
string R2 = D[i + 1].substr(j, 2);
diff += (R1 == C1 && R2 == C2 ? 1 : 0);
D[i][j] = prevch;
string R1 = D[i].substr(j, 2);
string R2 = D[i + 1].substr(j, 2);
diff -= (R1 == C1 && R2 == C2 ? 1 : 0);
}
}
ret = max(ret, sum + diff);
}
D[i][j] = prevch;
}
}
printf("%d\n", ret);
return 0;
} | a.cc: In function 'int main()':
a.cc:65:56: error: redeclaration of 'std::string R1'
65 | string R1 = D[i - 1].substr(j - 1, 2);
| ^~
a.cc:58:56: note: 'std::string R1' previously declared here
58 | string R1 = D[i - 1].substr(j - 1, 2);
| ^~
a.cc:66:56: error: redeclaration of 'std::string R2'
66 | string R2 = D[i].substr(j - 1, 2);
| ^~
a.cc:59:56: note: 'std::string R2' previously declared here
59 | string R2 = D[i].substr(j - 1, 2);
| ^~
a.cc:82:56: error: redeclaration of 'std::string R1'
82 | string R1 = D[i - 1].substr(j, 2);
| ^~
a.cc:75:56: note: 'std::string R1' previously declared here
75 | string R1 = D[i - 1].substr(j, 2);
| ^~
a.cc:83:56: error: redeclaration of 'std::string R2'
83 | string R2 = D[i].substr(j, 2);
| ^~
a.cc:76:56: note: 'std::string R2' previously declared here
76 | string R2 = D[i].substr(j, 2);
| ^~
a.cc:99:56: error: redeclaration of 'std::string R1'
99 | string R1 = D[i].substr(j - 1, 2);
| ^~
a.cc:92:56: note: 'std::string R1' previously declared here
92 | string R1 = D[i].substr(j - 1, 2);
| ^~
a.cc:100:56: error: redeclaration of 'std::string R2'
100 | string R2 = D[i + 1].substr(j - 1, 2);
| ^~
a.cc:93:56: note: 'std::string R2' previously declared here
93 | string R2 = D[i + 1].substr(j - 1, 2);
| ^~
a.cc:116:56: error: redeclaration of 'std::string R1'
116 | string R1 = D[i].substr(j, 2);
| ^~
a.cc:109:56: note: 'std::string R1' previously declared here
109 | string R1 = D[i].substr(j, 2);
| ^~
a.cc:117:56: error: redeclaration of 'std::string R2'
117 | string R2 = D[i + 1].substr(j, 2);
| ^~
a.cc:110:56: note: 'std::string R2' previously declared here
110 | string R2 = D[i + 1].substr(j, 2);
| ^~
|
s877635867 | p00521 | C++ | #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
struct st {
int x, y;
char c;
};
bool operator<(st a, st b) {
if (a.x == b.x&&a.y == b.y)return a.c < b.c;
if (a.x == b.x)return a.y < b.y;
return a.x < b.x;
}
char s[1000][1001], f[2][3];
int main() {
int m, n; scanf("%d%d", &m, &n);
rep(i, m)scanf("%s", s[i]);
rep(i, 2)scanf("%s", f[i]);
map<st, int>mp;
int ans = 0;
rep(i, m - 1) {
rep(j, n - 1) {
bool match[4]{};
rep(k, 2)rep(t, 2) {
if (s[i + k][j + t] == f[k][t])
match[k * 2 + t] = true;
}
int cnt = count(match, match + 4, true);
if (cnt == 4)ans++;
if (cnt == 3) {
rep(k, 4) {
if (!match[k])
mp[{i + k / 2, j + k % 2, f[k / 2][k % 2]}]++;
}
}
}
}
int Max = 0;
for (auto p : mp) {
int cnt = 0;
rep(i, 2)rep(j, 2) {
int x = p.first.x + i, y = p.first.y + j;
bool ok = true;
rep(k, 2)rep(t, 2) {
if (s[x + k][y + t] != f[k][t])ok = false;
}
if (ok) {
swap(s[p.first.x][p.first.y], (char)p.first.c);
if (s[p.first.x][p.first.y] != f[i][j])cnt++;
swap(s[p.first.x][p.first.y], (char)p.first.c);
}
}
Max = max(Max, p.second - cnt);
}
printf("%d\n", ans + Max);
} | a.cc: In function 'int main()':
a.cc:48:37: error: no matching function for call to 'swap(char&, char)'
48 | swap(s[p.first.x][p.first.y], (char)p.first.c);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/move.h:226:5: note: candidate: 'std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char; _Require<__not_<__is_tuple_like<_Tp> >, is_move_constructible<_Tp>, is_move_assignable<_Tp> > = void]' (near match)
226 | swap(_Tp& __a, _Tp& __b)
| ^~~~
/usr/include/c++/14/bits/move.h:226:5: note: conversion of argument 2 would be ill-formed:
a.cc:48:63: error: cannot bind non-const lvalue reference of type 'char&' to an rvalue of type 'char'
48 | swap(s[p.first.x][p.first.y], (char)p.first.c);
| ^~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:77:
/usr/include/c++/14/any:430:15: note: candidate: 'void std::swap(any&, any&)' (near match)
430 | inline void swap(any& __x, any& __y) noexcept { __x.swap(__y); }
| ^~~~
/usr/include/c++/14/any:430:15: note: conversion of argument 2 would be ill-formed:
a.cc:48:63: error: cannot bind non-const lvalue reference of type 'std::any&' to an rvalue of type 'std::any'
48 | swap(s[p.first.x][p.first.y], (char)p.first.c);
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/any:191:7: note: after user-defined conversion: 'std::any::any(_Tp&&) [with _Tp = char; _VTp = char; _Mgr = _Manager_internal<char>; typename std::enable_if<(is_copy_constructible_v<_VTp> && (! __is_in_place_type_v<_VTp>)), bool>::type <anonymous> = true]'
191 | any(_Tp&& __value)
| ^~~
In file included from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/stdexcept:38,
from /usr/include/c++/14/system_error:43,
from /usr/include/c++/14/bits/ios_base.h:46,
from /usr/include/c++/14/streambuf:43,
from /usr/include/c++/14/bits/streambuf_iterator.h:35,
from /usr/include/c++/14/iterator:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/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 'char' to 'std::__exception_ptr::exception_ptr&'
229 | swap(exception_ptr& __lhs, exception_ptr& __rhs)
| ~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/future:51,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:176:
/usr/include/c++/14/bits/std_thread.h:328:3: note: candidate: 'void std::swap(thread&, thread&)'
328 | swap(thread& __x, thread& __y) noexcept
| ^~~~
/usr/include/c++/14/bits/std_thread.h:328:16: note: no known conversion for argument 1 from 'char' to 'std::thread&'
328 | swap(thread& __x, thread& __y) noexcept
| ~~~~~~~~^~~
In file included from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/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:48:37: note: mismatched types 'std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>' and 'char'
48 | swap(s[p.first.x][p.first.y], (char)p.first.c);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:48:37: note: mismatched types 'std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>' and 'char'
48 | swap(s[p.first.x][p.first.y], (char)p.first.c);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:48:37: note: mismatched types 'std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>' and 'char'
48 | swap(s[p.first.x][p.first.y], (char)p.first.c);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:48:37: note: mismatched types 'std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>' and 'char'
48 | swap(s[p.first.x][p.first.y], (char)p.first.c);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181:
/usr/include/c++/14/bits/regex.h:896:5: note: candidate: 'template<class _Ch_type, class _Rx_traits> void std::__cxx11::swap(basic_regex<_Ch_type, _Rx_traits>&, basic_regex<_Ch_type, _Rx_traits>&)'
896 | swap(basic_regex<_Ch_type, _Rx_traits>& __lhs,
| ^~~~
/usr/include/c++/14/bits/regex.h:896:5: note: template argument deduction/substitution failed:
a.cc:48:37: note: mismatched types 'std::__cxx11::basic_regex<_Ch_type, _Rx_traits>' and 'char'
48 | swap(s[p.first.x][p.first.y], (char)p.first.c);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2230:5: note: candidate: 'template<class _Bi_iter, class _Alloc> void std::__cxx11::swap(match_results<_BiIter, _Alloc>&, match_results<_BiIter, _Alloc>&)'
2230 | swap(match_results<_Bi_iter, _Alloc>& __lhs,
| ^~~~
/usr/include/c++/14/bits/regex.h:2230:5: note: template argument deduction/substitution failed:
a.cc:48:37: note: mismatched types 'std::__cxx11::match_results<_BiIter, _Alloc>' and 'char'
48 | swap(s[p.first.x][p.first.y], (char)p.first.c);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:48:37: note: mismatched types '_Tp [_Nm]' and 'char'
48 | swap(s[p.first.x][p.first.y], (char)p.first.c);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:48:37: note: mismatched types 'std::pair<_T1, _T2>' and 'char'
48 | swap(s[p.first.x][p.first.y], (char)p.first.c);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:48:37: note: mismatched types 'std::pair<_T1, _T2>' and 'char'
48 | swap(s[p.first.x][p.first.y], (char)p.first.c);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52 |
s499013106 | p00521 | C++ | #include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <set>
#define INF_LL 9000000000000000000
#define INF 2000000000
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PPII;
typedef pair<int, PPII> PPPII;
class Union_find{
private:
vector<int> par;
vector<int> rank;
int n;
public:
Union_find(int a){
n = a;
for(int i = 0;i < n;i++){
par.push_back(i);
rank.push_back(0);
}
}
int find(int x){
if(par[x] == x){
return x;
}else{
return par[x] = find(par[x]);
}
}
void unite(int x, int y){
x = find(x);
y = find(y);
if(x == y) return;
if(rank[x] < rank[y]){
par[x] = y;
}else{
par[y] = x;
if(rank[x] == rank[y]) rank[x]++;
}
}
bool same(int x, int y){
return find(x) == find(y);
}
};
int main(void){
int N, M;
string flag[2];
string base[1010];
ll res = 0;
cin >> M >> N;
REP(i, M){
cin >> base[i];
}
REP(i, 2){
cin >> flag[i];
}
REP(i, M-1){
REP(j, N-1){
bool ok = true;
REP(a, 2){
REP(b, 2){
if(flag[a][b] != base[i+a][j+b]){
ok = false;
}
}
}
if(ok)
res++;
}
}
int mp = 0;
REP(i, M){
REP(j, N){
char ch[] = {'J', 'O', 'I'};
char org = base[i][j];
REP(k, 3){
base[i][j] = ch[k];
int cnt = 0;
FOR(a, max(i-1, 0), i+1){
FOR(b, max(j-1, 0), j+1){
bool ok = true;
REP(c, 2){
REP(d, 2){
if(flag[c][d] != base[a+c][b+d])
ok =false;
}
}
if(ok) cnt++;
}
}
if(mp < cnt && ch[k] != org)
mp = cnt;
}
}
}
cout << res + mp << endl;
} | a.cc: In function 'int main()':
a.cc:74:9: error: 'cin' was not declared in this scope
74 | cin >> M >> N;
| ^~~
a.cc:12:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
11 | #include <set>
+++ |+#include <iostream>
12 |
a.cc:122:9: error: 'cout' was not declared in this scope
122 | cout << res + mp << endl;
| ^~~~
a.cc:122:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s617091352 | p00521 | C++ | //============================================================================
// Name : AOJ.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
char D[1002][1002]={};
int main() {
int M,N;
char E[2][2];
char b[4]="SJOI";
cin>>M>>N;
for(int i=1;i<M+1;i++){
for(int j=1;j<N+1;j++){
cin>>D[i][j];
}
}
for(int i=0;i<2;i++){
for(int j=0;j<2;j++){
cin>>E[i][j];
}
}
int a=0;
for(int i=1;i<M;i++){
for(int j=1;j<N;j++){
if(D[i][j]==E[0][0]&&D[i][j+1]==E[0][1]&&D[i+1][j]==E[1][0]&&D[i+1][j+1]==E[1][1]){
a+=1;
}
}
}
int c[4];
char C;
int R=0;
for(int i=1;i<M+1;i++){
for(int j=1;j<N+1;j++){
b[0]=D[i][j];
for(int k=0;k<4;++k){
D[i][j]=b[k];
c[k]=0;
if(D[i][j]==E[0][0]&&D[i][j+1]==E[0][1]&&D[i+1][j]==E[1][0]&&D[i+1][j+1]==E[1][1])c[k]+=1;
if(D[i][j-1]==E[0][0]&&D[i][j]==E[0][1]&&D[i+1][j-1]==E[1][0]&&D[i+1][j]==E[1][1])c[k]+=1;
if(D[i-1][j-1]==E[0][0]&&D[i-1][j]==E[0][1]&&D[i][j-1]==E[1][0]&&D[i][j]==E[1][1])c[k]+=1;
if(D[i-1][j]==E[0][0]&&D[i-1][j+1]==E[0][1]&&D[i][j]==E[1][0]&&D[i][j+1]==E[1][1])c[k]+=1;
C=D[i][j];
}
D[i][j]=b[0];
R=max(R,a+c[1]-c[0]);
R=max(R,a+c[2]-c[0]);
R=max(R,a+c[3]-c[0]);
}
}
cout<<R<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:16:19: error: initializer-string for 'char [4]' is too long [-fpermissive]
16 | char b[4]="SJOI";
| ^~~~~~
|
s316626869 | p00522 | 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 m=ir.nextInt(),n=ir.nextInt();
int[] p=ir.nextIntArray(m);
int[][] box=new int[n][];
for(int i=0;i<n;i++) box[i]=ir.nextIntArray(2);
mergeSort(p);
p=reverseArray(p);
int[][] dp=new int[m+1][n+1];
int[] sum=new int[m+1];
for(int i=0;i<m;i++) sum[i+1]+=sum[i]+p[i];
for(int i=m-1;i>=0;i--){
for(int j=n-1;j>=0;j--){
int last=Math.min(i+box[j][0],m);
dp[i][j]=Math.max(dp[i][j],dp[last][j+1]+sum[last]-sum[i]-box[j][1]);
dp[i][j]=Math.max(dp[i][j],dp[i][j+1]);
}
}
out.println(dp[0][0]);
}
static int[] buff;
static void __mergeSort(int[] a,int left,int right){
if(left<right){
int i,mid=(left+right)/2,p=0,j=0,k=left;
__mergeSort(a,left,mid);
__mergeSort(a,mid+1,right);
for(i=left;i<=mid;i++)
buff[p++]=a[i];
while(i<=right&&j<p)
a[k++]=(buff[j]<=a[i])?buff[j++]:a[i++];
while(j<p)
a[k++]=buff[j++];
}
}
static void mergeSort(int[] a){
buff=new int[a.length];
__mergeSort(a,0,a.length-1);
buff=null;
}
public static int[] reverseArray(int[] a){
int[] ret=new int[a.length];
for(int i=0;i<n;i++) ret[a.length-1-i]=a[i];
return ret;
}
public static void main(String[] args) throws Exception{
ir=new InputReader(System.in);
out=new PrintWriter(System.out);
solve();
out.flush();
}
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 BigInteger nextBigInteger(){return new BigInteger(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:60: error: cannot find symbol
for(int i=0;i<n;i++) ret[a.length-1-i]=a[i];
^
symbol: variable n
location: class Main
1 error
|
s530864115 | p00522 | C++ | #include<iostream>
using namespace std;
const int INF = 1000000000;
int M,N,ans;
int ma[10003];
int ha[503][2];
int dp[503][10003];
int main(void){
cin >> M >> N;
for(int i = 0;i < m;i++){
cin>>ma[i];
}
sort(ma,ma + M,greater<int>());
for(int i = 1;i < M;i++)ma[i] += ma[i-1];
for(int i = 0;i < N;i++){
cin >> ha[i][0] >>ha[i][1];
}
for(int i = 0;i <= N;i++){
for(int j = 1;j <= M;j++){
dp[i][j] = INF;
}
}
for(int i = 1;i <= ha[0][0];i++){
dp[1][i] = ha[0][1];
ans = max(ans,ma[i-1]-dp[1][i]);
}
for(int i = 2;i <= N;i++){
for(int j = 1;j <= M;j++){
dp[i][j] = min(dp[i-1][j],ha[i-1][1]+dp[i-1][max(0,j-ha[i-1][0])]);
ans = max(ans,ma[j-1]-dp[i][j]);
}
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:27: error: 'm' was not declared in this scope
11 | for(int i = 0;i < m;i++){
| ^
a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'short'?
14 | sort(ma,ma + M,greater<int>());
| ^~~~
| short
|
s397891793 | p00522 | C++ | #include <functional>
#include <iostream>
int p[100100],c[100100],e[100100];
int dp[2][100100];//dp[i+1][j]:=i番目までの箱を使ってj個の饅頭
int main()
{
int n,m;
cin >> n >> m;
int sum=0;
for(int i=0;i<n;i++)cin >> p[i];
for(int i=0;i<m;i++)cin >> c[i] >> e[i];
sort(p,p+n,greater<int>());
for(int i=0;i<n;i++)p[i+1]+=p[i];
for(int i=0;i<2;i++)
{
for(int j=0;j<=n;j++)
{
dp[i][j]=INF;
}
}
dp[0][0]=0;
for(int i=0;i<m;i++)
{
for(int j=0;j<=n;j++)
{
dp[(i+1)%2][j]=min(dp[i%2][j],dp[i%2][max(j-c[i],0)]+e[i]);
}
}
int ans=0;
for(int i=1;i<=n;i++)
{
ans=max(ans,p[i-1]-dp[m%2][i]);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:8:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
8 | cin >> n >> m;
| ^~~
| 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
| ^~~
a.cc:12:16: error: 'greater' was not declared in this scope; did you mean 'std::greater'?
12 | sort(p,p+n,greater<int>());
| ^~~~~~~
| std::greater
In file included from /usr/include/c++/14/functional:49,
from a.cc:1:
/usr/include/c++/14/bits/stl_function.h:353:12: note: 'std::greater' declared here
353 | struct greater;
| ^~~~~~~
a.cc:12:24: error: expected primary-expression before 'int'
12 | sort(p,p+n,greater<int>());
| ^~~
a.cc:12:5: error: 'sort' was not declared in this scope; did you mean 'short'?
12 | sort(p,p+n,greater<int>());
| ^~~~
| short
a.cc:18:22: error: 'INF' was not declared in this scope
18 | dp[i][j]=INF;
| ^~~
a.cc:26:51: error: 'max' was not declared in this scope; did you mean 'std::max'?
26 | dp[(i+1)%2][j]=min(dp[i%2][j],dp[i%2][max(j-c[i],0)]+e[i]);
| ^~~
| std::max
In file included from /usr/include/c++/14/bits/hashtable_policy.h:36,
from /usr/include/c++/14/bits/hashtable.h:35,
from /usr/include/c++/14/bits/unordered_map.h:33,
from /usr/include/c++/14/unordered_map:41,
from /usr/include/c++/14/functional:63:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
a.cc:26:28: error: 'min' was not declared in this scope; did you mean 'std::min'?
26 | dp[(i+1)%2][j]=min(dp[i%2][j],dp[i%2][max(j-c[i],0)]+e[i]);
| ^~~
| std::min
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
a.cc:32:13: error: 'max' was not declared in this scope; did you mean 'std::max'?
32 | ans=max(ans,p[i-1]-dp[m%2][i]);
| ^~~
| std::max
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
a.cc:34:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
34 | cout << ans << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:34:20: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
34 | cout << ans << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s957512823 | p00522 | C++ | #include <functional>
#include <iostream>
using namespace std;
int p[100100],c[100100],e[100100];
int dp[2][100100];//dp[i+1][j]:=i番目までの箱を使ってj個の饅頭
int main()
{
int n,m;
cin >> n >> m;
int sum=0;
for(int i=0;i<n;i++)cin >> p[i];
for(int i=0;i<m;i++)cin >> c[i] >> e[i];
sort(p,p+n,greater<int>());
for(int i=0;i<n;i++)p[i+1]+=p[i];
for(int i=0;i<2;i++)
{
for(int j=0;j<=n;j++)
{
dp[i][j]=INF;
}
}
dp[0][0]=0;
for(int i=0;i<m;i++)
{
for(int j=0;j<=n;j++)
{
dp[(i+1)%2][j]=min(dp[i%2][j],dp[i%2][max(j-c[i],0)]+e[i]);
}
}
int ans=0;
for(int i=1;i<=n;i++)
{
ans=max(ans,p[i-1]-dp[m%2][i]);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:13:5: error: 'sort' was not declared in this scope; did you mean 'short'?
13 | sort(p,p+n,greater<int>());
| ^~~~
| short
a.cc:19:22: error: 'INF' was not declared in this scope
19 | dp[i][j]=INF;
| ^~~
|
s182841722 | p00522 | C++ | #include <iostream>
#include <queue>
using namespace std;
int main() {
const int INF = 1001001001;
const int LIM_M = 10000;
const int LIM_N = 500;
int M, N;
int P[LIM_M + 10];
int C[LIM_N + 10], E[LIM_N + 10];
int PSum[LIM_M + 10];
int dp[LIM_M + 10];
int main() {
int i, j;
scanf("%d%d", &M, &N);
for (i = 0; i < M; ++i) {
scanf("%d", &P[i]);
}
for (j = 0; j < N; ++j) {
scanf("%d%d", &C[j], &E[j]);
}
// PSum[i] := maximum price for selling i manjus.
sort(P, P + M, greater<int>());
for (i = 0; i < M; ++i) {
PSum[i + 1] = PSum[i] + P[i];
}
// dp[i] := minimum expense for boxes to pack i manjus.
// invariant: dp[0] <= dp[1] <= ... <= dp[M].
for (i = 0; i <= M; ++i) {
dp[i] = INF;
}
dp[0] = 0;
for (j = 0; j < N; ++j) {
for (i = M; i >= 0; --i) {
if (dp[i] > dp[max(i - C[j], 0)] + E[j]) {
dp[i] = dp[max(i - C[j], 0)] + E[j];
}
}
}
int ans = 0;
for (i = 0; i <= M; ++i) {
if (ans < PSum[i] - dp[i]) {
ans = PSum[i] - dp[i];
}
}
printf("%d\n", ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:18:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
18 | int main() {
| ^~
a.cc:18:9: note: remove parentheses to default-initialize a variable
18 | int main() {
| ^~
| --
a.cc:18:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:18:12: error: a function-definition is not allowed here before '{' token
18 | int main() {
| ^
a.cc:58:2: error: expected '}' at end of input
58 | }
| ^
a.cc:5:12: note: to match this '{'
5 | int main() {
| ^
|
s743686088 | p00522 | C++ | #include<iostream>
#include<vector>
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dump(x) cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define INF 999999999
int main(){
int m,n;
cin>>m>>n;
vector<int> man;
rep(i,m){
int a;
cin>>a;
man.pb(a);
}
vector<pii> box;
rep(i,n){
int a,b;
cin>>a>>b;
box.pb(pii(a,b));
}
static int dp[600][11000];
rep(i,11000)rep(j,600)dp[j][i]=INF;
dp[0][0]=0;
for(int i=0;i<n;i++){
for(int j=n;j>=1;j--){
for(int k=0;k<=10100;k++){
if(k-box[i].first>=0)
dp[j][k]=min( dp[j-1][k-box[i].first]+box[i].second , dp[j][k] );
}
}
}
vector<int> data;
rep(i,10100){
int x=INF;
rep(j,n+1){x=min(x,dp[j][i]);
// cout<<"dp["<<j<<"]["<<i<<"]="<<dp[j][i]<<endl;
}
data.pb(x);
}
for(int i=10100-1;i>=1;i--){
if(data[i]<data[i-1])data[i-1]=data[i];
}
// rep(i,data.size())cout<<data[i]<<" ";cout<<endl;
// rep(i,10)cout<<data[i]<<" ";
sort(all(man),greater<int>());
for(int i=1;i<man.size();i++){
man[i]=man[i-1]+man[i];
}
int ans=0;
rep(i,m){
ans=max(ans,man[i]-data[i+1]);
// cout<<i<<" "<<ans<<" "<<data[i+1]<<endl;
}
cout<<ans<<endl;
} | a.cc: In function 'int main()':
a.cc:56:5: error: 'sort' was not declared in this scope; did you mean 'short'?
56 | sort(all(man),greater<int>());
| ^~~~
| short
|
s124542487 | p00522 | C++ | #include<iostream>
#include<vector>
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dump(x) cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define INF 999999999
int main(){
int m,n;
cin>>m>>n;
vector<int> man;
rep(i,m){
int a;
cin>>a;
man.pb(a);
}
vector<pii> box;
rep(i,n){
int a,b;
cin>>a>>b;
box.pb(pii(a,b));
}
static int dp[600][11000];
rep(i,11000)rep(j,600)dp[j][i]=INF;
dp[0][0]=0;
for(int i=0;i<n;i++){
for(int j=n;j>=1;j--){
for(int k=0;k<=10100;k++){
if(k-box[i].first>=0)
dp[j][k]=min( dp[j-1][k-box[i].first]+box[i].second , dp[j][k] );
}
}
}
vector<int> data;
rep(i,10100){
int x=INF;
rep(j,n+1){x=min(x,dp[j][i]);
// cout<<"dp["<<j<<"]["<<i<<"]="<<dp[j][i]<<endl;
}
data.pb(x);
}
for(int i=10100-1;i>=1;i--){
if(data[i]<data[i-1])data[i-1]=data[i];
}
// rep(i,data.size())cout<<data[i]<<" ";cout<<endl;
// rep(i,10)cout<<data[i]<<" ";
sort(all(man),greater<int>());
for(int i=1;i<man.size();i++){
man[i]=man[i-1]+man[i];
}
int ans=0;
rep(i,m){
ans=max(ans,man[i]-data[i+1]);
// cout<<i<<" "<<ans<<" "<<data[i+1]<<endl;
}
cout<<ans<<endl;
} | a.cc: In function 'int main()':
a.cc:56:5: error: 'sort' was not declared in this scope; did you mean 'short'?
56 | sort(all(man),greater<int>());
| ^~~~
| short
|
s310051136 | p00522 | C++ | #include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
int m, n;
int p[10001];
int c[501];
int e[501];
int dp[10001][501];
/*
??????????????? ?????????????£???? ??¨ ??±????????± ???????????????
?\?????????????????£??????¨??? ??????????????????
???????????\?????± ????????????
*/
int solve(int i,int j){
if (i < 0){
return (0);
}
if (j > m){
return 1e9;
}
if(dp[i][j] != -1){
return dp[i][j];
}
int tmp, tmp2;
tmp = e[j] + solve(i - c[j], j+1);
tmp2 = solve(i, j+1);
dp[i][j] = min(tmp, tmp2);
//printf(" %d %d %d\n", i, j, dp[i][j]);
return dp[i][j];
}
int main()
{
scanf("%d %d", &m, &n);
for (int i = 0; i < m; i++){
scanf("%d", &p[i]);
}
for (int i = 0; i < n; i++){
scanf("%d %d", &c[i], &e[i]);
}
memset(dp, -1, sizeof(dp));
solve(m, 0);
sort(p, p + m);
reverse(p, p + m);
int set_value = 0;
int rieki = 0;
for(int i = 0; i < m;i++){
set_value += p[i];
rieki = max(rieki, set_value - solve(i, 0));
}
printf("%d\n", rieki);
} | a.cc: In function 'int main()':
a.cc:47:9: error: 'memset' was not declared in this scope
47 | memset(dp, -1, sizeof(dp));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <map>
+++ |+#include <cstring>
4 |
|
s063713133 | p00522 | C++ | #include <cstdio>
#include <algorithm>
#include <map>
#include <memset>
using namespace std;
int m, n;
int p[10001];
int c[501];
int e[501];
int dp[10001][501];
/*
??????????????? ?????????????£???? ??¨ ??±????????± ???????????????
?\?????????????????£??????¨??? ??????????????????
???????????\?????± ????????????
*/
int solve(int i,int j){
if (i < 0){
return (0);
}
if (j > m){
return 1e9;
}
if(dp[i][j] != -1){
return dp[i][j];
}
int tmp, tmp2;
tmp = e[j] + solve(i - c[j], j+1);
tmp2 = solve(i, j+1);
dp[i][j] = min(tmp, tmp2);
//printf(" %d %d %d\n", i, j, dp[i][j]);
return dp[i][j];
}
int main()
{
scanf("%d %d", &m, &n);
for (int i = 0; i < m; i++){
scanf("%d", &p[i]);
}
for (int i = 0; i < n; i++){
scanf("%d %d", &c[i], &e[i]);
}
memset(dp, -1, sizeof(dp));
solve(m, 0);
sort(p, p + m);
reverse(p, p + m);
int set_value = 0;
int rieki = 0;
for(int i = 0; i < m;i++){
set_value += p[i];
rieki = max(rieki, set_value - solve(i, 0));
}
printf("%d\n", rieki);
} | a.cc:4:10: fatal error: memset: No such file or directory
4 | #include <memset>
| ^~~~~~~~
compilation terminated.
|
s635148795 | p00522 | C++ | #include<bits/stdc++.h>
using namespace std;
#define INF (1<<30)
??
int main()
{
????int M, N, C[10000], E[10000];
????int P[10001] = {0};
??
????cin >> M >> N;
????for(int i = 1; i <= M; i++) {
????????cin >> P[i];
????}
????for(int i = 0; i < N; i++) {
????????cin >> C[i] >> E[i];
????}
??
????sort(P + 1, P + M + 1, greater< int >());
????for(int i = 1; i <= M; i++) {
????????P[i] += P[i - 1];
????}
??
????int dp[20001];
????fill_n(dp, 20001, INF);
????dp[0] = 0;
????for(int i = 0; i < N; i++) {
????????for(int j = 20000; j >= C[i]; j--) {
????????????dp[j] = min(dp[j], dp[j - C[i]] + E[i]);
????????}
????}
????int ret = 0;
????for(int i = 0; i <= M; i++) {
????????ret = max(ret, P[i] - dp[i]);
????}
????cout << ret << endl;
} | a.cc:4:1: error: expected unqualified-id before '?' token
4 | ??
| ^
|
s100982747 | p00522 | C++ | #include<bits/stdc++.h>
using namespace std;
#define INF (1<<30)
??
int main()
{
????int M, N, C[10000], E[10000];
????int P[10001] = {0};
??
????cin >> M >> N;
????for(int i = 1; i <= M; i++) {
????????cin >> P[i];
????}
????for(int i = 0; i < N; i++) {
????????cin >> C[i] >> E[i];
????}
??
????sort(P + 1, P + M + 1, greater< int >());
????for(int i = 1; i <= M; i++) {
????????P[i] += P[i - 1];
????}
??
????int dp[20001];
????fill_n(dp, 20001, INF);
????dp[0] = 0;
????for(int i = 0; i < N; i++) {
????????for(int j = 20000; j >= C[i]; j--) {
????????????dp[j] = min(dp[j], dp[j - C[i]] + E[i]);
????????}
????}
????int ret = 0;
????for(int i = 0; i <= M; i++) {
????????ret = max(ret, P[i] - dp[i]);
????}
????cout << ret << endl;
} | a.cc:4:1: error: expected unqualified-id before '?' token
4 | ??
| ^
|
s407341698 | p00522 | C++ | #include<bits/stdc++.h>
using namespace std;
#define INF (1<<55)
const long long INF = 1LL << 55;
int main()
{
int M, N, C[10000], E[10000];
int P[10001] = {0};
cin >> M >> N;
for(int i = 1; i <= M; i++) {
cin >> P[i];
}
for(int i = 0; i < N; i++) {
cin >> C[i] >> E[i];
}
sort(P + 1, P + M + 1, greater< int >());
for(int i = 1; i <= M; i++) {
P[i] += P[i - 1];
}
int dp[20001];
fill_n(dp, 20001, INF);
dp[0] = 0;
for(int i = 0; i < N; i++) {
for(int j = 20000; j >= C[i]; j--) {
dp[j] = min(dp[j], dp[j - C[i]] + E[i]);
}
}
int ret = 0;
for(int i = 0; i <= M; i++) {
ret = max(ret, P[i] - dp[i]);
}
cout << ret << endl;
} | a.cc:3:14: error: expected unqualified-id before numeric constant
3 | #define INF (1<<55)
| ^
a.cc:4:17: note: in expansion of macro 'INF'
4 | const long long INF = 1LL << 55;
| ^~~
a.cc:3:14: error: expected ')' before numeric constant
3 | #define INF (1<<55)
| ~^
a.cc:4:17: note: in expansion of macro 'INF'
4 | const long long INF = 1LL << 55;
| ^~~
a.cc: In function 'int main()':
a.cc:3:15: warning: left shift count >= width of type [-Wshift-count-overflow]
3 | #define INF (1<<55)
| ~^~~~
a.cc:25:21: note: in expansion of macro 'INF'
25 | fill_n(dp, 20001, INF);
| ^~~
|
s199624926 | p00522 | C++ | 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 m=ir.nextInt(),n=ir.nextInt();
int[] p=ir.nextIntArray(m);
int[][] box=new int[n][];
for(int i=0;i<n;i++) box[i]=ir.nextIntArray(2);
mergeSort(p);
p=reverseArray(p);
int[][] dp=new int[m+1][n+1];
int[] sum=new int[m+1];
for(int i=0;i<m;i++) sum[i+1]+=sum[i]+p[i];
for(int i=m-1;i>=0;i--){
for(int j=n-1;j>=0;j--){
int last=Math.min(i+box[j][0],m);
dp[i][j]=Math.max(dp[i][j],dp[last][j+1]+sum[last]-sum[i]-box[j][1]);
dp[i][j]=Math.max(dp[i][j],dp[i][j+1]);
}
}
out.println(dp[0][0]);
}
static int[] buff;
static void __mergeSort(int[] a,int left,int right){
if(left<right){
int i,mid=(left+right)/2,p=0,j=0,k=left;
__mergeSort(a,left,mid);
__mergeSort(a,mid+1,right);
for(i=left;i<=mid;i++)
buff[p++]=a[i];
while(i<=right&&j<p)
a[k++]=(buff[j]<=a[i])?buff[j++]:a[i++];
while(j<p)
a[k++]=buff[j++];
}
}
static void mergeSort(int[] a){
buff=new int[a.length];
__mergeSort(a,0,a.length-1);
buff=null;
}
public static int[] reverseArray(int[] a){
int[] ret=new int[a.length];
for(int i=0;i<n;i++) ret[a.length-1-i]=a[i];
return ret;
}
public static void main(String[] args) throws Exception{
ir=new InputReader(System.in);
out=new PrintWriter(System.out);
solve();
out.flush();
}
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 BigInteger nextBigInteger(){return new BigInteger(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;
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.io.InputStream;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.io.IOException;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.io.PrintWriter;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.util.ArrayList;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.util.Arrays;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
6 | import java.util.Comparator;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
7 | import java.util.InputMismatchException;
| ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: 'import' does not name a type
8 | import java.util.NoSuchElementException;
| ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: 'import' does not name a type
9 | import java.math.BigInteger;
| ^~~~~~
a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:11:1: error: expected unqualified-id before 'public'
11 | public class Main{
| ^~~~~~
|
s982759391 | p00522 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define INF 10000000
typedef pair<int,int> P;
int main()
{
int M, N;
cin >> M >> N;
vector<int> man;
vector<P> pack;
for(int i=0; i<M; ++i) {
int temp;
cin >> temp;
man.push_back(temp);
}
sort(man.rbegin(),man.rend());
for(int i=1; i<M; ++i) {
man[i]+=man[i-1];
}
for(int i=0; i<N; ++i) {
int c,e;
cin >> c >> e;
pack.push_back(make_pair(c,e));
}
int dp[N][M];
for(int j=0; j<M; ++j) {
dp[0][j]=INF;
dp[1][j]=INF;
}
for(int i=0; i<M; ++i) {
if(i<pack[0].first) dp[0][i]=pack[0].second;
}
for(int i=1; i<N; ++i) {
for(int j=0; j<M; ++j) {
if(j<pack[i].first) {
dp[i%2][j]=min(dp[i%2][j],dp[(i-1)%2][j]);
dp[i%2][j]=min(dp[i%2][j],pack[i].second);
}
if(j+pack[i].first<M) {
dp[i%2][j+pack[i].first]=min(dp[(i-1)%2][j+pack[i].first],dp[(i-1)%2][j]+pack[i].second);
}
}
}
long long ans=0;
for(int i=0; i<M; ++i) {
ans=max(ans,man[i]-dp[(N-1)%2][i]);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:62:16: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
62 | ans=max(ans,man[i]-dp[(N-1)%2][i]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
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:62:16: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
62 | ans=max(ans,man[i]-dp[(N-1)%2][i]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:62:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
62 | ans=max(ans,man[i]-dp[(N-1)%2][i]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s670822651 | p00523 | 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;
static long[] sum;
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
N=ir.nextInt();
int[] a=ir.toIntArray(N);
sum=new long[2*N+1];
sum[0]=0;
for(int i=1;i<=2*N;i++) sum[i]=sum[i-1]+(long)a[(i-1)%N];
long ans=0;
for(int i=0;i<N-2;i++){
int l=i+1;
int r=i+2;
while(true){
if(r>=N) break;
long a=sum[i+N]-sum[r];
long b=sum[r]-sum[l];
long c=sum[l]-sum[i];
long res;
if(a<=b&&a<=c){
ans=Math.max(ans,a);
break;
}
else if(b<=a&&b<=c){
res=b;
r++;
}
else{
res=c;
if(r>l+1) l++;
else r++;
}
ans=Math.max(ans,res);
}
}
out.println(ans);
out.flush();
}
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:40: error: variable a is already defined in method main(String[])
long a=sum[i+N]-sum[r];
^
1 error
|
s710358250 | p00523 | 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(){
N=ir.nextInt();
int[] s=ir.nextIntArray(N);
long[] sum=new long[2*N+1];
sum[0]=0;
for(int i=1;i<=2*N;i++) sum[i]=sum[i-1]+(long)s[(i-1)%N];
long ans=0;
int l=0;
int m=1;
int r=2;
while(true){
if(r>=N) break;
long a=sum[l+N]-sum[r],b=sum[r]-sum[m],c=sum[m]-sum[l],res;
if(a<=b&&a<=c){
res=a;
if(m>l+1) l++;
else {
m++; l++;
}
}
else if(b<=a&&b<=c){
res=b;
r++;
}
else{
res=c;
if(r>m+1) m++;
else{
r++; m++;
}
}
ans=Math.max(ans,res);
}
out.println(ans);
}
public static void main(String[] args) throws Exception{
ir=new InputReader(System.in);
out=new PrintWriter(System.out);
solve();
out.flush();
}
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:17: error: cannot find symbol
N=ir.nextInt();
^
symbol: variable N
location: class Main
Main.java:18: error: cannot find symbol
int[] s=ir.nextIntArray(N);
^
symbol: variable N
location: class Main
Main.java:19: error: cannot find symbol
long[] sum=new long[2*N+1];
^
symbol: variable N
location: class Main
Main.java:21: error: cannot find symbol
for(int i=1;i<=2*N;i++) sum[i]=sum[i-1]+(long)s[(i-1)%N];
^
symbol: variable N
location: class Main
Main.java:21: error: cannot find symbol
for(int i=1;i<=2*N;i++) sum[i]=sum[i-1]+(long)s[(i-1)%N];
^
symbol: variable N
location: class Main
Main.java:27: error: cannot find symbol
if(r>=N) break;
^
symbol: variable N
location: class Main
Main.java:28: error: cannot find symbol
long a=sum[l+N]-sum[r],b=sum[r]-sum[m],c=sum[m]-sum[l],res;
^
symbol: variable N
location: class Main
7 errors
|
s477610096 | p00523 | Java | import java.util.Scanner;
public class Baumkuchen {
public static void main(String[] args){
int B1 = 0;
int B2 = 0;
int B3 = 0;
int B4 = 0;
int Bmin = 0;
int BMIN = 0;
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int b[] = new int[n];
for(int x = 0; x <= n-1; x++){
b[x] = scan.nextInt();
}
for(int p = 1; p <= n-2; p++){
for(int q = p+1; q <= n-1; q++){
B1 = 0;
B2 = 0;
B3 = 0;
for(int i = 0; i <= p-1; i++){
B1 += b[i];
}
for(int j = p; j <= q-1; j++){
B2 += b[j];
}
for(int k = q; k <= n-1; k++){
B3 += b[k];
}
Bmin = Math.min(B1, B2);
Bmin = Math.min(Bmin, B3);
BMIN = Math.max(BMIN, Bmin);
}
}
for(int p = 1; p <= n-3; p++){
for(int q = p+1; q <= n-2; q++){
for(int r = q+1; r <= n-1; r++){
B1 = 0;
B2 = 0;
B3 = 0;
B4 = 0;
for(int i = 0; i <= p-1; i++){
B1 += b[i];
}
for(int j = p; j <= q-1; j++){
B2 += b[j];
}
for(int k = q; k <= r-1; k++){
B3 += b[k];
}
for(int l = r; l <= n-1; l++){
B4 += b[l];
}
Bmin = Math.min(B1+B4, B2);
Bmin = Math.min(Bmin, B3);
BMIN = Math.max(BMIN, Bmin);
}
}
}
System.out.println("????°????????????§??????"+BMIN+"??§???");
}
} | Main.java:3: error: class Baumkuchen is public, should be declared in a file named Baumkuchen.java
public class Baumkuchen {
^
1 error
|
s135122699 | p00523 | Java | 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++){
A[i] = Integer.perseInt(br.readLine())//引数に戻り値のあるメソッドを指定してよいかわからない
}
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);
}
}
| Main.java:16: error: ';' expected
A[i] = Integer.perseInt(br.readLine())//??????????????????????????
^
1 error
|
s213421696 | p00523 | Java | 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);
}
}
| Main.java:16: error: ';' expected
str = br.readLine()
^
Main.java:17: error: ';' expected
A[i] = Integer.perseInt(str)//??????????????????????????
^
2 errors
|
s563870074 | p00523 | Java | import java.io.*;
public class Main{
public static void main(String[] args) throws IOException{
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);
}
}
| Main.java:6: error: cannot find symbol
BufferedReader br = BufferedReader(is);
^
symbol: method BufferedReader(InputStreamReader)
location: class Main
Main.java:9: error: cannot find symbol
int kosuu = Integer.perseInt(str);
^
symbol: method perseInt(String)
location: class Integer
Main.java:17: error: cannot find symbol
A[i] = Integer.perseInt(str);//??????????????????????????
^
symbol: method perseInt(String)
location: class Integer
3 errors
|
s883553113 | 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 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);
}
}
| Main.java:9: error: cannot find symbol
int kosuu = Integer.perseInt(str);
^
symbol: method perseInt(String)
location: class Integer
Main.java:17: error: cannot find symbol
A[i] = Integer.perseInt(str);//??????????????????????????
^
symbol: method perseInt(String)
location: class Integer
2 errors
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.