submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s376280853 | p00118 | C++ | #include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 105;
int h, w;
char Map[maxn][maxn];
int dir[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
void Dfs(int x, int y, char c){
Map[x][y] = '.';
for(int i = 0; i < 4; i++){
int xx = x + dir[i][0];
int yy = y + dir[i][1];
if(xx >= 0 && xx < h && yy >= 0 && yy < w && Map[xx][yy] == c){
Dfs(xx, yy, c);
}
}
}
int main(){
while(~scanf("%d%d",&h, &w)){
if(!h + !w)) break;
int ans = 0;
for(int i = 0; i < h; i++)
scanf("%s",Map[i]);
for(int i = 0; i < h; i++){
for(int j = 0; j < h; j++){
if(Map[i][j] != '.'){
Dfs(i, j, Map[i][j]);
ans++;
}
}
}
printf("%d\n",ans);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:20:20: error: expected primary-expression before ')' token
20 | if(!h + !w)) break;
| ^
|
s539138442 | p00118 | C++ | import java.util.*;
class Main {
public static int[] dx = {-1, 0, 1, 0};
public static int[] dy = {0, -1, 0, 1};
public static void dfs(int x, int y, char[][] region, int n, int m)
{
char c = region[x][y];
region[x][y] = 'x';
for(int i=0;i<4;i++)
{
int new_x = x + dx[i];
int new_y = y + dy[i];
if(new_x >= 0 && new_x < n && new_y >= 0 && new_y < m && region[new_x][new_y] == c)
{
dfs(new_x, new_y, region,n, m);
}
}
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
while(true)
{
int m = sc.nextInt();
int n = sc.nextInt();
String temp = sc.nextLine();
if(m==0&&n==0)
{
return;
}
// System.out.println(m+" "+n);
char[][] region = new char[m][n];
for(int i=0;i<m;i++)
{
// System.out.println(i);
String line = sc.nextLine();
// System.out.println(line);
for(int j=0;j<n;j++)
{
region[i][j] = line.charAt(j);
}
}
int res = 0;
for(int i=0;i<m;i++)
{
for(int j=0; j<n;j++)
{
if(region[i][j] == 'x')
continue;
else
{
res += 1;
dfs(i,j, region, n, m);
}
}
}
System.out.println(res);
}
}
}
| a.cc:1:1: error: 'import' does not name a type
1 | import java.util.*;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:11: error: expected ':' before 'static'
4 | public static int[] dx = {-1, 0, 1, 0};
| ^~~~~~~
| :
a.cc:4:22: error: expected unqualified-id before '[' token
4 | public static int[] dx = {-1, 0, 1, 0};
| ^
a.cc:5:11: error: expected ':' before 'static'
5 | public static int[] dy = {0, -1, 0, 1};
| ^~~~~~~
| :
a.cc:5:22: error: expected unqualified-id before '[' token
5 | public static int[] dy = {0, -1, 0, 1};
| ^
a.cc:6:11: error: expected ':' before 'static'
6 | public static void dfs(int x, int y, char[][] region, int n, int m)
| ^~~~~~~
| :
a.cc:6:49: error: multidimensional array must have bounds for all dimensions except the first
6 | public static void dfs(int x, int y, char[][] region, int n, int m)
| ^
a.cc:6:51: error: expected ',' or '...' before 'region'
6 | public static void dfs(int x, int y, char[][] region, int n, int m)
| ^~~~~~
a.cc:23:11: error: expected ':' before 'static'
23 | public static void main(String args[]) {
| ^~~~~~~
| :
a.cc:23:29: error: 'String' has not been declared
23 | public static void main(String args[]) {
| ^~~~~~
a.cc:64:2: error: expected ';' after class definition
64 | }
| ^
| ;
a.cc: In static member function 'static void Main::dfs(...)':
a.cc:8:18: error: 'region' was not declared in this scope
8 | char c = region[x][y];
| ^~~~~~
a.cc:13:29: error: 'dx' was not declared in this scope; did you mean 'x'?
13 | int new_x = x + dx[i];
| ^~
| x
a.cc:14:29: error: 'dy' was not declared in this scope; did you mean 'y'?
14 | int new_y = y + dy[i];
| ^~
| y
a.cc:15:38: error: 'n' was not declared in this scope
15 | if(new_x >= 0 && new_x < n && new_y >= 0 && new_y < m && region[new_x][new_y] == c)
| ^
a.cc:15:65: error: 'm' was not declared in this scope
15 | if(new_x >= 0 && new_x < n && new_y >= 0 && new_y < m && region[new_x][new_y] == c)
| ^
a.cc: In static member function 'static void Main::main(int*)':
a.cc:24:9: error: 'Scanner' was not declared in this scope
24 | Scanner sc = new Scanner(System.in);
| ^~~~~~~
a.cc:27:21: error: 'sc' was not declared in this scope
27 | int m = sc.nextInt();
| ^~
a.cc:29:13: error: 'String' was not declared in this scope
29 | String temp = sc.nextLine();
| ^~~~~~
a.cc:35:17: error: structured binding declaration cannot have type 'char'
35 | char[][] region = new char[m][n];
| ^~
a.cc:35:17: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:35:17: error: empty structured binding declaration
a.cc:35:19: error: expected initializer before '[' token
35 | char[][] region = new char[m][n];
| ^
a.cc:39:24: error: expected ';' before 'line'
39 | String line = sc.nextLine();
| ^~~~
a.cc:43:21: error: 'region' was not declared in this scope
43 | region[i][j] = line.charAt(j);
| ^~~~~~
a.cc:43:36: error: 'line' was not declared in this scope
43 | region[i][j] = line.charAt(j);
| ^~~~
a.cc:52:24: error: 'region' was not declared in this scope
52 | if(region[i][j] == 'x')
| ^~~~~~
a.cc:61:13: error: 'System' was not declared in this scope
61 | System.out.println(res);
| ^~~~~~
|
s345635335 | p00118 | C++ | #include <iostream>
using namespace std;
#define MaxH 20
#define MaxW 20
int W,H;
bool visited[MaxH][MaxW];
char A[MaxH][MaxW];
int dx[4] = {-1,0,1,0},dy[4] = {0,1,0,-1};
void dfs(int x, int y){
for (int i = 0; i < 4; ++i) {
int nextx = x + dx[i];
int nexty = y + dy[i];
if (nextx >=0 && nextx < H && nexty < W && nexty >= 0){
if (!visited[nextx][nexty]){
if ( A[x][y] == A[nextx][nexty]){
visited[nextx][nexty] = true;
dfs(nextx, nexty);
}else
continue;
}
}
}
}
int main(){
while(cin>>W>>H && W && H) {
// cin >> W >> H;
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
cin >> A[i][j];
}
}
int res = 0;
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
if (!visited[i][j]) {
dfs(i, j);
res++;
}
}
}
cout << res;
}
return 0;
| a.cc: In function 'int main()':
a.cc:49:14: error: expected '}' at end of input
49 | return 0;
| ^
a.cc:29:11: note: to match this '{'
29 | int main(){
| ^
|
s928331398 | p00118 | C++ | #include <iostream>
using namespace std;
#define MaxH 20
#define MaxW 20
int W,H;
bool visited[MaxH][MaxW];
char A[MaxH][MaxW];
int dx[4] = {-1,0,1,0},dy[4] = {0,1,0,-1};
void dfs(int x, int y){
for (int i = 0; i < 4; ++i) {
int nextx = x + dx[i];
int nexty = y + dy[i];
if (nextx >=0 && nextx < H && nexty < W && nexty >= 0){
if (!visited[nextx][nexty]){
if ( A[x][y] == A[nextx][nexty]){
visited[nextx][nexty] = true;
dfs(nextx, nexty);
}else
continue;
}
}
}
}
int main(){
while(cin>>W>>H && W!=0 && H!=0) {
// cin >> W >> H;
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
cin >> A[i][j];
}
}
int res = 0;
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
if (!visited[i][j]) {
dfs(i, j);
res++;
}
}
}
cout << res;
}
return 0;
| a.cc: In function 'int main()':
a.cc:49:14: error: expected '}' at end of input
49 | return 0;
| ^
a.cc:29:11: note: to match this '{'
29 | int main(){
| ^
|
s114642618 | p00118 | C++ | #include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
ssss
using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int h, w;
char ch[200][200];
int fl[200][200];
void dfs(int x, int y) {
fl[x][y] = 0;
int dx[] = { -1,0,1,0 };
int dy[] = { 0,1,0,-1 };
int nx, ny;
printf("(%d,%d)", x, y);
fori0(4) {
nx = x + dx[i];
ny = y + dy[i];
if (0 <= nx && nx < h && 0 <= ny && ny < w&&fl[nx][ny]&&ch[x][y]==ch[nx][ny]) { dfs(nx, ny); }
}
return;
}
int main() {
int co;
while (1) {
co = 0;
cin >> h >> w;
if (h == 0 && w == 0)break;
fori0(h)forj0(w) {
cin >> ch[i][j];
fl[i][j] = 1;
}
fori0(h)forj0(w) {
if (fl[i][j]) {
//fl[i][j] = 0;
co++;
dfs(i, j);
}
}
printf("%d\n", co);
}
//system("pause");
return 0;
}
| a.cc:7:1: error: 'ssss' does not name a type
7 | ssss
| ^~~~
a.cc: In function 'int main()':
a.cc:43:17: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
43 | cin >> h >> w;
| ^~~
| std::cin
In file included from a.cc:3:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
|
s024981243 | p00118 | C++ | #include <iostream>
#include <cstdio>
#include <queue>
#include <memory.h>
using namespace std;
const int LIM = 100;
char m[LIM][LIM];
bool vis[LIM][LIM + 1];
int R, C;
struct node {
int r, c;
} DIR[] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
void bfs(const int & r, const int & c, char ch) {
queue<node> q;
node crt = {r, c};
vis[r][c] = true;
q.push(crt);
while (!q.empty()) {
crt = q.front();
q.pop();
m[crt.r][crt.c] = '!';
node next;
for (int i = 0; i < 4; i++) {
next.r = crt.r + DIR[i].r;
next.c = crt.c + DIR[i].c;
if (!vis[next.r][next.c] && m[next.r][next.c] == ch && next.r >= 0 && next.r < R && next.c >= 0 && next.c < C) {
vis[next.r][next.c] = true;
q.push(next);
}
}
}
}
int main(void) {
while (~scanf("%d%d", &R, &C) && R && C) {
int cnt = 0;
getchar();
memset(vis, false, sizeof vis);
for (int i = 0; i < R; i++)
gets(m[i]);
for (int i = 0; i < R; i++)
for (int j = 0; j < C; j++)
if (m[i][j] != '!') {
cnt++;
bfs(i, j, m[i][j]);
}
printf("%d\n", cnt);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:46:13: error: 'gets' was not declared in this scope; did you mean 'getw'?
46 | gets(m[i]);
| ^~~~
| getw
|
s904699754 | p00118 | C++ |
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=110;
int next[][2]={{0,1},{1,0},{0,-1},{-1,0}};
int h,w;
char s[maxn][maxn];
int safe(int row,int col)
{
return row<h&&row>=0&&col<w&&col>=0;
}
void dfs(int row,int col)
{
char c=s[row][col];
s[row][col]='.';
for(int i=0;i<4;i++){
int x=row+next[i][0];
int y=col+next[i][1];
if(safe(x,y)&&s[x][y]==c){
dfs(x,y);
}
}
return ;
}
int main()
{
while(scanf("%d%d",&h,&w)!=EOF){
if(h==0&&w==0){
break;
}else{
for(int i=0;i<h;i++){
scanf("%s",s[i]);
}
/*for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
printf("%c",s[i][j]);
}
printf("\n");
}*/
int ans=0;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(s[i][j]!='.'){
ans++;
dfs(i,j);
}
}
}
printf("%d\n",ans);
}
}
return 0;
}
| a.cc: In function 'void dfs(int, int)':
a.cc:22:27: error: reference to 'next' is ambiguous
22 | int x=row+next[i][0];
| ^~~~
In file included from /usr/include/c++/14/string:47,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:8:5: note: 'int next [4][2]'
8 | int next[][2]={{0,1},{1,0},{0,-1},{-1,0}};
| ^~~~
a.cc:23:27: error: reference to 'next' is ambiguous
23 | int y=col+next[i][1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:8:5: note: 'int next [4][2]'
8 | int next[][2]={{0,1},{1,0},{0,-1},{-1,0}};
| ^~~~
|
s389412403 | p00118 | C++ | #include<bits./stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i<k,i++)
int H,W;
char m[102][102];
int dx[4]={1,0,-1,0}
int dy[4]=(0,1,0,-1)
void DFS(int x,int y,char c){
if(m[x][y]!='c')break;
m[x][y]='.';
rep(i,0.4){
DFS(x+dx[i],y+dy[i],c);
}
}
int main(){
cin >>H>>W;
while(H!=0){
int count =0;
rep(i,0,102)rep(j,0,102)m[i][j]='.';
rep(i,1,H)rep(j,1,W)cin >>m[i][j];
rep(i,1,H)rep(j,1,W){
if(m[i][j]!='.'){
DFS(i,j,m[i][j]);
count++;
}
}
cout << count<<endl;
cin >> H>>W;
}
return 0;
}
| a.cc:1:9: fatal error: bits./stdc++.h: No such file or directory
1 | #include<bits./stdc++.h>
| ^~~~~~~~~~~~~~~~
compilation terminated.
|
s300401748 | p00118 | C++ | #include <iostream>
using namespace std;
char F[102][102];
void DFS(int Y,int X,char c){
if(F[Y][X]!=c){
return;
}
F[Y][X] = c;
DFS(Y-1,X );
DFS(Y-1,X+1);
DFS(Y ,X+1);
DFS(Y+1,X+1);
DFS(Y+1,X );
DFS(Y+1,X-1);
DFS(Y ,X-1);
DFS(Y-1,X-1);
}
int main(){
int N,M;
cin >> N >> M;
for(int y=1;y<=N;y++){
for(int x=1;x<=M;x++){
cin >> F[y][x];
}
}
int cnt = 0;
for(int y=1;y<=N;y++){
for(int x=1;x<=M;x++){
if(F[y][x]=='@'){
cnt++;
DFS(y,x,'@');
}
}
}
for(int y=1;y<=N;y++){
for(int x=1;x<=M;x++){
if(F[y][x]=='#'){
cnt++;
DFS(y,x,'#');
}
}
}
for(int y=1;y<=N;y++){
for(int x=1;x<=M;x++){
if(F[y][x]=='*'){
cnt++;
DFS(y,x,'*');
}
}
}
cout << cnt << endl;
return 0;
}
| a.cc: In function 'void DFS(int, int, char)':
a.cc:13:6: error: too few arguments to function 'void DFS(int, int, char)'
13 | DFS(Y-1,X );
| ~~~^~~~~~~~~
a.cc:6:6: note: declared here
6 | void DFS(int Y,int X,char c){
| ^~~
a.cc:14:6: error: too few arguments to function 'void DFS(int, int, char)'
14 | DFS(Y-1,X+1);
| ~~~^~~~~~~~~
a.cc:6:6: note: declared here
6 | void DFS(int Y,int X,char c){
| ^~~
a.cc:15:6: error: too few arguments to function 'void DFS(int, int, char)'
15 | DFS(Y ,X+1);
| ~~~^~~~~~~~~
a.cc:6:6: note: declared here
6 | void DFS(int Y,int X,char c){
| ^~~
a.cc:16:6: error: too few arguments to function 'void DFS(int, int, char)'
16 | DFS(Y+1,X+1);
| ~~~^~~~~~~~~
a.cc:6:6: note: declared here
6 | void DFS(int Y,int X,char c){
| ^~~
a.cc:17:6: error: too few arguments to function 'void DFS(int, int, char)'
17 | DFS(Y+1,X );
| ~~~^~~~~~~~~
a.cc:6:6: note: declared here
6 | void DFS(int Y,int X,char c){
| ^~~
a.cc:18:6: error: too few arguments to function 'void DFS(int, int, char)'
18 | DFS(Y+1,X-1);
| ~~~^~~~~~~~~
a.cc:6:6: note: declared here
6 | void DFS(int Y,int X,char c){
| ^~~
a.cc:19:6: error: too few arguments to function 'void DFS(int, int, char)'
19 | DFS(Y ,X-1);
| ~~~^~~~~~~~~
a.cc:6:6: note: declared here
6 | void DFS(int Y,int X,char c){
| ^~~
a.cc:20:6: error: too few arguments to function 'void DFS(int, int, char)'
20 | DFS(Y-1,X-1);
| ~~~^~~~~~~~~
a.cc:6:6: note: declared here
6 | void DFS(int Y,int X,char c){
| ^~~
|
s997651847 | p00118 | C++ | int main(){
while(1){
int N,M;
cin>>N>>M;
if(N==0&&M==0){
break;
}
for(int h=1;h<=N;h++){
for(int w=1;w<=M;w++){
cin>>F[h][w];
}
}
int cnt=0;
for(int h=1;h<=N;h++){
for(int w=1;w<=M;w++){
if(F[h][w]=='@'){
cnt++;
DFS(h,w,'@');
}else if(F[h][w]=='#'){
cnt++;
DFS(h,w,'#');
}else if(F[h][w]=='*'){
cnt++;
DFS(h,w,'*');
}
}
}
cout<<cnt<<endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope
4 | cin>>N>>M;
| ^~~
a.cc:10:12: error: 'F' was not declared in this scope
10 | cin>>F[h][w];
| ^
a.cc:17:10: error: 'F' was not declared in this scope
17 | if(F[h][w]=='@'){
| ^
a.cc:19:9: error: 'DFS' was not declared in this scope
19 | DFS(h,w,'@');
| ^~~
a.cc:22:9: error: 'DFS' was not declared in this scope
22 | DFS(h,w,'#');
| ^~~
a.cc:25:11: error: 'DFS' was not declared in this scope
25 | DFS(h,w,'*');
| ^~~
a.cc:29:3: error: 'cout' was not declared in this scope
29 | cout<<cnt<<endl;
| ^~~~
a.cc:29:14: error: 'endl' was not declared in this scope
29 | cout<<cnt<<endl;
| ^~~~
|
s643116617 | p00118 | C++ | #include <iostream>
using namespace std;
char F[100][100];
void DFS(int H, int W, char c){
if(F[H][W]!=c)
return;
F[H][W] = '.';
DFS(H-1, W ,c);
DFS(H , W+1,c);
DFS(H+1, W ,c);
DFS(H , W-1,c);
}
int main(){
int N,M;
cin >> N >> M;
for(int y=1; y<=N; y++)
for(int x=1; x<=M; x++)
cin >> F[y][x];
int cnt = 0;
for(int y=1; y<=N; y++)
for(int x=1; x<=M; x++)
if(F[y][x]!='.'){
cnt++;
DFS(y, x, F[y][x]);
}
cout << cnt << endl;
}
while(true){
int w,h;
cin >> w >> h;
if(w==0){
break;
}
}
return 0;
}
| a.cc:34:1: error: expected unqualified-id before 'while'
34 | while(true){
| ^~~~~
a.cc:41:3: error: expected unqualified-id before 'return'
41 | return 0;
| ^~~~~~
a.cc:42:1: error: expected declaration before '}' token
42 | }
| ^
|
s957876350 | p00118 | C++ | #include<iostream>
using namespace std;
char F[102][102];
void DFS(int y, int x, char a){#include<iostream>
using namespace std;
char F[102][102];
void DFS(int y, int x, char a){
if(F[y][x]!=a){
return;
}
F[y][x]='.';
DFS(y-1,x,a);
DFS(y,x+1,a);
DFS(y+1,x,a);
DFS(y,x-1,a);
}
int main(){
int n,m;
while(1){
cin >> n >> m;
if(n==m==0){
break;
}
for(int y=1; y<=n; y++){
for(int x=1; x<=m; x++){
cin >> F[y][x];
}
}
int cnt=0;
for(int y=1; y<=n; y++){
for(int x=1; x<=m; x++){
if(F[y][x]=='#'){
cnt++;
DFS(y,x,'#');
}
if(F[y][x]=='*'){
cnt++;
DFS(y,x,'*');
}
if(F[y][x]=='@'){
cnt++;
DFS(y,x,'@');
}
}
}
cout << cnt << endl;
return 0;
}
}
if(F[y][x]!=a){
return;
}
F[y][x]='.';
DFS(y-1,x,a);
DFS(y,x+1,a);
DFS(y+1,x,a);
DFS(y,x-1,a);
}
int main(){
int n,m;
while(1){
cin >> n >> m;
if(n==m==0){
break;
}
for(int y=1; y<=n; y++){
for(int x=1; x<=m; x++){
cin >> F[y][x];
}
}
int cnt=0;
for(int y=1; y<=n; y++){
for(int x=1; x<=m; x++){
if(F[y][x]=='#'){
cnt++;
DFS(y,x,'#');
}
if(F[y][x]=='*'){
cnt++;
DFS(y,x,'*');
}
if(F[y][x]=='@'){
cnt++;
DFS(y,x,'@');
}
}
}
cout << cnt << endl;
return 0;
}
}
| a.cc:6:32: error: stray '#' in program
6 | void DFS(int y, int x, char a){#include<iostream>
| ^
a.cc: In function 'void DFS(int, int, char)':
a.cc:6:33: error: 'include' was not declared in this scope
6 | void DFS(int y, int x, char a){#include<iostream>
| ^~~~~~~
a.cc:6:49: error: expected primary-expression before '>' token
6 | void DFS(int y, int x, char a){#include<iostream>
| ^
a.cc:7:1: error: expected primary-expression before 'using'
7 | using namespace std;
| ^~~~~
a.cc:11:31: error: a function-definition is not allowed here before '{' token
11 | void DFS(int y, int x, char a){
| ^
a.cc:23:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
23 | int main(){
| ^~
a.cc:23:9: note: remove parentheses to default-initialize a variable
23 | int main(){
| ^~
| --
a.cc:23:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:23:11: error: a function-definition is not allowed here before '{' token
23 | int main(){
| ^
|
s739493883 | p00118 | C++ | nclude<iostream>
using namespace std;
char f[102][102];
char cnt_c[1];
void DFS(int y,int x){
if(f[y][x]=='.'||f[y][x]==0||f[y][x]!=cnt_c[0])return;
if(f[y][x]==cnt_c[0]){
f[y][x]='.';
}
DFS(y+1,x);
DFS(y-1,x);
DFS(y,x+1);
DFS(y,x-1);
}
int main(){
int H,W;
while(cin>>H>>W){
if(H==0&&W==0)return 0;
for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){
cin>>f[i][j];
}
}
int cnt=0;
for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){
if(f[i][j]=='@'||f[i][j]=='#'||f[i][j]=='*'){
cnt_c[0]=f[i][j];
DFS(i,j);
cnt++;
}
}
}
cout<<cnt<<endl;
}
}
| a.cc:1:1: error: 'nclude' does not name a type
1 | nclude<iostream>
| ^~~~~~
a.cc: In function 'int main()':
a.cc:20:9: error: 'cin' was not declared in this scope
20 | while(cin>>H>>W){
| ^~~
a.cc:37:7: error: 'cout' was not declared in this scope
37 | cout<<cnt<<endl;
| ^~~~
a.cc:37:18: error: 'endl' was not declared in this scope
37 | cout<<cnt<<endl;
| ^~~~
|
s073971956 | p00118 | C++ | import java.util.Scanner;
import java.util.Queue;
import java.util.Stack;
public class Main {
int H, W;
char[][] map;
int res;
char tmp;
char ringo = '@', kaki = '#', mikan = '*', non = '.';
void deback() {
for(int i = 0; i < H; i++) {
for(int j = 0; j < W; j++) {
System.out.print(map[i][j]);
}
System.out.println();
}
System.out.println();
}
void dfs(int y, int x) {
if(y < 0 || x < 0 || y >= H || x >= W) return;
// deback();
if(tmp == map[y][x]) {
map[y][x] = non;
dfs(y, x+1);
dfs(y+1, x);
dfs(y, x-1);
dfs(y-1, x);
}
}
void solve() {
res = 0;
for(int i = 0; i < H; i++) {
for(int j = 0; j < W; j++) {
if(map[i][j] == '.') continue;
tmp = map[i][j];
dfs(i, j);
res += 1;
// deback();
}
}
System.out.println(res);
}
void run() {
Scanner scan = new Scanner(System.in);
while(true) {
H = scan.nextInt();
W = scan.nextInt();
if (H==0 && W==0) break;
map = new char[H][];
for(int i = 0; i < H; i++) {
map[i] = scan.next().toCharArray();
}
// System.out.println(map[0][9]);
solve();
}
}
public static void main(String[] args) {
new Main().run();
}
}
| a.cc:1:1: error: 'import' does not name a type
1 | import java.util.Scanner;
| ^~~~~~
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.Queue;
| ^~~~~~
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.Stack;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
5 | public class Main {
| ^~~~~~
|
s748772801 | p00118 | C++ | //
// main.cpp
//
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits>
#include <math.h>
#include <queue>
#include <tuple>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "string.h"
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <set>
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0118
using namespace std;
// #define TEST
#ifdef TEST
static const string g_SAMPLE = R"(10 10
####*****@
@#@@@@#*#*
@##***@@@*
#****#*@**
##@*#@@*##
*@@@@*@@@#
***#@*@##*
*@@@*@@##@
*@*#*@##**
@****#@@#@
0 0)";
static FILE* g_IN_FP;
static const char* g_IN_FN = "in.txt";
#define scanf(...) fscanf(g_IN_FP, __VA_ARGS__)
#endif // TEST
int main() {
#ifdef TEST
g_IN_FP = fopen(g_IN_FN, "w");
fwrite(g_SAMPLE.c_str(), 1, g_SAMPLE.size(), g_IN_FP);
fclose(g_IN_FP);
g_IN_FP = fopen(g_IN_FN, "r");
#endif // TEST
while (true) {
int W, H;
scanf("%d %d", &W, &H);
if (W == 0 && H == 0) {
return 0;
}
unique_ptr<char[]> field(new char[W * H]);
for (int i = 0; i < H; i++) {
scanf("%s", field.get()+(W*i));
}
vector<int> stack;
stack.reserve(W*H);
int count = 0;
for (int x = 0; x < W; x++) {
for (int y = 0; y < H; y++) {
if (field[x+y*W] == 'X') {
continue;
}
count++;
char fruit = field[x+y*W];
stack.push_back(x+y*W);
field[x+y*W] = 'X';
while (!stack.empty()) {
int idx = stack.back();
stack.pop_back();
int cx = idx % W;
int cy = idx / W;
for (int dx = 0; dx < 2; dx++) {
for (int dy = 0; dy < 2; dy++) {
int nx = cx + -1 + 1*dx + 1*dy;
int ny = cy + 0 + (-1)*dx + 1*dy;
if (nx < 0 || nx >= W || ny < 0 || ny >= H) {
continue;
}
if (field[nx+ny*W] != fruit) {
continue;
}
stack.push_back(nx+ny*W);
field[nx+ny*W] = 'X';
}
}
}
#ifdef TEST
cout << "=====" << endl;
for (int y = 0; y < H; y++) {
for (int x = 0; x < W; x++) {
cout << field[x+y*W];
}
cout << endl;
}
cout << "=====" << endl;
#endif // TEST
}
}
cout << count << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:58:17: error: 'unique_ptr' was not declared in this scope
58 | unique_ptr<char[]> field(new char[W * H]);
| ^~~~~~~~~~
a.cc:20:1: note: 'std::unique_ptr' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
19 | #include <set>
+++ |+#include <memory>
20 |
a.cc:58:28: error: expected primary-expression before 'char'
58 | unique_ptr<char[]> field(new char[W * H]);
| ^~~~
a.cc:60:37: error: 'field' was not declared in this scope
60 | scanf("%s", field.get()+(W*i));
| ^~~~~
a.cc:67:37: error: 'field' was not declared in this scope
67 | if (field[x+y*W] == 'X') {
| ^~~~~
a.cc:71:46: error: 'field' was not declared in this scope
71 | char fruit = field[x+y*W];
| ^~~~~
|
s118644509 | p00118 | C++ | //
// main.cpp
//
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits>
#include <math.h>
#include <queue>
#include <tuple>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "string.h"
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <set>
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0118
using namespace std;
// #define TEST
#ifdef TEST
static const string g_SAMPLE = R"(10 10
####*****@
@#@@@@#*#*
@##***@@@*
#****#*@**
##@*#@@*##
*@@@@*@@@#
***#@*@##*
*@@@*@@##@
*@*#*@##**
@****#@@#@
0 0)";
static FILE* g_IN_FP;
static const char* g_IN_FN = "in.txt";
#define scanf(...) fscanf(g_IN_FP, __VA_ARGS__)
#endif // TEST
int main() {
#ifdef TEST
g_IN_FP = fopen(g_IN_FN, "w");
fwrite(g_SAMPLE.c_str(), 1, g_SAMPLE.size(), g_IN_FP);
fclose(g_IN_FP);
g_IN_FP = fopen(g_IN_FN, "r");
#endif // TEST
while (true) {
int W, H;
scanf("%d %d", &W, &H);
if (W == 0 && H == 0) {
return 0;
}
unique_ptr<char[]> field(new char[W * H]);
for (int i = 0; i < H; i++) {
scanf("%s", field.get()+(W*i));
}
vector<int> stack;
stack.reserve(W*H);
int count = 0;
for (int x = 0; x < W; x++) {
for (int y = 0; y < H; y++) {
if (field[x+y*W] == 'X') {
continue;
}
count++;
char fruit = field[x+y*W];
stack.push_back(x+y*W);
field[x+y*W] = 'X';
while (!stack.empty()) {
int idx = stack.back();
stack.pop_back();
int cx = idx % W;
int cy = idx / W;
for (int dx = 0; dx < 2; dx++) {
for (int dy = 0; dy < 2; dy++) {
int nx = cx + -1 + 1*dx + 1*dy;
int ny = cy + 0 + (-1)*dx + 1*dy;
if (nx < 0 || nx >= W || ny < 0 || ny >= H) {
continue;
}
if (field[nx+ny*W] != fruit) {
continue;
}
stack.push_back(nx+ny*W);
field[nx+ny*W] = 'X';
}
}
}
#ifdef TEST
cout << "=====" << endl;
for (int y = 0; y < H; y++) {
for (int x = 0; x < W; x++) {
cout << field[x+y*W];
}
cout << endl;
}
cout << "=====" << endl;
#endif // TEST
}
}
cout << count << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:58:9: error: 'unique_ptr' was not declared in this scope
58 | unique_ptr<char[]> field(new char[W * H]);
| ^~~~~~~~~~
a.cc:20:1: note: 'std::unique_ptr' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
19 | #include <set>
+++ |+#include <memory>
20 |
a.cc:58:20: error: expected primary-expression before 'char'
58 | unique_ptr<char[]> field(new char[W * H]);
| ^~~~
a.cc:60:25: error: 'field' was not declared in this scope
60 | scanf("%s", field.get()+(W*i));
| ^~~~~
a.cc:67:21: error: 'field' was not declared in this scope
67 | if (field[x+y*W] == 'X') {
| ^~~~~
a.cc:71:30: error: 'field' was not declared in this scope
71 | char fruit = field[x+y*W];
| ^~~~~
|
s900211666 | p00118 | C++ | #include<iostream>
using namespace std;
#define LP(i,N) for(int i=0;i<N;i++)
#define MAX 100
int H,W;
char map[MAX+1][MAX+1];
int dx[]={ 0, 1, 0,-1};
int dy[]={-1, 0, 1, 0};
void dfs(int h,int w,char fruit){
if(map[h][w]=='0')return ;
fruit
map[h][w]='0';
LP(i,4){
if(h+dy[i]<0||w+dx[i]<0||h+dy[i]>=W||w+dx[i]>=H||fruit!=map[h+dy[i]][w+dx[i]])continue;
dfs(h+dy[i],w+dx[i],fruit);
}
return ;
}
int
main(){
while(cin>>H>>W&&(H||W)){
int count=0;
LP(i,H){
LP(j,W)cin>>map[i][j];
}
LP(i,H){
LP(j,W)
if(map[i][j]!='0'){
count++;
dfs(i,j,map[i][j]);
}
}
cout<<count<<endl;
}
return 0;
} | a.cc: In function 'void dfs(int, int, char)':
a.cc:12:14: error: expected ';' before 'map'
12 | fruit
| ^
| ;
13 | map[h][w]='0';
| ~~~
|
s027135702 | p00118 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int farm[101][101];
void kubun(int k,int a,int b){
farm[a][b]=0;
if(k==farm[a-1][b])kubun(farm[a-1][b],a-1,b);
if(k==farm[a+1][b])kubun(farm[a+1][b],a+1,b);
if(k==farm[a][b-1])kubun(farm[a][b-1],a,b-1);
if(k==farm[a][b+1])kubun(farm[a][b+1],a,b+1);
}
int main(void){
char c[101][101];
int a,b;
int h,w;
int ans=0;
while(1){
ans=0;
memset(farm,0,sizeof(farm));
cin >> h >> w;
if(h==0 && w==0)break;
for(b=0;b<w;b++){
cin >> c[b];
for(a=0;a<h;a++){
if(c[b][a]=='@')farm[a][b]=1;
if(c[b][a]=='#')farm[a][b]=2;
if(c[b][a]=='*')farm[a][b]=3;
}
}
for(b=0;b<w;b++){
for(a=0;a<h;a++){
if(farm[a][b]==0);
else{
ans++;
kubun(farm[a][b],a,b);
}
}
}
cout<< ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:17: error: 'memset' was not declared in this scope
24 | memset(farm,0,sizeof(farm));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include<vector>
+++ |+#include <cstring>
5 | using namespace std;
|
s890617214 | p00118 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int farm[101][101];
void kubun(int k,int a,int b){
farm[a][b]=0;
if(k==farm[a-1][b])kubun(farm[a-1][b],a-1,b);
if(k==farm[a+1][b])kubun(farm[a+1][b],a+1,b);
if(k==farm[a][b-1])kubun(farm[a][b-1],a,b-1);
if(k==farm[a][b+1])kubun(farm[a][b+1],a,b+1);
return;
}
int main(void){
char c[101][101];
int a,b;
int h,w;
int ans=0;
while(1){
ans=0;
memset(farm,0,sizeof(farm));
cin >> h >> w;
if(h==0 && w==0)break;
for(b=0;b<w;b++){
cin >> c[b];
for(a=0;a<h;a++){
if(c[b][a]=='@')farm[a][b]=1;
if(c[b][a]=='#')farm[a][b]=2;
if(c[b][a]=='*')farm[a][b]=3;
}
}
for(b=0;b<w;b++){
for(a=0;a<h;a++){
if(farm[a][b]==0);
else{
ans++;
kubun(farm[a][b],a,b);
}
}
}
cout<< ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:25:17: error: 'memset' was not declared in this scope
25 | memset(farm,0,sizeof(farm));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include<vector>
+++ |+#include <cstring>
5 | using namespace std;
|
s105525563 | p00118 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int farm[101][101];
void kubun(int k,int a,int b){
farm[a][b]=0;
if(k==farm[a-1][b])kubun(farm[a-1][b],a-1,b);
if(k==farm[a+1][b])kubun(farm[a+1][b],a+1,b);
if(k==farm[a][b-1])kubun(farm[a][b-1],a,b-1);
if(k==farm[a][b+1])kubun(farm[a][b+1],a,b+1);
return;
}
int main(){
char c[101][101];
int a,b;
int h,w;
int ans=0;
while(1){
ans=0;
memset(farm,0,sizeof(farm));
cin >> h >> w;
if(h==0 && w==0)break;
for(b=0;b<w;b++){
cin >> c[b];
for(a=0;a<h;a++){
if(c[b][a]=='@')farm[a][b]=1;
if(c[b][a]=='#')farm[a][b]=2;
if(c[b][a]=='*')farm[a][b]=3;
}
}
for(b=0;b<w;b++){
for(a=0;a<h;a++){
if(farm[a][b]==0);
else{
ans++;
kubun(farm[a][b],a,b);
}
}
}
cout<< ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:25:17: error: 'memset' was not declared in this scope
25 | memset(farm,0,sizeof(farm));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include<vector>
+++ |+#include <cstring>
5 | using namespace std;
|
s887707317 | p00118 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int farm[101][101];
void kubun(int k,int a,int b){
farm[a][b]=0;
if(k==farm[a-1][b])kubun(farm[a-1][b],a-1,b);
if(k==farm[a+1][b])kubun(farm[a+1][b],a+1,b);
if(k==farm[a][b-1])kubun(farm[a][b-1],a,b-1);
if(k==farm[a][b+1])kubun(farm[a][b+1],a,b+1);
return;
}
int main(){
char c[101][101];
int a,b;
int h,w;
int ans=0;
while(1){
ans=0;
memset(farm,0,sizeof(farm));
cin >> h >> w;
if(h==0 && w==0)break;
for(b=0;b<w;b++){
cin >> c[b];
for(a=0;a<h;a++){
if(c[b][a]=='@')farm[a][b]=1;
if(c[b][a]=='#')farm[a][b]=2;
if(c[b][a]=='*')farm[a][b]=3;
}
}
for(b=0;b<w;b++){
for(a=0;a<h;a++){
if(farm[a][b]==0);
else{
ans++;
kubun(farm[a][b],a,b);
}
}
}
cout<< ans << "\n";
}
return 0;
} | a.cc: In function 'int main()':
a.cc:25:17: error: 'memset' was not declared in this scope
25 | memset(farm,0,sizeof(farm));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include<vector>
+++ |+#include <cstring>
5 | using namespace std;
|
s979392496 | p00118 | C++ | #include<iostream>
#include<string>
using namespace std;
int farm[101][101];
void kubun(int k,int a,int b){
farm[a][b]=0;
if(k==farm[a-1][b])kubun(farm[a-1][b],a-1,b);
if(k==farm[a+1][b])kubun(farm[a+1][b],a+1,b);
if(k==farm[a][b-1])kubun(farm[a][b-1],a,b-1);
if(k==farm[a][b+1])kubun(farm[a][b+1],a,b+1);
}
int main(){
char c[101][101];
int a,b;
int h,w;
int ans=0;
while(1){
ans=0;
memset(farm,0,sizeof(farm));
scanf("%d %d",&h,&w);
if(h==0 && w==0)break;
for(b=0;b<h;b++){
scanf("%s",c[b]);
for(a=0;a<w;a++){
if(c[b][a]=='@')farm[a][b]=1;
if(c[b][a]=='#')farm[a][b]=2;
if(c[b][a]=='*')farm[a][b]=3;
}
}
for(b=0;b<h;b++){
for(a=0;a<w;a++){
if(farm[a][b]==0);
else{
ans++;
kubun(farm[a][b],a,b);
}
}
}
printf("%d\n",ans);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:22:17: error: 'memset' was not declared in this scope
22 | memset(farm,0,sizeof(farm));
| ^~~~~~
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>
|
s702166213 | p00118 | C++ | #include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int h,w;
string s[100];
void newland(int i, int j) {
char t = s[i][j];
s[i][j] = '.';
if(j!=w-1 && t == s[i][j+1]) newland(i,j+1);
if(i!=h-1 && t == s[i+1][j]) newland(i+1,j);
if(j!=0 && t == s[i][j-1]) newland(i,j-1);
if(i!=0 && t == s[i-1][j]) newland(i-1,j);
}
void solve() {
int i,j;
while(1) {
int n=0
cin >> h >> w;
if(h==0) break;
for(i=0 ; i<h ; i++) {
cin >> s[i];
}
for(i=0 ; i<h ; i++) {
for(j=0 ; j<w ; j++) {
if(s[i][j]!='.') {
newland(i,j);
n++;
}
}
}
cout << n << endl;
}
}
int main(void) {
solve();
return 0;
} | a.cc: In function 'void solve()':
a.cc:22:5: error: expected ',' or ';' before 'cin'
22 | cin >> h >> w;
| ^~~
|
s726430112 | p00118 | C++ | #include <cstdio>
#define N_MAX 100
#define M_MAX 100
int N, M;
char Field[N][M+1]
int main(void) {
scanf("%d %d", &N, &M);
int i, j;
for(i = 0; i < N; i++) {
scanf("%s", Field[i]);
}
scanf("%d %d", &i, &j);
if(i == 0 && j == 0) return 1;
int count = 0;
for(i = 0; i < N; i++) {
for(j = 0; j < M; j++) {
if(Field[i][j] != '.') {
solve(i, j);
count++;
}
}
}
printf("%d", count);
return 0;
}
void solve(int x, int y) {
char tmp = Field[x][y];
Field[x][y] = '.';
int nx, ny;
for(int i = -1; i <= 1; i++) {
for(int j =-1; j<= 1; j++) {
nx = x + i;
ny = y + i;
if(0 <= nx && nx < N && 0<= ny && ny < M && Field[nx][ny] == tmp) {
solve(nx, ny);
}
}
}
return;
} | a.cc:9:1: error: expected initializer before 'int'
9 | int main(void) {
| ^~~
a.cc: In function 'void solve(int, int)':
a.cc:32:16: error: 'Field' was not declared in this scope
32 | char tmp = Field[x][y];
| ^~~~~
|
s609726531 | p00118 | C++ | #include <cstdio>
#define N_MAX 100
#define M_MAX 100
int N, M;
char Field[N][M+1];
int main(void) {
scanf("%d %d", &N, &M);
int i, j;
for(i = 0; i < N; i++) {
scanf("%s", Field[i]);
}
scanf("%d %d", &i, &j);
if(i == 0 && j == 0) return 1;
int count = 0;
for(i = 0; i < N; i++) {
for(j = 0; j < M; j++) {
if(Field[i][j] != '.') {
solve(i, j);
count++;
}
}
}
printf("%d", count);
return 0;
}
void solve(int x, int y) {
char tmp = Field[x][y];
Field[x][y] = '.';
int nx, ny;
for(int i = -1; i <= 1; i++) {
for(int j =-1; j<= 1; j++) {
nx = x + i;
ny = y + i;
if(0 <= nx && nx < N && 0<= ny && ny < M && Field[nx][ny] == tmp) {
solve(nx, ny);
}
}
}
return;
} | a.cc:7:16: error: size of array 'Field' is not an integral constant-expression
7 | char Field[N][M+1];
| ~^~
a.cc:7:12: error: size of array 'Field' is not an integral constant-expression
7 | char Field[N][M+1];
| ^
a.cc: In function 'int main()':
a.cc:22:17: error: 'solve' was not declared in this scope
22 | solve(i, j);
| ^~~~~
|
s174547704 | p00118 | C++ | #include <cstdio>
#define N_MAX 100
#define M_MAX 100
int N, M;
char Field[N_MAX][M_MAX+1];
int main(void) {
scanf("%d %d", &N, &M);
int i, j;
for(i = 0; i < N; i++) {
scanf("%s", Field[i]);
}
scanf("%d %d", &i, &j);
if(i == 0 && j == 0) return 1;
int count = 0;
for(i = 0; i < N; i++) {
for(j = 0; j < M; j++) {
if(Field[i][j] != '.') {
solve(i, j);
count++;
}
}
}
printf("%d", count);
return 0;
}
void solve(int x, int y) {
char tmp = Field[x][y];
Field[x][y] = '.';
int nx, ny;
for(int i = -1; i <= 1; i++) {
for(int j =-1; j<= 1; j++) {
nx = x + i;
ny = y + i;
if(0 <= nx && nx < N && 0<= ny && ny < M && Field[nx][ny] == tmp) {
solve(nx, ny);
}
}
}
return;
} | a.cc: In function 'int main()':
a.cc:22:17: error: 'solve' was not declared in this scope
22 | solve(i, j);
| ^~~~~
|
s944366759 | p00118 | C++ | #include<iostream>
using namespace std;
void dfs(int x,int y,char z);
char a[100][100];
int ans = 0;
int main(){
int h,w;
while(cin>>h>>w,h){
ans = 0;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
cin>>a[i][j];
}
}
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(a[i][j]!='.')dfs(i,j,a[i][j]),ans++;
}
}
cout<<ans<<endl;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
a[i][j] = '.';
}
}
}
return 0;
}
void dfs(int x,int y,char z){
a[x][y] = '.';
if(z==a[x][y+1]&&y+1<w)dfs(x,y+1,z);
if(z==a[x+1][y]&&x+1<h)dfs(x+1,y,z);
if(z==a[x][y-1]&&y-1>=0)dfs(x,y-1,z);
if(z==a[x-1][y]&&x-1>=0)dfs(x-1,y,z);
return;
} | a.cc: In function 'void dfs(int, int, char)':
a.cc:35:26: error: 'w' was not declared in this scope
35 | if(z==a[x][y+1]&&y+1<w)dfs(x,y+1,z);
| ^
a.cc:36:26: error: 'h' was not declared in this scope
36 | if(z==a[x+1][y]&&x+1<h)dfs(x+1,y,z);
| ^
|
s920096875 | p00118 | C++ | #include<algorithm>
#include<iostream>
#include<string.h>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
using namespace std;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
const double PI=acos(-1.0);
const int maxn=100010;
typedef __int64 ll;
char maze[150][150];
int n,m;
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
void dfs(int x,int y)
{
int i,nx,ny;
char t=maze[x][y];
maze[x][y]=0;
for(i=0;i<4;i++)
{
nx=x+dx[i];
ny=y+dy[i];
if(nx>=0&&nx<n&&ny>=0&&ny<m&&maze[nx][ny]==t)
dfs(nx,ny);
}
}
int main()
{
int i,j,ans;
while(scanf("%d%d",&n,&m),n||m)
{
ans=0;
for(i=0;i<n;i++)
scanf("%s",maze[i]);
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(maze[i][j]!=0)
{
ans++;
dfs(i,j);
}
}
}
printf("%d\n",ans);
}
return 0;
} | a.cc:18:9: error: '__int64' does not name a type; did you mean '__int64_t'?
18 | typedef __int64 ll;
| ^~~~~~~
| __int64_t
|
s469909202 | p00118 | C++ | //-*-coding:utf-8-*-
//----------------------------------------------------------
// module: main
//----------------------------------------------------------
#include <algorithm>
#include <vector>
#include <deque>
#include <map>
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX_S = 100+1;
int w;
int h;
char m[MAX_S][MAX_S]; // map
bool u[MAX_S][MAX_S]; // used
typedef pair<int, int> pos;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
pos getnext(int i, pos p){
p.first += dx[i];
p.second += dy[i];
return p;
}
void walk(int x, int y){
vector<pos> s;
s.push_back(pos(x, y));
char tile = m[y][x];
while(!s.empty()){
pos p = s.back();
s.pop_back();
if(u[p.second][p.first]) continue;
u[p.second][p.first] = true;
for (int i = 0; i < 4; ++i)
{
pos next = getnext(i, p);
if (m[next.second][next.first] != tile) continue;
s.push_back(next);
}
}
}
void solve(){
memset(u, 0, MAX_S*MAX_S);
int count = 0;
for (int i = 0; i < h; ++i)
{
for (int j = 0; j < w; ++j)
{
if(u[i][j]) continue;
count ++;
walk(j, i);
}
}
printf("%d\n", count);
};
int main(int argc, char *argv[])
{
while(true){
scanf("%d %d", &w, &h);
if(w <= 0) break;
for (int i = 0; i < h; ++i)
{
scanf("%s", m[i]);
}
solve();
}
return 0;
} | a.cc: In function 'void solve()':
a.cc:57:5: error: 'memset' was not declared in this scope
57 | memset(u, 0, MAX_S*MAX_S);
| ^~~~~~
a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
11 | #include <cstdio>
+++ |+#include <cstring>
12 |
|
s277504321 | p00118 | C++ | //-*-coding:utf-8-*-
//----------------------------------------------------------
// module: main
//----------------------------------------------------------
#include <algorithm>
#include <vector>
#include <deque>
#include <map>
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX_S = 100+1;
int w;
int h;
char m[MAX_S][MAX_S]; // map
bool u[MAX_S][MAX_S]; // used
typedef pair<int, int> pos;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
pos getnext(int i, pos p){
p.first += dx[i];
p.second += dy[i];
return p;
}
void walk(int x, int y){
vector<pos> s;
s.push_back(pos(x, y));
char tile = m[y][x];
while(!s.empty()){
pos p = s.back();
s.pop_back();
if(u[p.second][p.first]) continue;
u[p.second][p.first] = true;
for (int i = 0; i < 4; ++i)
{
pos next = getnext(i, p);
if (m[next.second][next.first] != tile) continue;
s.push_back(next);
}
}
}
void solve(){
memset(u, 0, MAX_S*MAX_S);
int count = 0;
for (int i = 0; i < h; ++i)
{
for (int j = 0; j < w; ++j)
{
if(u[i][j]) continue;
count ++;
walk(j, i);
}
}
printf("%d\n", count);
};
int main(int argc, char *argv[])
{
while(true){
scanf("%d %d", &w, &h);
if(w <= 0) break;
for (int i = 0; i < h; ++i)
{
scanf("%s", m[i]);
}
solve();
}
return 0;
} | a.cc: In function 'void solve()':
a.cc:57:5: error: 'memset' was not declared in this scope
57 | memset(u, 0, MAX_S*MAX_S);
| ^~~~~~
a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
11 | #include <cstdio>
+++ |+#include <cstring>
12 |
|
s152122820 | p00118 | C++ | #include <cstdio>
using namespace std;
const int MAX_H = 101;
const int MAX_W = 101;
int H, W;
char blocks[MAX_H][MAX_W];
int init() {
scanf("%d%d", &H, &W);
if (H == 0 && W == 0) return -1;
for (int i = 0; i < H; i++) {
scanf("%s", blocks[i]);
}
return 0;
}
void fill(int row, int col) {
char type = blocks[row][col];
blocks[row][col] = ' ';
int di[] = {1, -1, 0, 0};
int dj[] = {0, 0, 1, -1};
for (int k = 0; k < 4; k++) {
int ti = i + di[k];
int tj = j + dj[k];
if (0 <= ti && ti < H && 0 <= tj && tj < W) {
if (blocks[ti][tj] == type) {
fill(row, col);
}
}
}
}
void solve() {
int ans = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (blocks[i][j] != ' ') {
fill(i, j);
ans++;
}
}
}
printf("%d\n", ans);
}
int main() {
while (!init()) {
solve();
}
} | a.cc: In function 'void fill(int, int)':
a.cc:30:26: error: 'i' was not declared in this scope; did you mean 'ti'?
30 | int ti = i + di[k];
| ^
| ti
a.cc:31:26: error: 'j' was not declared in this scope; did you mean 'tj'?
31 | int tj = j + dj[k];
| ^
| tj
|
s313889513 | p00118 | C++ | #include <iostream>
using namespace std;
const int MAX_H = 1000;
const int MAX_W = 1000;
char field[MAX_H][MAX_W];
int dy[] = { 0, -1, 0, 1 };
int dx[] = { -1, 0, 1, 0 };
void dfs(int i, int j) {
char c = field[i][j];
if (c == 0) return;
field[i][j] = 0; // mark as visited
for (int k = 0; k < 4; k++) {
int new_i = i + dy[k];
int new_j = j + dx[k];
if (field[new_i][new_j] == c) {
dfs(new_i, new_j);
}
}
}
int main() {
while (1) {
int W, H;
cin >> H >> W;
if (W == 0 && H == 0) {
break;
}
int ans = 0;
memset(field, 0, MAX_W * MAX_H);
for (int i = 1; i <= H; i++) {
for (int j = 1; j <= W; j++) {
cin >> field[i][j];
}
}
for (int i = 1; i <= H; i++) {
for (int j = 1; j <= W; j++) {
if (field[i][j]) {
dfs(i, j);
ans++;
}
}
}
cout << ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:37:5: error: 'memset' was not declared in this scope
37 | memset(field, 0, MAX_W * MAX_H);
| ^~~~~~
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 |
|
s694257902 | p00118 | C++ | #include <iostream>
#include <cstdlib>
using namespace std;
const int MAX_H = 1000;
const int MAX_W = 1000;
char field[MAX_H][MAX_W];
int dy[] = { 0, -1, 0, 1 };
int dx[] = { -1, 0, 1, 0 };
void dfs(int i, int j) {
char c = field[i][j];
if (c == 0) return;
field[i][j] = 0; // mark as visited
for (int k = 0; k < 4; k++) {
int new_i = i + dy[k];
int new_j = j + dx[k];
if (field[new_i][new_j] == c) {
dfs(new_i, new_j);
}
}
}
int main() {
while (1) {
int W, H;
cin >> H >> W;
if (W == 0 && H == 0) {
break;
}
int ans = 0;
memset(field, 0, MAX_W * MAX_H);
for (int i = 1; i <= H; i++) {
for (int j = 1; j <= W; j++) {
cin >> field[i][j];
}
}
for (int i = 1; i <= H; i++) {
for (int j = 1; j <= W; j++) {
if (field[i][j]) {
dfs(i, j);
ans++;
}
}
}
cout << ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:38:5: error: 'memset' was not declared in this scope
38 | memset(field, 0, MAX_W * MAX_H);
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <cstdlib>
+++ |+#include <cstring>
3 |
|
s738996428 | p00118 | C++ | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef vector<int> veci;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define foreach(i, n) for (typeof(n) i = 0; i < (n); ++i)
#define foreach_eq(i, n) for (typeof(n) i = 0; i <= (n); ++i)
#define foreach_from(i, m, n) for (typeof(n) i = m; i < (n); ++i)
#define foreach_eq_from(i, m, n) for (typeof(n) i = m; i <= (n); ++i)
int dirctions[4][2] = {{0,-1}, {0,1}, {-1,0}, {1,0}};
#define MAX_H 100
#define MAX_W 100
int H, W;
char data[MAX_H][MAX_W];
stack<pii> stk;
int main() {
cin >> H >> W;
foreach (i, H) foreach (j, W) cin >> data[i][j];
int cnt = 0;
foreach (i, H) {
foreach (j, W) {
char self = data[i][j];
if (not self) continue;
++ cnt;
stk.push(pii(i,j));
while (not stk.empty()) {
pii pos = stk.top();
stk.pop();
foreach (d, 4) {
pii nxt = pii(pos.first + dirctions[d][0], pos.second + dirctions[d][1]);
if (nxt.first < 0 || H <= nxt.first || nxt.second < 0 || W <= nxt.second) continue;
if (data[nxt.first][nxt.second] != self) continue;
data[nxt.first][nxt.second] = 0;
stk.push(nxt);
}
}
}
}
cout << cnt << endl;
} | a.cc: In function 'int main()':
a.cc:41:42: error: reference to 'data' is ambiguous
41 | foreach (i, H) foreach (j, W) cin >> data[i][j];
| ^~~~
In file included from /usr/include/c++/14/deque:68,
from a.cc:4:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:36:6: note: 'char data [100][100]'
36 | char data[MAX_H][MAX_W];
| ^~~~
a.cc:46:25: error: reference to 'data' is ambiguous
46 | char self = data[i][j];
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:36:6: note: 'char data [100][100]'
36 | char data[MAX_H][MAX_W];
| ^~~~
a.cc:56:25: error: reference to 'data' is ambiguous
56 | if (data[nxt.first][nxt.second] != self) continue;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:36:6: note: 'char data [100][100]'
36 | char data[MAX_H][MAX_W];
| ^~~~
a.cc:57:21: error: reference to 'data' is ambiguous
57 | data[nxt.first][nxt.second] = 0;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:36:6: note: 'char data [100][100]'
36 | char data[MAX_H][MAX_W];
| ^~~~
|
s657394349 | p00118 | C++ | #include <stdio.h>
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
const int M = 186;
int n;
int m;
char g[M][M];
int dir[4][2] = {{0,-1},{0,1},{-1,0},{1,0}};
void dfs(int x,int y,char k)
{
int i;
int dx;
int dy;
for(i = 0 ;i < 4; i++)
{
dx = x+dir[i][0];
dy = y+dir[i][1];
if( 0<=dx < n && 0 <= dy < m && g[dx][dy] == k)
{
g[dx][dy] = 'b';
dfs(dx,dy,k);
}
}
}
void solve()
{
int i;
int j;
int count = 0;
while(scanf("%d%d",&n,&m)!=EOF)
{
if(n == 0 && m == 0)
{
break;
}
count = 0;
for(i=0;i<n;i++)
{
scanf("%s",g[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(g[i][j]!='b')
{
dfs(i,j,g[i][j]);
count++;
}
}
}
cout<<count<<endl;
}
}
int main()
{
solve();
return 0; | a.cc: In function 'int main()':
a.cc:65:18: error: expected '}' at end of input
65 | return 0;
| ^
a.cc:63:1: note: to match this '{'
63 | {
| ^
|
s858130273 | p00119 | Java | import java.util.Scanner;
import java.util.Deque;
import java.util.ArrayDeque;
public class Main {
static Scanner sc = new Scanner(System.in);
static int h, w;
static char fruitFarm;
static int dx = {-1, 0, 1, 0};
static int dy = {0, -1, 0, 1};
static Deque<int> stack;
public static void main(String args){
while (true) {
h = sc.nextInt();
w = sc.nextInt();
if (h == 0 && w == 0) break;
//fruitFarm???????????????
fruitFarm = new char[h][w];
for (int i = 0; i < h; i++) {
String s = sc.next();
for (int j = 0; j < w; j++) {
fruitFarm[i][j] = s.charAt(j);
}
}
int answer = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (fruitFarm[i][j] != '.') {
stack = new ArrayDeque<int>();
stack.offerLast(new int{i, j});
//stack??????????????£?????????????????§??????????????????????¨???????????????????????????????????????£???
while (!stack.isEmpty()) {
int xy = stack.pollLast();
int x = xy[0];
int y = xy[1];
dfs(x, y);
}
answer++;
}
}
}
System.out.println(answer);
}
}
static void dfs(int x, int y) {
char target = fruitFarm[x][y];
fruitFarm[x][y] = '.';
//?§??????????4??????????????????
for (int k = 0; k < 4; k++) {
int nx = x + dx[k];
int ny = y + dy[k];
//nx??¨ny???????????????????????????????????????????¨??????????????????????????????????????????????
if (target != '.' && nx >= 0 && nx <= h - 1 && ny >= 0 && ny <= w - 1 && fruitFarm[nx][ny] == target) {
stack.offerLast(new int{nx, ny});
}
}
}
} | Main.java:29: error: '[' expected
stack.offerLast(new int{i, j});
^
Main.java:54: error: '[' expected
stack.offerLast(new int{nx, ny});
^
2 errors
|
s181022060 | p00119 | C++ | #include <queue>
#include <cstdio>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
int n,m; scanf("%d%d",&n,&m);
vector<int> G[20];
int deg[20]={};
rep(i,m){
int u,v; scanf("%d%d",&u,&v); u--; v--;
G[u].push_back(v);
deg[v]++;
}
vector<int> ans;
bool vis[20]={};
while(count(vis,vis+n,false)>0){
rep(u,n) if(!vis[u] && deg[u]==0) {
vis[u]=true;
rep(i,G[u].size()){
int v=G[u][i];
deg[v]--;
}
if(u!=1) ans.push_back(u);
}
}
ans.push_back(1);
rep(u,n) printf("%d%c",ans[u]+1,u<n-1?' ':'\n');
return 0;
} | a.cc: In function 'int main()':
a.cc:20:15: error: 'count' was not declared in this scope
20 | while(count(vis,vis+n,false)>0){
| ^~~~~
|
s652366061 | p00119 | C++ | #include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
using namespace std;
vector<int> ans, usd(22), g[22];
void dfs(int s){
if(usd[s]) return;
usd[s]=1;
for(auto v: g[s]) if(!usd[v]) dfa(v);
ans.push_back(s);
}
int main()
{
int n,m;
cin >> m >> n;
rep(i,n){
int x,y; cin >>x >>y;
g[x-1].push_back(y-1);
}
rep(i,m) dfs(i);
for(int i=ans.size()-1;i>=0;i--) printf("%d\n",ans[i]+1);
return 0;
} | a.cc: In function 'void dfs(int)':
a.cc:13:39: error: 'dfa' was not declared in this scope; did you mean 'dfs'?
13 | for(auto v: g[s]) if(!usd[v]) dfa(v);
| ^~~
| dfs
|
s845283565 | p00119 | C++ | #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>
#include <map>
using namespace std;
typedef long long int lint;
void AOJ0119()
{
int m, n, x, y;
cin >> m >> n;
//??£??\?????????
vector< vector< int > > list(m + 1);
for (int i = 0; i < n; i++) {
cin >> x >> y;
list[x].push_back(y);
}
//L ??? ??????????????????????????????????????????????????????????????????
vector< int > L;
//S ??? ??\???????????????????????????????????????????????????
vector< int > S;
//??\???????????¨??????????????°
bool* flag = new bool[m + 1];
for (int i = 1; i <= m; i++) {
flag[i] = true;
}
for (int i = 1; i <= m; i++) {
for (auto itr = list[i].begin(); itr != list[i].end(); itr++) {
flag[*itr] = false;
}
}
for (int i = 1; i <= m; i++) {
if (flag[i]) {
S.push_back(i);
}
}
while (!S.empty()) {
int a = S.back();
L.push_back(a);
S.pop_back();
//foreach a ???????????? e ??¨????????????????????? b do
while (!list[a].empty()) {
int b = list[a].back();
list[a].pop_back();
bool found = false;
for (int i = 1; i <= m; i++) {
if (find(list[i].begin(), list[i].end(), b) != list[i].end()) {
found = true;
break;
}
}
if (!found) {
S.push_back(b);
}
}
}
for (auto itr = L.begin(); itr != L.end(); itr++) {
cout << *itr << endl;
}
delete[] flag;
return;
}
int main()
{
AOJ0119();
return 0;
} | a.cc: In function 'void AOJ0119()':
a.cc:67:41: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
67 | if (find(list[i].begin(), list[i].end(), b) != list[i].end()) {
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:7:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:67:41: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
67 | if (find(list[i].begin(), list[i].end(), b) != list[i].end()) {
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s992309308 | p00119 | C++ | #include <iostream>
#include <vector>
using namespace std;
struct st {int from, to;};
vector<st> v;
int main() {
int m, n, a, b;
cin >> m >> n;
int c[21];
fill(c, c+21, 0);
for (int i = 0;i < n;i++) {
cin >> a >> b;
v.push_back((st){a, v});
c[y]++;
}
for (int i = 0;i < m;i++) {
for (int j = 1;j <= m;j++) {
if (c[j] == 0) {
cout << j << endl;
c[j] = (1 << 10);
for (int k = 0;k < n;k++) {
c[v[k].to] -= (v[k].from == j);
}
break;
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:16:29: error: cannot convert 'std::vector<st>' to 'int' in initialization
16 | v.push_back((st){a, v});
| ^
| |
| std::vector<st>
a.cc:17:11: error: 'y' was not declared in this scope
17 | c[y]++;
| ^
|
s269600651 | p00119 | C++ | v#include <bits/stdc++.h>
using namespace std;
int main() {
int m, n; cin >> m >> n;
vector<vector<int>> g(m);
vector<int> cnt(m, 0);
while (n--) {
int x, y; cin >> x >> y;
--x; --y;
g[x].push_back(y);
++cnt[y];
}
vector<bool> used(m, false);
for (int i = 0; i < m; ++i) {
for (int j = 0; j < m; ++j) {
if (cnt[j] == 0 && !used[j]) {
cout << j + 1 << endl;
used[j] = true;
for (auto&& x : g[j]) cnt[x] = max(0, cnt[x] - 1);
}
}
}
return 0;
}
| a.cc:1:2: error: stray '#' in program
1 | v#include <bits/stdc++.h>
| ^
a.cc:1:1: error: 'v' does not name a type
1 | v#include <bits/stdc++.h>
| ^
a.cc: In function 'int main()':
a.cc:5:13: error: 'cin' was not declared in this scope
5 | int m, n; cin >> m >> n;
| ^~~
a.cc:6:3: error: 'vector' was not declared in this scope
6 | vector<vector<int>> g(m);
| ^~~~~~
a.cc:6:17: error: expected primary-expression before 'int'
6 | vector<vector<int>> g(m);
| ^~~
a.cc:7:10: error: expected primary-expression before 'int'
7 | vector<int> cnt(m, 0);
| ^~~
a.cc:11:5: error: 'g' was not declared in this scope
11 | g[x].push_back(y);
| ^
a.cc:12:7: error: 'cnt' was not declared in this scope; did you mean 'int'?
12 | ++cnt[y];
| ^~~
| int
a.cc:14:10: error: expected primary-expression before 'bool'
14 | vector<bool> used(m, false);
| ^~~~
a.cc:17:11: error: 'cnt' was not declared in this scope; did you mean 'int'?
17 | if (cnt[j] == 0 && !used[j]) {
| ^~~
| int
a.cc:17:27: error: 'used' was not declared in this scope
17 | if (cnt[j] == 0 && !used[j]) {
| ^~~~
a.cc:18:9: error: 'cout' was not declared in this scope
18 | cout << j + 1 << endl;
| ^~~~
a.cc:18:26: error: 'endl' was not declared in this scope
18 | cout << j + 1 << endl;
| ^~~~
a.cc:20:25: error: 'g' was not declared in this scope
20 | for (auto&& x : g[j]) cnt[x] = max(0, cnt[x] - 1);
| ^
a.cc:20:40: error: 'max' was not declared in this scope
20 | for (auto&& x : g[j]) cnt[x] = max(0, cnt[x] - 1);
| ^~~
|
s759667764 | p00119 | C++ | #include<iostream>
int main{
std::cout<<"Hello!"<<endl;
} | a.cc:3:5: error: cannot declare '::main' to be a global variable
3 | int main{
| ^~~~
a.cc:4:26: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
4 | std::cout<<"Hello!"<<endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
a.cc:4:30: error: expected '}' before ';' token
4 | std::cout<<"Hello!"<<endl;
| ^
a.cc:3:9: note: to match this '{'
3 | int main{
| ^
a.cc:5:1: error: expected declaration before '}' token
5 | }
| ^
|
s199288110 | p00119 | C++ | #include<iostream>
#include<vector>
using namespace std;
int main()
{
int n,m;
cin >> m >> n;
cerr << m >> " " << n << endl;
vector<int> per;
vector<vector<int> > G;
G.resize(m);
bool used[m];
per.resize(m);
for(int i=0;i<m;i++)
per[i] = 0,used[i] = false;
for(int i=0;i<n;i++)
{
int x,y;
cin >> x >> y;
cerr << x << " " << y << endl;
x--,y--;
per[y]++;
G[x].push_back(y);
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(used[j])
continue;
if(!per[j])
{
cout << j+1 << endl;
used[j] = true;
for(int k=0;k<G[j].size();k++)
per[G[j][k]]--;
break;
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:10:13: error: no match for 'operator>>' (operand types are 'std::basic_ostream<char>' and 'const char [2]')
10 | cerr << m >> " " << n << endl;
| ~~~~~~~~~ ^~ ~~~
| | |
| | const char [2]
| std::basic_ostream<char>
In file included from /usr/include/c++/14/string:55,
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/basic_string.tcc:835:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
835 | operator>>(basic_istream<_CharT, _Traits>& __in,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<_CharT, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
In file included from /usr/include/c++/14/bits/memory_resource.h:38,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)'
131 | operator>>(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:131:5: note: template argument deduction/substitution failed:
a.cc:10:8: note: cannot convert 'std::cerr.std::basic_ostream<char>::operator<<(m)' (type 'std::basic_ostream<char>') to type 'std::byte'
10 | cerr << m >> " " << n << endl;
| ~~~~~^~~~
In file included from /usr/include/c++/14/istream:1109,
from /usr/include/c++/14/iostream:42:
/usr/include/c++/14/bits/istream.tcc:978:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT&)'
978 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
| ^~~~~~~~
/usr/include/c++/14/bits/istream.tcc:978:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<_CharT, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:849:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char&)'
849 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:849:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<char, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:854:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char&)'
854 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:854:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<char, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:896:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT*)'
896 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:896:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<_CharT, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:939:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char*)'
939 | operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:939:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<char, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:945:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char*)'
945 | operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:945:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<char, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:1099:5: note: candidate: 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&)'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
/usr/include/c++/14/istream:1099:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/istream: In substitution of 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&) [with _Istream = std::basic_ostream<char>&; _Tp = const char (&)[2]]':
a.cc:10:16: required from here
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:1099:5: error: no type named 'type' in 'struct std::enable_if<false, void>'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
|
s929683455 | p00119 | C++ | #include<iostream>
#include<vector>
using namespace std;
int main()
{
int n,m;
cin >> m >> n;
cerr << m >> " " << n << endl;
vector<int> per;
vector<vector<int> > G;
G.resize(m);
bool used[m];
per.resize(m);
for(int i=0;i<m;i++)
per[i] = 0,used[i] = false;
for(int i=0;i<n;i++)
{
int x,y;
cin >> x >> y;
cerr << x << " " << y << endl;
x--,y--;
per[y]++;
G[x].push_back(y);
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(used[j])
continue;
if(!per[j])
{
cout << j+1 << endl;
used[j] = true;
for(int k=0;k<G[j].size();k++)
per[G[j][k]]--;
break;
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:10:13: error: no match for 'operator>>' (operand types are 'std::basic_ostream<char>' and 'const char [2]')
10 | cerr << m >> " " << n << endl;
| ~~~~~~~~~ ^~ ~~~
| | |
| | const char [2]
| std::basic_ostream<char>
In file included from /usr/include/c++/14/string:55,
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/basic_string.tcc:835:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
835 | operator>>(basic_istream<_CharT, _Traits>& __in,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<_CharT, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
In file included from /usr/include/c++/14/bits/memory_resource.h:38,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)'
131 | operator>>(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:131:5: note: template argument deduction/substitution failed:
a.cc:10:8: note: cannot convert 'std::cerr.std::basic_ostream<char>::operator<<(m)' (type 'std::basic_ostream<char>') to type 'std::byte'
10 | cerr << m >> " " << n << endl;
| ~~~~~^~~~
In file included from /usr/include/c++/14/istream:1109,
from /usr/include/c++/14/iostream:42:
/usr/include/c++/14/bits/istream.tcc:978:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT&)'
978 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
| ^~~~~~~~
/usr/include/c++/14/bits/istream.tcc:978:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<_CharT, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:849:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char&)'
849 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:849:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<char, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:854:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char&)'
854 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:854:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<char, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:896:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT*)'
896 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:896:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<_CharT, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:939:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char*)'
939 | operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:939:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<char, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:945:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char*)'
945 | operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:945:5: note: template argument deduction/substitution failed:
a.cc:10:16: note: 'std::basic_ostream<char>' is not derived from 'std::basic_istream<char, _Traits>'
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:1099:5: note: candidate: 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&)'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
/usr/include/c++/14/istream:1099:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/istream: In substitution of 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&) [with _Istream = std::basic_ostream<char>&; _Tp = const char (&)[2]]':
a.cc:10:16: required from here
10 | cerr << m >> " " << n << endl;
| ^~~
/usr/include/c++/14/istream:1099:5: error: no type named 'type' in 'struct std::enable_if<false, void>'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
|
s474722615 | p00119 | C++ | #include <queue>
#include <cstdio>
using namespace std;
main(){
int n,m,x,y;
scanf("%d%d",&m,&n);
vector<vector<int> >v(m+1);
vector<int>c(m+1);
queue<int>q;
for(;n--;)scanf("%d%d",&x,&y),v[x].push_back(y),c[y]++;
for(x=1;x<=m;x++)if(!c[x])q.push(x);
for(;!q.empty();)for(printf("%d\n",n=q.front),q.pop(),x=0;x<v[n].size();x++)if(--c[v[n][x]]==0)q.push(v[n][x]);
} | a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
4 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:12:48: error: cannot resolve overloaded function 'front' based on conversion to type 'int'
12 | for(;!q.empty();)for(printf("%d\n",n=q.front),q.pop(),x=0;x<v[n].size();x++)if(--c[v[n][x]]==0)q.push(v[n][x]);
| ^~~~~
|
s201233372 | p00119 | C++ | $m = gets.to_i
$n = gets.to_i
$s = (1..$n).map{gets.split.map(&:to_i)}
def solve(a)
if a.size == $m
return a
end
$s.select{|e|a.include?(e[1])&& !a.include?(e[0])}.map{|e|
solve(a + [e[0]])
}.shuffle[0]
end
p solve([2]) | a.cc:3:7: error: too many decimal points in number
3 | $s = (1..$n).map{gets.split.map(&:to_i)}
| ^~~~~
a.cc:1:1: error: '$m' does not name a type
1 | $m = gets.to_i
| ^~
a.cc:5:1: error: 'def' does not name a type
5 | def solve(a)
| ^~~
a.cc:9:53: error: expected unqualified-id before '.' token
9 | $s.select{|e|a.include?(e[1])&& !a.include?(e[0])}.map{|e|
| ^
a.cc:11:4: error: expected unqualified-id before '.' token
11 | }.shuffle[0]
| ^
|
s528732768 | p00119 | C++ | def solve(a,M):
for x,y in xy:
if x in a and (y not in a or a.index(x) > a.index(y)): break
else:
if len(a) == m: return a
for i in range(len(M)):
r = solve([M[i]] + a,M[:i]+M[i+1:])
if r: return r
m = input()
xy = [map(int,raw_input().split()) for i in range(input())]
for i in solve([],range(1,m+1)): print i | a.cc:1:1: error: 'def' does not name a type
1 | def solve(a,M):
| ^~~
|
s411365195 | p00119 | C++ | #include<iostream>
#include<cstdlib>
using namespace std;
// Ans
// 有向グラフの先の出次数が0のところから取り除いて、出力する
#define N 21
#define rep(i, n) for(int i=0; i<n; ++i)
int main() {
int m, n, x, y, deg[N];
bool e[N][N];
memset(deg, 0, sizeof(deg));
memset(e, 0, sizeof(e));
cin >> m >> n;
rep(i, n) {
cin >> x >> y; --x; --y;
e[x][y] = true;
++deg[y];
}
rep(i, m) {
rep(j, m) {
if(deg[j]==0) {
deg[j] = -1;
cout << j+1 << endl;
rep(k, m) {
if(e[j][k]) --deg[k];
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:15:9: error: 'memset' was not declared in this scope
15 | memset(deg, 0, sizeof(deg));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<cstdlib>
+++ |+#include <cstring>
3 | using namespace std;
|
s005110046 | p00119 | C++ | #include<iostream>
#include<cstdio>
using namespace std;
// Ans
// 有向グラフの先の出次数が0のところから取り除いて、出力する
#define N 21
#define rep(i, n) for(int i=0; i<n; ++i)
int main() {
int m, n, x, y, deg[N];
bool e[N][N];
memset(deg, 0, sizeof(deg));
memset(e, 0, sizeof(e));
cin >> m >> n;
rep(i, n) {
cin >> x >> y; --x; --y;
e[x][y] = true;
++deg[y];
}
rep(i, m) {
rep(j, m) {
if(deg[j]==0) {
deg[j] = -1;
cout << j+1 << endl;
rep(k, m) {
if(e[j][k]) --deg[k];
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:15:9: error: 'memset' was not declared in this scope
15 | memset(deg, 0, sizeof(deg));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<cstdio>
+++ |+#include <cstring>
3 | using namespace std;
|
s117009431 | p00120 | Java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Main {
public static void main(String[] args) throws IOException{
//Scanner sc = new Scanner(System.in);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while(true){
String str;
if((str = br.readLine()) == null || str.equals("")){
break;
}
String[] params = str.split(" ");
final int box_length = Integer.parseInt(params[0]);
final int cakes = params.length - 1;
int[] cake_len = new int[cakes];
for(int i = 0; i < cakes; i++){
cake_len[i] = Integer.parseInt(params[i+1]);
}
Arrays.sort(cake_len);
List<Integer> list = new ArrayList<Integer>();
for(int i = 0; i < cakes/2; i++){
if((i % 2) == 0){
list.add(0, cake_len[i]);
list.add(cake_len[cakes - i - 1]);
}else{
list.add(0, cake_len[cakes - i - 1]);
list.add(cake_len[i]);
}
}
if(cakes % 2 == 1){
if(list.get(0) > list.get(cakes - 2)){
list.add(0, cake_len[cakes/2]);
}else{
list.add(cake_len[cakes/2]);
}
}
double sum = list.get(0) + list.get(cakes-1);
for(int i = 0; i < cakes-1; i++){
sum += Math.sqrt(list.get(i) * list.get(i+1) * 4);
}
if(sum < box_length){
System.out.println("OK");
}else{
System.out.println("NG");
}
}
}
} | Main.java:7: error: cannot find symbol
public static void main(String[] args) throws IOException{
^
symbol: class IOException
location: class Main
Main.java:10: error: cannot find symbol
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
^
symbol: class BufferedReader
location: class Main
Main.java:10: error: cannot find symbol
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
^
symbol: class BufferedReader
location: class Main
Main.java:10: error: cannot find symbol
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
^
symbol: class InputStreamReader
location: class Main
4 errors
|
s665415970 | p00120 | Java | import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
public class Sample0120 {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
while(sc.hasNext()){
int box = sc.nextInt();
LinkedList<Integer> array = new LinkedList<Integer>();
while(sc.hasNextInt())
array.push(sc.nextInt());
double[][] data = new double[(1<<array.size())][array.size()];
for(int i=0;i<1<<array.size();i++)
Arrays.fill(data[i], Double.MAX_VALUE);
for(int i=0;i<array.size();i++)
data[1<<i][i]=array.get(i);
for(int i=0;i<1<<array.size();i++){
for(int j=0;j<array.size();j++){
int tmp = 1<<j;
if((i&tmp)==0){
for(int k=0;k<array.size();k++){
double x = (double)array.get(j);
double y = (double)array.get(k);
data[i|tmp][j]=Math.min(data[i][k]+Math.sqrt((x+y)*(x+y)-(x-y)*(x-y)),data[i|tmp][j]);
}
}
}
}
double min = Double.MAX_VALUE;
for(int i=0;i<array.size();i++){
data[(1<<array.size())-1][i]+=array.get(i);
min = Math.min(min,data[(1<<array.size())-1][i]);
}
if(min<(box+1e-8)){
System.out.println("OK");
}
else
System.out.println("NA");
}
}
} | Main.java:5: error: class Sample0120 is public, should be declared in a file named Sample0120.java
public class Sample0120 {
^
1 error
|
s557681630 | p00120 | Java | import java.util.Scanner;
public class A0120 {
static double dp[][][];
static int n, a;
static double r[];
public static double f(int left, int right, int bit) {
if (0 < dp[left][right][bit]) {
return dp[left][right][bit];
}
int k = check(bit);
if (k == 1) {
return dp[left][right][bit] = 2.0 * r[left];
}
if (k == 2) {
return dp[left][right][bit] = r[left] + r[right] + 2.0 * Math.sqrt(r[left] * r[right]);
}
double min = Double.MAX_VALUE;
for (int i = 0; i < n; i++) {
if (i == left || i == right || (bit & (1 << i)) == 0) {
continue;
}
for (int j = 0; j < n; j++) {
if (j == left || j == right || (bit & (1 << j)) == 0) {
continue;
}
if (3 < k && i == j) {
continue;
}
double sub = f(i, j, (bit ^ (1 << left)) ^ (1 << right));
sub -= r[i] + r[j];
sub += 2.0 * (Math.sqrt(r[left] * r[i]) + Math.sqrt(r[right] * r[j]));
sub += r[left] + r[right];
min = Math.min(min, sub);
}
}
return dp[left][right][bit] = min;
}
public static int check(int bit) {
int count = 0;
for (int i = 0; i < 12; i++) {
if (0 < (bit & (1 << i))) {
count++;
}
}
return count;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String b[] = sc.nextLine().split(" ");
a = Integer.parseInt(b[0]);
n = b.length - 1;
r = new double[n];
dp = new double[n][n][1 << n];
for (int i = 0; i < n; i++) {
r[i] = Integer.parseInt(b[i + 1]);
}
double min = Double.MAX_VALUE;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i != j) {
min = Math.min(min, f(i, j, (1 << n) - 1));
}
}
}
System.out.println(min <= a ? "OK" : "NA");
}
}
} | Main.java:3: error: class A0120 is public, should be declared in a file named A0120.java
public class A0120 {
^
1 error
|
s125260162 | p00120 | C | clude <stdio.h> // printf()
#include <stdlib.h> // exit(), free(), strtol()
#include <stdbool.h>
#include <errno.h> // errno
#include <error.h> // error()
#define MAX_N 12
int lineno;
char *linebuff = NULL;
size_t linebuffsize = 0;
int r[MAX_N];
void
cleanup(int ecode)
{
if (linebuff)
{
free(linebuff);
linebuff = NULL;
linebuffsize = 0;
}
exit(ecode);
}
bool
ope_line()
{
errno = 0;
if(getline(&linebuff, &linebuffsize, stdin) == -1) // read line
{
if(errno == 0) // EOF?
return false;
error(0, errno, "Can't read line");
cleanup(1);
}
lineno++;
// const char *s = linebuff;
return true;
}
int
main(int argc, char **argv)
{
lineno = 0;
while (true) // process for each line
{
if (!ope_line())
break;
}
return 0;
} | main.c:1:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
1 | clude <stdio.h> // printf()
| ^
In file included from main.c:2:
/usr/include/stdlib.h:98:8: error: unknown type name 'size_t'
98 | extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
| ^~~~~~
/usr/include/stdlib.h:57:1: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
56 | #include <bits/floatn.h>
+++ |+#include <stddef.h>
57 |
/usr/include/stdlib.h:531:25: error: unknown type name 'size_t'
531 | size_t __statelen) __THROW __nonnull ((2));
| ^~~~~~
/usr/include/stdlib.h:531:25: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:561:25: error: unknown type name 'size_t'
561 | size_t __statelen,
| ^~~~~~
/usr/include/stdlib.h:561:25: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:661:42: error: unknown type name 'size_t'
661 | extern void arc4random_buf (void *__buf, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:661:42: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:672:22: error: unknown type name 'size_t'
672 | extern void *malloc (size_t __size) __THROW __attribute_malloc__
| ^~~~~~
/usr/include/stdlib.h:672:22: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:675:22: error: unknown type name 'size_t'
675 | extern void *calloc (size_t __nmemb, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:675:22: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:675:38: error: unknown type name 'size_t'
675 | extern void *calloc (size_t __nmemb, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:675:38: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:683:36: error: unknown type name 'size_t'
683 | extern void *realloc (void *__ptr, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:683:36: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:695:41: error: unknown type name 'size_t'
695 | extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:695:41: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:695:57: error: unknown type name 'size_t'
695 | extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:695:57: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:701:41: error: unknown type name 'size_t'
701 | extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:701:41: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:701:57: error: unknown type name 'size_t'
701 | extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:701:57: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
In file included from /usr/include/stdlib.h:706:
/usr/include/alloca.h:32:22: error: unknown type name 'size_t'
32 | extern void *alloca (size_t __size) __THROW;
| ^~~~~~
/usr/include/alloca.h:25:1: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
24 | #include <stddef.h>
+++ |+#include <stddef.h>
25 |
/usr/include/stdlib.h:712:22: error: unknown type name 'size_t'
712 | extern void *valloc (size_t __size) __THROW __attribute_malloc__
| ^~~~~~
/usr/include/stdlib.h:712:22: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:718:45: error: unknown type name 'size_t'
718 | extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:718:45: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:718:65: error: unknown type name 'size_t'
718 | extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:718:65: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:724:29: error: unknown type name 'size_t'
724 | extern void *aligned_alloc (size_t __alignment, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:724:29: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:724:49: error: unknown type name 'size_t'
724 | extern void *aligned_alloc (size_t __alignment, size_t __size)
| ^~~~~~
/usr/include/stdlib.h:724:49: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:961:23: error: unknown type name 'size_t'
961 | size_t __nmemb, size_t __size, __compar_fn_t __compar)
| ^~~~~~
/usr/include/stdlib.h:961:23: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:961:39: error: unknown type name 'size_t'
961 | size_t __nmemb, size_t __size, __compar_fn_t __compar)
| ^~~~~~
/usr/include/stdlib.h:961:39: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:970:34: error: unknown type name 'size_t'
970 | extern void qsort (void *__base, size_t __nmemb, size_t __size,
| ^~~~~~
/usr/include/stdlib.h:970:34: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:970:50: error: unknown type name 'size_t'
970 | extern void qsort (void *__base, size_t __nmemb, size_t __size,
| ^~~~~~
/usr/include/stdlib.h:970:50: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1044:20: error: unknown type name 'size_t'
1044 | size_t __len) __THROW __nonnull ((3, 4, 5));
| ^~~~~~
/usr/include/stdlib.h:1044:20: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1047:20: error: unknown type name 'size_t'
1047 | size_t __len) __THROW __nonnull ((3, 4, 5));
| ^~~~~~
/usr/include/stdlib.h:1047:20: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1051:45: error: unknown type name 'size_t'
1051 | char *__restrict __buf, size_t __len)
| ^~~~~~
/usr/include/stdlib.h:1051:45: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1055:45: error: unknown type name 'size_t'
1055 | char *__restrict __buf, size_t __len)
| ^~~~~~
/usr/include/stdlib.h:1055:45: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1062:36: error: unknown type name 'size_t'
1062 | extern int mblen (const char *__s, size_t __n) __THROW;
| ^~~~~~
/usr/include/stdlib.h:1062:36: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1066:48: error: unknown type name 'size_t'
1066 | const char *__restrict __s, size_t __n) __THROW;
| ^~~~~~
/usr/include/stdlib.h:1066:48: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1073:8: error: unknown type name 'size_t'
1073 | extern size_t mbstowcs (wchar_t *__restrict __pwcs,
| ^~~~~~
/usr/include/stdlib.h:1073:8: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1074:53: error: unknown type name 'size_t'
1074 | const char *__restrict __s, size_t __n) __THROW
| ^~~~~~
/usr/include/stdlib.h:1074:53: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdlib.h:1077:8: error: unknown type name 'size_t'
1077 | extern size_t wcstombs (char *__restrict __s,
| ^~~~~~
/usr/include/stdlib.h:1077:8: note: 'size_t' is defined in header '<stddef.h> |
s151057563 | p00120 | C | #define N 12
double M[N][1<<N],r;
int D[N],n;
double dfs(int p,int f){
if(M[p][f]<0){
int i=0;
M[p][f]=0;
for(;i<n;i++){
if(f&1<<i)continue;
M[p][f]=max(M[p][f],dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]));
}
}
return M[p][f];
}
main(){
int L,l,i,j,d;
string s;
for(;~scanf("%d",&L);){
d=0;do{scanf("%d",D+n);d+=D[n++]*2;}while(getchar()!='\n');
for(i=0;i<n;i++)for(j=0;j<1<<n;j++)M[i][j]=-1;
for(r=i=0;i<n;i++)r=max(r,dfs(i,1<<i));
puts(d-r<=L?"OK":"NA");
}
exit(0);
} | main.c: In function 'dfs':
main.c:10:33: error: implicit declaration of function 'max' [-Wimplicit-function-declaration]
10 | M[p][f]=max(M[p][f],dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]));
| ^~~
main.c:10:71: error: implicit declaration of function 'sqrt' [-Wimplicit-function-declaration]
10 | M[p][f]=max(M[p][f],dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]));
| ^~~~
main.c:1:1: note: include '<math.h>' or provide a declaration of 'sqrt'
+++ |+#include <math.h>
1 | #define N 12
main.c:10:71: warning: incompatible implicit declaration of built-in function 'sqrt' [-Wbuiltin-declaration-mismatch]
10 | M[p][f]=max(M[p][f],dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]));
| ^~~~
main.c:10:71: note: include '<math.h>' or provide a declaration of 'sqrt'
main.c: At top level:
main.c:15:1: error: return type defaults to 'int' [-Wimplicit-int]
15 | main(){
| ^~~~
main.c: In function 'main':
main.c:17:9: error: unknown type name 'string'
17 | string s;
| ^~~~~~
main.c:18:15: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
18 | for(;~scanf("%d",&L);){
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | #define N 12
main.c:18:15: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
18 | for(;~scanf("%d",&L);){
| ^~~~~
main.c:18:15: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:19:59: error: implicit declaration of function 'getchar' [-Wimplicit-function-declaration]
19 | d=0;do{scanf("%d",D+n);d+=D[n++]*2;}while(getchar()!='\n');
| ^~~~~~~
main.c:19:59: note: 'getchar' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
main.c:22:17: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
22 | puts(d-r<=L?"OK":"NA");
| ^~~~
main.c:22:17: note: include '<stdio.h>' or provide a declaration of 'puts'
main.c:24:1: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
24 | exit(0);
| ^~~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
+++ |+#include <stdlib.h>
1 | #define N 12
main.c:24:1: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
24 | exit(0);
| ^~~~
main.c:24:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
|
s852797739 | p00120 | C | #define N 12
double M[N][1<<N],r;
int D[N],n;
double dfs(int p,int f){
if(M[p][f]<0){
int i=0;
M[p][f]=0;
for(;i<n;i++){
if(f&1<<i)continue;
M[p][f]=max(M[p][f],dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]));
}
}
return M[p][f];
}
main(){
int L,l,i,j,d;
for(;~scanf("%d",&L);){
d=0;do{scanf("%d",D+n);d+=D[n++]*2;}while(getchar()!='\n');
for(i=0;i<n;i++)for(j=0;j<1<<n;j++)M[i][j]=-1;
for(r=i=0;i<n;i++)r=max(r,dfs(i,1<<i));
puts(d-r<=L?"OK":"NA");
}
exit(0);
} | main.c: In function 'dfs':
main.c:10:33: error: implicit declaration of function 'max' [-Wimplicit-function-declaration]
10 | M[p][f]=max(M[p][f],dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]));
| ^~~
main.c:10:71: error: implicit declaration of function 'sqrt' [-Wimplicit-function-declaration]
10 | M[p][f]=max(M[p][f],dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]));
| ^~~~
main.c:1:1: note: include '<math.h>' or provide a declaration of 'sqrt'
+++ |+#include <math.h>
1 | #define N 12
main.c:10:71: warning: incompatible implicit declaration of built-in function 'sqrt' [-Wbuiltin-declaration-mismatch]
10 | M[p][f]=max(M[p][f],dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]));
| ^~~~
main.c:10:71: note: include '<math.h>' or provide a declaration of 'sqrt'
main.c: At top level:
main.c:15:1: error: return type defaults to 'int' [-Wimplicit-int]
15 | main(){
| ^~~~
main.c: In function 'main':
main.c:17:15: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
17 | for(;~scanf("%d",&L);){
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | #define N 12
main.c:17:15: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
17 | for(;~scanf("%d",&L);){
| ^~~~~
main.c:17:15: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:18:59: error: implicit declaration of function 'getchar' [-Wimplicit-function-declaration]
18 | d=0;do{scanf("%d",D+n);d+=D[n++]*2;}while(getchar()!='\n');
| ^~~~~~~
main.c:18:59: note: 'getchar' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
main.c:21:17: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
21 | puts(d-r<=L?"OK":"NA");
| ^~~~
main.c:21:17: note: include '<stdio.h>' or provide a declaration of 'puts'
main.c:23:1: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
23 | exit(0);
| ^~~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
+++ |+#include <stdlib.h>
1 | #define N 12
main.c:23:1: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
23 | exit(0);
| ^~~~
main.c:23:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
|
s454174140 | p00120 | C | double M[12][4096],r,t;D[N],n;
double dfs(p,f){if(M[p][f]<0){
int i=0;
for(M[p][f]=0;i<n;i++)if(!(f&1<<i)&&(t=dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]),M[p][f]<t))M[p][f]=t;
}return M[p][f];}
main(l,i,j,d){for(;~scanf("%d",&l);puts(d-r<=l?"OK":"NA")){
for(d=n=0;getchar()!='\n';d+=D[n++]*2)scanf("%d",D+n);
for(i=0;i<n;i++)for(j=0;j<1<<n;j++)M[i][j]=-1;
for(r=i=0;i<n;i++)if(t=dfs(i,1<<i),r<t)r=t;
}exit(0);} | main.c:1:26: error: 'N' undeclared here (not in a function)
1 | double M[12][4096],r,t;D[N],n;
| ^
main.c:1:24: warning: data definition has no type or storage class
1 | double M[12][4096],r,t;D[N],n;
| ^
main.c:1:24: error: type defaults to 'int' in declaration of 'D' [-Wimplicit-int]
main.c:1:29: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
1 | double M[12][4096],r,t;D[N],n;
| ^
main.c: In function 'dfs':
main.c:2:8: error: type of 'p' defaults to 'int' [-Wimplicit-int]
2 | double dfs(p,f){if(M[p][f]<0){
| ^~~
main.c:2:8: error: type of 'f' defaults to 'int' [-Wimplicit-int]
main.c:4:66: error: implicit declaration of function 'sqrt' [-Wimplicit-function-declaration]
4 | for(M[p][f]=0;i<n;i++)if(!(f&1<<i)&&(t=dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]),M[p][f]<t))M[p][f]=t;
| ^~~~
main.c:1:1: note: include '<math.h>' or provide a declaration of 'sqrt'
+++ |+#include <math.h>
1 | double M[12][4096],r,t;D[N],n;
main.c:4:66: warning: incompatible implicit declaration of built-in function 'sqrt' [-Wbuiltin-declaration-mismatch]
4 | for(M[p][f]=0;i<n;i++)if(!(f&1<<i)&&(t=dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]),M[p][f]<t))M[p][f]=t;
| ^~~~
main.c:4:66: note: include '<math.h>' or provide a declaration of 'sqrt'
main.c: At top level:
main.c:6:1: error: return type defaults to 'int' [-Wimplicit-int]
6 | main(l,i,j,d){for(;~scanf("%d",&l);puts(d-r<=l?"OK":"NA")){
| ^~~~
main.c: In function 'main':
main.c:6:1: error: type of 'l' defaults to 'int' [-Wimplicit-int]
main.c:6:1: error: type of 'i' defaults to 'int' [-Wimplicit-int]
main.c:6:1: error: type of 'j' defaults to 'int' [-Wimplicit-int]
main.c:6:1: error: type of 'd' defaults to 'int' [-Wimplicit-int]
main.c:6:21: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
6 | main(l,i,j,d){for(;~scanf("%d",&l);puts(d-r<=l?"OK":"NA")){
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | double M[12][4096],r,t;D[N],n;
main.c:6:21: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
6 | main(l,i,j,d){for(;~scanf("%d",&l);puts(d-r<=l?"OK":"NA")){
| ^~~~~
main.c:6:21: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:6:36: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
6 | main(l,i,j,d){for(;~scanf("%d",&l);puts(d-r<=l?"OK":"NA")){
| ^~~~
main.c:6:36: note: include '<stdio.h>' or provide a declaration of 'puts'
main.c:7:11: error: implicit declaration of function 'getchar' [-Wimplicit-function-declaration]
7 | for(d=n=0;getchar()!='\n';d+=D[n++]*2)scanf("%d",D+n);
| ^~~~~~~
main.c:7:11: note: 'getchar' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>'
main.c:10:2: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
10 | }exit(0);}
| ^~~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
+++ |+#include <stdlib.h>
1 | double M[12][4096],r,t;D[N],n;
main.c:10:2: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
10 | }exit(0);}
| ^~~~
main.c:10:2: note: include '<stdlib.h>' or provide a declaration of 'exit'
|
s010714153 | p00120 | C++ | const int INF = 100000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;
/** Problem0120 : Patisserie **/
const int MAX_N = 12;
double W;
vector<double> size;
int dp[1<<MAX_N][MAX_N];
int N;
int sig(double a, double b) {
if(a < b - EPS) return -1;
if(a > b + EPS) return +1;
return 0;
}
bool rec(int S, int v, double w)
{
//printf("(S, v, w) = (%d, %d, %.2f)\n", S, v, w);
if (dp[S][v]>=0)
return dp[S][v];
if (S==(1<<N)-1) {
printf("%.2f %.2f\n", W, w);
return dp[S][v] = (sig(W, w)!=-1);
}
bool res=false;
rep(u, N) {
if (!(S>>u&1)) {
double nw = w - size[v] + size[u] + sqrt((size[u]+size[v])*(size[u]+size[v]) - (size[u]-size[v])*(size[u]-size[v]));
res |= rec(S|1<<u, u, nw);
}
}
return dp[S][v] = res;
}
int main()
{
string in;
while (getline(cin, in)) {
size.clear();
stringstream ss(in);
ss>>W;
double d;
while (ss>>d) {
size.push_back(d);
};
N=(int)size.size();
memset(dp, -1, sizeof(dp));
bool ans=false;
rep(i, N) {
ans |= rec(1<<i, i, 2*size[i]);
}
cout << (ans?"OK":"NA") << endl;
}
} | a.cc:7:9: error: 'pair' does not name a type
7 | typedef pair<int, int> P;
| ^~~~
a.cc:13:1: error: 'vector' does not name a type
13 | vector<double> size;
| ^~~~~~
a.cc: In function 'bool rec(int, int, double)':
a.cc:31:17: error: 'printf' was not declared in this scope
31 | printf("%.2f %.2f\n", W, w);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | const int INF = 100000000;
a.cc:36:13: error: 'u' was not declared in this scope
36 | rep(u, N) {
| ^
a.cc:36:9: error: 'rep' was not declared in this scope; did you mean 'res'?
36 | rep(u, N) {
| ^~~
| res
a.cc: In function 'int main()':
a.cc:48:9: error: 'string' was not declared in this scope
48 | string in;
| ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
+++ |+#include <string>
1 | const int INF = 100000000;
a.cc:49:24: error: 'cin' was not declared in this scope
49 | while (getline(cin, in)) {
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | const int INF = 100000000;
a.cc:49:29: error: 'in' was not declared in this scope; did you mean 'int'?
49 | while (getline(cin, in)) {
| ^~
| int
a.cc:49:16: error: 'getline' was not declared in this scope
49 | while (getline(cin, in)) {
| ^~~~~~~
a.cc:50:17: error: 'size' was not declared in this scope
50 | size.clear();
| ^~~~
a.cc:52:17: error: 'stringstream' was not declared in this scope
52 | stringstream ss(in);
| ^~~~~~~~~~~~
a.cc:1:1: note: 'std::stringstream' is defined in header '<sstream>'; this is probably fixable by adding '#include <sstream>'
+++ |+#include <sstream>
1 | const int INF = 100000000;
a.cc:53:17: error: 'ss' was not declared in this scope
53 | ss>>W;
| ^~
a.cc:60:17: error: 'memset' was not declared in this scope
60 | memset(dp, -1, sizeof(dp));
| ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
+++ |+#include <cstring>
1 | const int INF = 100000000;
a.cc:63:21: error: 'i' was not declared in this scope
63 | rep(i, N) {
| ^
a.cc:63:17: error: 'rep' was not declared in this scope; did you mean 'rec'?
63 | rep(i, N) {
| ^~~
| rec
a.cc:67:17: error: 'cout' was not declared in this scope
67 | cout << (ans?"OK":"NA") << endl;
| ^~~~
a.cc:67:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:67:44: error: 'endl' was not declared in this scope
67 | cout << (ans?"OK":"NA") << endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 | const int INF = 100000000;
|
s958669013 | p00120 | C++ | #include <algorithm>
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
double getPackWidth(vector<int> &v) {
int n = v.size();
double ret = v[0] + v[n-1];
for (int i=0; i+1<n; ++i) {
ret += sqrt(pow(v[i] + v[i+1], 2) - pow(v[i] - v[i+1], 2));
}
return ret;
}
int main() {
string s;
while (getline(cin,s)) {
stringstream ss(s);
int w;
ss >> w;
int r;
vector<int> cake;
while (ss >> r) cake.push_back(r);
sort(cake.begin(), cake.end());
vector<int> v1, v2;
int n = cake.size();
for (int i=0; i<=n-1-i; ++i) {
if (i == n-1-i) {
v1.push_back(cake[i]);
v2.push_back(cake[i]);
} else {
v1.push_back(cake[i]);
v1.push_back(cake[n-1-i]);
v2.push_back(cake[n-1-i]);
v2.push_back(cake[i]);
}
}
bool ok = getPackWidth(v1) <= w || getPackWidth(v2) <= w;
cout << (ok ? "OK" : "NA") << endl;
}
return 0;
} | a.cc: In function 'double getPackWidth(std::vector<int>&)':
a.cc:12:21: error: 'pow' was not declared in this scope
12 | ret += sqrt(pow(v[i] + v[i+1], 2) - pow(v[i] - v[i+1], 2));
| ^~~
a.cc:12:16: error: 'sqrt' was not declared in this scope
12 | ret += sqrt(pow(v[i] + v[i+1], 2) - pow(v[i] - v[i+1], 2));
| ^~~~
|
s776330700 | p00120 | C++ | import sys
from math import sqrt
def rec(state, v):
if state == (1 << N) - 1:
return cakes[v]
if dp[state][v] != -1:
return dp[state][v]
ret = INF
for i in range(N):
if not (state >> i & 1):
ret = min(ret, rec(state | 1 << i, i) + sqrt(pow(cakes[i] + cakes[v], 2) - pow(cakes[i] - cakes[v], 2)))
dp[state][v] = ret
return ret
testcases = [[int(x) for x in line.split()] for line in sys.stdin.readlines()]
for testcase in testcases:
box, *cakes = testcase
N = len(cakes)
INF = box + 1
ans = INF
for i in range(N):
dp = [[-1] * N for _ in range(1 << N)]
ans = min(ans, rec(1 << i, i) + cakes[i])
print('OK' if ans <= box else 'NA') | a.cc:29:11: warning: multi-character character constant [-Wmultichar]
29 | print('OK' if ans <= box else 'NA')
| ^~~~
a.cc:29:35: warning: multi-character character constant [-Wmultichar]
29 | print('OK' if ans <= box else 'NA')
| ^~~~
a.cc:1:1: error: 'import' does not name a type
1 | import sys
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
|
s808970035 | p00120 | C++ | #include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
const int LOOP = 10000; //??????????????°
const double EPS = 1e-6; //??????????????¨(?°??????????????????????)
int L;
int N; //???????????±???????????°
//???????????±????????????????????????????????¨?????¨???????¨????????¨??????????
double Evaluate(int r[12]) {
double val = r[0] + r[N-1];
for (int i = 0; i < N - 1; i++)
{
int a = abs(r[i] - r[i+1]), c = r[i] + r[i+1];
val += sqrt(c*c - a*a);
}
return val;
}
//?????¨?????????????????°???????????¨??????????????????????§???????????±???????
//(????§?????????????true)
bool Changes(int cnt) {
return cnt < rand()%LOOP;
}
//?????????????????????????????¢??°
//?????????????°??????????????¨?????????????
//int r[12] : ???????????±?????????0??????N-1???????????????????????????????????????????????????????´???????
double Solve(int r[12]) {
double score = Evaluate(r); //?????¨?????¶???r[]????¨???????????´????????????°
double mi = score; //???????????§?????¶???????¨???????????°???????????´????????????°
for (int cnt = 0; cnt < LOOP; cnt++)
{
swap(r[rand()%N],r[rand()%N]);
double evaluate = Evaluate(r);
if(evaluate <= mi){
mi = evaluate;
}else{
if(Changes(cnt)){
mi = evaluate;
}
}
}
return mi; //????°?????????????
}
//??\?????¢????????????????????¢????????£????????§???????????????
int main() {
while (cin >> L)
{
N = 0;
int r[12];
string S;
getline(cin, S);
stringstream SS(S);
while (!SS.eof()) SS >> r[N++];
double ans;
if (N == 1) ans = r[0]*2;
else ans = Solve(r);
if (L - ans + EPS > 0) puts("OK");
else puts("NA");
}
return 0;
} | a.cc: In function 'double Evaluate(int*)':
a.cc:18:24: error: 'sqrt' was not declared in this scope
18 | val += sqrt(c*c - a*a);
| ^~~~
|
s815153133 | p00120 | C++ | #include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include<time>
#include<cstdlib>
using namespace std;
const int LOOP = 10000; //??????????????°
const double EPS = 1e-6; //??????????????¨(?°??????????????????????)
int L;
int N; //???????????±???????????°
//???????????±????????????????????????????????¨?????¨???????¨????????¨??????????
double Evaluate(int r[12]) {
double val = r[0] + r[N-1];
for (int i = 0; i < N - 1; i++)
{
int a = abs(r[i] - r[i+1]), c = r[i] + r[i+1];
val += sqrt(c*c - a*a);
}
return val;
}
//?????¨?????????????????°???????????¨??????????????????????§???????????±???????
//(????§?????????????true)
bool Changes(int cnt) {
return cnt < rand()%LOOP;
}
//?????????????????????????????¢??°
//?????????????°??????????????¨?????????????
//int r[12] : ???????????±?????????0??????N-1???????????????????????????????????????????????????????´???????
double Solve(int r[12]) {
double score = Evaluate(r); //?????¨?????¶???r[]????¨???????????´????????????°
double mi = score; //???????????§?????¶???????¨???????????°???????????´????????????°
for (int cnt = 0; cnt < LOOP; cnt++)
{
swap(r[rand()%N],r[rand()%N]);
double evaluate = Evaluate(r);
if(evaluate <= mi){
mi = evaluate;
}else{
if(Changes(cnt)){
mi = evaluate;
}
}
}
return mi; //????°?????????????
}
//??\?????¢????????????????????¢????????£????????§???????????????
int main() {
srand(time(NULL));
while (cin >> L)
{
N = 0;
int r[12];
string S;
getline(cin, S);
stringstream SS(S);
while (!SS.eof()) SS >> r[N++];
double ans;
if (N == 1) ans = r[0]*2;
else ans = Solve(r);
if (L - ans + EPS > 0) puts("OK");
else puts("NA");
}
return 0;
} | a.cc:5:9: fatal error: time: No such file or directory
5 | #include<time>
| ^~~~~~
compilation terminated.
|
s334764017 | p00120 | C++ | #include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <ctime>
#include<cstdlib>
using namespace std;
const int LOOP = 10000; //??????????????°
const double EPS = 1e-6; //??????????????¨(?°??????????????????????)
int L;
int N; //???????????±???????????°
//???????????±????????????????????????????????¨?????¨???????¨????????¨??????????
double Evaluate(int r[12]) {
double val = r[0] + r[N-1];
for (int i = 0; i < N - 1; i++)
{
int a = abs(r[i] - r[i+1]), c = r[i] + r[i+1];
val += sqrt(c*c - a*a);
}
return val;
}
//?????¨?????????????????°???????????¨??????????????????????§???????????±???????
//(????§?????????????true)
bool Changes(int cnt) {
return cnt < rand()%LOOP;
}
//?????????????????????????????¢??°
//?????????????°??????????????¨?????????????
//int r[12] : ???????????±?????????0??????N-1???????????????????????????????????????????????????????´???????
double Solve(int r[12]) {
double score = Evaluate(r); //?????¨?????¶???r[]????¨???????????´????????????°
double mi = score; //???????????§?????¶???????¨???????????°???????????´????????????°
for (int cnt = 0; cnt < LOOP; cnt++)
{
swap(r[rand()%N],r[rand()%N]);
double evaluate = Evaluate(r);
if(evaluate <= mi){
mi = evaluate;
}else{
if(Changes(cnt)){
mi = evaluate;
}
}
}
return mi; //????°?????????????
}
//??\?????¢????????????????????¢????????£????????§???????????????
int main() {
srand(time(NULL));
while (cin >> L)
{
N = 0;
int r[12];
string S;
getline(cin, S);
stringstream SS(S);
while (!SS.eof()) SS >> r[N++];
double ans;
if (N == 1) ans = r[0]*2;
else ans = Solve(r);
if (L - ans + EPS > 0) puts("OK");
else puts("NA");
}
return 0;
} | a.cc: In function 'double Evaluate(int*)':
a.cc:20:24: error: 'sqrt' was not declared in this scope
20 | val += sqrt(c*c - a*a);
| ^~~~
|
s703073099 | p00120 | C++ | #include <algorithm>
#include <string>
#include <stream>
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <cstdio>
using namespace std;
const int LOOP = 10000; //??????????????°
const double EPS = 1e-6; //??????????????¨(?°??????????????????????)
int L;
int N; //???????????±???????????°
//???????????±????????????????????????????????¨?????¨???????¨????????¨??????????
double Evaluate(int r[12]) {
double val = r[0] + r[N-1];
for (int i = 0; i < N - 1; i++)
{
int a = abs(r[i] - r[i+1]), c = r[i] + r[i+1];
val += sqrt(c*c - a*a);
}
return val;
}
//?????¨?????????????????°???????????¨??????????????????????§???????????±???????
//(????§?????????????true)
bool Changes(int cnt) {
return cnt < rand()%LOOP;
}
//?????????????????????????????¢??°
//?????????????°??????????????¨?????????????
//int r[12] : ???????????±?????????0??????N-1???????????????????????????????????????????????????????´???????
double Solve(int r[12]) {
double score = Evaluate(r); //?????¨?????¶???r[]????¨???????????´????????????°
double mi = score; //???????????§?????¶???????¨???????????°???????????´????????????°
for (int cnt = 0; cnt < LOOP; cnt++)
{
swap(r[rand()%N],r[rand()%N]);
double evaluate = Evaluate(r);
if(evaluate <= mi){
mi = evaluate;
}else{
if(Changes(cnt)){
mi = evaluate;
}
}
}
return mi; //????°?????????????
}
//??\?????¢????????????????????¢????????£????????§???????????????
int main() {
srand(time(NULL));
while (cin >> L)
{
N = 0;
int r[12];
string S;
getline(cin, S);
stringstream SS(S);
while (!SS.eof()) SS >> r[N++];
double ans;
if (N == 1) ans = r[0]*2;
else ans = Solve(r);
if (L - ans + EPS > 0) puts("OK");
else puts("NA");
}
return 0;
} | a.cc:3:10: fatal error: stream: No such file or directory
3 | #include <stream>
| ^~~~~~~~
compilation terminated.
|
s866426022 | p00120 | C++ | #include<sstream>
#include<iostream>
#include<cmath>
using namespace std;
int w,n; int c[12];
string s;
double calc(int *c){
double r=c[0]+c[n-1];
for(int i=0;i<n-1;i++)r+=2*sqrt(c[i]*c[i+1]);
return r;
}
int main(){
while(getline(cin,s)){
stringstream ss; ss<<s;
ss>>w;
for(n=0;ss>>c[n];n++);
do{
if(calc(c)<=w){
cout<<"OK"<<endl;
goto NEXT;
}
}while(next_permutation(c,c+n));
cout<<"NA"<<endl;
NEXT:;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:23:24: error: 'next_permutation' was not declared in this scope
23 | }while(next_permutation(c,c+n));
| ^~~~~~~~~~~~~~~~
|
s698399342 | p00120 | C++ | #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
#define MAX 12
double sqs[MAX][MAX] = {{0,}};
class Cake{
public:
Cake():r(0),used(false){};
int r;
bool used;
bool operator<(const Cake &t) const{
return r < t.r;
}
};
bool check(int p[], int n, int w){
double t = 0;
t += p[0];
for(int i = 0; i < n-1; i++){
t += 2.0*sqrt((double)p[i]*p[i+1]);
}
t += p[n-1];
return t <= w;
}
bool solve2(int p[], int pos, int w, Cake cakes[], int n, bool greater){
if( pos == n ){
return check(p,n,w);
}else{
for(int i = 0; i < n; i++){
if( (greater ? p[pos-1] <= cakes[i].r : p[pos-1] >= cakes[i].r) && !cakes[i].used ){
p[pos] = cakes[i].r;
cakes[i].used = true;
if( solve2( p, pos+1, w, cakes, n, !greater) ) return true;
cakes[i].used = false;
}
}
return false;
}
}
bool solve(int p[], int n, int w, int r[]){
/*
High Speed but not alphameric order.
genperm1 from http://www5.airnet.ne.jp/tomy/cpro/pe1.htm (C) Tomy
*/
double tw;
int *c,*pc,*q,k,t;
c = new int[n];
for(k=1,q=p,pc=c;k<=n;)*q++=*pc++=k++;k=1;pc=c;
do{t=*(p+k);*(p+k)=*(q=p+((k&1)?*pc:0));*q=t;
//TODO
tw = r[0] + 2.0 * sqs[r[0]][r[p[0]+1]];
for(int i = 0; i < n-1; i++){
tw += 2.0 * sqs[ r[p[i]+1] ][ r[p[i+1]+1] ];
}
tw += r[1] + 2.0 * sqs[ r[1] ][ r[p[n-1]+1] ];
if( tw <= w ){
//cout << tw << endl;
delete [] c;
return true;
}
k=1;pc = c;while(*pc==0)*pc++=k++;(*pc)--;}while(k<n);
delete [] c;
return false;
}
double CalcCirclesLength(vector<int> &r){
double ret;
ret = r[0];
cout << r[0] << ' ';
for(unsigned int i = 0; i < r.size() - 1; ++i){
ret += 2.0 * sqs[ r[i] ][ r[i+1] ];
cout << sqs[ r[i] ][ r[i+1] ] << ' ';
}
cout << r[r.size() - 1] << endl;
ret += r[r.size() - 1];
return ret;
}
int main(void){
for(int i = 1; i < sizeof(sqs)/sizeof(*sqs); ++i){
for(int j = 1; j < sizeof(*sqs)/sizeof(**sqs); ++j){
sqs[i][j] = sqrt((double)i * j);
}
}
while(true){
int w;
double length = 0;
vector<int> vCandR;
vector<int> vR;
cin >> w;
if( cin.eof() ) break;
while( true ){
int tmp;
cin >> tmp;
vCandR.push_back(tmp);
if( '\n' == cin.get() ) break;
}
vR.push_back(vCandR[0]);
vCandR.erase( vCandR.begin()+0 );
while( vCandR.size() > 0 ){
for(unsigned int i = 0; i < vCandR.size(); ++i){
double minlen = 5000;
int minind = 0;
int minins = 0;
double l;
for(unsigned j = 0; j <= vR.size(); j++){
vR.insert(vR.begin()+j,vCandR[i]);
l = CalcCirclesLength( vR );
if( l < minlen ){
minlen = l; minind = i; minins = j;
}
vR.erase(vR.begin()+j);
}
}
vR.insert( vR.begin() + minins, vCandR[minind] );
/*for(unsigned int i = 0; i < vR.size(); ++i){
cout << vR[i] << ' ';
}
cout << endl;*/
vCandR.erase( vCandR.begin() + minind );
}
cout << CalcCirclesLength( vR ) << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:130:49: error: 'minins' was not declared in this scope
130 | vR.insert( vR.begin() + minins, vCandR[minind] );
| ^~~~~~
a.cc:130:64: error: 'minind' was not declared in this scope
130 | vR.insert( vR.begin() + minins, vCandR[minind] );
| ^~~~~~
|
s867420629 | p00120 | C++ | #include<iostream>
#include<vector>
#include<cmath>
#include<cassert>
#include<algorithm>
#define MAX 12
using namespace std;
typedef unsigned int set;
typedef struct tagcombstruct{
set K,N,x,overx;
} combStruct;
int g_cnt;
/* gencomb1 from http://www5.airnet.ne.jp/tomy/cpro/pe1.htm (C) Tomy */
set nextset(set x){
set smallest, ripple, new_smallest, ones;
smallest = x & (~x+1);
ripple = x + smallest;
new_smallest = ripple & (~ripple+1);
ones = ((new_smallest / smallest) >> 1) - 1;
return ripple | ones;
}
bool subcomb(set p[], combStruct &cmst){
set tj, *tq;
set ts;
cmst.x = nextset(cmst.x);
if(cmst.x & cmst.overx) return false;
for(tj = 1, tq = p, ts = cmst.x; tj <= cmst.N; tj++){ if(ts & 1) *tq++ = tj; ts >>= 1; }
return true;
}
template<typename T>
vector<pair<T, int> > unique(const vector<T> &v){
vector<pair<T, int> > vret;
unsigned int now;
for(unsigned int i = 0; i < v.size(); i++) vret.push_back( make_pair(v[i],0) );
now = 0;
while( now < vret.size() ){
int cnt = 1;
for(unsigned int i = now+1; i < vret.size(); ++i){
if( vret[i].first != vret[i - 1].first ) break;
else cnt++;
}
for(unsigned int i = now; i < now + cnt; ++i) vret[i].second = cnt;
now += cnt;
}
while( true ){
vector<pair<T, int > >::iterator itV = unique( vret.begin(), vret.end() );
if( itV != vret.end() ) vret.erase( itV, vret.end() );
else break;
}
return vret;
}
bool Solve3(pair<int, bool> *box, set num, set combn, vector<pair<int,int> > &v, int pos, long double w){
if( pos == v.size() ){
long double ret;
ret = box[0].first + box[num - 1].first;
for(unsigned int i = 0; i < num - 1; ++i){
ret += 2 * sqrt((long double)(box[i].first * box[i+1].first));
}
if( ret <= w ){
//cout << ret << endl;
return true;
}
}else{
combStruct cmst;
set p[MAX];
set j, *q;
set s;
vector<int> vEmptyPlaces;
for(unsigned int i = 0; i < num; i++) if( !box[i].second ){
//cout << i << ' ';
vEmptyPlaces.push_back(i);
}
//cout << endl;
cmst.N = vEmptyPlaces.size();
cmst.K = v[pos].second;
cmst.x = ( 1 << cmst.K ) - 1L;
cmst.overx = ~( ( 1 << cmst.N ) - 1L );
for(j = 1, q = p, s = cmst.x; j <= cmst.N; j++){ if(s & 1) *q++ = j; s >>= 1; }
do{
// TODO
/*for(int i = 0; i < cmst.K; i++){
cout << p[i] << ' ';
}
cout << endl;*/
//cout << '(' << cmst.K << ',' << vEmptyPlaces.size() << ")\n";
for(unsigned int i = 0; i < cmst.K; ++i){
box[ vEmptyPlaces[p[i] - 1] ] = make_pair( v[pos].first, true );
}
if( Solve3( box, num, num-cmst.K, v, pos+1, w ) ) return true;
for(unsigned int i = 0; i < cmst.K; ++i){
box[ vEmptyPlaces[p[i] - 1] ] = make_pair( 0, false );
}
}while( subcomb( p, cmst ) );
}
return false;
}
int main(void){
while(true){
int num = 0;
long double boxLength;
pair<int,bool> box[MAX];
vector<pair<int,int> > vRCakes;
vector<int> vCakes;
cin >> boxLength;
if( cin.eof() ) break;
while( true ){
int tmp;
if( '\n' == cin.get() ) break;
cin >> tmp;
vCakes.push_back( tmp );
box[num].first = 0;
box[num].second = false;
num++;
}
sort(vCakes.begin(), vCakes.end());
// unique
vRCakes = unique(vCakes);
g_cnt = 0;
if( Solve3(box,num,num,vRCakes,0,boxLength) ) cout << "OK\n";
else cout << "NA\n";
//cout << g_cnt << endl;
}
return 0;
} | a.cc: In function 'std::vector<std::pair<T, int> > unique(const std::vector<T>&)':
a.cc:57:17: error: need 'typename' before 'std::vector<std::pair<T, int> >::iterator' because 'std::vector<std::pair<T, int> >' is a dependent scope
57 | vector<pair<T, int > >::iterator itV = unique( vret.begin(), vret.end() );
| ^~~~~~~~~~~~~~~~~~~~~~
a.cc:57:49: error: expected ';' before 'itV'
57 | vector<pair<T, int > >::iterator itV = unique( vret.begin(), vret.end() );
| ^~~~
| ;
a.cc:58:21: error: 'itV' was not declared in this scope
58 | if( itV != vret.end() ) vret.erase( itV, vret.end() );
| ^~~
a.cc: In instantiation of 'std::vector<std::pair<T, int> > unique(const std::vector<T>&) [with T = int]':
a.cc:136:19: required from here
136 | vRCakes = unique(vCakes);
| ~~~~~~^~~~~~~~
a.cc:57:41: error: dependent-name 'std::vector<std::pair<T, int> >::iterator' is parsed as a non-type, but instantiation yields a type
57 | vector<pair<T, int > >::iterator itV = unique( vret.begin(), vret.end() );
| ^~~~~~~~
a.cc:57:41: note: say 'typename std::vector<std::pair<T, int> >::iterator' if a type is meant
|
s358446664 | p00120 | C++ | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int length;
vector<int> rn;
double dp[1 << 12 + 1][12];
const int INF = 1000000;
// nÌrbgª§ÁÄ¢éª»Ý ÉüÁÄ¢é~
// nÌóÔ©ç½Çè¯éŬ̷³ðßé
void solve(){
for(int i = 0; i < 1 << rn.size(); i++){
fill(dp[i],dp[i]+12,INF);
}
for(int i = 0; i < rn.size(); i++){
dp[1<<i][i] = 2*rn[i];
}
for(int s = 1; s < 1 << rn.size(); s++){
for(int j = 0; j < rn.size(); j++){
if((s >> j & 1) == 0){
continue;
}
for(int i = 0; i < rn.size(); i++){
if((s >> i) & 1 == 0){
dp[s|1<<i][i] = min(dp[s|1<<i][i]
,dp[s][j] + 2*sqrt(rn[j]+rn[i])-rn[j]+rn[i]);
}
}
}
}
double minNum = INF;
for(int i = 0; i < rn.size(); i++){
minNum = min(minNum,dp[(1<<rn.size())-1][i]);
}
if(minNum < (double)length){
cout << "OK" << endl;
}
else
cout << "NA" << endl;
}
int main(){
int n;
string str;
while(1){
// fill(dp,dp+1<<12,-1);
rn.clear();
getline(cin,str);
if(cin.eof())
break;
bool flag = true;
string s;
for(int i = 0; i < str.size(); i++){
if(str[i] == ' '){
if(flag){
length = atoi(s.c_str());
flag = false;
}
else{
rn.push_back(atoi(s.c_str()));
}
s = "";
}
else if(i == str.size()-1){
s += str[i];
rn.push_back(atoi(s.c_str()));
}
else
s += str[i];
}
solve();
// cout << length << " " << flush;
// for(int i = 0; i < rn.size(); i++){
// cout << rn[i] << " " << flush;
// }
// cout << endl;
}
return 0;
} PAA= | a.cc:91:2: warning: null character(s) ignored
91 | }<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0006><U+0000><U+0000><U+0000>PA<U+001A>A<U+0008><U+001D>=<U+001D><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>
| ^~~~~~~~
a.cc:91:60: error: stray '\6' in program
91 | }<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0006><U+0000><U+0000><U+0000>PA<U+001A>A<U+0008><U+001D>=<U+001D><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>
| ^~~~~~~~
a.cc:91:61: warning: null character(s) ignored
91 | }<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0006><U+0000><U+0000><U+0000>PA<U+001A>A<U+0008><U+001D>=<U+001D><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>
| ^~~~~~~~
a.cc:91:66: error: stray '\32' in program
91 | }<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0006><U+0000><U+0000><U+0000>PA<U+001A>A<U+0008><U+001D>=<U+001D><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>
| ^~~~~~~~
a.cc:91:68: error: stray '\10' in program
91 | }<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0006><U+0000><U+0000><U+0000>PA<U+001A>A<U+0008><U+001D>=<U+001D><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>
| ^~~~~~~~
a.cc:91:69: error: stray '\35' in program
91 | }<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0006><U+0000><U+0000><U+0000>PA<U+001A>A<U+0008><U+001D>=<U+001D><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>
| ^~~~~~~~
a.cc:91:71: error: stray '\35' in program
91 | }<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0006><U+0000><U+0000><U+0000>PA<U+001A>A<U+0008><U+001D>=<U+001D><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>
| ^~~~~~~~
a.cc:91:72: warning: null character(s) ignored
91 | }<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0006><U+0000><U+0000><U+0000>PA<U+001A>A<U+0008><U+001D>=<U+001D><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>
| ^~~~~~~~
a.cc:91:74: error: stray '\1' in program
91 | }<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0006><U+0000><U+0000><U+0000>PA<U+001A>A<U+0008><U+001D>=<U+001D><U+0000><U+0000><U+0001><U+0000><U+000 |
s109262884 | p00120 | C++ | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A) (A).begin(),(A).end()
#define DUMP(A) cout<<#A<<"="<<(A)<< endl
#define SIZE(A) (int)((A).size())
#define SQ(A) ((A)*(A))
using namespace std;
typedef long long ll;
int main(){
int role[12];
char li[100];
while(gets(li)!=NULL){
int len;
char sp[]=" ";
char *res=NULL;
sscanf(strtok(li,sp),"%d",&len);
int n=0;
for(;;){
res=strtok(NULL,sp);
if(res==NULL) break;
sscanf(res,"%d",&role[n]);
n++;
}
double path[13][13];
for(int i=0;i<n;i++){
path[0][i]=path[i][0]=role[i];
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
path[i][j]=sqrt(SQ(role[i]+role[j])-SQ(role[i]-role[j]));
}
}
double dp[1<<n][n];
for(int i=0;i<n;i++){
dp[0][i]=0;
}
for(int i=1;i<(1<<n);i++){
for(int j=0;j<n;j++){
dp[i][j]=10000;
if(i&(1<<j)){
int bef=i-(i&(1<<j));
for(int k=0;k<n;k++){
if(bef==0){
dp[i][j]=min(dp[i][j],(double)role[j]);
}else if(bef&(1<<k)){
dp[i][j]=min(dp[i][j],dp[bef][k]+path[k][j]);
}
}
}
}
}
double ret=10000;
for(int i=0;i<n;i++){
ret=min(ret,dp[(1<<n)-1][i]+role[i]);
}
if(ret<=len) printf("OK\n");
else printf("NA\n");
}
} | a.cc: In function 'int main()':
a.cc:33:11: error: 'gets' was not declared in this scope; did you mean 'getw'?
33 | while(gets(li)!=NULL){
| ^~~~
| getw
|
s501040219 | p00120 | C++ | //38
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<cmath>
using namespace std;
int c[11];
bool dfs(double r,int nr,int p){
if(nr==0){
return r>=p;
}else{
for(int i=3;i<=10;i++){
if(c[i]){
c[i]--;
if(dfs(r-2*sqrt(i*p),nr-1,i))return true;
c[i]++;
}
}
return false;
}
}
int main(){
for(int w;cin>>w;){
string s;
getline(cin,s);
stringstream ss(s);
fill(c,c+11,0);
int nr=0;
for(int r;ss>>r;){
c[r]++;
nr++;
}
int i;
for(i=3;i<=10;i++){
if(c[i]){
c[i]--;
if(dfs(w-i,nr-1,i))break;
c[i]++;
}
}
cout<<((i<v.size())?"OK":"NA")<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:46:15: error: 'v' was not declared in this scope
46 | cout<<((i<v.size())?"OK":"NA")<<endl;
| ^
|
s463614858 | p00120 | C++ | #include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include <sstream>
using namespace std;
const double INF=1000000000;
double ans;
double l;
bool flag;
string str;
vector<double> r;
double dp[1<<12][12];
void rec(int x,int bit,double nl,double nh){
if(dp[bit][x]<nl)return;
dp[bit][x]=nl;
if(bit==(1<<r.size())-1){
if(nl+nh<=l)flag=true;
ans=min(ans,nl+nh);
return;
}
else{
for(int i=0;i<r.size();i++){
if(!(bit>>i & 1)){
double nnh=r[i];
double nnl=nl+sqrt(pow(nh+nnh,2)-pow(fabs(nh-nnh),2));
if(nnl<dp[bit | 1<<i][i]){
dp[bit | 1<<i][i]=nnl;
rec(i,bit | 1<<i,nnl,nnh);
}
}
}
}
}
int main(void){
while(getline(cin,str)){
flag=false;
ans=INF;
r.clear();
for(int i=0;i<(1<<12)-1;i++){
for(int j=0;j<12;j++){
dp[i][j]=INF;
}
}
stringstream input(str);
input >> l;
double a;
while(input >> a)r.push_back(a);
for(int i=0;i<r.size();i++){
rec(i,1<<i,r[i],r[i]);
}
if(flag)cout << "OK" << endl;
else cout << "NA" << endl;
}
return 0;
} | a.cc: In function 'void rec(int, int, double, double)':
a.cc:29:52: error: 'pow' was not declared in this scope
29 | double nnl=nl+sqrt(pow(nh+nnh,2)-pow(fabs(nh-nnh),2));
| ^~~
a.cc:29:70: error: 'fabs' was not declared in this scope; did you mean 'labs'?
29 | double nnl=nl+sqrt(pow(nh+nnh,2)-pow(fabs(nh-nnh),2));
| ^~~~
| labs
a.cc:29:47: error: 'sqrt' was not declared in this scope
29 | double nnl=nl+sqrt(pow(nh+nnh,2)-pow(fabs(nh-nnh),2));
| ^~~~
|
s026535665 | p00120 | C++ | #include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <cmath>
#define MAX 12
using namespace std;
vector<int> split(const string &str, char delim){
istringstream iss(str); string tmp; vector<int> res;
while(getline(iss, tmp, delim)) {
int i;
std::istringstream iss(tmp);
iss >> i;
res.push_back(i);
}
return res;
}
float d[MAX][MAX];
float dp[1 << MAX][MAX];
int size;
float rec(int S, int v) {
if (dp[S][v] >= 0) return dp[S][v];
if (S == (1 << size) -1 && v == 0) {
return dp[S][v] = 0;
}
float res = 99999;
for (int u = 0; u < size; u++) {
if(!(S >> u & 1))
res = min(res, rec(S | 1 << u, u) + d[v][u]);
}
return dp[S][v] = res;
}
int main(int argc, char const* argv[])
{
string line;
while(getline(cin, line)) {
vector<int> params = split(line, ' ');
vector<int> cakes;
int weight = params.front();
for (vector<int>::iterator it = params.begin(); it != params.end(); it++) {
if(it == params.begin()) {weight = *it; continue;}
cakes.push_back(*it);
}
size = cakes.size();
for (int i = 0; i < size; i++) {
for (int j = i; j < size; j++) {
int i_r = cakes.at(i);
int j_r = cakes.at(j);
float sq = sqrt(pow(i_r + j_r, 2.0) - pow(i_r - j_r, 2.0));
if (i_r == j_r) sq = i_r + j_r;
d[i][j] = sq;
d[j][i] = sq;
}
}
memset(dp, -1, sizeof(dp));
float min_val = 99999;
for (int i = 0; i < size; i++) {
float rec_val = rec(0,i);
if (rec_val == 0) continue;
min_val = min(rec_val, min_val);
}
if (min_val > weight) {
std::cout << "NA" << std::endl;
} else {
std::cout << "OK" << std::endl;
}
}
return 0;
} | a.cc: In function 'float rec(int, int)':
a.cc:29:20: error: reference to 'size' is ambiguous
29 | if (S == (1 << size) -1 && v == 0) {
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc:34:25: error: reference to 'size' is ambiguous
34 | for (int u = 0; u < size; u++) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc: In function 'int main(int, const char**)':
a.cc:57:9: error: reference to 'size' is ambiguous
57 | size = cakes.size();
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc:58:29: error: reference to 'size' is ambiguous
58 | for (int i = 0; i < size; i++) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc:59:33: error: reference to 'size' is ambiguous
59 | for (int j = i; j < size; j++) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc:69:9: error: 'memset' was not declared in this scope
69 | memset(dp, -1, sizeof(dp));
| ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
5 | #include <cmath>
+++ |+#include <cstring>
6 |
a.cc:72:29: error: reference to 'size' is ambiguous
72 | for (int i = 0; i < size; i++) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
|
s847088919 | p00120 | C++ | #include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <cmath>
#define MAX 12
using namespace std;
vector<int> split(const string &str, char delim){
istringstream iss(str); string tmp; vector<int> res;
while(getline(iss, tmp, delim)) {
int i;
std::istringstream iss(tmp);
iss >> i;
res.push_back(i);
}
return res;
}
float d[MAX][MAX];
float dp[1 << MAX][MAX];
int size;
float rec(int S, int v) {
if (dp[S][v] >= 0) return dp[S][v];
if (S == (1 << size) -1 && v == 0) {
return dp[S][v] = 0;
}
float res = 99999;
for (int u = 0; u < size; u++) {
if(!(S >> u & 1))
res = min(res, rec(S | 1 << u, u) + d[v][u]);
}
return dp[S][v] = res;
}
int main(int argc, char const* argv[])
{
string line;
while(getline(cin, line)) {
vector<int> params = split(line, ' ');
vector<int> cakes;
int weight = params.front();
for (vector<int>::iterator it = params.begin(); it != params.end(); it++) {
if(it == params.begin()) {weight = *it; continue;}
cakes.push_back(*it);
}
size = cakes.size();
for (int i = 0; i < size; i++) {
for (int j = i; j < size; j++) {
int i_r = cakes.at(i);
int j_r = cakes.at(j);
float sq = sqrt(pow(i_r + j_r, 2.0) - pow(i_r - j_r, 2.0));
if (i_r == j_r) sq = i_r + j_r;
d[i][j] = sq;
d[j][i] = sq;
}
}
memset(dp, -1, sizeof(dp));
float min_val = 99999;
for (int i = 0; i < size; i++) {
float rec_val = rec(0,i);
if (rec_val == 0) continue;
min_val = min(rec_val, min_val);
}
if (min_val > weight) {
std::cout << "NA" << std::endl;
} else {
std::cout << "OK" << std::endl;
}
}
return 0;
} | a.cc: In function 'float rec(int, int)':
a.cc:29:20: error: reference to 'size' is ambiguous
29 | if (S == (1 << size) -1 && v == 0) {
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc:34:25: error: reference to 'size' is ambiguous
34 | for (int u = 0; u < size; u++) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc: In function 'int main(int, const char**)':
a.cc:57:9: error: reference to 'size' is ambiguous
57 | size = cakes.size();
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc:58:29: error: reference to 'size' is ambiguous
58 | for (int i = 0; i < size; i++) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc:59:33: error: reference to 'size' is ambiguous
59 | for (int j = i; j < size; j++) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc:69:9: error: 'memset' was not declared in this scope
69 | memset(dp, -1, sizeof(dp));
| ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
5 | #include <cmath>
+++ |+#include <cstring>
6 |
a.cc:72:29: error: reference to 'size' is ambiguous
72 | for (int i = 0; i < size; i++) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
|
s023550640 | p00120 | C++ | #include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <cmath>
#define MAX 12
using namespace std;
vector<int> split(const string &str, char delim){
istringstream iss(str); string tmp; vector<int> res;
while(getline(iss, tmp, delim)) {
int i;
std::istringstream iss(tmp);
iss >> i;
res.push_back(i);
}
return res;
}
float d[MAX][MAX];
float dp[1 << MAX][MAX];
int size;
float rec(int S, int v) {
if (dp[S][v] >= 0) return dp[S][v];
if (S == (1 << size) -1 && v == 0) {
return dp[S][v] = 0;
}
float res = 99999;
for (int u = 0; u < size; u++) {
if(!(S >> u & 1))
res = min(res, rec(S | 1 << u, u) + d[v][u]);
}
return dp[S][v] = res;
}
int main(int argc, char const* argv[])
{
string line;
while(getline(cin, line)) {
vector<int> params = split(line, ' ');
vector<int> cakes;
int weight = params.front();
for (vector<int>::iterator it = params.begin(); it != params.end(); it++) {
if(it == params.begin()) {weight = *it; continue;}
cakes.push_back(*it);
}
size = cakes.size();
for (int i = 0; i < size; i++) {
for (int j = i; j < size; j++) {
int i_r = cakes.at(i);
int j_r = cakes.at(j);
float sq = sqrt(pow(i_r + j_r, 2.0) - pow(i_r - j_r, 2.0));
if (i_r == j_r) sq = i_r + j_r;
d[i][j] = sq;
d[j][i] = sq;
}
}
memset(dp, -1, sizeof(dp));
float min_val = 99999;
for (int i = 0; i < size; i++) {
float rec_val = rec(0,i);
if (rec_val == 0) continue;
min_val = min(rec_val, min_val);
}
if (min_val > weight) {
std::cout << "NA" << std::endl;
} else {
std::cout << "OK" << std::endl;
}
}
return 0;
} | a.cc: In function 'float rec(int, int)':
a.cc:29:20: error: reference to 'size' is ambiguous
29 | if (S == (1 << size) -1 && v == 0) {
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc:34:25: error: reference to 'size' is ambiguous
34 | for (int u = 0; u < size; u++) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc: In function 'int main(int, const char**)':
a.cc:57:9: error: reference to 'size' is ambiguous
57 | size = cakes.size();
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc:58:29: error: reference to 'size' is ambiguous
58 | for (int i = 0; i < size; i++) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc:59:33: error: reference to 'size' is ambiguous
59 | for (int j = i; j < size; j++) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
a.cc:69:9: error: 'memset' was not declared in this scope
69 | memset(dp, -1, sizeof(dp));
| ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
5 | #include <cmath>
+++ |+#include <cstring>
6 |
a.cc:72:29: error: reference to 'size' is ambiguous
72 | for (int i = 0; i < size; i++) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:24:5: note: 'int size'
24 | int size;
| ^~~~
|
s162944387 | p00120 | C++ | #include <iostream>
#include <vector>
#include <set>
#include <sstream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
typedef long long LL;
#define OFFSET 2
int box_width;
double dist(int r1, int r2)
{
double a = pow(abs(r1 - r2), 2);
double b = pow(r1 + r2, 2);
return sqrt(-a + b);
}
bool solve(vector<int> cakes, LL state)
{
if (cakes.empty()) {
// calculate the length
double length = 0;
int prev = 0;
int save_state = state;
do {
int current = state % 10 + OFFSET;
state /= 10;
if (prev) {
length -= prev;
length += dist(prev, current);
length += current;
} else {
length += current * 2;
}
prev = current;
} while (state);
// cout << "state: " << save_state << ", length: " << length << endl;
if (length <= box_width) {
return true;
} else {
return false;
}
}
int prev_cake = 0;
for (int i = 0; i < cakes.size(); ++i) {
vector<int> next_cakes = cakes;
int cake = next_cakes[i];
if (cake == prev_cake) {
next;
}
LL next_state = state * 10 + (cake - OFFSET);
next_cakes.erase(next_cakes.begin() + i);
if (solve(next_cakes, next_state)) {
return true;
}
prev_cake = cake;
}
return false;
}
int main()
{
while (cin >> box_width) {
string line;
stringstream ss;
vector<int> cakes;
getline(cin, line);
ss << line;
int r;
while (ss >> r) {
cakes.push_back(r);
}
sort(cakes.begin(), cakes.end());
if (solve(cakes, 0)) {
cout << "OK" << endl;
} else {
cout << "NA" << endl;
}
}
} | a.cc: In function 'bool solve(std::vector<int>, LL)':
a.cc:53:29: error: statement cannot resolve address of overloaded function
53 | next;
| ^
|
s627180401 | p00121 | Java | import com.sun.tools.javac.parser.Tokens;
import java.io.*;
import java.util.*;
public class Main {
void run() {
try {
for (String line; (line = in.readLine()) != null; ) {
StringTokenizer tokenizer = new StringTokenizer(line);
int[] init = new int[8];
for (int i = 0; i < 8; i++) {
init[i] = Integer.parseInt(tokenizer.nextToken());
}
// sysout.println("init = " + Arrays.toString(init));
HashMap<String, Integer> d = new HashMap<String, Integer>();
d.put(Arrays.toString(init), 0);
Queue<int[]> que = new ArrayDeque<>();
que.add(init);
int[][] swap = {{1, 4}, {0, 2, 5}, {1, 3, 6}, {2, 7}, {0, 5}, {1, 4, 6}, {2, 5, 7}, {3, 6}};
while (que.isEmpty() == false) {
int zeroPos = -1;
int[] cur = que.poll();
// sysout.println(Arrays.toString(cur) + " -> " + d.get(Arrays.toString(cur)));
for (int i = 0; i < 8; i++) {
if (cur[i] == 0) {
zeroPos = i;
}
}
for (int i = 0; i < swap[zeroPos].length; i++) {
int swapPos = swap[zeroPos][i];
int[] next = cur.clone();
int t = next[zeroPos];
next[zeroPos] = next[swapPos];
next[swapPos] = t;
String s = Arrays.toString(next);
if (d.containsKey(s) == false) {
d.put(s, d.get(Arrays.toString(cur)) + 1);
que.add(next);
}
}
}
sysout.println(d.get(Arrays.toString(new int[]{0, 1, 2, 3, 4, 5, 6, 7})));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static void main(String[] args) {
new Main().run();
}
// flush automatically iff you call `println` or `printf` or `format`.
PrintWriter sysout = new PrintWriter(System.out, true);
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer buffer = new StringTokenizer("");
String read() {
if (!buffer.hasMoreTokens()) {
try {
buffer = new StringTokenizer(in.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return buffer.nextToken();
}
int readInt() {
return Integer.parseInt(read());
}
long readLong() {
return Long.parseLong(read());
}
double readDouble() {
return Double.parseDouble(read());
}
String readLine() {
buffer = new StringTokenizer("");
try {
return in.readLine();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
} | Main.java:1: error: package com.sun.tools.javac.parser is not visible
import com.sun.tools.javac.parser.Tokens;
^
(package com.sun.tools.javac.parser is declared in module jdk.compiler, which does not export it to the unnamed module)
1 error
|
s983299331 | p00121 | Java | import com.sun.tools.javac.parser.Tokens;
import java.io.*;
import java.util.*;
public class Main {
void run() {
try {
for (String line; (line = in.readLine()) != null; ) {
StringTokenizer tokenizer = new StringTokenizer(line);
int[] init = new int[8];
for (int i = 0; i < 8; i++) {
init[i] = Integer.parseInt(tokenizer.nextToken());
}
// sysout.println("init = " + Arrays.toString(init));
HashMap<String, Integer> d = new HashMap<String, Integer>();
d.put(Arrays.toString(init), 0);
Queue<int[]> que = new ArrayDeque<int[]>();
que.add(init);
int[][] swap = {{1, 4}, {0, 2, 5}, {1, 3, 6}, {2, 7}, {0, 5}, {1, 4, 6}, {2, 5, 7}, {3, 6}};
while (que.isEmpty() == false) {
int zeroPos = -1;
int[] cur = que.poll();
// sysout.println(Arrays.toString(cur) + " -> " + d.get(Arrays.toString(cur)));
for (int i = 0; i < 8; i++) {
if (cur[i] == 0) {
zeroPos = i;
}
}
for (int i = 0; i < swap[zeroPos].length; i++) {
int swapPos = swap[zeroPos][i];
int[] next = cur.clone();
int t = next[zeroPos];
next[zeroPos] = next[swapPos];
next[swapPos] = t;
String s = Arrays.toString(next);
if (d.containsKey(s) == false) {
d.put(s, d.get(Arrays.toString(cur)) + 1);
que.add(next);
}
}
}
sysout.println(d.get(Arrays.toString(new int[]{0, 1, 2, 3, 4, 5, 6, 7})));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static void main(String[] args) {
new Main().run();
}
// flush automatically iff you call `println` or `printf` or `format`.
PrintWriter sysout = new PrintWriter(System.out, true);
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer buffer = new StringTokenizer("");
String read() {
if (!buffer.hasMoreTokens()) {
try {
buffer = new StringTokenizer(in.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return buffer.nextToken();
}
int readInt() {
return Integer.parseInt(read());
}
long readLong() {
return Long.parseLong(read());
}
double readDouble() {
return Double.parseDouble(read());
}
String readLine() {
buffer = new StringTokenizer("");
try {
return in.readLine();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
} | Main.java:1: error: package com.sun.tools.javac.parser is not visible
import com.sun.tools.javac.parser.Tokens;
^
(package com.sun.tools.javac.parser is declared in module jdk.compiler, which does not export it to the unnamed module)
1 error
|
s370820359 | p00121 | Java |
import java.util.*;
public class Main {
static final int[] dir={1,-1,4,-4};
static Map<String,Integer> m=new HashMap<String,Integer>();
static void bfs(){
String s="01234567";
m.put(s,0);
Queue<String> que=new LinkedList<String>();
que.offer(s);
while(!que.isEmpty()){
String tmp=que.poll();
int step=m.get(tmp);
//謇セ蛻ー'0'
int index=-100;
for(int i=0;i<8;i++)
if(tmp.charAt(i)=='0') index=i;
//遘サ蜉ィ'0'
for(int i=0;i<4;i++){
if((index==3&&dir[i]==1)||(index==4&&dir[i]==-1)) continue;
int newindex=index+dir[i];
if(newindex>=0&&newindex<8){
//莠、謐「
StringBuffer sss=new StringBuffer(tmp);
sss.setCharAt(index, tmp.charAt(newindex));
sss.setCharAt(newindex, tmp.charAt(index));
//System.out.println(tmp+" "+sss.toString());
String tmp1=sss.toString();
//譛ェ蜃コ邇ー鬘コ蠎擾シ悟?髦? if(m.get(tmp1)==null){
m.put(tmp1,step+1);
que.offer(tmp1);
}
}
}
}
}
public static void main(String[] args){
bfs();
String input=null;
Scanner scan=new Scanner(System.in);
while((input=scan.nextLine()).length()>7){
input=input.replace(" ","");
System.out.println(m.get(input));
}
scan.close();
}
} | Main.java:39: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args){
^
(use --enable-preview to enable unnamed classes)
Main.java:49: error: class, interface, enum, or record expected
}
^
2 errors
|
s430281300 | p00121 | Java | import java.util.*;
class State {
private static int[] vy = {0, 1, 0, -1};
private static int[] vx = {1, 0, -1, 0};
private int[][] nums;
private int zeroY, zeroX;
private int hash;
int step;
public State(int[][] _nums, int _zeroY, int _zeroX, int _step) {
nums = _nums;
zeroY = _zeroY;
zeroX = _zeroX;
hash = -1;
step = _step;
}
@Override
public int hashCode() {
if (hash != -1) return hash;
hash = 0;
for (int y=0; y<2; y++) {
for (int x=0; x<4; x++) {
hash = hash*10 + nums[y][x];
}
}
return hash;
}
public LinkedList<State> nextMove() {
LinkedList<State> ret = new LinkedList<>();
for (int i=0; i<4; i++) {
int nextZeroY = zeroY + vy[i];
if (nextZeroY < 0 || nextZeroY >= 2) continue;
int nextZeroX = zeroX + vx[i];
if (nextZeroX < 0 || nextZeroX >= 4) continue;
int[][] nextNums = new int[2][4];
for (int y=0; y<2; y++) {
for (int x=0; x<4; x++) {
nextNums[y][x] = nums[y][x];
}
}
nextNums[nextZeroY][nextZeroX] = 0;
nextNums[zeroY][zeroX] = nums[nextZeroY][nextZeroX];
ret.add(new State(nextNums, nextZeroY, nextZeroX, step+1));
}
return ret;
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Queue<State> queue = new LinkedList<>();
Set<Integer> set = new HashSet<>();
State firstState;
int[][] firstNums = new int[2][4];
int firstZeroY = -1, firstZeroX = -1;
while (sc.hasNext()) {
for (int y=0; y<2; y++) {
for (int x=0; x<4; x++) {
firstNums[y][x] = sc.nextInt();
if (firstNums[y][x] == 0) {
firstZeroY = y;
firstZeroX = x;
}
}
}
firstState = new State(firstNums, firstZeroY, firstZeroX, 0);
set.add(firstState.hashCode());
queue.add(firstState);
while (!queue.isEmpty()) {
State nowState = queue.poll();
if (nowState.hashCode() == 1234567) {
System.out.println(nowState.step);
break;
}
for (State nextState : nowState.nextMove()) {
if (!set.contains(nextState.hashCode())) {
set.add(nextState.hashCode());
queue.add(nextState);
}
}
}
queue.clear();
set.clear();
}
} | Main.java:101: error: reached end of file while parsing
}
^
1 error
|
s203577446 | p00121 | Java | public class Main {
private static int[] move = {1, -1, 4, -4};
private static Map<String, Integer> map = new HashMap<>();
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
dsf();
while (in.hasNext()) {
String str = in.nextLine();
str = str.replaceAll("\\s+", "");
System.out.println(map.get(str));
}
}
private static void dsf() {
Queue<String> q = new LinkedList<>();
map.put("01234567", 0);
q.add("01234567");
while (!q.isEmpty()) {
String init = q.peek();
q.poll();
int p = 0;
for (int i = 0; i < 8; i++) {
if (init.charAt(i) == '0') {
p = i;
break;
}
}
for (int i = 0; i < 4; i++) {
int dx = p + move[i]; // ?????¢????¬??????????
if (0 <= dx && dx < 8 &&
!(p == 3 && i == 0) && // ??????????????????????§?
!(p == 4 && i == 1)) { // ??????????????????????§?
String next = swap(init, p, dx);
if (!map.containsKey(next)) {
int val = map.get(init) + 1;
map.put(next, val);
q.add(next);
}
}
}
}
}
private static String swap(String str, int init, int toChange) {
char[] chars = str.toCharArray();
char temp = chars[init];
chars[init] = chars[toChange];
chars[toChange] = temp;
return new String(chars);
}
} | Main.java:3: error: cannot find symbol
private static Map<String, Integer> map = new HashMap<>();
^
symbol: class Map
location: class Main
Main.java:3: error: cannot find symbol
private static Map<String, Integer> map = new HashMap<>();
^
symbol: class HashMap
location: class Main
Main.java:5: error: cannot find symbol
Scanner in = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:5: error: cannot find symbol
Scanner in = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:14: error: cannot find symbol
Queue<String> q = new LinkedList<>();
^
symbol: class Queue
location: class Main
Main.java:14: error: cannot find symbol
Queue<String> q = new LinkedList<>();
^
symbol: class LinkedList
location: class Main
6 errors
|
s233068448 | p00121 | Java | import java.util.*;
import java.io.*;
public class q0121 {
static IO io = new IO();
public static void main(String[] args) {
while (io.hasNext()) {
// 0..7:????????????????????¶??? 8:???????????§?¨? 9:??´??????????????§?¨? 10:???????????°
int n[] = new int[11];
Deque<int[]> que = new ArrayDeque<int[]>();
for (int i=0; i<=7; i++) {
n[i] = io.nextInt();
if (n[i]==0) n[8] = i;
}
n[9] = -1;
que.offer(n);
int ans = 0;
while (!que.isEmpty()) {
int[] poll = que.pollFirst();
int now = poll[8];
int pre = poll[9];
boolean finish = true;
for (int i=0; i<=7; i++) if (poll[i]!=i) {
finish = false;
break;
}
if (finish) {
ans = poll[10];
break;
}
poll[10]++;
if (now!=0 && now!=4 && pre!=now-1) {//???
poll[now] = poll[now-1];
poll[now-1] = 0;
poll[8]--;
poll[9]=now;
que.offer(poll.clone());
poll[now-1] = poll[now];
poll[now] = 0;
poll[8]++;
poll[9]=pre;
}
if (4<=now && pre!=now-4) {//???
poll[now] = poll[now-4];
poll[now-4] = 0;
poll[8]-=4;
poll[9]=now;
que.offer(poll.clone());
poll[now-4] = poll[now];
poll[now] = 0;
poll[8]+=4;
poll[9]=pre;
}
if (now!=3 && now!=7 && pre!=now+1) {//???
poll[now] = poll[now+1];
poll[now+1] = 0;
poll[8]++;
poll[9]=now;
que.offer(poll.clone());
poll[now+1] = poll[now];
poll[now] = 0;
poll[8]--;
poll[9]=pre;
}
if (now<=3 && pre!=now+4) {//???
poll[now] = poll[now+4];
poll[now+4] = 0;
poll[8]+=4;
poll[9]=now;
que.offer(poll.clone());
poll[now+4] = poll[now];
poll[now] = 0;
poll[8]-=4;
poll[9]=pre;
}
}
System.out.println(ans);
}
}
static class IO extends PrintWriter {
private final InputStream in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
public IO() { this(System.in);}
public IO(InputStream source) { super(System.out); this.in = source;}
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
}else{
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
private static boolean isNewLine(int c) { return c == '\n' || c == '\r';}
private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
private void skipNewLine() { while(hasNextByte() && isNewLine(buffer[ptr])) ptr++;}
public boolean hasNext() { skipUnprintable(); return hasNextByte();}
public boolean hasNextLine() { skipNewLine(); return hasNextByte();}
public String next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
StringBuilder sb = new StringBuilder();
int b = readByte();
while(isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public char[] nextCharArray(int len) {
if (!hasNext()) {
throw new NoSuchElementException();
}
char[] s = new char[len];
int i = 0;
int b = readByte();
while(isPrintableChar(b)) {
if (i == len) {
throw new InputMismatchException();
}
s[i++] = (char) b;
b = readByte();
}
return s;
}
public String nextLine() {
if (!hasNextLine()) {
throw new NoSuchElementException();
}
StringBuilder sb = new StringBuilder();
int b = readByte();
while(!isNewLine(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext()) {
throw new NoSuchElementException();
}
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while(true){
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
}else if(b == -1 || !isPrintableChar(b)){
return minus ? -n : n;
}else{
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() {
long nl = nextLong();
if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
throw new NumberFormatException();
}
return (int) nl;
}
public char nextChar() {
if (!hasNext()) {
throw new NoSuchElementException();
}
return (char) readByte();
}
public double nextDouble() { return Double.parseDouble(next());}
public int[] arrayInt(int n) { int[] a = new int[n]; for(int i=0;i<n;i++) a[i] = nextInt(); return a;}
public long[] arrayLong(int n) { long[] a = new long[n]; for(int i=0;i<n;i++) a[i] = nextLong(); return a;}
public double[] arrayDouble(int n) { double[] a = new double[n]; for(int i=0;i<n;i++) a[i] = nextDouble(); return a;}
public void arrayInt(int[]... a) {for(int i=0;i<a[0].length;i++) for(int j=0;j<a.length;j++) a[j][i] = nextInt();}
public int[][] matrixInt(int n,int m) { int[][] a = new int[n][]; for(int i=0;i<n;i++) a[i] = arrayInt(m); return a;}
public char[][] charMap(int n,int m) { char[][] a = new char[n][]; for(int i=0;i<n;i++) a[i] = nextCharArray(m); return a;}
public void close() {
super.close();
try {
in.close();
} catch (IOException e) {}
}
}
} | Main.java:3: error: class q0121 is public, should be declared in a file named q0121.java
public class q0121 {
^
1 error
|
s556747771 | p00121 | Java | import java.util.*;
import java.io.*;
public class Main {
static IO io = new IO();
public static void main(String[] args) {
while (io.hasNext()) {
// 0..7:????????????????????¶??? 8:???????????§?¨? 9:??´??????????????§?¨? 10:???????????°
int n[] = new int[11];
Deque<int[]> que = new ArrayDeque<int[]>();
for (int i=0; i<=7; i++) {
n[i] = io.nextInt();
if (n[i]==0) n[8] = i;
}
n[9] = -1;
que.offer(n);
int ans = 0;
while (!que.isEmpty()) {
int[] poll = que.pollFirst();
int now = poll[8];
int pre = poll[9];
boolean finish = true;
for (int i=0; i<=7; i++) if (poll[i]!=i) {
finish = false;
break;
}
if (finish) {
ans = poll[10];
break;
}
poll[10]++;
if (now!=0 && now!=4 && pre!=now-1) {//???
poll[now] = poll[now-1];
poll[now-1] = 0;
poll[8]--;
poll[9]=now;
que.offer(poll.clone());
poll[now-1] = poll[now];
poll[now] = 0;
poll[8]++;
poll[9]=pre;
}
if (4<=now && pre!=now-4) {//???
poll[now] = poll[now-4];
poll[now-4] = 0;
poll[8]-=4;
poll[9]=now;
que.offer(poll.clone());
poll[now-4] = poll[now];
poll[now] = 0;
poll[8]+=4;
poll[9]=pre;
}
if (now!=3 && now!=7 && pre!=now+1) {//???
poll[now] = poll[now+1];
poll[now+1] = 0;
poll[8]++;
poll[9]=now;
que.offer(poll.clone());
poll[now+1] = poll[now];
poll[now] = 0;
poll[8]--;
poll[9]=pre;
}
if (now<=3 && pre!=now+4) {//???
poll[now] = poll[now+4];
poll[now+4] = 0;
poll[8]+=4;
poll[9]=now;
que.offer(poll.clone());
poll[now+4] = poll[now];
poll[now] = 0;
poll[8]-=4;
poll[9]=pre;
}
}
System.out.println(ans);
}
}
static class IO extends PrintWriter {
private final InputStream in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
public IO() { this(System.in);}
public IO(InputStream source) { super(System.out); this.in = source;}
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
}else{
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
private static boolean isNewLine(int c) { return c == '\n' || c == '\r';}
private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
private void skipNewLine() { while(hasNextByte() && isNewLine(buffer[ptr])) ptr++;}
public boolean hasNext() { skipUnprintable(); return hasNextByte();}
public boolean hasNextLine() { skipNewLine(); return hasNextByte();}
public String next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
StringBuilder sb = new StringBuilder();
int b = readByte();
while(isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public char[] nextCharArray(int len) {
if (!hasNext()) {
throw new NoSuchElementException();
}
char[] s = new char[len];
int i = 0;
int b = readByte();
while(isPrintableChar(b)) {
if (i == len) {
throw new InputMismatchException();
}
s[i++] = (char) b;
b = readByte();
}
return s;
}
public String nextLine() {
if (!hasNextLine()) {
throw new NoSuchElementException();
}
StringBuilder sb = new StringBuilder();
int b = readByte();
while(!isNewLine(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext()) {
throw new NoSuchElementException();
}
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while(true){
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
}else if(b == -1 || !isPrintableChar(b)){
return minus ? -n : n;
}else{
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() {
long nl = nextLong();
if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
throw new NumberFormatException();
}
return (int) nl;
}
public char nextChar() {
if (!hasNext()) {
throw new NoSuchElementException();
}
return (char) readByte();
}
public double nextDouble() { return Double.parseDouble(next());}
public int[] arrayInt(int n) { int[] a = new int[n]; for(int i=0;i<n;i++) a[i] = nextInt(); return a;}
public long[] arrayLong(int n) { long[] a = new long[n]; for(int i=0;i<n;i++) a[i] = nextLong(); return a;}
public double[] arrayDouble(int n) { double[] a = new double[n]; for(int i=0;i<n;i++) a[i] = nextDouble(); return a;}
public void arrayInt(int[]... a) {for(int i=0;i<a[0].length;i++) for(int j=0;j<a.length;j++) a[j][i] = nextInt();}
public int[][] matrixInt(int n,int m) { int[][] a = new int[n][]; for(int i=0;i<n;i++) a[i] = arrayInt(m); return a;}
public char[][] charMap(int n,int m) { char[][] a = new char[n][]; for(int i=0;i<n;i++) a[i] = nextCharArray(m); return a;}
public void close() {
super.close();
try {
in.close();
} catch (IOException e) {}
}
}
}
import java.util.*;
import java.io.*;
public class q0121 {
static IO io = new IO();
public static void main(String[] args) {
while (io.hasNext()) {
// 0..7:????????????????????¶??? 8:???????????§?¨? 9:??´??????????????§?¨? 10:???????????°
int n[] = new int[11];
Deque<int[]> que = new ArrayDeque<int[]>();
for (int i=0; i<=7; i++) {
n[i] = io.nextInt();
if (n[i]==0) n[8] = i;
}
n[9] = -1;
que.offer(n);
int ans = 0;
while (!que.isEmpty()) {
int[] poll = que.pollFirst();
int now = poll[8];
int pre = poll[9];
boolean finish = true;
for (int i=0; i<=7; i++) if (poll[i]!=i) {
finish = false;
break;
}
if (finish) {
ans = poll[10];
break;
}
poll[10]++;
if (now!=0 && now!=4 && pre!=now-1) {//???
poll[now] = poll[now-1];
poll[now-1] = 0;
poll[8]--;
poll[9]=now;
que.offer(poll.clone());
poll[now-1] = poll[now];
poll[now] = 0;
poll[8]++;
poll[9]=pre;
}
if (4<=now && pre!=now-4) {//???
poll[now] = poll[now-4];
poll[now-4] = 0;
poll[8]-=4;
poll[9]=now;
que.offer(poll.clone());
poll[now-4] = poll[now];
poll[now] = 0;
poll[8]+=4;
poll[9]=pre;
}
if (now!=3 && now!=7 && pre!=now+1) {//???
poll[now] = poll[now+1];
poll[now+1] = 0;
poll[8]++;
poll[9]=now;
que.offer(poll.clone());
poll[now+1] = poll[now];
poll[now] = 0;
poll[8]--;
poll[9]=pre;
}
if (now<=3 && pre!=now+4) {//???
poll[now] = poll[now+4];
poll[now+4] = 0;
poll[8]+=4;
poll[9]=now;
que.offer(poll.clone());
poll[now+4] = poll[now];
poll[now] = 0;
poll[8]-=4;
poll[9]=pre;
}
}
System.out.println(ans);
}
}
static class IO extends PrintWriter {
private final InputStream in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
public IO() { this(System.in);}
public IO(InputStream source) { super(System.out); this.in = source;}
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
}else{
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
private static boolean isNewLine(int c) { return c == '\n' || c == '\r';}
private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
private void skipNewLine() { while(hasNextByte() && isNewLine(buffer[ptr])) ptr++;}
public boolean hasNext() { skipUnprintable(); return hasNextByte();}
public boolean hasNextLine() { skipNewLine(); return hasNextByte();}
public String next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
StringBuilder sb = new StringBuilder();
int b = readByte();
while(isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public char[] nextCharArray(int len) {
if (!hasNext()) {
throw new NoSuchElementException();
}
char[] s = new char[len];
int i = 0;
int b = readByte();
while(isPrintableChar(b)) {
if (i == len) {
throw new InputMismatchException();
}
s[i++] = (char) b;
b = readByte();
}
return s;
}
public String nextLine() {
if (!hasNextLine()) {
throw new NoSuchElementException();
}
StringBuilder sb = new StringBuilder();
int b = readByte();
while(!isNewLine(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext()) {
throw new NoSuchElementException();
}
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while(true){
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
}else if(b == -1 || !isPrintableChar(b)){
return minus ? -n : n;
}else{
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() {
long nl = nextLong();
if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
throw new NumberFormatException();
}
return (int) nl;
}
public char nextChar() {
if (!hasNext()) {
throw new NoSuchElementException();
}
return (char) readByte();
}
public double nextDouble() { return Double.parseDouble(next());}
public int[] arrayInt(int n) { int[] a = new int[n]; for(int i=0;i<n;i++) a[i] = nextInt(); return a;}
public long[] arrayLong(int n) { long[] a = new long[n]; for(int i=0;i<n;i++) a[i] = nextLong(); return a;}
public double[] arrayDouble(int n) { double[] a = new double[n]; for(int i=0;i<n;i++) a[i] = nextDouble(); return a;}
public void arrayInt(int[]... a) {for(int i=0;i<a[0].length;i++) for(int j=0;j<a.length;j++) a[j][i] = nextInt();}
public int[][] matrixInt(int n,int m) { int[][] a = new int[n][]; for(int i=0;i<n;i++) a[i] = arrayInt(m); return a;}
public char[][] charMap(int n,int m) { char[][] a = new char[n][]; for(int i=0;i<n;i++) a[i] = nextCharArray(m); return a;}
public void close() {
super.close();
try {
in.close();
} catch (IOException e) {}
}
}
} | Main.java:209: error: class, interface, enum, or record expected
import java.util.*;
^
Main.java:210: error: class, interface, enum, or record expected
import java.io.*;
^
2 errors
|
s260537844 | p00121 | Java | import java.util.Scanner;
import java.util.LinkedList;
import java.util.Queue;
public class sevenp{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
int[][] a = new int[2][4];
int i,j,m;
long k=1,n=0;
while(s.hasNext()){
for(i=0;i<2;i++){
for(j=0;j<4;j++){
m=s.nextInt();
n+=k*(long)m;
k*=10;
}
}
m = solve(n);
System.out.println(m);
n=0;
k=1;
}
}
public static int solve(long n){
Queue<Long> qu=new LinkedList<Long>();
int[] x = {1,-1,0,0},y= {0,0,1,-1};
int[] za = new int[100000];
int[] zb = new int[100000];
long[] zc =new long[10000000];
int[][] arr = new int[2][4];
int i,j,zh=-5,zw=-5,e,ppp=0,col=0,kri=0;
long k=n,temp,no;
boolean ch=false,chk=false;
qu.add(n);
while(true){
k = qu.remove();
if(k%100000000==76543210)return (int)k/100000000+kri;
for(i=0;i<2;i++){
for(j=0;j<4;j++){
arr[i][j]=(int)k%10;
k/=10;
if(arr[i][j]==0){
zh=i;
zw=j;
}
}
}
// System.out.println(k+" " +col);
if(k==19){
kri=20;
k=0;
}
else k++;
k*=100000000;
no = k;
for(e=0;e<4;e++){
if(zh+x[e]>=0&&zh+x[e]<2&&zw+y[e]>=0&&zw+y[e]<4){
arr[zh][zw] = arr[zh+x[e]][zw+y[e]];
arr[zh+x[e]][zw+y[e]]=0;
temp =1;
for(i=0;i<2;i++){
for(j=0;j<4;j++){
k+=temp*(long)arr[i][j];
temp*=10;
}
}
for(ppp=0;ppp<col;ppp++)if(zc[ppp]==k%100000000)ch=true;
if(ch==false){
zc[col]=k%100000000;
qu.add(k);
col++;
}
else ch = false;
k = no;
arr[zh+x[e]][zw+y[e]] = arr[zh][zw];
arr[zh][zw]=0;
}
}
}
}
}
| Main.java:6: error: class sevenp is public, should be declared in a file named sevenp.java
public class sevenp{
^
1 error
|
s078512123 | p00121 | Java | public class Main {
public static void main(String[] agrs){
Scanner x = new Scanner(System.in);
int data [] = new int[8];
for(int i = 0;i<8;i++) {
data[i]=x.nextInt();
}
int count = 0;
for(int i = 0;i < data.length;i++) {
for(int j = i + 1; j<data.length;j++) {
if(data[i]>data[j]) {
int a = data[i];
data[i] = data[j];
data [j]= a;
count ++;
}
}
}
System.out.println(count);
x.close();
}
}
| Main.java:5: error: cannot find symbol
Scanner x = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:5: error: cannot find symbol
Scanner x = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s408702276 | p00121 | Java | 7 パズルは 8 つの正方形のカードとこれらのカードがぴたりと収まる枠で構成されています。それぞれのカードには、互いに区別できるように 0, 1, 2, ..., 7 と番号がつけられています。枠には、縦に 2 個、横に 4 個のカードを並べることができます。
7 パズルを始めるときには、まず枠にすべてのカードを入れます。枠のなかで 0 のカードだけは、上下左右に隣接するカードと位置を交換することができます。たとえば、枠の状態が図(a) のときに、0 のカードの右に隣接した、7 のカードと位置を交換すれば、図(b) の状態になります。あるいは、図(a) の状態から 0 のカードの下に隣接した 2 のカードと位置を交換すれば図(c) の状態になります。図(a) の状態で 0 のカードと上下左右に隣接するカードは 7 と 2 のカードだけなので、これ以外の位置の入れ替えは許されません。
| Main.java:1: error: class, interface, enum, or record expected
7 ???? 8 ?????????????????????????????????????????????????????????? 0, 1, 2, ..., 7 ??????????????????? 2 ???? 4 ?????????????????
^
Main.java:1: error: illegal character: '\u3002'
7 ???? 8 ?????????????????????????????????????????????????????????? 0, 1, 2, ..., 7 ??????????????????? 2 ???? 4 ?????????????????
^
Main.java:1: error: illegal character: '\u3001'
7 ???? 8 ?????????????????????????????????????????????????????????? 0, 1, 2, ..., 7 ??????????????????? 2 ???? 4 ?????????????????
^
Main.java:1: error: illegal character: '\u3002'
7 ???? 8 ?????????????????????????????????????????????????????????? 0, 1, 2, ..., 7 ??????????????????? 2 ???? 4 ?????????????????
^
Main.java:1: error: illegal character: '\u3001'
7 ???? 8 ?????????????????????????????????????????????????????????? 0, 1, 2, ..., 7 ??????????????????? 2 ???? 4 ?????????????????
^
Main.java:1: error: illegal character: '\u3001'
7 ???? 8 ?????????????????????????????????????????????????????????? 0, 1, 2, ..., 7 ??????????????????? 2 ???? 4 ?????????????????
^
Main.java:1: error: illegal character: '\u3002'
7 ???? 8 ?????????????????????????????????????????????????????????? 0, 1, 2, ..., 7 ??????????????????? 2 ???? 4 ?????????????????
^
Main.java:3: error: illegal character: '\u3001'
7 ?????????????????????????????????? 0 ???????????????????????????????????????????????(a) ?????0 ????????????7 ???????????????(b) ???????????????(a) ????? 0 ??????????? 2 ??????????????(c) ??????????(a) ???? 0 ?????????????????? 7 ? 2 ??????????????????????????????
^
Main.java:3: error: illegal character: '\u3002'
7 ?????????????????????????????????? 0 ???????????????????????????????????????????????(a) ?????0 ????????????7 ???????????????(b) ???????????????(a) ????? 0 ??????????? 2 ??????????????(c) ??????????(a) ???? 0 ?????????????????? 7 ? 2 ??????????????????????????????
^
Main.java:3: error: illegal character: '\u3001'
7 ?????????????????????????????????? 0 ???????????????????????????????????????????????(a) ?????0 ????????????7 ???????????????(b) ???????????????(a) ????? 0 ??????????? 2 ??????????????(c) ??????????(a) ???? 0 ?????????????????? 7 ? 2 ??????????????????????????????
^
Main.java:3: error: illegal character: '\u3002'
7 ?????????????????????????????????? 0 ???????????????????????????????????????????????(a) ?????0 ????????????7 ???????????????(b) ???????????????(a) ????? 0 ??????????? 2 ??????????????(c) ??????????(a) ???? 0 ?????????????????? 7 ? 2 ??????????????????????????????
^
Main.java:3: error: illegal character: '\u3001'
7 ?????????????????????????????????? 0 ???????????????????????????????????????????????(a) ?????0 ????????????7 ???????????????(b) ???????????????(a) ????? 0 ??????????? 2 ??????????????(c) ??????????(a) ???? 0 ?????????????????? 7 ? 2 ??????????????????????????????
^
Main.java:3: error: illegal character: '\u3001'
7 ?????????????????????????????????? 0 ???????????????????????????????????????????????(a) ?????0 ????????????7 ???????????????(b) ???????????????(a) ????? 0 ??????????? 2 ??????????????(c) ??????????(a) ???? 0 ?????????????????? 7 ? 2 ??????????????????????????????
^
Main.java:3: error: illegal character: '\u3001'
7 ?????????????????????????????????? 0 ???????????????????????????????????????????????(a) ?????0 ????????????7 ???????????????(b) ???????????????(a) ????? 0 ??????????? 2 ??????????????(c) ??????????(a) ???? 0 ?????????????????? 7 ? 2 ??????????????????????????????
^
Main.java:3: error: illegal character: '\u3001'
7 ?????????????????????????????????? 0 ???????????????????????????????????????????????(a) ?????0 ????????????7 ???????????????(b) ???????????????(a) ????? 0 ??????????? 2 ??????????????(c) ??????????(a) ???? 0 ?????????????????? 7 ? 2 ??????????????????????????????
^
Main.java:3: error: illegal character: '\u3002'
7 ?????????????????????????????????? 0 ???????????????????????????????????????????????(a) ?????0 ????????????7 ???????????????(b) ???????????????(a) ????? 0 ??????????? 2 ??????????????(c) ??????????(a) ???? 0 ?????????????????? 7 ? 2 ??????????????????????????????
^
Main.java:3: error: illegal character: '\u3001'
7 ?????????????????????????????????? 0 ???????????????????????????????????????????????(a) ?????0 ????????????7 ???????????????(b) ???????????????(a) ????? 0 ??????????? 2 ??????????????(c) ??????????(a) ???? 0 ?????????????????? 7 ? 2 ??????????????????????????????
^
Main.java:3: error: illegal character: '\u3002'
7 ?????????????????????????????????? 0 ???????????????????????????????????????????????(a) ?????0 ????????????7 ???????????????(b) ???????????????(a) ????? 0 ??????????? 2 ??????????????(c) ??????????(a) ???? 0 ?????????????????? 7 ? 2 ??????????????????????????????
^
Main.java:3: error: illegal character: '\u3001'
7 ?????????????????????????????????? 0 ???????????????????????????????????????????????(a) ?????0 ????????????7 ???????????????(b) ???????????????(a) ????? 0 ??????????? 2 ??????????????(c) ??????????(a) ???? 0 ?????????????????? 7 ? 2 ??????????????????????????????
^
Main.java:3: error: illegal character: '\u3002'
7 ?????????????????????????????????? 0 ???????????????????????????????????????????????(a) ?????0 ????????????7 ???????????????(b) ???????????????(a) ????? 0 ??????????? 2 ??????????????(c) ??????????(a) ???? 0 ?????????????????? 7 ? 2 ??????????????????????????????
^
20 errors
|
s087319137 | p00121 | Java | public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
HashMap<Integer, Integer> map = new HashMap<>();
Queue<int[]> que = new ArrayDeque<int[]>();
int[] state = new int[9];
int[] temp = new int[9];
int[] give = new int[9];
for (int i = 0; i < 8; i++) {
give[i] = sc.nextInt();
if(give[i] == 0)give[8] = i;
}
map.put(key(give), 0);
que.add(give.clone());
if (key(give) != 76543210) {
while (que.size() > 0) {
state = que.remove();
if (state[8] != 0 && state[8] != 4) {
temp = state.clone();
temp[temp[8]] = temp[temp[8] - 1];
temp[temp[8] - 1] = 0;
temp[8] -= 1;
if (!map.containsKey(key(temp))) {
map.put(key(temp), map.get(key(state)) + 1);
que.add(temp.clone());
}
if (key(give) == 76543210) break;
}
if (state[8] != 3 && state[8] != 7) {
temp = state.clone();
temp[temp[8]] = temp[temp[8] + 1];
temp[temp[8] + 1] = 0;
temp[8] += 1;
if (!map.containsKey(key(temp))) {
map.put(key(temp), map.get(key(state)) + 1);
que.add(temp.clone());
}
if (key(give) == 76543210) break;
}
if (state[8] < 4) {
temp = state.clone();
temp[temp[8]] = temp[temp[8] + 4];
temp[temp[8] + 4] = 0;
temp[8] += 4;
if (!map.containsKey(key(temp))) {
map.put(key(temp), map.get(key(state)) + 1);
que.add(temp.clone());
}
if (key(give) == 76543210) break;
} else {
temp = state.clone();
temp[temp[8]] = temp[temp[8] - 4];
temp[temp[8] - 4] = 0;
temp[8] -= 4;
if (!map.containsKey(key(temp))) {
map.put(key(temp), map.get(key(state)) + 1);
que.add(temp.clone());
}
if (key(give) == 76543210) break;
}
}
}
System.out.println(map.get(76543210));
}
}
public static int key(int[] a) {
int j = 1, key = 0;
for (int i = 0; i < 8; i++) {
key += a[i] * j;
j *= 10;
}
return key;
}
}
| Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:6: error: cannot find symbol
HashMap<Integer, Integer> map = new HashMap<>();
^
symbol: class HashMap
location: class Main
Main.java:6: error: cannot find symbol
HashMap<Integer, Integer> map = new HashMap<>();
^
symbol: class HashMap
location: class Main
Main.java:7: error: cannot find symbol
Queue<int[]> que = new ArrayDeque<int[]>();
^
symbol: class Queue
location: class Main
Main.java:7: error: cannot find symbol
Queue<int[]> que = new ArrayDeque<int[]>();
^
symbol: class ArrayDeque
location: class Main
6 errors
|
s438629375 | p00121 | Java |
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class P0121 {
int INF = 1 << 28;
int[][] next = {{1,4},
{0,2,5},
{1,3,6},
{2,7},
{0,5},
{1,4,6},
{2,5,7},
{3,6}};
void run() {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
int[] q = new int[8];
for(int i=0;i<8;i++) {
q[i] = sc.nextInt();
}
System.out.println(dfs(q));
}
}
int dfs(int[] s) {
LinkedList<String> visited = new LinkedList<String>();
Struct now = new Struct(s, 0);
LinkedList<Struct> que = new LinkedList<Struct>();
que.add(now);
visited.add(toString(s));
for(;!que.isEmpty();) {
now = que.removeFirst();
// System.out.println(toString(now.s));
if(toString(now.s).equals("01234567")) break;
int a[] = now.s.clone();
int zero = 0;
for(int i=0;i<8;i++) if(a[i] == 0) {
zero = i; break;
}
for(int i=0;i<next[zero].length;i++) {
int[] b = a.clone();
int tmp = b[zero];
b[zero] = b[next[zero][i]];
b[next[zero][i]] = tmp;
Struct next_s = new Struct(b, now.c+1);
if( !visited.contains(toString(b)) ) {
visited.add(toString(b));
que.addLast(next_s);
}
}
}
return now.c;
}
String toString(int[] a) {
String ret = "";
for(int i=0;i<8;i++) ret += a[i];
return ret;
}
public static void main(String[] args) {
new P0121().run();
}
class Struct {
int[] s;
int c;
int zero;
Struct(int s[], int c) {
this.s = s.clone();
this.c = c;
}
}
} | Main.java:6: error: class P0121 is public, should be declared in a file named P0121.java
public class P0121 {
^
1 error
|
s446828134 | p00121 | Java | package aizu_olinejudge;
import java.util.*;
public class SevenPuzzle {
public static int lzh(int puzzle[]){
return puzzle[0]*10000000+puzzle[1]*1000000+puzzle[2]*100000+puzzle[3]*10000+puzzle[4]*1000+puzzle[5]*100+puzzle[6]*10+puzzle[7];
}
public static void changein(int puzzle[],LinkedList<Integer> que,int a,int b,int cnt){
int[] puzzle_ = new int[8];
for(int i=0;i<8;i++){
puzzle_[i]=puzzle[i];
}
puzzle_[a]=puzzle[b];
puzzle_[b]=puzzle[a];
que.offer(lzh(puzzle_));
que.offer(cnt+1);
}
public static int solve(int puzzle[]){
LinkedList<Integer> que = new LinkedList<Integer>();
boolean[] memo = new boolean[76543211];
int a=0;
int now,cnt=0;
int wzero=0;
//はじめの配置
a=lzh(puzzle);
que.offer(a);
que.offer(0);
while(que.size()>0){
now=que.poll();
cnt=que.poll();
if(memo[now]) //前に調べたことがあるからtbs
continue;
else
memo[now]=true;
if(now==1234567)
break;
for(int i=0;i<8;i++){
puzzle[i]=(now/(int)Math.pow(10, 7-i))%10;
if(puzzle[i]==0) wzero=i;
}
if(wzero==0){
changein(puzzle,que,0,1,cnt);
changein(puzzle,que,0,4,cnt);
}
if(wzero==4){
changein(puzzle,que,4,5,cnt);
changein(puzzle,que,0,4,cnt);
}
if(wzero==3){
changein(puzzle,que,2,3,cnt);
changein(puzzle,que,3,7,cnt);
}
if(wzero==7){
changein(puzzle,que,3,7,cnt);
changein(puzzle,que,6,7,cnt);
}
if(wzero==1){
changein(puzzle,que,0,1,cnt);
changein(puzzle,que,1,5,cnt);
changein(puzzle,que,1,2,cnt);
}
if(wzero==5){
changein(puzzle,que,4,5,cnt);
changein(puzzle,que,5,1,cnt);
changein(puzzle,que,5,6,cnt);
}
if(wzero==2){
changein(puzzle,que,1,2,cnt);
changein(puzzle,que,2,6,cnt);
changein(puzzle,que,2,3,cnt);
}
if(wzero==6){
changein(puzzle,que,2,6,cnt);
changein(puzzle,que,6,5,cnt);
changein(puzzle,que,6,7,cnt);
}
}
return cnt;
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int[] puzzle = new int[8];
while(scan.hasNext()){
for(int i=0;i<8;i++){
puzzle[i]=scan.nextInt();
}
System.out.println(solve(puzzle));
}
}
} | Main.java:5: error: class SevenPuzzle is public, should be declared in a file named SevenPuzzle.java
public class SevenPuzzle {
^
1 error
|
s947488992 | p00121 | Java | #include <iostream>
#include <cstring>
#include <queue>
#define SIZE (8)
#define ANSWER_STATE_CODE (342391)
#define STATE_SIZE (16434824+1-ANSWER_STATE_CODE)
int coefficients[SIZE] = {2097152, 262144, 32768, 4096, 512, 64, 8, 1};
int movablePairs[SIZE][4] = {
{1,4,-1,-1}, {0,2,5,-1}, {1,3,6,-1}, {2,7,-1,-1},
{0,5,-1,-1}, {1,4,6,-1}, {2,5,7,-1}, {3,6,-1,-1}
};
bool isVisit[STATE_SIZE];
typedef struct {
short state[SIZE];
int depth;
int movablePiecePoint;
int stateCode;
} puzzle;
void move(short state[], short nextState[], int point1, int point2)
{
memcpy(nextState, state, sizeof(short)*SIZE);
short tmp = nextState[point1];
nextState[point1] = nextState[point2];
nextState[point2] = tmp;
return;
}
int puzzleInit(puzzle *p)
{
short movablePieceNum = 0;
int tmpStateCode = -ANSWER_STATE_CODE;
int tmpMovablePiecePoint = -1;
for (int i=0; i<SIZE; i++) {
if(movablePieceNum == (*p).state[i]){
tmpMovablePiecePoint = i;
}
tmpStateCode += coefficients[i]*(int)(*p).state[i];
}
(*p).stateCode = tmpStateCode;
(*p).movablePiecePoint = tmpMovablePiecePoint;
return 0;
}
int solve(short input[])
{
std::queue<puzzle> qu;
for (int i=0; i<STATE_SIZE; i++) {
isVisit[i] = false;
}
puzzle init;
memcpy(init.state, input, sizeof(short)*SIZE);
init.depth = 0;
puzzleInit(&init);
qu.push(init);
while (!qu.empty()) {
puzzle now = qu.front();
qu.pop();
if (0 == now.stateCode) {
return now.depth;
}
if (!isVisit[now.stateCode]) {
for (int i=0; movablePairs[now.movablePiecePoint][i]>=0; i++){
int nextMove = movablePairs[now.movablePiecePoint][i];
puzzle nextP;
move(now.state, nextP.state, now.movablePiecePoint, nextMove);
nextP.depth = now.depth+1;
puzzleInit(&nextP);
qu.push(nextP);
}
isVisit[now.stateCode] = true;
}
}
return -1;
}
int main(int argc, const char * argv[])
{
while (true) {
short input[SIZE];
for(int i=0; i<SIZE; i++){
std::cin >> input[i];
}
int count = solve(input);
std::cout << count<< std::endl;
}
return 0;
} | Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <cstring>
^
Main.java:3: error: illegal character: '#'
#include <queue>
^
Main.java:5: error: illegal character: '#'
#define SIZE (8)
^
Main.java:6: error: illegal character: '#'
#define ANSWER_STATE_CODE (342391)
^
Main.java:7: error: illegal character: '#'
#define STATE_SIZE (16434824+1-ANSWER_STATE_CODE)
^
Main.java:12: error: class, interface, enum, or record expected
int movablePairs[SIZE][4] = {
^
Main.java:17: error: class, interface, enum, or record expected
bool isVisit[STATE_SIZE];
^
Main.java:19: error: class, interface, enum, or record expected
typedef struct {
^
Main.java:21: error: unnamed classes are a preview feature and are disabled by default.
int depth;
^
(use --enable-preview to enable unnamed classes)
Main.java:24: error: class, interface, enum, or record expected
} puzzle;
^
Main.java:28: error: '.class' expected
memcpy(nextState, state, sizeof(short)*SIZE);
^
Main.java:35: error: <identifier> expected
int puzzleInit(puzzle *p)
^
Main.java:41: error: illegal start of expression
if(movablePieceNum == (*p).state[i]){
^
Main.java:44: error: illegal start of expression
tmpStateCode += coefficients[i]*(int)(*p).state[i];
^
Main.java:46: error: illegal start of expression
(*p).stateCode = tmpStateCode;
^
Main.java:47: error: illegal start of expression
(*p).movablePiecePoint = tmpMovablePiecePoint;
^
Main.java:53: error: not a statement
std::queue<puzzle> qu;
^
Main.java:59: error: '.class' expected
memcpy(init.state, input, sizeof(short)*SIZE);
^
Main.java:61: error: illegal start of expression
puzzleInit(&init);
^
Main.java:77: error: illegal start of expression
puzzleInit(&nextP);
^
Main.java:87: error: illegal start of type
int main(int argc, const char * argv[])
^
Main.java:87: error: class, interface, enum, or record expected
int main(int argc, const char * argv[])
^
Main.java:91: error: class, interface, enum, or record expected
for(int i=0; i<SIZE; i++){
^
Main.java:91: error: class, interface, enum, or record expected
for(int i=0; i<SIZE; i++){
^
Main.java:91: error: class, interface, enum, or record expected
for(int i=0; i<SIZE; i++){
^
Main.java:93: error: class, interface, enum, or record expected
}
^
Main.java:95: error: class, interface, enum, or record expected
std::cout << count<< std::endl;
^
Main.java:96: error: class, interface, enum, or record expected
}
^
Main.java:99: error: class, interface, enum, or record expected
}
^
30 errors
|
s008843856 | p00121 | Java | import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
private final static int SIZE = 8;
private final static int[][] MOVABLE_PAIRS = {
{1,4}, {0,2,5}, {1,3,6}, {2,7},
{0,5}, {1,4,6}, {2,5,7}, {3,6}
};
private final static int[] coefficients = {5040, 720, 120, 24, 6, 2, 1, 0};
private static final int[] ANSWER_STATE = {0,1,2,3,4,5,6,7};
private static final int FORE_DIRECTION = 1;
private static final int BACK_DIRECTION = -1;
private Main() {
Scanner in = new Scanner(System.in);
while(in.hasNext()) {
int[] puzzle = new int[SIZE];
for(int i=0; i<SIZE; i++) {
puzzle[i] = in.nextInt();
}
System.out.println(solve(puzzle));
- start);
}
in.close();
}
final class Puzzle {
// 座標番号
// 0 1 2 3
// 4 5 6 7
final int[] state; // パズルの状態
final int depth; // 深さ(操作回数)
final int movablePiecePoint; // パズル内にある動かせるピースの座標
final int point;// 移動可能なピースの直前にあった座標
final boolean isRoot; // 根ノードかどうか
int stateCode;
final int direction; // 探索の向き
public Puzzle(int[] state, int direction) {
this.isRoot = true;
this.depth = 0;
this.state = state;
this.point = -1;
this.direction = direction;
setStateCode();
for(int i=0; i<SIZE; i++) {
if(state[i]==0) {
this.movablePiecePoint = i;
return;
}
}
this.movablePiecePoint = -1;
}
public Puzzle (Puzzle parent, int nextMove){
this.isRoot = false;
this.depth = parent.depth+1;
this.point = parent.movablePiecePoint;
this.movablePiecePoint = nextMove;
this.direction = parent.direction;
this.state = Arrays.copyOf(parent.state, SIZE);
this.state[this.point] = this.state[nextMove];
this.state[nextMove] = 0;
setStateCode();
}
private final void setStateCode() {
for(int i=0; i<SIZE-1; i++) {
int c = 0;
for(int j=i+1; j<SIZE; j++) {
if(this.state[i] > this.state[j]) {
c++;
}
}
this.stateCode += coefficients[i]*c;
}
}
}
private final int solve(int[] puzzle) {
int[] isVisit = new int[50430];
ArrayDeque<Puzzle> queue = new ArrayDeque<Puzzle>();
queue.add(new Puzzle(puzzle, FORE_DIRECTION));
queue.add(new Puzzle(ANSWER_STATE, BACK_DIRECTION));
while(!queue.isEmpty()) {
Puzzle now = queue.poll();
if(now.stateCode==0 && now.direction==FORE_DIRECTION) {
return now.depth;
} else if(isVisit[now.stateCode]!=0 && isVisit[now.stateCode]*now.direction<0) {
return now.depth + StrictMath.abs(isVisit[now.stateCode]);
}
for(int nextMove : MOVABLE_PAIRS[now.movablePiecePoint]) {
if (now.isRoot || now.point!=nextMove) {
queue.add(new Puzzle(now, nextMove));
}
}
isVisit[now.stateCode] = now.direction*now.depth;
}
return -1;
}
public static void main(String[] args) {
new Main();
}
} | Main.java:29: error: not a statement
- start);
^
Main.java:29: error: ';' expected
- start);
^
2 errors
|
s385348450 | p00121 | Java | package exp0121;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
private final static int SIZE = 8;
private final static int[][] MOVABLE_PAIRS = {
{1,4}, {0,2,5}, {1,3,6}, {2,7},
{0,5}, {1,4,6}, {2,5,7}, {3,6}
};
private final static int[] coefficients = {5040, 720, 120, 24, 6, 2, 1, 0};
private static final int[] ANSWER_STATE = {0,1,2,3,4,5,6,7};
private static final int FORE_DIRECTION = 1;
private static final int BACK_DIRECTION = -1;
private Main3() {
Scanner in = new Scanner(System.in);
while(in.hasNext()) {
int[] puzzle = new int[SIZE];
for(int i=0; i<SIZE; i++) {
puzzle[i] = in.nextInt();
}
System.out.println(solve(puzzle));
}
in.close();
}
final class Puzzle {
final int[] state;
final int depth;
final int movablePiecePoint;
final int point;
final boolean isRoot;
int stateCode;
final int direction;
public Puzzle(int[] state, int direction) {
this.isRoot = true;
this.depth = 0;
this.state = state;
this.point = -1;
this.direction = direction;
setStateCode();
for(int i=0; i<SIZE; i++) {
if(state[i]==0) {
this.movablePiecePoint = i;
return;
}
}
this.movablePiecePoint = -1;
}
public Puzzle (Puzzle parent, int nextMove){
this.isRoot = false;
this.depth = parent.depth+1;
this.point = parent.movablePiecePoint;
this.movablePiecePoint = nextMove;
this.direction = parent.direction;
this.state = Arrays.copyOf(parent.state, SIZE);
this.state[this.point] = this.state[nextMove];
this.state[nextMove] = 0;
setStateCode();
}
private final void setStateCode() {
for(int i=0; i<SIZE-1; i++) {
int c = 0;
for(int j=i+1; j<SIZE; j++) {
if(this.state[i] > this.state[j]) {
c++;
}
}
this.stateCode += coefficients[i]*c;
}
}
public String toString() {
StringBuilder str = new StringBuilder("");
for(int s:state) {
str.append(s+" ");
}
return str.toString();
}
}
private final int solve(int[] puzzle) {
int[] isVisit = new int[50430];
ArrayDeque<Puzzle> queue = new ArrayDeque<Puzzle>();
queue.add(new Puzzle(puzzle, FORE_DIRECTION)); // 初期状態から
queue.add(new Puzzle(ANSWER_STATE, BACK_DIRECTION)); // 完成形から
while(!queue.isEmpty()) {
Puzzle now = queue.poll();
if(now.stateCode==0 && now.direction==FORE_DIRECTION) { // 初期状態から直接完成形にたどり着いた場合
return now.depth;
} else if(isVisit[now.stateCode]!=0 && isVisit[now.stateCode]*now.direction<0) { // 01234567のstateCodeは0
return now.depth + StrictMath.abs(isVisit[now.stateCode]);
}
for(int nextMove : MOVABLE_PAIRS[now.movablePiecePoint]) {
if (now.isRoot || now.point!=nextMove) { // 直前の状態に戻ることを禁止する
queue.add(new Puzzle(now, nextMove));
}
}
isVisit[now.stateCode] = now.direction*now.depth;
}
return -1;
}
public static void main(String[] args) {
new Main();
}
} | Main.java:22: error: invalid method declaration; return type required
private Main3() {
^
1 error
|
s836399618 | p00121 | Java |
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;
public class P0121_ {
int INF = 1 << 28;
//long INF = 1L << 62;
double EPS = 1e-10;
HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
void run() {
Scanner sc = new Scanner(System.in);
pow = new int[8];
pow[0] = 1;
for (int i=1;i<8;i++) pow[i] = pow[i-1]*10;
solve();
// debug(map.size(), 2*3*4*5*6*7*8);
for (;sc.hasNext();) {
String num = "";
for (int i=0;i<8;i++) {
num += sc.nextInt();
}
System.out.println(map.get(Integer.parseInt(num)));
}
}
void solve() {
LinkedList<Integer> q = new LinkedList<Integer>();
LinkedList<Integer> d = new LinkedList<Integer>();
q.add(1234567);
d.add(0);
map.put(1234567, 0);
while(!q.isEmpty()) {
int cp = q.removeFirst(), cd = d.removeFirst();
// debug(nextState(cp));
for (int i: nextState(cp)) if (! map.containsKey(i)) {
map.put(i, cd + 1);
q.add(i); d.add(cd + 1);
}
}
}
int[] pow;
int[] nextState(int s) {
int p=0;
String num = "" + s;
if (num.length() == 7) p = 0;
else for (;p<8;p++) if (num.charAt(p) == '0') break;
p = 7-p;
if (p == 1 || p == 2 || p == 5 || p == 6) {
int[] next = new int[3];
next[0] = swap(s, p, p-1);
next[1] = swap(s, p, p+1);
next[2] = swap(s, p, (p+4)%8);
return next;
}
if (p == 0 || p == 4) {
int[] next = new int[2];
next[0] = swap(s, p, p+1);
next[1] = swap(s, p, (p+4)%8);
return next;
}
int[] next = new int[2];
next[0] = swap(s, p, p-1);
next[1] = swap(s, p, (p+4)%8);
return next;
}
int swap(int a, int s, int t) {
int tmp1 = (a / pow[s]) % 10;
int tmp2 = (a / pow[t]) % 10;
return a + (tmp2 - tmp1) * pow[s] + (tmp1 - tmp2) * pow[t];
}
void debug(Object... os) {
System.err.println(Arrays.deepToString(os));
}
public static void main(String[] args) {
new Main().run();
}
} | Main.java:8: error: class P0121_ is public, should be declared in a file named P0121_.java
public class P0121_ {
^
Main.java:84: error: cannot access Main
new Main().run();
^
bad source file: ./Main.java
file does not contain class Main
Please remove or make sure it appears in the correct subdirectory of the sourcepath.
2 errors
|
s682368592 | p00121 | C | //??-2015-11-8
# include <cstdio>
# include <algorithm>
# include <iostream>
# include <string>
# include <cstring>
# include <map>
# include <queue>
using namespace std;
int direction[4] = { -4, 4, -1, 1 }; //4个方向,上下左右
map<string, int>dp; //事先将?果保存在?里
void Bfs()
{
string p = "01234567";
queue<string>Q;
Q.push(p);
dp[p] = 0; //在?个地方是不用??的
while (!Q.empty())
{
printf("出不去\n");
string q = Q.front();
Q.pop();
int v,w,i,j;
for (v = 0; v < q.length(); v++)
{
if (q[v] == '0')
{
w = v; //??0的位置,然后以他?中心?行走?
break;
}
}
for (i = 0; i < 4; i++)
{
string temp2 = q;
int r = w + direction[i];
if (r >= 0 && r < 8 && !(w == 3 && i == 3) && !(w == 4 && i == 2)) //特?看清楚?个限制条件
{
char c; //交?位置
c = temp2[r];
temp2[r] = temp2[w];
temp2[w] = c;
//必?要是map中没有的,?才??列,要不永不停止
if (dp.find(temp2) == dp.end()) //没找到,一定要想?法知道是否已??找?
{
Q.push(temp2);
dp[temp2] = dp[q] + 1;
}
}
}
}
}
int main(void)
{
//freopen("in.txt", "r", stdin);
string s;
Bfs();
while (getline(cin, s))
{
int i;
string temp;
for (i = 0; i < s.length(); i++)
{
if (s[i] != ' ')
temp.push_back(s[i]);
}
cout << dp[temp] << endl;
}
return 0;
} | main.c:2:11: fatal error: cstdio: No such file or directory
2 | # include <cstdio>
| ^~~~~~~~
compilation terminated.
|
s368533737 | p00121 | C | #include<cstdio>
#include<map>
#include<queue>
using namespace std;
map<int,bool>p;
map<int,int>ans;
int a[10],b[10],dr[4]={1,-1,4,-4};
struct nde
{
int x,c,t;
}f,g;
queue<nde>q;
int main()
{
int i,j,k;
while(scanf("%d",&a[1])==1)
{
while(!q.empty()) q.pop();
p.clear();
f.t=0;
for(i=2;i<=8;i++)
{
scanf("%d",&a[i]);
if(!a[i]) f.x=i;
}
for(i=1,j=1,f.c=0;i<=8;i++,j*=10) f.c+=a[i]*j;
if(ans[f.c]) {printf("%d\n",ans[f.c]);continue;}
q.push(f);
while(!q.empty())
{
g=q.front();q.pop();
if(g.c==76543210) {printf("%d\n",g.t);ans[g.c]=g.t;break;}
p[g.c]=1;
int r=g.c;
for(j=1;j<=8;r/=10,j++)
b[j]=r%10;
for(i=0;i<4;i++)
{
f.x=g.x+dr[i];f.t=g.t+1;
if(f.x<=0||f.x>8||(f.x==4&&dr[i]==-1)||(f.x==5&&dr[i]==1)) continue;
int t=b[f.x];b[f.x]=b[g.x];b[g.x]=t;
for(j=1,k=1,f.c=0;j<=8;j++,k*=10) f.c+=b[j]*k;
if(p[f.c]) {t=b[f.x];b[f.x]=b[g.x];b[g.x]=t;continue;}
if(f.c==76543210) {printf("%d\n",f.t);break;}
p[f.c]=1;q.push(f);
t=b[f.x];b[f.x]=b[g.x];b[g.x]=t;
}
if(f.c==76543210||g.c==76543210) break;
}
}
} | main.c:1:9: fatal error: cstdio: No such file or directory
1 | #include<cstdio>
| ^~~~~~~~
compilation terminated.
|
s026058177 | p00121 | C | #include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
using namespace std;
#define maxn 305
int map[3][5];
int main()
{
int i,j;
cin>>i;
cout<<1<<endl;
return 0;
}
| main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s393725865 | p00121 | C | #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef pair<string, int> P;
vector<string> make(string str) {
vector<string> ret;
int pos;
for (int i = 0; i < str.size(); ++i)
if (str[i] == '0') pos = i;
vector<int> v;
if (pos % 4 != 3) v.push_back( pos+1 );
if (pos % 4 != 0) v.push_back( pos-1 );
if (pos < 4) v.push_back( pos+4 );
else v.push_back( pos-4 );
for (int i = 0; i < v.size(); ++i) {
string s = str;
swap(s[pos], s[v[i]]);
ret.push_back(s);
}
return ret;
}
int main() {
while (1) {
string str;
for (int i = 0; i < 8; ++i) {
int a; if ( !(cin >> a) ) return 0;
str += a + '0';
}
queue<P> Q; Q.push( P(str, 0) );
map<string, bool> m;
while ( !Q.empty() ) {
P p = Q.front(); Q.pop();
string str = p.first;
int step = p.second;
if (m[str]) continue;
m[str] = true;
if (str == "01234567") {
cout << step << endl;
break;
}
vector<string> v = make(str);
for (int i = 0; i < v.size(); ++i)
Q.push( P(v[i], step+1) );
}
}
} | main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s949536936 | p00121 | C | #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstdio>
#include <queue>
using namespace std;
typedef pair<string, int> P;
string String(vector<int> v) {
string ret = "";
for (int i = 0; i < v.size(); ++i)
ret += v[i] + '0';
return ret;
}
int main() {
map<string, int> steps;
queue<P> Q; Q.push( P("01234567", 0) );
while ( !Q.empty() ) {
P p = Q.front(); Q.pop();
string str = p.first;
int step = p.second;
if (steps[str]) continue;
steps[str] = step+1;
int pos = -1;
for (int i = 0; i < 8; ++i)
if (str[i] == '0') pos = i;
string next = str;
if (pos > 3) swap(next[pos], next[pos-4]);
else swap(next[pos], next[pos+4]);
Q.push( P(next, step+1) ); next = str;
if (pos % 4 != 0) { swap(next[pos], next[pos-1]); Q.push( P(next, step+1) ); next = str; }
if (pos % 4 != 3) { swap(next[pos], next[pos+1]); Q.push( P(next, step+1) ); next = str; }
}
int a;
while (scanf("%d", &a) != EOF) {
vector<int> now(8, a);
for (int i = 1; i < 8; ++i) cin >> now[i];
cout << (steps[String(now)]-1) << endl;
}
} | main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s723654453 | p00121 | C++ | #include <cstdio>
#include <queue>
#include <complex>
#include <algorithm>
using namespace std;
const int MAX_PTN = 76543211;
struct state {
int i;
int n;
int t;
state(int i, int n, int t) : i(i), n(n), t(t) {}
};
bool done[MAX_PTN];
int zi, n;
int di[4] = {4, -4, 1, -1};
int make_nextnum(state cur, int nexti)
{
int nd = (cur.n / (int)pow(10, 7 - nexti)) % 10;
int ret = cur.n + nd * (int)pow(10, 7 - cur.i) - nd * (int)pow(10, 7 - nexti);
return ret;
}
int bfs()
{
queue<state> que;
que.push(state(zi, n, 0));
memset(done, false, sizeof done);
done[n] = true;
while (!que.empty()) {
state s = que.front(); que.pop();
if (s.n == 1234567) return s.t;
for (int i = 0; i < 4; i++) {
int ni = s.i + di[i];
int nn;
if (s.i == 3 && di[i] == 1) continue;
if (s.i == 4 && di[i] == -1) continue;
if (ni < 0 || 7 < ni) continue;
nn = make_nextnum(s, ni);
if (done[nn]) continue;
done[nn] = true;
que.push(state(ni, nn, s.t + 1));
}
}
return -1;
}
int solve()
{
return bfs();
}
int main()
{
while (true) {
char s[32];
int d = 10000000;
fgets(s, 31, stdin);
if (s[0] < '0' || '9' < s[0]) break;
n = 0;
for (int i = 0; i < 8; i++) {
int a;
a = s[2 * i] - '0';
n += a * d;
d /= 10;
if (a == 0) { zi = i; }
}
printf("%d\n", solve());
}
return 0;
}
| a.cc: In function 'int bfs()':
a.cc:32:3: error: 'memset' was not declared in this scope
32 | memset(done, false, sizeof done);
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <algorithm>
+++ |+#include <cstring>
5 | using namespace std;
|
s478579597 | p00121 | C++ | #include <cstdio>
#include <queue>
#include <complex>
#include <algorithm>
using namespace std;
const int MAX_PTN = 76543211;
struct state {
int i;
int n;
int t;
state(int i, int n, int t) : i(i), n(n), t(t) {}
};
bool done[MAX_PTN];
int zi, n;
int di[4] = {4, -4, 1, -1};
int make_nextnum(state cur, int nexti)
{
int nd = (cur.n / (int)pow(10, 7 - nexti)) % 10;
int ret = cur.n + nd * (int)pow(10, 7 - cur.i) - nd * (int)pow(10, 7 - nexti);
return ret;
}
int bfs()
{
queue<state> que;
que.push(state(zi, n, 0));
memset(done, false, sizeof done);
done[n] = true;
while (!que.empty()) {
state s = que.front(); que.pop();
if (s.n == 1234567) return s.t;
for (int i = 0; i < 4; i++) {
int ni = s.i + di[i];
int nn;
if (s.i == 3 && di[i] == 1) continue;
if (s.i == 4 && di[i] == -1) continue;
if (ni < 0 || 7 < ni) continue;
nn = make_nextnum(s, ni);
if (done[nn]) continue;
done[nn] = true;
que.push(state(ni, nn, s.t + 1));
}
}
return -1;
}
int solve()
{
return bfs();
}
int main()
{
while (true) {
char s[32];
int d = 10000000;
fgets(s, 31, stdin);
if (s[0] < '0' || '9' < s[0]) break;
n = 0;
for (int i = 0; i < 8; i++) {
int a;
a = s[2 * i] - '0';
n += a * d;
d /= 10;
if (a == 0) { zi = i; }
}
printf("%d\n", solve());
}
return 0;
}
| a.cc: In function 'int bfs()':
a.cc:32:3: error: 'memset' was not declared in this scope
32 | memset(done, false, sizeof done);
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <algorithm>
+++ |+#include <cstring>
5 | using namespace std;
|
s764043680 | p00121 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
int paSize = printArray.size();
for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
if (between != '\n') {cerr << endl;}
}
// ------------------------------------------------------------------------------------------
bool check(vector<int> v) {
for (int i = 0; i < v.size(); i++) {
if (v[i] != i) {
return false;
}
}
return true;
}
int bfs(vector<int> v) {
queue<vector<int>> que;
que.push(v);
map<vector<int>, int> mp;
mp[v] = 0;
int ans = -1;
while (que.size()) {
vector<int> t = que.front(); que.pop();
初手に戻ったかチェックする
if (check(t)) {
ans = mp[t];
break;
}
// 0の位置を求める
int zeroPos = 0;
for (int i = 0; i < t.size(); i++) {
if (t[i] == 0) zeroPos = i;
}
int y = zeroPos / 4, x = zeroPos % 4;
for (int i = 0; i < 4; i++) {
int ny = y + dy[i], nx = x + dx[i];
if (ny < 0 || ny >= 2 || nx < 0 || nx >= 4) continue;
vector<int> tt = t;
int pos = y * 4 + x, npos = ny * 4 + nx;
swap(tt[pos], tt[npos]);
if (mp.count(tt)) continue;
mp[tt] = mp[t] + 1;
que.push(tt);
}
}
return ans;
}
signed main() {
string s;
vector<int> v;
while (getline(cin, s)) {
for (int i = 0; i < s.size(); i+=2) {
v.push_back(s[i] - '0');
}
cout << bfs(v) << endl;
}
return 0;
}
| a.cc: In function 'long long int bfs(std::vector<long long int>)':
a.cc:52:5: error: '\U0000521d\U0000624b\U0000306b\U0000623b\U00003063\U0000305f\U0000304b\U000030c1\U000030a7\U000030c3\U000030af\U00003059\U0000308b' was not declared in this scope
52 | 初手に戻ったかチェックする
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
|
s544982742 | p00121 | C++ | #include<iostream>
#include<queue>
using namespace std;
bool acceptable(int** p) {
for (int j = 0; j < 2; j++)
for (int i = 0; i < 4; i++)
if (p[i][j] != j * 4 + i) return false;
return true;
}
int** move_0_up(int** p) {
int val[4][2];
for (int j = 0; j < 2; j++)
for (int i = 0; i < 4; i++)
val[i][j] = p[i][j];
int x, y;
for (int j = 0; j < 2; j++) {
for (int i = 0; i < 4; i++) {
if (p[i][j] == 0) {
x = i; y = j;
}
}
}
val[x][y] = p[x][(y == 0)? 1:0];
val[x][(y == 0)? 1:0] = 0;
return val;
}
int** move_0_right(int** p) {
int val[4][2];
for (int j = 0; j < 2; j++)
for (int i = 0; i < 4; i++)
val[i][j] = p[i][j];
int x, y;
for (int j = 0; j < 2; j++) {
for (int i = 0; i < 4; i++) {
if (p[i][j] == 0) {
x = i; y = j;
}
}
}
if (x == 3) return val;
val[x][y] = p[x+1][y] | a.cc: In function 'int** move_0_up(int**)':
a.cc:32:10: error: cannot convert 'int (*)[2]' to 'int**' in return
32 | return val;
| ^~~
| |
| int (*)[2]
a.cc: In function 'int** move_0_right(int**)':
a.cc:51:22: error: cannot convert 'int (*)[2]' to 'int**' in return
51 | if (x == 3) return val;
| ^~~
| |
| int (*)[2]
a.cc:53:24: error: expected ';' at end of input
53 | val[x][y] = p[x+1][y]
| ^
| ;
a.cc:53:24: error: expected '}' at end of input
a.cc:35:29: note: to match this '{'
35 | int** move_0_right(int** p) {
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.