submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s899147511 | p00223 | C++ | #include <bits/stdc++.h>
using namespace std;
int table[52][52];
bool memo[52][52][52][52];
const int leftmove = -1;
const int rightmove = 1;
const int upmove = -1;
const int downmove = 1;
int main() {
while(1){
int w,h;
//scanf(" %d %d",&w,&h);
cin >> w >> h;
if(w==0&&h==0) break;
int tx,ty,kx,ky;
//scanf(" %d %d %d %d",&tx,&ty,&kx,&ky);
cin >> tx >> ty >> kx >> ky;
for(int i=0;i<52;i++){
for(int j=0;j<52;j++){
for(int k=0;k<52;k++){
for(int r=0;r<52;r++){
memo[i][j][k][r] = false;
}
}
}
}
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
//scanf(" %d",&table[i][j]);
cin >> table[i][j];
}
}
/*printf("\n");
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
printf("%d ",table[i][j]);
}
printf("\n");
}*/
//memset(memo,false,sizeof(memo));
queue<vector<int> > q;
vector<int> v(5);
v[0] = tx; v[1] = ty; v[2] = kx; v[3] = ky; v[4] = 0;
if(table[v[0]][v[1]] == 1 || table[v[2]][v[3]] == 1){
cout << "NA" << endl;
continue;
}
if(v[0] == v[2] && v[1] == v[3]){
check = true;
cout << v[4] << endl;
break;
}
q.push(v);
bool check = false;
while(!q.empty()){
v = q.front(); q.pop();
if(v[0] == v[2] && v[1] == v[3]){
check = true;
cout << v[4] << endl;
break;
}
memo[v[0]][v[1]][v[2]][v[3]] = true;
v[4]++;
if(v[4] >= 100){
break;
}
vector<int> before(5);
for(int i=0;i<5;i++){
before[i] = v[i];
}
if(v[0]+leftmove != 0 && table[v[0]+leftmove][v[1]] == 0){
v[0]+=leftmove;
}
if(v[2]+rightmove != w+1 && table[v[2]+rightmove][v[3]] == 0){
v[2]+=rightmove;
}
if(!memo[v[0]][v[1]][v[2]][v[3]]) {
if(v[0] == v[2] && v[1] == v[3]){
check = true;
cout << v[4] << endl;
break;
}
memo[v[0]][v[1]][v[2]][v[3]] = true;
q.push(v);
}
for(int i=0;i<5;i++){
v[i] = before[i];
}
if(v[2]+leftmove != 0 && table[v[2]+leftmove][v[3]] == 0){
v[2]+=leftmove;
}
if(v[0]+rightmove != w+1 && table[v[0]+rightmove][v[1]] == 0){
v[0]+=rightmove;
}
if(!memo[v[0]][v[1]][v[2]][v[3]]) {
if(v[0] == v[2] && v[1] == v[3]){
check = true;
cout << v[4] << endl;
break;
}
memo[v[0]][v[1]][v[2]][v[3]] = true;
q.push(v);
}
for(int i=0;i<5;i++){
v[i] = before[i];
}
if(v[3]+upmove != 0 && table[v[2]][v[3]+upmove] == 0){
v[3]+=upmove;
}
if(v[1]+downmove != h+1 && table[v[0]][v[1]+downmove] == 0){
v[1]+=downmove;
}
if(!memo[v[0]][v[1]][v[2]][v[3]]) {
if(v[0] == v[2] && v[1] == v[3]){
check = true;
cout << v[4] << endl;
break;
}
memo[v[0]][v[1]][v[2]][v[3]] = true;
q.push(v);
}
for(int i=0;i<5;i++){
v[i] = before[i];
}
if(v[1]+upmove != 0 && table[v[0]][v[1]+upmove] == 0){
v[1]+=upmove;
}
if(v[3]+downmove != h+1 && table[v[2]][v[3]+downmove] == 0){
v[3]+=downmove;
}
if(!memo[v[0]][v[1]][v[2]][v[3]]) {
if(v[0] == v[2] && v[1] == v[3]){
check = true;
cout << v[4] << endl;
break;
}
memo[v[0]][v[1]][v[2]][v[3]] = true;
q.push(v);
}
}
if(!check){
cout << "NA" << endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:71:13: error: 'check' was not declared in this scope
71 | check = true;
| ^~~~~
|
s458885114 | p00223 | C++ | #include<string.h>
using namespace std;
struct Y{
int hx,hy,rx,ry,tim;
};
int mp[52][52],vh[52][52],vr[52][52];
int main(){
int n,w,h,i,j,a[2]={1,-1},b[2],g,k;
Y e;
queue<Y> q;
while(1){
g=0;
k=0;
cin>>w>>h;
if(w==0&&h==0)break;
cin>>e.hx>>e.hy>>e.rx>>e.ry;
e.tim=0;
q.push(e);
memset(mp,0,sizeof(mp));
memset(vr,0,sizeof(vr));
memset(vh,0,sizeof(vh));
for(i=0;i<=h+1;i++){
mp[i][0]=1;
mp[i][w+1]=1;
}
for(i=0;i<=w+1;i++){
mp[0][i]=1;
mp[h+1][i]=1;
}
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
cin>>mp[j][i];
if(mp[j][i]==1)k++;
}
}
while(1){
e=q.front();
q.pop();
if(vh[e.hy][e.hx]!=1)g++;
if(vr[e.ry][e.rx]!=1)g++;
vh[e.hy][e.hx]=1;
vr[e.ry][e.rx]=1;
if(e.tim>=100||e.hx==e.rx&&e.hy==e.ry||g==(w*h-k)*2)break;
e.tim++;
for(i=0;i<2;i++){
if(mp[e.hy+a[i]][e.hx]!=1&&vh[e.hy+a[i]][e.hx]!=1||mp[e.ry-a[i]][e.rx]!=1&&vr[e.ry-a[i]][e.rx]!=1){
b[0]=0;
b[1]=0;
if(mp[e.hy+a[i]][e.hx]!=1){
e.hy+=a[i];
b[0]=1;
}
if(mp[e.ry-a[i]][e.rx]!=1){
e.ry-=a[i];
b[1]=1;
}
if(vh[e.hy][e.hx]!=1)g++;
if(vr[e.ry][e.rx]!=1)g++;
vh[e.hy][e.hx]=1;
vr[e.ry][e.rx]=1;
q.push(e);
if(b[0]==1)e.hy-=a[i];
if(b[1]==1)e.ry+=a[i];
}
if(mp[e.hy][e.hx+a[i]]!=1&&vh[e.hy][e.hx+a[i]]!=1||mp[e.ry][e.rx-a[i]]!=1&&vr[e.ry][e.rx-a[i]]!=1){
b[0]=0;
b[1]=0;
if(mp[e.hy][e.hx+a[i]]!=1){
e.hx+=a[i];
b[0]=1;
}
if(mp[e.ry][e.rx-a[i]]!=1){
e.rx-=a[i];
b[1]=1;
}
if(vh[e.hy][e.hx]!=1)g++;
if(vr[e.ry][e.rx]!=1)g++;
vh[e.hy][e.hx]=1;
vr[e.ry][e.rx]=1;
q.push(e);
if(b[0]==1)e.hx-=a[i];
if(b[1]==1)e.rx+=a[i];
}
}
e.tim--;
}
while(!q.empty())q.pop();
if(e.tim>=100||g==(w*h-k)*2)printf("NA\n");
else cout<<e.tim<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:10:1: error: 'queue' was not declared in this scope
10 | queue<Y> q;
| ^~~~~
a.cc:2:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
1 | #include<string.h>
+++ |+#include <queue>
2 | using namespace std;
a.cc:10:8: error: expected primary-expression before '>' token
10 | queue<Y> q;
| ^
a.cc:10:10: error: 'q' was not declared in this scope
10 | queue<Y> q;
| ^
a.cc:14:9: error: 'cin' was not declared in this scope
14 | cin>>w>>h;
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include<string.h>
+++ |+#include <iostream>
2 | using namespace std;
a.cc:88:37: error: 'printf' was not declared in this scope
88 | if(e.tim>=100||g==(w*h-k)*2)printf("NA\n");
| ^~~~~~
a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
1 | #include<string.h>
+++ |+#include <cstdio>
2 | using namespace std;
a.cc:89:14: error: 'cout' was not declared in this scope
89 | else cout<<e.tim<<endl;
| ^~~~
a.cc:89:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:89:27: error: 'endl' was not declared in this scope
89 | else cout<<e.tim<<endl;
| ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
1 | #include<string.h>
+++ |+#include <ostream>
2 | using namespace std;
|
s396999545 | p00223 | C++ | #include<iostream>
#include<queue>
#include<cstring>
using namespace std;
bool went[50 + 10][50 + 10][50 + 10][50 + 10] = { 0 };
int map[50 + 10][50 + 10]/* = { 0 }*/;
int gx[] = { 1,0,-1,0,-1,0,1,0 };
int gy[] = { 0,1,0,-1,0,-1,0,1 };
struct ST
{
int tx, ty;
int kx, ky;
int tim=0;
};
bool ChekNow(ST);
ST GoMap(ST, int);
void test(ST ex, int h, int w)
{
int i, j;
cout << endl;
for (i = 1; i <= h; i++)
{
for (j = 1; j <= w; j++)
{
if ((i == ex.ky && j == ex.kx) || (i == ex.ty && j == ex.tx))
cout << "*";
else cout << map[i][j];
}
cout << endl;
}
cout << ex.tim << endl;
}
int main()
{
ST now,tmp;
queue <ST> nx;
int w, h;
int tsx, tsy;
int ksx, ksy;
bool flg;
int i, j;
while (cin >> w >> h, w != 0 && h != 0)
{
flg = true;
cin >> tsx >> tsy;
cin >> ksx >> ksy;
for (i = 1; i <= h; i++)
{
map[i][0] = map[i][w + 1] = 1;
for (j = 1; j <= w; j++)
{
cin >> map[i][j];
}
}
for (i = 0; i <= w + 1; i++)
{
map[0][i] = 1;
map[h + 1][i] = 1;
}
now.tx = tsx;
now.ty = tsy;
now.kx = ksx;
now.ky = ksy;
now.tim = 0;
nx.push(now);
while (!nx.empty()) && now.tim<100)
{
now = nx.front();
nx.pop();
/*
if (now.tim >= 100)
{
break;
}
*/
//if (ChekNow(now))
//{
// continue;
//}
//went[now.tx][now.ty][now.kx][now.ky] = true;
//test(now, h, w);
if (now.tx == now.kx && now.ty == now.ky)
{
cout << now.tim << endl;
flg = false;
break;
}
for (i = 0; i < 4; i++)
{
//tmp=GoMap(now, i);
tmp = now;
if (map[now.ty + gy[i]][now.tx + gx[i]] == 0)
{
tmp.ty += gy[i];
tmp.tx += gx[i];
}
if (map[now.ky + gy[i + 4]][now.kx + gx[i + 4]] == 0)
{
tmp.ky += gy[i + 4];
tmp.kx += gx[i + 4];
}
if (!ChekNow(tmp))
{
tmp.tim++;
went[tmp.tx][tmp.ty][tmp.kx][tmp.ky] = true;
nx.push(tmp);
}
}
}
if (flg)
{
cout << "NA\n";
}
while (!nx.empty())
{
nx.pop();
}
memset(went, 0, sizeof(went));
}
return 0;
}
bool ChekNow (ST ex)
{
return went[ex.tx][ex.ty][ex.kx][ex.ky];
}
ST GoMap(ST ex, int i)
{
if (map[ex.ty + gy[i]][ex.tx + gx[i]] == 0)
{
ex.ty += gy[i];
ex.tx += gx[i];
}
if (map[ex.ky + gy[i + 4]][ex.kx + gx[i + 4]] == 0)
{
ex.ky += gy[i + 4];
ex.kx += gx[i + 4];
}
return ex;
} | a.cc: In function 'int main()':
a.cc:89:44: error: expected ';' before '.' token
89 | while (!nx.empty()) && now.tim<100)
| ^
| ;
a.cc:89:41: error: label 'now' used but not defined
89 | while (!nx.empty()) && now.tim<100)
| ^~~
|
s775141521 | p00223 | C++ | package main
import (
"fmt"
"math"
)
type Position struct {
X int64
Y int64
}
func (one Position) Distance(another Position) int64 {
return int64(math.Abs(float64(one.X-another.X)) + math.Abs(float64(one.Y-another.Y)))
}
type PersonPosition struct {
Takayuki Position
Kazuyuki Position
}
func (one PersonPosition) Distance() int64 {
return one.Takayuki.Distance(one.Kazuyuki)
}
type Status struct {
Person PersonPosition
Turn int64
}
type PQStatus []*Status
func solve(h, w int64) {
var tx, ty, kx, ky int64
fmt.Scan(&tx, &ty, &kx, &ky)
tx--
ty--
kx--
ky--
m := make([][]int64, h)
for i := range m {
m[i] = make([]int64, w)
for j := int64(0); j < w; j++ {
fmt.Scan(&m[i][j])
}
}
start := &Status{Person: PersonPosition{Takayuki: Position{X: tx, Y: ty}, Kazuyuki: Position{X: kx, Y: ky}}, Turn: 0}
pq := make(PQStatus, 0)
pq = append(pq, start)
dx := []int64{0, 1, 0, -1}
dy := []int64{1, 0, -1, 0}
memo := make(map[PersonPosition]int64, 0)
ans := int64(102)
for pq.Len() > 0 {
now := pq[0]
pq = pq[1:]
if now.Person.Distance() == 0 && ans > now.Turn {
ans = now.Turn
}
if ans <= now.Turn {
continue
}
if _, ok := memo[now.Person]; ok {
continue
}
memo[now.Person] = now.Turn
for i := 0; i < 4; i++ {
next := &Status{}
*next = *now
next.Person.Kazuyuki.X += dx[i]
next.Person.Kazuyuki.Y += dy[i]
if next.Person.Kazuyuki.X < 0 || next.Person.Kazuyuki.X >= w ||
next.Person.Kazuyuki.Y < 0 || next.Person.Kazuyuki.Y >= h ||
m[next.Person.Kazuyuki.Y][next.Person.Kazuyuki.X] == 1 {
next.Person.Kazuyuki.X -= dx[i]
next.Person.Kazuyuki.Y -= dy[i]
}
next.Person.Takayuki.X -= dx[i]
next.Person.Takayuki.Y -= dy[i]
if next.Person.Takayuki.X < 0 || next.Person.Takayuki.X >= w ||
next.Person.Takayuki.Y < 0 || next.Person.Takayuki.Y >= h ||
m[next.Person.Takayuki.Y][next.Person.Takayuki.X] == 1 {
next.Person.Takayuki.X += dx[i]
next.Person.Takayuki.Y += dy[i]
}
next.Turn++
if next.Turn <= 100 {
pq = append(pq, next)
}
}
}
if ans == 102 {
fmt.Println("NA")
} else {
fmt.Println(ans)
}
}
func main() {
var h, w int64
for {
fmt.Scan(&h, &w)
if h == 0 && w == 0 {
break
}
solve(h, w)
}
}
| a.cc:1:1: error: 'package' does not name a type
1 | package main
| ^~~~~~~
a.cc:13:6: error: expected constructor, destructor, or type conversion before '(' token
13 | func (one Position) Distance(another Position) int64 {
| ^
a.cc:17:1: error: 'type' does not name a type; did you mean 'typeof'?
17 | type PersonPosition struct {
| ^~~~
| typeof
a.cc:22:6: error: expected constructor, destructor, or type conversion before '(' token
22 | func (one PersonPosition) Distance() int64 {
| ^
a.cc:26:1: error: 'type' does not name a type; did you mean 'typeof'?
26 | type Status struct {
| ^~~~
| typeof
a.cc:31:1: error: 'type' does not name a type; did you mean 'typeof'?
31 | type PQStatus []*Status
| ^~~~
| typeof
a.cc:101:1: error: 'func' does not name a type
101 | func main() {
| ^~~~
|
s761134812 | p00223 | C++ | #include <iostream>
#include <queue>
using namespace std;
const int INF=100000000;
class Point{
public:
int tx;
int ty;
int kx;
int ky;
};
int main(){
while(true){
int X,Y;
cin>>X>>Y;
if(X==0&&Y==0){
break;
}
char F[X+2][Y+2];
int D[X+1][Y+1];
for(int x=1;x<=X;x++){
for(int y=1;y<=Y;y++){
D[x][y]=INF;
}
}
int tx,ty,kx,ky;
cin>>tx>>ty;
cin>>kx>>ky;
D[tx][ty]=0;
D[kx][ky]=0;
for(int x=0;x<=X+1;x++){
for(int y=0;y<=Y+1;y++){
F[x][y]=1;
}
}
int a;
for(int x=1;x<=X;x++){
for(int y=1;y<=Y;y++){
cin>>a;
F[x][y]=a;
}
}
queue<Point> que;
Point p;
p.tx=tx;
p.ty=ty;
p.kx=kx;
p.ky=ky;
que.push(p);
while(!que.empty()){
p=que.front();
que.pop();
if(p.tx==p.kx&&p.ty==p.ky){
if(D[p.tx][p.ty]>100){
cout<<"NA"<<endl;
break;
}
cout<<D[p.tx][p.ty]<<endl;
break;
}
if(D[p.tx-1][p.ty]==INF&&D[p.kx+1][p.ky]==INF){
Point q;
q.tx=p.tx-1;
q.ty=p.ty;
q.kx=p.kx+1;
q.ky=p.ky;
if(F[q.tx][q.ty]==1){
q.tx=q.tx+1;
D[q.kx][q.ky]=D[p.kx][p.ky]+1;
}else
if(F[q.kx][q.ky]==1){
q.kx=q.kx-1;
D[q.tx][q.ty]=D[p.tx][p.ty]+1;
}else{
D[q.kx][q.ky]=D[p.kx][p.ky]+1;
D[q.tx][q.ty]=D[p.tx][p.ty]+1;
}
que.push(q);
}
if(D[p.tx+1][p.ty]==INF&&D[p.kx-1][p.ky]==INF){
Point q;
q.tx=p.tx+1;
q.ty=p.ty;
q.kx=p.kx-1;
q.ky=p.ky;
if(F[q.tx][q.ty]==1){
q.tx=q.tx+1;
D[q.kx][q.ky]=D[p.kx][p.ky]+1;
}else
if(F[q.kx][q.ky]==1){
q.kx=q.kx-1;
D[q.tx][q.ty]=D[p.tx][p.ty]+1;
}else{
D[q.kx][q.ky]=D[p.kx][p.ky]+1;
D[q.tx][q.ty]=D[p.tx][p.ty]+1;
}
que.push(q);
}
if(D[p.tx][p.ty+1]==INF&&D[p.kx][p.ky-1]==INF){
Point q;
q.tx=p.tx;
q.ty=p.ty+1;
q.kx=p.kx;
q.ky=p.ky-1;
que.push(q);
if(F[q.tx][q.ty]==1){
q.tx=q.tx+1;
D[q.kx][q.ky]=D[p.kx][p.ky]+1;
}else
if(F[q.kx][q.ky]==1){
q.kx=q.kx-1;
D[q.tx][q.ty]=D[p.tx][p.ty]+1;
}else{
D[q.kx][q.ky]=D[p.kx][p.ky]+1;
D[q.tx][q.ty]=D[p.tx][p.ty]+1;
}
que.push(q);
}
if(D[p.tx][p.ty-1]==INF&&D[p.kx][p.ky+1]==INF){
Point q;
q.tx=p.tx;
q.ty=p.ty-1;
q.kx=p.kx;
q.ky=p.ky+1;
if(F[q.tx][q.ty]==1){
q.tx=q.tx+1;
D[q.kx][q.ky]=D[p.kx][p.ky]+1;
}else
if(F[q.kx][q.ky]==1){
q.kx=q.kx-1;
D[q.tx][q.ty]=D[p.tx][p.ty]+1;
}else{
D[q.kx][q.ky]=D[p.kx][p.ky]+1;
D[q.tx][q.ty]=D[p.tx][p.ty]+1;
}
que.push(q);=1;y<=Y;y++){
cin>>a;
}
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:149:21: error: expected primary-expression before '=' token
149 | que.push(q);=1;y<=Y;y++){
| ^
a.cc:149:24: error: 'y' was not declared in this scope
149 | que.push(q);=1;y<=Y;y++){
| ^
a.cc:157:2: error: expected '}' at end of input
157 | }
| ^
a.cc:15:11: note: to match this '{'
15 | int main(){
| ^
|
s804078732 | p00223 | C++ | /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
| |
s894728158 | p00223 | C++ | #include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
int x, y;
int time[51][51][51][51];
char field[51][51];
int dx[] = {
0, -1, 0, 1
};
int dy[] = {
1, 0, -1, 0
};
struct twins{
int x1;
int y1;
int x2;
int y2;
};
bool can_move(int x1, int y1){
if(x1 > 0 && x1 <= x && y1 > 0 && y1 <= y){
if(field[y1][x1] == '0') return true;
else return false;
}
return false;
}
void get_time(int x1, int y1, int x2, int y2){
twins t0;
t0.x1 = x1, t0.x2 = x2, t0.y1 = y1, t0.y2 = y2;
queue<twins> qt;
qt.push(t0);
while(!qt.empty()){
twins t = qt.front(); qt.pop();
for(int i = 0; i < 4; i++){
int ay = t.y1 + dy[i];
int ax = t.x1 + dx[i];
int by = t.y2 - dy[i];
int bx = t.x2 - dx[i];
if(!can_move(ax, ay)){
ay = t.y1;
ax = t.x1;
}
if(!can_move(bx, by)){
by = t.y2;
bx = t.x2;
}
if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
time[ay][ax][by][bx] = time[t.y1][t.x1][t.y2][t.x2] + 1;
t0.x1 = ax, t0.x2 = bx, t0.y1 = ay, t0.y2 = by;
qt.push(t0);
}
}
}
}
int main(){
int ax, ay, bx, by;
while(cin >> x >> y && (x || y)){
int count = 101;
memset(time, -1, sizeof(time));
cin >> ax >> ay >> bx >> by;
for(int i = 1; i <= y; i++){
for(int j = 1; j <= x; j++){
cin >> field[i][j];
}
}
time[ay][ax][by][bx] = 0;
get_time(ax, ay, bx, by);
for(int i = 1; i <= y; i++){
for(int j = 1; j <= x; j++){
if(time[i][j][i][j] >= 0) count = min(count, time[i][j][i][j]);
}
}
if(count == 101) cout << "NA" << endl;
else cout << count << endl;
}
return 0;
} | a.cc:14:24: error: 'int time [51][51][51][51]' redeclared as different kind of entity
14 | int time[51][51][51][51];
| ^
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'void get_time(int, int, int, int)':
a.cc:57:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ^
a.cc:57:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ^
a.cc:57:43: warning: pointer to a function used in arithmetic [-Wpointer-arith]
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ^
a.cc:57:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ^
a.cc:57:49: error: ordered comparison of pointer with integer zero ('time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} and 'int')
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:57:63: warning: pointer to a function used in arithmetic [-Wpointer-arith]
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ^
a.cc:57:67: warning: pointer to a function used in arithmetic [-Wpointer-arith]
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ^
a.cc:57:71: warning: pointer to a function used in arithmetic [-Wpointer-arith]
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ^
a.cc:57:75: warning: pointer to a function used in arithmetic [-Wpointer-arith]
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ^
a.cc:57:88: warning: pointer to a function used in arithmetic [-Wpointer-arith]
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ^
a.cc:57:94: warning: pointer to a function used in arithmetic [-Wpointer-arith]
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ^
a.cc:57:100: warning: pointer to a function used in arithmetic [-Wpointer-arith]
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ^
a.cc:57:106: warning: pointer to a function used in arithmetic [-Wpointer-arith]
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ^
a.cc:57:108: warning: pointer to a function used in arithmetic [-Wpointer-arith]
57 | if(time[ay][ax][by][bx] < 0 || time[ay][ax][by][bx] > time[t.y1][t.x1][t.y2][t.x2] + 1){
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:58:40: warning: pointer to a function used in arithmetic [-Wpointer-arith]
58 | time[ay][ax][by][bx] = time[t.y1][t.x1][t.y2][t.x2] + 1;
| ^
a.cc:58:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
58 | time[ay][ax][by][bx] = time[t.y1][t.x1][t.y2][t.x2] + 1;
| ^
a.cc:58:48: warning: pointer to a function used in arithmetic [-Wpointer-arith]
58 | time[ay][ax][by][bx] = time[t.y1][t.x1][t.y2][t.x2] + 1;
| ^
a.cc:58:52: warning: pointer to a function used in arithmetic [-Wpointer-arith]
58 | time[ay][ax][by][bx] = time[t.y1][t.x1][t.y2][t.x2] + 1;
| ^
a.cc:58:65: warning: pointer to a function used in arithmetic [-Wpointer-arith]
58 | time[ay][ax][by][bx] = time[t.y1][t.x1][t.y2][t.x2] + 1;
| ^
a.cc:58:71: warning: pointer to a function used in arithmetic [-Wpointer-arith]
58 | time[ay][ax][by][bx] = time[t.y1][t.x1][t.y2][t.x2] + 1;
| ^
a.cc:58:77: warning: pointer to a function used in arithmetic [-Wpointer-arith]
58 | time[ay][ax][by][bx] = time[t.y1][t.x1][t.y2][t.x2] + 1;
| ^
a.cc:58:83: warning: pointer to a function used in arithmetic [-Wpointer-arith]
58 | time[ay][ax][by][bx] = time[t.y1][t.x1][t.y2][t.x2] + 1;
| ^
a.cc:58:85: warning: pointer to a function used in arithmetic [-Wpointer-arith]
58 | time[ay][ax][by][bx] = time[t.y1][t.x1][t.y2][t.x2] + 1;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:58:54: error: assignment of read-only location '*(time + (((((sizetype)ay) + ((sizetype)ax)) + ((sizetype)by)) + ((sizetype)bx)))'
58 | time[ay][ax][by][bx] = time[t.y1][t.x1][t.y2][t.x2] + 1;
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:70:41: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
70 | memset(time, -1, sizeof(time));
| ~^~~~~
a.cc:70:17: error: 'memset' was not declared in this scope
70 | memset(time, -1, sizeof(time));
| ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
9 | #include <map>
+++ |+#include <cstring>
10 | using namespace std;
a.cc:77:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
77 | time[ay][ax][by][bx] = 0;
| ^
a.cc:77:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
77 | time[ay][ax][by][bx] = 0;
| ^
a.cc:77:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
77 | time[ay][ax][by][bx] = 0;
| ^
a.cc:77:36: warning: pointer to a function used in arithmetic [-Wpointer-arith]
77 | time[ay][ax][by][bx] = 0;
| ^
a.cc:77:38: error: assignment of read-only location '*(time + (((((sizetype)ay) + ((sizetype)ax)) + ((sizetype)by)) + ((sizetype)bx)))'
77 | time[ay][ax][by][bx] = 0;
| ~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:81:42: warning: pointer to a function used in arithmetic [-Wpointer-arith]
81 | if(time[i][j][i][j] >= 0) count = min(count, time[i][j][i][j]);
| ^
a.cc:81:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
81 | if(time[i][j][i][j] >= 0) count = min(count, time[i][j][i][j]);
| ^
a.cc:81:48: warning: pointer to a function used in arithmetic [-Wpointer-arith]
81 | if(time[i][j][i][j] >= 0) count = min(count, time[i][j][i][j]);
| ^
a.cc:81:51: warning: pointer to a function used in arithmetic [-Wpointer-arith]
81 | if(time[i][j][i][j] >= 0) count = min(count, time[i][j][i][j]);
| ^
a.cc:81:53: error: ordered comparison of pointer with integer zero ('time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} and 'int')
81 | if(time[i][j][i][j] >= 0) count = min(count, time[i][j][i][j]);
| ~~~~~~~~~~~~~~~~~^~~~
a.cc:81 |
s039417296 | p00223 | C++ | #include <iostream>
#include <queue>
using namespace std;
struct PointPair {
int step;
int tx, ty, kx, ky;
};
const int dx[] = { -1, 1, 0, 0 };
const int dy[] = { 0, 0, -1, 1 };
bool passed[50][50][50][50];
bool field[50][50];
int main(){
while(true){
memset(passed, 0, sizeof(passed));
memset(field, 0, sizeof(field));
int X, Y, tx, ty, kx, ky;
cin >> X >> Y;
if(X == 0 || Y == 0){ break; }
cin >> tx >> ty >> kx >> ky;
for(int i = 0; i < Y; ++i){
for(int j = 0; j < X; ++j){
int f;
cin >> f;
field[i][j] = (f != 0);
}
}
--tx; --ty; --kx; --ky;
PointPair init = { 0, tx, ty, kx, ky };
queue<PointPair> q;
q.push(init);
passed[tx][ty][kx][ky] = true;
int answer = -1;
while(!q.empty()){
PointPair p = q.front();
if(p.step >= 100){ break; }
if(p.tx == p.kx && p.ty == p.ky){
answer = p.step;
break;
}
q.pop();
for(int i = 0; i < 4; ++i){
PointPair next;
next.step = p.step + 1;
next.tx = p.tx + dx[i];
next.ty = p.ty + dy[i];
if(field[next.tx][next.ty]){
next.tx = p.tx;
next.ty = p.ty;
}else{
if(next.tx < 0){ next.tx = 0; }
if(next.tx >= X){ next.tx = X - 1; }
if(next.ty < 0){ next.ty = 0; }
if(next.ty >= Y){ next.ty = Y - 1; }
}
next.kx = p.kx - dx[i];
next.ky = p.ky - dy[i];
if(field[next.kx][next.ky]){
next.kx = p.kx;
next.ky = p.ky;
}else{
if(next.kx < 0){ next.kx = 0; }
if(next.kx >= X){ next.kx = X - 1; }
if(next.ky < 0){ next.ky = 0; }
if(next.ky >= Y){ next.ky = Y - 1; }
}
if(!passed[next.tx][next.ty][next.kx][next.ky]){
passed[next.tx][next.ty][next.kx][next.ky] = true;
q.push(next);
}
}
}
if(answer < 0){
cout << "NA" << endl;
}else{
cout << answer << endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:18:17: error: 'memset' was not declared in this scope
18 | memset(passed, 0, sizeof(passed));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <queue>
+++ |+#include <cstring>
3 |
|
s071333476 | p00223 | C++ | g#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
typedef long long LL;
static const double EPS = 1e-8;
static const int INF = (int)1e8;
#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())
struct P{
int tx,ty,kx,ky;
int t;
P(int tx,int ty,int kx,int ky,int t) : tx(tx),ty(ty),kx(kx),ky(ky),t(t) {}
};
bool operator < (P p, P q){
return p.t > q.t;
}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
bool memo[51][51][51][51];
int main(void){
int w,h;
while(cin>>w>>h,w){
memset(memo,0,sizeof(memo));
int grid[51][51];
int tx,ty,kx,ky;
cin>>tx>>ty>>kx>>ky;
tx--;ty--;kx--;ky--;
REP(y,h)REP(x,w)cin>>grid[y][x];
priority_queue<P> que;
que.push(P(tx,ty,kx,ky,0));
int ans=-1;
while(!que.empty()){
P p = que.top(); que.pop();
if(memo[p.tx][p.ty][p.kx][p.ky])continue;
memo[p.tx][p.ty][p.kx][p.ky] = true;
if(p.t>=100){
ans = -1;
break;
}
if(p.tx==p.kx&&p.ty==p.ky){
ans = p.t;
break;
}
REP(r,4){
int ntx = p.tx + dx[r];
int nty = p.ty + dy[r];
int nkx = p.kx - dx[r];
int nky = p.ky - dy[r];
if(!(ntx>=0&&ntx<w&&nty>=0&&nty<h&&grid[nty][ntx]==0)){
ntx = p.tx;
nty = p.ty;
}
if(!(nkx>=0&&nkx<w&&nky>=0&&nky<h&&grid[nky][nkx]==0)){
nkx = p.kx;
nky = p.ky;
}
que.push(P(ntx,nty,nkx,nky,p.t+1));
}
}
if(ans==-1) cout<<"NA"<<endl;
else cout<<ans<<endl;
}
return 0;
} | a.cc:1:2: error: stray '#' in program
1 | g#include <cstdio>
| ^
a.cc:1:1: error: 'g' does not name a type
1 | g#include <cstdio>
| ^
In file included from /usr/include/c++/14/cmath:45,
from a.cc:3:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/bits/specfun.h:43,
from /usr/include/c++/14/cmath:3906:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
In file included from /usr/include/stdlib.h:32,
from /usr/include/c++/14/cstdlib:79,
from a.cc:2:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:65:
/usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type
125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
+++ |+#include <cstddef>
1 | // Types used in iterator implementation -*- C++ -*-
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type
214 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type
225 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_algobase.h:66:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type
112 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
65 | #include <debug/assertions.h>
+++ |+#include <cstddef>
66 | #include <bits/stl_iterator_base_types.h>
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type
118 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_iterator.h:67,
from /usr/include/c++/14/bits/stl_alg |
s492822018 | p00223 | C++ | #include<iostream>
#include<queue>
using namespace std;
#define MAX 51
int xy[MAX][MAX];
int cost[MAX][MAX][MAX][MAX];
int X,Y;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
struct state{
int tx;
int ty;
int kx;
int ky;
int co;
state(){}
state(int tx,int ty,int kx,int ky,int co):
tx(tx),ty(ty),kx(kx),ky(ky),co(co){}
};
int solve(int tx,int ty,int kx,int ky){
memset(cost,101,sizeof(cost));
queue<state> q;
q.push( state(tx,ty,kx,ky,0) );
while( !q.empty() ){
state p=q.front();
q.pop();
//printf("co=%d\n",p.co);
if(p.co==100){
break;
}
tx=p.tx;
ty=p.ty;
kx=p.kx;
ky=p.ky;
for(int i=0;i<4;i++){
/* if( (tx+dx[i] < 0 || ty+dy[i] <0 || tx+dx[i] >= X || ty+dy[i] >= Y) || xy[ty+dy[i]][tx+dx[i]]==1 ){
fl++;
}
if(kx+dx[i]*-1 < 0 || ky+dy[i]*-1 <0 || kx+dx[i]*-1 >= X || ty+dy[i]*-1 >= Y || xy[ky+dy[i]*-1][kx+dx[i]*-1]==1){
fl+=10;
}*/
if(kx+dx[i]*-1 < 0 || ky+dy[i]*-1 <0 || kx+dx[i]*-1 >= X || ty+dy[i]*-1 >= Y ||
tx+dx[i] < 0 || ty+dy[i] <0 || tx+dx[i] >= X || ty+dy[i] >= Y )
continue;
cost[tx][ty][kx][ky]=p.co;
if( cost[tx+dx[i]][ty+dy[i]][kx+dx[i]*-1][ky+dy[i]*-1] < p.co)
continue;
if( xy[ty+dy[i]][tx+dx[i]]==1 || xy[ky+dy[i]*-1][kx+dx[i]*-1]==1 )
continue;
if(tx+dx[i] == kx+dx[i]*-1 && ty+dy[i] == ky+dy[i]*-1){
if(p.co+1>=100) return -1;
return p.co+1;
}
//if(cost[p.tx+dx[i]][p.ty+dy[i]] < p.co)
//continue;
//if(cosk[p.kx+dx[i]*-1][p.ky+dy[i]*-1] < p.co)
//continue;
//cost[p.tx+dx[i]][p.ty+dy[i]]=p.co+1;
//cosk[p.kx+dx[i]*-1][p.ky+dy[i]*-1]=p.co+1;
/*if(fl%10==1 && fl/10==1)
continue;
else if(fl%10==1)
q.push( state(tx+dx[i],ty+dy[i],kx,ky,p.co+1) );
else if(fl/10==1)
q.push( state(tx,ty,kx+dx[i]*-1,ky+dy[i]*-1,p.co+1) );
else*/
q.push( state(tx+dx[i],ty+dy[i],kx+dx[i]*-1,ky+dy[i]*-1,p.co+1) );
}
}
return -1;
}
main(){
int i,j;
int kx,ky,tx,ty;
int n;
while(1){
cin >> X >> Y;
if(X==0 && Y==0) break;
cin >> tx >> ty;
cin >> kx >> ky;
for(i=0;i<Y;i++){
for(j=0;j<X;j++){
cin >> xy[i][j];
}
}
n=solve(tx-1,ty-1,kx-1,ky-1);
if(n==-1)
cout << "NA" << endl;
else
cout << n << endl;
}
return 0;
} | a.cc: In function 'int solve(int, int, int, int)':
a.cc:28:3: error: 'memset' was not declared in this scope
28 | memset(cost,101,sizeof(cost));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<queue>
+++ |+#include <cstring>
3 |
a.cc: At global scope:
a.cc:98:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
98 | main(){
| ^~~~
|
s727454251 | p00223 | C++ | #include<iostream>
#include<queue>
using namespace std;
#define MAX 51
int xy[MAX][MAX];
int cost[MAX][MAX][MAX][MAX];
int X,Y;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
struct state{
int tx;
int ty;
int kx;
int ky;
int co;
state(){}
state(int tx,int ty,int kx,int ky,int co):
tx(tx),ty(ty),kx(kx),ky(ky),co(co){}
};
int solve(int tx,int ty,int kx,int ky){
memset(cost,101,sizeof(cost));
queue<state> q;
q.push( state(tx,ty,kx,ky,0) );
while( !q.empty() ){
state p=q.front();
q.pop();
if(p.co==100){
break;
}
tx=p.tx;
ty=p.ty;
kx=p.kx;
ky=p.ky;
for(int i=0;i<4;i++){
if(kx+dx[i]*-1 < 0 || ky+dy[i]*-1 <0 || kx+dx[i]*-1 >= X || ty+dy[i]*-1 >= Y ||
tx+dx[i] < 0 || ty+dy[i] <0 || tx+dx[i] >= X || ty+dy[i] >= Y )
continue;
cost[tx][ty][kx][ky]=p.co;
if( cost[tx+dx[i]][ty+dy[i]][kx+dx[i]*-1][ky+dy[i]*-1] < p.co)
continue;
if( xy[ty+dy[i]][tx+dx[i]]==1 || xy[ky+dy[i]*-1][kx+dx[i]*-1]==1 )
continue;
if(tx+dx[i] == kx+dx[i]*-1 && ty+dy[i] == ky+dy[i]*-1){
if(p.co+1>=100) return -1;
return p.co+1;
}
q.push( state(tx+dx[i],ty+dy[i],kx+dx[i]*-1,ky+dy[i]*-1,p.co+1) );
}
}
return -1;
}
main(){
int i,j;
int kx,ky,tx,ty;
int n;
while(1){
cin >> X >> Y;
if(X==0 && Y==0) break;
cin >> tx >> ty;
cin >> kx >> ky;
for(i=0;i<Y;i++){
for(j=0;j<X;j++){
cin >> xy[i][j];
}
}
n=solve(tx-1,ty-1,kx-1,ky-1);
if(n==-1)
cout << "NA" << endl;
else
cout << n << endl;
}
return 0;
} | a.cc: In function 'int solve(int, int, int, int)':
a.cc:28:3: error: 'memset' was not declared in this scope
28 | memset(cost,101,sizeof(cost));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<queue>
+++ |+#include <cstring>
3 |
a.cc: At global scope:
a.cc:72:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
72 | main(){
| ^~~~
|
s780292612 | p00223 | C++ | #include<cstdio>
#include<string.h>
using namespace std;
#define MAX 51
int xy[MAX][MAX];
int cost[MAX][MAX][MAX][MAX];
int X,Y;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
struct state{
int tx;
int ty;
int kx;
int ky;
int co;
state(){}
state(int tx,int ty,int kx,int ky,int co):
tx(tx),ty(ty),kx(kx),ky(ky),co(co){}
};
int solve(int tx,int ty,int kx,int ky){
memset(cost,101,sizeof(cost));
queue<state> q;
q.push( state(tx,ty,kx,ky,0) );
while( !q.empty() ){
state p=q.front();
q.pop();
if(p.co==100){
break;
}
tx=p.tx;
ty=p.ty;
kx=p.kx;
ky=p.ky;
for(int i=0;i<4;i++){
if(kx+dx[i]*-1 < 0 || ky+dy[i]*-1 <0 || kx+dx[i]*-1 >= X || ty+dy[i]*-1 >= Y ||
tx+dx[i] < 0 || ty+dy[i] <0 || tx+dx[i] >= X || ty+dy[i] >= Y )
continue;
cost[tx][ty][kx][ky]=p.co;
if( cost[tx+dx[i]][ty+dy[i]][kx+dx[i]*-1][ky+dy[i]*-1] < p.co)
continue;
if( xy[ty+dy[i]][tx+dx[i]]==1 || xy[ky+dy[i]*-1][kx+dx[i]*-1]==1 )
continue;
if(tx+dx[i] == kx+dx[i]*-1 && ty+dy[i] == ky+dy[i]*-1)
return p.co+1;
q.push( state(tx+dx[i],ty+dy[i],kx+dx[i]*-1,ky+dy[i]*-1,p.co+1) );
}
}
return -1;
}
main(){
int i,j;
int kx,ky,tx,ty;
int n;
while(1){
cin >> X >> Y;
if(X==0 && Y==0) break;
cin >> tx >> ty;
cin >> kx >> ky;
for(i=0;i<Y;i++){
for(j=0;j<X;j++){
cin >> xy[i][j];
}
}
n=solve(tx-1,ty-1,kx-1,ky-1);
if(n==-1)
cout << "NA" << endl;
else
cout << n << endl;
}
return 0;
} | a.cc: In function 'int solve(int, int, int, int)':
a.cc:30:3: error: 'queue' was not declared in this scope
30 | queue<state> q;
| ^~~~~
a.cc:3:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
2 | #include<string.h>
+++ |+#include <queue>
3 |
a.cc:30:14: error: expected primary-expression before '>' token
30 | queue<state> q;
| ^
a.cc:30:16: error: 'q' was not declared in this scope
30 | queue<state> q;
| ^
a.cc: At global scope:
a.cc:70:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
70 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:78:5: error: 'cin' was not declared in this scope
78 | cin >> X >> Y;
| ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
2 | #include<string.h>
+++ |+#include <iostream>
3 |
a.cc:94:7: error: 'cout' was not declared in this scope
94 | cout << "NA" << endl;
| ^~~~
a.cc:94:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:94:23: error: 'endl' was not declared in this scope
94 | cout << "NA" << endl;
| ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
2 | #include<string.h>
+++ |+#include <ostream>
3 |
a.cc:96:7: error: 'cout' was not declared in this scope
96 | cout << n << endl;
| ^~~~
a.cc:96:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:96:20: error: 'endl' was not declared in this scope
96 | cout << n << endl;
| ^~~~
a.cc:96:20: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
|
s138355795 | p00223 | C++ | #include <iostream>
#include <queue>
#include <map>
#define INF 100000000
#define MAX_X 1000
#define MAX_Y 1000
using namespace std;
typedef pair<pair<int,int>,pair<int,int> > P;
int d[MAX_Y][MAX_X][MAX_Y][MAX_X];
int tx,ty,kx,ky,ntx,nty,nkx,nky;
int ans;
short maze[MAX_Y][MAX_X];
int Y,X;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
bool bfs(){
queue<P> que;
map<P,int> mat;
que.push(make_pair(make_pair(ty,tx),make_pair(ky,kx)));
mat[que.front()]=0;
while (que.size()&&100>=d[nty][ntx][nky][nkx]) {
P p=que.front();
que.pop();
if (p.first.first==p.second.first&&p.first.second==p.second.second) {
ans=d[p.first.first][p.first.second][p.second.first][p.second.second];
return true;
}
if (mat[que.front()]) {
continue;
}
for (int i=0; i<4; i++) {
ntx=p.first.second+dx[i],nty=p.first.first+dy[i],nkx=p.second.second+dx[i]*(-1),nky=p.second.first+dy[i]*(-1);
int flag=2;
if (!(0<=ntx&&ntx<X&&0<=nty&&nty<Y&&maze[nty][ntx]!=1)){
flag-=1;
ntx=p.first.second;
nty=p.first.first;
}
if (!(0<=nkx&&nkx<X&&0<=nky&&nky<Y&&maze[nky][nkx]!=1)) {
flag-=1;
nkx=p.second.second;
nky=p.second.first;
}
if (flag!=0) {
que.push(P(make_pair(nty,ntx),make_pair(nky,nkx)));
d[nty][ntx][nky][nkx]=d[p.first.first][p.first.second][p.second.first][p.second.second]+1;
}
mat[que.front()] = d[nty][ntx][nky][nkx];
}
}
return false;
}
int main(){
while (cin>>X>>Y&&X&&Y) {
cin>>tx>>ty>>kx>>ky;
tx-=1;
ty-=1;
kx-=1;
ky-=1;
for (int i=0; i<Y; i++) {
for (int j=0; j<X; j++) {
cin>>maze[i][j];
}
}
if(bfs()){
cout << ans <<endl;
}
else {
cout << "NA" << endl;
}
}
} | /tmp/ccvd5Gl5.o: in function `bfs()':
a.cc:(.text+0x2d): relocation truncated to fit: R_X86_64_PC32 against symbol `kx' defined in .bss section in /tmp/ccvd5Gl5.o
a.cc:(.text+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `ky' defined in .bss section in /tmp/ccvd5Gl5.o
a.cc:(.text+0x4a): relocation truncated to fit: R_X86_64_PC32 against symbol `tx' defined in .bss section in /tmp/ccvd5Gl5.o
a.cc:(.text+0x54): relocation truncated to fit: R_X86_64_PC32 against symbol `ty' defined in .bss section in /tmp/ccvd5Gl5.o
a.cc:(.text+0x16c): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccvd5Gl5.o
a.cc:(.text+0x1db): relocation truncated to fit: R_X86_64_PC32 against symbol `ntx' defined in .bss section in /tmp/ccvd5Gl5.o
a.cc:(.text+0x200): relocation truncated to fit: R_X86_64_PC32 against symbol `nty' defined in .bss section in /tmp/ccvd5Gl5.o
a.cc:(.text+0x225): relocation truncated to fit: R_X86_64_PC32 against symbol `nkx' defined in .bss section in /tmp/ccvd5Gl5.o
a.cc:(.text+0x24a): relocation truncated to fit: R_X86_64_PC32 against symbol `nky' defined in .bss section in /tmp/ccvd5Gl5.o
a.cc:(.text+0x257): relocation truncated to fit: R_X86_64_PC32 against symbol `ntx' defined in .bss section in /tmp/ccvd5Gl5.o
a.cc:(.text+0x261): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s093458009 | p00223 | C++ | #include <iostream>
#include <queue>
#include <map>
#define INF 100000000
#define MAX_X 1000
#define MAX_Y 1000
using namespace std;
typedef pair<pair<int,int>,pair<int,int> > P;
int d[MAX_Y][MAX_X][MAX_Y][MAX_X];
int tx,ty,kx,ky,ntx,nty,nkx,nky;
int ans;
short maze[MAX_Y][MAX_X];
int Y,X;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
bool bfs(){
queue<P> que;
map<P,int> mat;
que.push(make_pair(make_pair(ty,tx),make_pair(ky,kx)));
mat[que.front()]=0;
while (que.size()) {
P p=que.front();
que.pop();
if (p.first.first==p.second.first&&p.first.second==p.second.second) {
ans=d[p.first.first][p.first.second][p.second.first][p.second.second];
return true;
}
if (d[p.first.first][p.first.second][p.second.first][p.second.second]>=100) {
return false;
}
if (mat[que.front()]) {
continue;
}
for (int i=0; i<4; i++) {
ntx=p.first.second+dx[i],nty=p.first.first+dy[i],nkx=p.second.second+dx[i]*(-1),nky=p.second.first+dy[i]*(-1);
int flag=2;
if (!(0<=ntx&&ntx<X&&0<=nty&&nty<Y&&maze[nty][ntx]!=1)){
flag-=1;
ntx=p.first.second;
nty=p.first.first;
}
if (!(0<=nkx&&nkx<X&&0<=nky&&nky<Y&&maze[nky][nkx]!=1)) {
flag-=1;
nkx=p.second.second;
nky=p.second.first;
}
if (flag!=0) {
que.push(P(make_pair(nty,ntx),make_pair(nky,nkx)));
d[nty][ntx][nky][nkx]=d[p.first.first][p.first.second][p.second.first][p.second.second]+1;
}
mat[que.front()] = d[nty][ntx][nky][nkx];
}
}
return false;
}
int main(){
while (cin>>X>>Y&&X&&Y) {
cin>>tx>>ty>>kx>>ky;
tx-=1;
ty-=1;
kx-=1;
ky-=1;
for (int i=0; i<Y; i++) {
for (int j=0; j<X; j++) {
cin>>maze[i][j];
}
}
if(bfs()){
cout << ans <<endl;
}
else {
cout << "NA" << endl;
}
}
} | /tmp/ccsKjFln.o: in function `bfs()':
a.cc:(.text+0x2d): relocation truncated to fit: R_X86_64_PC32 against symbol `kx' defined in .bss section in /tmp/ccsKjFln.o
a.cc:(.text+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `ky' defined in .bss section in /tmp/ccsKjFln.o
a.cc:(.text+0x4a): relocation truncated to fit: R_X86_64_PC32 against symbol `tx' defined in .bss section in /tmp/ccsKjFln.o
a.cc:(.text+0x54): relocation truncated to fit: R_X86_64_PC32 against symbol `ty' defined in .bss section in /tmp/ccsKjFln.o
a.cc:(.text+0x16c): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccsKjFln.o
a.cc:(.text+0x23d): relocation truncated to fit: R_X86_64_PC32 against symbol `ntx' defined in .bss section in /tmp/ccsKjFln.o
a.cc:(.text+0x262): relocation truncated to fit: R_X86_64_PC32 against symbol `nty' defined in .bss section in /tmp/ccsKjFln.o
a.cc:(.text+0x287): relocation truncated to fit: R_X86_64_PC32 against symbol `nkx' defined in .bss section in /tmp/ccsKjFln.o
a.cc:(.text+0x2ac): relocation truncated to fit: R_X86_64_PC32 against symbol `nky' defined in .bss section in /tmp/ccsKjFln.o
a.cc:(.text+0x2b9): relocation truncated to fit: R_X86_64_PC32 against symbol `ntx' defined in .bss section in /tmp/ccsKjFln.o
a.cc:(.text+0x2c3): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s666717151 | p00223 | C++ | #include <iostream>
#include <queue>
#include <map>
#define MAX_X 1000
#define MAX_Y 1000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int d[MAX_Y][MAX_X][MAX_Y][MAX_X];
int tx,ty,kx,ky,ntx,nty,nkx,nky;
int ans;
short maze[MAX_Y][MAX_X];
int Y,X;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
bool bfs(){
queue<PP> que;
map<PP,int> mat;
que.push(make_pair(make_pair(ty,tx),make_pair(ky,kx)));
mat[que.front()]=0;
while (que.size()) {
PP p=que.front();
que.pop();
if (p.first.first==p.second.first&&p.first.second==p.second.second) {
ans=d[p.first.first][p.first.second][p.second.first][p.second.second];
return true;
}
if (d[p.first.first][p.first.second][p.second.first][p.second.second]>=100) {
return false;
}
if (mat[que.front()]) {
continue;
}
for (int i=0; i<4; i++) {
ntx=p.first.second+dx[i],nty=p.first.first+dy[i],nkx=p.second.second+dx[i]*(-1),nky=p.second.first+dy[i]*(-1);
int flag=2;
if (!(0<=ntx&&ntx<X&&0<=nty&&nty<Y&&maze[nty][ntx]!=1)){
flag-=1;
ntx=p.first.second;
nty=p.first.first;
}
if (!(0<=nkx&&nkx<X&&0<=nky&&nky<Y&&maze[nky][nkx]!=1)) {
flag-=1;
nkx=p.second.second;
nky=p.second.first;
}
if (flag!=0) {
que.push(make_pair(make_pair(nty,ntx),make_pair(nky,nkx)));
d[nty][ntx][nky][nkx]=d[p.first.first][p.first.second][p.second.first][p.second.second]+1;
}
mat[que.front()] = d[nty][ntx][nky][nkx];
}
}
return false;
}
int main(){
while (cin>>X>>Y&&X&&Y) {
cin>>tx>>ty>>kx>>ky;
tx-=1;
ty-=1;
kx-=1;
ky-=1;
for (int i=0; i<Y; i++) {
for (int j=0; j<X; j++) {
cin>>maze[i][j];
}
}
if(bfs()){
cout << ans <<endl;
}
else {
cout << "NA" << endl;
}
}
} | /tmp/cc0G4e3U.o: in function `bfs()':
a.cc:(.text+0x2d): relocation truncated to fit: R_X86_64_PC32 against symbol `kx' defined in .bss section in /tmp/cc0G4e3U.o
a.cc:(.text+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `ky' defined in .bss section in /tmp/cc0G4e3U.o
a.cc:(.text+0x4a): relocation truncated to fit: R_X86_64_PC32 against symbol `tx' defined in .bss section in /tmp/cc0G4e3U.o
a.cc:(.text+0x54): relocation truncated to fit: R_X86_64_PC32 against symbol `ty' defined in .bss section in /tmp/cc0G4e3U.o
a.cc:(.text+0x16c): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc0G4e3U.o
a.cc:(.text+0x23d): relocation truncated to fit: R_X86_64_PC32 against symbol `ntx' defined in .bss section in /tmp/cc0G4e3U.o
a.cc:(.text+0x262): relocation truncated to fit: R_X86_64_PC32 against symbol `nty' defined in .bss section in /tmp/cc0G4e3U.o
a.cc:(.text+0x287): relocation truncated to fit: R_X86_64_PC32 against symbol `nkx' defined in .bss section in /tmp/cc0G4e3U.o
a.cc:(.text+0x2ac): relocation truncated to fit: R_X86_64_PC32 against symbol `nky' defined in .bss section in /tmp/cc0G4e3U.o
a.cc:(.text+0x2b9): relocation truncated to fit: R_X86_64_PC32 against symbol `ntx' defined in .bss section in /tmp/cc0G4e3U.o
a.cc:(.text+0x2c3): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s411827051 | p00223 | C++ | #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF (1 << 30)
int xs[] = {0, 1, 0, -1}, ys[] = {1, 0, -1, 0};
int x, y;
int field[50][50];
char dp[50][50][50][50];
int solve(int tx, int ty, int kx, int ky){
int ntx, nty, nkx, nky;
if(dp[tx][ty][kx][ky] != -1){
return dp[tx][ty][kx][ky];
}
dp[tx][ty][kx][ky] = INF;
for(int i = 0;i < 4;i++){
ntx = tx + xs[i];
nty = ty + ys[i];
nkx = kx - xs[i];
nky = ky - ys[i];
if(ntx < 0 || ntx >= x || nty < 0 || nty >= y || field[ntx][nty] == 1){
ntx = tx;
nty = ty;
}
if(nkx < 0 || nkx >= x || nky < 0 || nky >= y || field[nkx][nky] == 1){
nkx = kx;
nky = ky;
}
dp[tx][ty][kx][ky] = min(dp[tx][ty][kx][ky], solve(ntx, nty, nkx, nky) + 1);
}
return dp[tx][ty][kx][ky];
}
int main(){
int tx, ty, kx, ky;
while(true){
scanf("%d%d", &x, &y);
memset(dp, -1, sizeof(dp));
if(x == 0 && y == 0) return 0;
scanf("%d%d", &tx, &ty);
scanf("%d%d", &kx, &ky);
for(int i = 0;i < y;i++){
for(int j = 0;j < x;j++){
scanf("%d", &field[x][y]);
dp[i][j][i][j] = 0;
}
}
int ans = solve(tx - 1, ty - 1, kx - 1, ky - 1);
if(ans > 100)
puts("NA");
else
printf("%d\n", ans);
}
} | a.cc: In function 'int solve(int, int, int, int)':
a.cc:5:16: warning: overflow in conversion from 'int' to 'char' changes value from '1073741824' to '0' [-Woverflow]
5 | #define INF (1 << 30)
| ~~~^~~~~~
a.cc:17:24: note: in expansion of macro 'INF'
17 | dp[tx][ty][kx][ky] = INF;
| ^~~
a.cc:31:29: error: no matching function for call to 'min(char&, int)'
31 | dp[tx][ty][kx][ky] = min(dp[tx][ty][kx][ky], solve(ntx, nty, nkx, nky) + 1);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:31:29: note: deduced conflicting types for parameter 'const _Tp' ('char' and 'int')
31 | dp[tx][ty][kx][ky] = min(dp[tx][ty][kx][ky], solve(ntx, nty, nkx, nky) + 1);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:31:29: note: mismatched types 'std::initializer_list<_Tp>' and 'char'
31 | dp[tx][ty][kx][ky] = min(dp[tx][ty][kx][ky], solve(ntx, nty, nkx, nky) + 1);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s929570644 | p00223 | C++ | #include <cstdio>
#include <queue>
#include <map>
#include <algorithm>
#define Z(n)get<n>(z)
#define M make_pair
#define F first
#define S second
using namespace std;
typedef pair<int,int> pii;
typedef tuple<pii,pii,int> T;
int t[51][51],dx[]={-1,0,1,0},dy[]={0,-1,0,1},a,b,x,y,X,Y,i,j,k;
int main(){
for(;scanf("%d%d",&a,&b),a;){
map<pair<pii,pii>,int>m;
scanf("%d%d%d%d",&x,&y,&X,&Y);x--,y--,X--,Y--;
for(j=0;j<b;j++)for(i=0;i<a;i++)scanf("%d",t[i]+j);
queue<T>q;
m[M(M(x,y),M(X,Y))]=1;
for(q.push(make_tuple(M(x,y),M(X,Y),0));!q.empty();){
T z=q.front();q.pop();
if(Z(0)==Z(1)){printf("%d\n",get<2>(z));goto OK;}
if(Z(2)<100)for(i=0;i<4;i++){
pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
if(!(0<=c1.F&&c1.F<a&&0<=c1.S&&c1.S<b&&!t[c1.F][c1.S]))c1=Z(0),k|=1;
pii c2=make_pair(Z(1).F+dx[(i+2)%4],Z(1).S+dy[(i+2)%4]);
if(!(0<=c2.F&&c2.F<a&&0<=c2.S&&c2.S<b&&!t[c2.F][c2.S]))c2=Z(1),k|=2;
if(k<3&&!m[M(c1,c2)]){
q.push(make_tuple(c1,c2,Z(2)+1));
m[M(c1,c2)]=1;
}
}
}
puts("NA");
OK:;
}
} | a.cc: In function 'int main()':
a.cc:5:19: error: no matching function for call to 'get<(k = 0)>(T&)'
5 | #define Z(n)get<n>(z)
| ~~~~~~^~~
a.cc:24:50: note: in expansion of macro 'Z'
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/deque:62,
from /usr/include/c++/14/queue:62,
from a.cc:2:
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
1250 | get(pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)'
1255 | get(pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)'
1260 | get(const pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)'
1265 | get(const pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/deque:81:
/usr/include/c++/14/tuple:2445:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)'
2445 | get(tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2445:5: note: template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
/usr/include/c++/14/tuple:2451:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)'
2451 | get(const tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2451:5: note: template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
/usr/include/c++/14/tuple:2457:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)'
2457 | get(tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2457:5: note: template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
/usr/include/c++/14/tuple:2466:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&)'
2466 | get(const tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2466:5: note: template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
/usr/include/c++/14/bits/stl_pair.h:138:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(array<_Tp, _Nm>&)'
138 | get(array<_Tp, _Nm>&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:138:5: note: template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
24 | pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
| ~^~
a.cc:5:17: note: in definition of macro 'Z'
5 | #define Z(n)get<n>(z)
| ^
/usr/include/c++/14/bits/stl_pair.h:142:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& s |
s458448621 | p00223 | C++ | #include <cstdio>
#include <utility>
#include <queue>
using namespace std;
typedef pair<int,int> __P;
typedef pair<__P,__P> _P;
typedef pair<_P,int> P;
#define C(A,B) (0<=(A)&&(A)<(B))
int main() {
queue<P> que;
int X,Y;
int tx,ty;
int kx,ky;
int count;
int d[50][50];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
while(true) {
scanf("%d %d",&X,&Y);
if(X==0&&Y==0) break;
scanf("%d %d",&tx,&ty);
scanf("%d %d",&kx,&ky);
tx--;ty--;kx--;ky--;
for(int i=0;i<Y;i++) {
for(int j=0;j<X;j++) {
scanf("%d",&d[j][i]);
}
}
que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
count=-1;
while(que.size()) {
P& p=que.front();
tx=p.first.first.first;
ty=p.first.first.second;
kx=p.first.second.first;
ky=p.first.second.second;
if(p.second>=100) {
break;
}
if(tx==kx&&ty==ky) {
count=p.second;
break;
}
bool b=false;
for(int i=0;i<4;i++) {
int ntx=tx,nty=ty,nkx=kx,nky=ky;
if(C(ntx+dx[i],X)&&C(nty+dy[i],Y)&&!d[ntx+dx[i]][ty+dy[i]]) {
ntx+=dx[i],nty+=dy[i];
b=true;
}
if(C(nkx-dx[i],X)&&C(nky-dy[i],Y)&&!d[kx-dx[i]][ky-dy[i]]) {
nkx-=dx[i],nky-=dy[i];
b=true;
}
que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
}
if(!b) break;
que.pop();
}
if(count!=-1) {
printf("%d\n",count);
}else {
printf("NA\n");
}
}
} | a.cc:31:40: error: macro "__P" passed 2 arguments, but takes just 1
31 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cstdio:41,
from a.cc:1:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc:31:51: error: macro "__P" passed 2 arguments, but takes just 1
31 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc:57:58: error: macro "__P" passed 2 arguments, but takes just 1
57 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc:57:71: error: macro "__P" passed 2 arguments, but takes just 1
57 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc: In function 'int main()':
a.cc:31:27: error: expected primary-expression before '(' token
31 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:31:30: error: expected primary-expression before '(' token
31 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:31:41: error: expected primary-expression before ',' token
31 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:31:52: error: expected primary-expression before ')' token
31 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:57:43: error: expected primary-expression before '(' token
57 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
a.cc:57:46: error: expected primary-expression before '(' token
57 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
a.cc:57:59: error: expected primary-expression before ',' token
57 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
a.cc:57:72: error: expected primary-expression before ')' token
57 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
|
s154499820 | p00223 | C++ | #include <cstdio>
#include <utility>
#include <queue>
#include <map>
using namespace std;
typedef pair<int,int> __P;
typedef pair<__P,__P> _P;
typedef pair<_P,int> P;
#define C(A,B) (0<=(A)&&(A)<(B))
int main() {
queue<P> que;
map<P,bool> mp;
int X,Y;
int tx,ty;
int kx,ky;
int count;
int d[50][50];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
while(true) {
scanf("%d %d",&X,&Y);
if(X==0&&Y==0) break;
scanf("%d %d",&tx,&ty);
scanf("%d %d",&kx,&ky);
tx--;ty--;kx--;ky--;
for(int i=0;i<Y;i++) {
for(int j=0;j<X;j++) {
scanf("%d",&d[j][i]);
}
}
que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
count=-1;
while(que.size()) {
P& p=que.front();
tx=p.first.first.first;
ty=p.first.first.second;
kx=p.first.second.first;
ky=p.first.second.second;
if(p.second>=100) {
break;
}
if(mp[p]==true) {
break;
}
if(tx==kx&&ty==ky) {
count=p.second;
break;
}
mp[p]=true;
for(int i=0;i<4;i++) {
int ntx=tx,nty=ty,nkx=kx,nky=ky;
if(C(ntx+dx[i],X)&&C(nty+dy[i],Y)&&!d[ntx+dx[i]][nty+dy[i]]) {
ntx+=dx[i],nty+=dy[i];
}
if(C(nkx-dx[i],X)&&C(nky-dy[i],Y)&&!d[nkx-dx[i]][nky-dy[i]]) {
nkx-=dx[i],nky-=dy[i];
}
que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
}
que.pop();
}
if(count!=-1) {
printf("%d\n",count);
}else {
printf("NA\n");
}
}
} | a.cc:33:40: error: macro "__P" passed 2 arguments, but takes just 1
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cstdio:41,
from a.cc:1:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc:33:51: error: macro "__P" passed 2 arguments, but takes just 1
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc:60:58: error: macro "__P" passed 2 arguments, but takes just 1
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc:60:71: error: macro "__P" passed 2 arguments, but takes just 1
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc: In function 'int main()':
a.cc:33:27: error: expected primary-expression before '(' token
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:33:30: error: expected primary-expression before '(' token
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:33:41: error: expected primary-expression before ',' token
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:33:52: error: expected primary-expression before ')' token
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:60:43: error: expected primary-expression before '(' token
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
a.cc:60:46: error: expected primary-expression before '(' token
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
a.cc:60:59: error: expected primary-expression before ',' token
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
a.cc:60:72: error: expected primary-expression before ')' token
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
|
s467130665 | p00223 | C++ | #include <cstdio>
#include <utility>
#include <queue>
#include <map>
using namespace std;
typedef pair<int,int> __P;
typedef pair<__P,__P> _P;
typedef pair<_P,int> P;
#define C(A,B) (0<=(A)&&(A)<(B))
int main() {
queue<P> que;
map<P,bool> mp;
int X,Y;
int tx,ty;
int kx,ky;
int count;
int d[50][50];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
while(true) {
scanf("%d %d",&X,&Y);
if(X==0&&Y==0) break;
scanf("%d %d",&tx,&ty);
scanf("%d %d",&kx,&ky);
tx--;ty--;kx--;ky--;
for(int i=0;i<Y;i++) {
for(int j=0;j<X;j++) {
scanf("%d",&d[j][i]);
}
}
que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
count=-1;
while(que.size()) {
P& p=que.front();
tx=p.first.first.first;
ty=p.first.first.second;
kx=p.first.second.first;
ky=p.first.second.second;
if(p.second>=100) {
break;
}
if(mp[p]==true) {
break;
}
if(tx==kx&&ty==ky) {
count=p.second;
break;
}
mp[p]=true;
for(int i=0;i<4;i++) {
int ntx=tx,nty=ty,nkx=kx,nky=ky;
if(C(ntx+dx[i],X)&&C(nty+dy[i],Y)&&!d[ntx+dx[i]][nty+dy[i]]) {
ntx+=dx[i],nty+=dy[i];
}
if(C(nkx-dx[i],X)&&C(nky-dy[i],Y)&&!d[nkx-dx[i]][nky-dy[i]]) {
nkx-=dx[i],nky-=dy[i];
}
que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
}
que.pop();
}
if(count!=-1) {
printf("%d\n",count);
}else {
printf("NA\n");
}
}
return 0;
} | a.cc:33:40: error: macro "__P" passed 2 arguments, but takes just 1
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cstdio:41,
from a.cc:1:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc:33:51: error: macro "__P" passed 2 arguments, but takes just 1
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc:60:58: error: macro "__P" passed 2 arguments, but takes just 1
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc:60:71: error: macro "__P" passed 2 arguments, but takes just 1
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc: In function 'int main()':
a.cc:33:27: error: expected primary-expression before '(' token
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:33:30: error: expected primary-expression before '(' token
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:33:41: error: expected primary-expression before ',' token
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:33:52: error: expected primary-expression before ')' token
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:60:43: error: expected primary-expression before '(' token
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
a.cc:60:46: error: expected primary-expression before '(' token
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
a.cc:60:59: error: expected primary-expression before ',' token
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
a.cc:60:72: error: expected primary-expression before ')' token
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
|
s148524232 | p00223 | C++ | #include <iostream>
#include <utility>
#include <queue>
#include <map>
using namespace std;
typedef pair<int,int> __P;
typedef pair<__P,__P> _P;
typedef pair<_P,int> P;
#define C(A,B) (0<=(A)&&(A)<(B))
int main() {
queue<P> que;
map<P,bool> mp;
int X,Y;
int tx,ty;
int kx,ky;
int count;
int d[50][50];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
while(true) {
cin>>X>>Y;
if(X==0&&Y==0) break;
cin>>tx>>ty;
cin>>kx>>ky;
tx--;ty--;kx--;ky--;
for(int i=0;i<Y;i++) {
for(int j=0;j<X;j++) {
cin>>d[i][j];
}
}
que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
count=-1;
while(que.size()) {
P& p=que.front();
tx=p.first.first.first;
ty=p.first.first.second;
kx=p.first.second.first;
ky=p.first.second.second;
if(p.second>=100) {
break;
}
if(mp[p]==true) {
break;
}
if(tx==kx&&ty==ky) {
count=p.second;
break;
}
mp[p]=true;
for(int i=0;i<4;i++) {
int ntx=tx,nty=ty,nkx=kx,nky=ky;
if(C(ntx+dx[i],X)&&C(nty+dy[i],Y)&&!d[ntx+dx[i]][nty+dy[i]]) {
ntx+=dx[i],nty+=dy[i];
}
if(C(nkx-dx[i],X)&&C(nky-dy[i],Y)&&!d[nkx-dx[i]][nky-dy[i]]) {
nkx-=dx[i],nky-=dy[i];
}
que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
}
que.pop();
}
if(count!=-1) {
cout<<count<<endl;
}else {
cout<<"NA"<<endl;
}
}
return 0;
} | a.cc:33:40: error: macro "__P" passed 2 arguments, but takes just 1
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/bits/requires_hosted.h:31,
from /usr/include/c++/14/iostream:38,
from a.cc:1:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc:33:51: error: macro "__P" passed 2 arguments, but takes just 1
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc:60:58: error: macro "__P" passed 2 arguments, but takes just 1
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc:60:71: error: macro "__P" passed 2 arguments, but takes just 1
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
/usr/include/x86_64-linux-gnu/sys/cdefs.h:125:9: note: macro "__P" defined here
125 | #define __P(args) args
| ^~~
a.cc: In function 'int main()':
a.cc:33:27: error: expected primary-expression before '(' token
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:33:30: error: expected primary-expression before '(' token
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:33:41: error: expected primary-expression before ',' token
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:33:52: error: expected primary-expression before ')' token
33 | que.push(P(_P(__P(tx,ty),__P(kx,ky)),0));
| ^
a.cc:60:43: error: expected primary-expression before '(' token
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
a.cc:60:46: error: expected primary-expression before '(' token
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
a.cc:60:59: error: expected primary-expression before ',' token
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
a.cc:60:72: error: expected primary-expression before ')' token
60 | que.push(P(_P(__P(ntx,nty),__P(nkx,nky)),p.second+1));
| ^
|
s666840560 | p00223 | C++ | #include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
struct S {
int tx,ty;
int kx,ky;
int turn;
S::S(int tx,int ty,int kx,int ky,int turn);
};
S::S(int _tx,int _ty,int _kx,int _ky,int _turn) {
tx=_tx;
ty=_ty;
kx=_kx;
ky=_ky;
turn=_turn;
}
bool d[50][50];
bool vst[50][50][50][50];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int main() {
int X,Y;
int tx,ty;
int kx,ky;
while(scanf("%d %d",&X,&Y),X||Y) {
scanf("%d %d",&tx,&ty);
scanf("%d %d",&kx,&ky);
for(int j=0;j<Y;j++) {
for(int i=0;i<X;i++) {
scanf("%d",&d[i][j]);
}
}
tx--;ty--;kx--;ky--;
queue<S> q;
bool ok=false;
q.push(S(tx,ty,kx,ky,0));
memset(vst,false,sizeof(vst));
vst[tx][ty][kx][ky]=true;
while(!q.empty()) {
S s=q.front();q.pop();
if(s.turn>=100) break;
if(s.tx==s.kx&&s.ty==s.ky) {
printf("%d\n",s.turn);
ok=true;
break;
}
for(int i=0;i<4;i++) {
int ntx=s.tx+dx[i],nty=s.ty+dy[i];
int nkx=s.kx-dx[i],nky=s.ky-dy[i];
if(0>ntx||ntx>=X||0>nty||nty>=Y||d[ntx][nty]) {
ntx-=dx[i],nty-=dy[i];
}
if(0>nkx||nkx>=X||0>nky||nky>=Y||d[nkx][nky]) {
nkx+=dx[i],nky+=dy[i];
}
if(!vst[ntx][nty][nkx][nky]) {
vst[ntx][nty][nkx][nky]=true;
q.push(S(ntx,nty,nkx,nky,s.turn+1));
}
}
}
if(!ok) printf("NA\n");
}
return 0;
} | a.cc:10:9: error: extra qualification 'S::' on member 'S' [-fpermissive]
10 | S::S(int tx,int ty,int kx,int ky,int turn);
| ^
|
s626483546 | p00223 | C++ | #include<iostream>
#include<queue>
#include<map>
using namespace std;
struct node
{
int step;
int tx,ty;
int kx,ky;
node(int s,int ttx,int tty,int kkx,int kky):
step(s),tx(ttx),ty(tty),kx(kkx),ky(kky){}
};
int main()
{
int x,y;
for(;cin>>x>>y,x;)
{
bool data[52][52];
int tx,ty,kx,ky;
cin>>tx>>ty>>kx>>ky;
memset(data,false,sizeof(data));
for(int i=1;i<=x;i++)
for(int j=1;j<=y;j++)
{
char tmp;
cin>>tmp;
data[j][i]=(tmp=='0');
}
queue<node> qu;
qu.push(node(0,tx,ty,kx,ky));
map< pair<pair<int,int>,pair<int,int> > ,bool >hash;
int ans=-1;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
while(!qu.empty())
{
node tmp=qu.front();
qu.pop();
// cout<<tmp.step<<" "<<tmp.tx<<" "<<tmp.ty<<" "<<tmp.kx<<" "<<tmp.ky<<endl;
if(hash[make_pair(make_pair(tmp.tx,tmp.ty),make_pair(tmp.kx,tmp.ky))])
continue;
if(tmp.tx==tmp.kx &&tmp.ty==tmp.ky)
{
ans=tmp.step;
break;
}
if(tmp.step>=99)
continue;
hash[make_pair(make_pair(tmp.tx,tmp.ty),make_pair(tmp.kx,tmp.ky))]=true;
for(int i=0;i<4;i++)
{
int ttx=tmp.tx,tty=tmp.ty,tkx=tmp.kx,tky=tmp.ky;
if(data[ttx+dx[i]][tty+dy[i]])
{
ttx+=dx[i];
tty+=dy[i];
}
if(data[tkx-dx[i]][tky-dy[i]])
{
tkx-=dx[i];
tky-=dy[i];
}
//cout<<"make"<<ttx<<" "<<tkx<<" "<<tty<<" "<<tty<<endl;
if(!hash[make_pair(make_pair(ttx,tty),make_pair(tkx,tky))])
qu.push(node(tmp.step+1,ttx,tty,tkx,tky));
}
}
if(ans==-1)
cout<<"NA"<<endl;
else
cout<<ans<<endl;
}
} | a.cc: In function 'int main()':
a.cc:23:7: error: 'memset' was not declared in this scope
23 | memset(data,false,sizeof(data));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<map>
+++ |+#include <cstring>
4 | using namespace std;
|
s268480631 | p00224 | Java |
ツ鳴セツ禿コツ閉淞督?づ可帰ツづィツづ慊つキツ?卍(ツゝツε鳴・ツ)vツキツャテ凝?
ツづ?づ債づ?づ催可シ | Main.java:154: error: class, interface, enum, or record expected
??????????????????????????????????v???????
^
Main.java:154: error: illegal character: '\uff08'
??????????????????????????????????v???????
^
Main.java:154: error: illegal character: '\u30fb'
??????????????????????????????????v???????
^
Main.java:154: error: illegal character: '\uff09'
??????????????????????????????????v???????
^
4 errors
|
s755861761 | p00224 | C | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#define MIN(x,y) (((x)<(y))?(x):(y))
#define INFTY (1<<21)
int m, n, k, d, C[7], G[110][110], N, D[110][64];
int getID(char *str);
int isC(int x);
int bellman(void);
int main(void){
char source[16], target[16];
int cost,s,t;
int i,j;
while(scanf("%d%*c%d%*c%d%*c%d%*c",&m,&n,&k,&d) && m ){
N = 2 + n + m;
for(i=1;i<m+1;i++) scanf("%d%*c",&C[i]);
for(i=0;i<N;i++) for(j=0;j<N;j++) G[i][j] = INFTY;
for(i=0;i<d;i++){
scanf("%s%*c%s%*c%d%*c",source,target,&cost);
s = getID(source);
t = getID(target);
G[t][s] = G[s][t] = MIN(G[s][t], cost * k);
}
printf("%d\n",bellman());
}
return 0;
}
int getID(char *str){
char num[16];
if ( str[0] == 'H' ) return 0;
if ( str[0] == 'D' ) return N - 1;
strcpy(num,str+1);
if ( str[0] == 'C' ) return atoi(num);
return atoi(num) + m;
}
int isC(int x){
return (1 <= x) && (x <= m);
}
int bellman(void){
bool change;
int minv;
int i,i1,i2,i3,i4,j;
for(i=0;i<N;i++) for(j=0;j<(1<<m);j++) D[i][j] = INFTY;
D[0][0] = 0;
for(i1=0;i1<N*(1<<m);i1++){
change=false;
for(i2=0;i2<N;i2++){
for(i3=0;i3<N;i3++){
if ( i2 == i3 || G[i2][i3] == INFTY ) continue;
for(i4=0;i4<(1<<m);i4++){
if (isC(i3) && (b&(1<<(i3-1))) != 0 ) continue;
if ( isC(i3) ) {
if ( D[i2][i4] + G[i2][i3] - C[i3] < D[i3][i4|(1<<(i3-1))] ) {
D[i3][i4|(1<<(i3-1))] = D[i2][i4] + G[i2][i3] - C[i3];
change = true;
}
} else {
if ( D[i2][i4] + G[i2][i3] < D[i3][i4] ){
D[i3][i4] = D[i2][i4] + G[i2][i3];
change = true;
}
}
}
}
}
if ( !change ) break;
}
minv = INFTY;
for(i=0;i<(1<<m);i++) minv = MIN(minv, D[N-1][i]);
return minv;
} | main.c: In function 'bellman':
main.c:61:27: error: 'b' undeclared (first use in this function)
61 | if (isC(i3) && (b&(1<<(i3-1))) != 0 ) continue;
| ^
main.c:61:27: note: each undeclared identifier is reported only once for each function it appears in
|
s792734213 | p00224 | C | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);} | main.c:1:1: warning: data definition has no type or storage class
1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
| ^~
main.c:1:1: error: type defaults to 'int' in declaration of 'cn' [-Wimplicit-int]
main.c:1:4: error: type defaults to 'int' in declaration of 'cake' [-Wimplicit-int]
1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
| ^~~~
main.c:1:12: warning: data definition has no type or storage class
1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
| ^~
main.c:1:12: error: type defaults to 'int' in declaration of 'wn' [-Wimplicit-int]
main.c:1:15: error: type defaults to 'int' in declaration of 'wg' [-Wimplicit-int]
1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
| ^~
main.c:1:28: warning: data definition has no type or storage class
1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
| ^~
main.c:1:28: error: type defaults to 'int' in declaration of 'ln' [-Wimplicit-int]
main.c:1:31: error: type defaults to 'int' in declaration of 'lg' [-Wimplicit-int]
1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
| ^~
main.c:1:40: error: return type defaults to 'int' [-Wimplicit-int]
1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
| ^~~~~
main.c: In function 'getid':
main.c:1:64: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c,n,i,t;memset(cost,1,sizeof(cost));c=s;cost[c]=0;for(;c>=0;){d[c]=1;n=-1;for(i=0;i<wn;i++){if(!d[i]){if(c>=cn||c==s){t=cost[c]+wg[c][i];if(t<cost[i])cost[i]=t;}if(n<0||cost[i]<cost[n])n=i;}}c=n;}for(i=0;i<ln;i++){lg[s][i]=cost[i];}}solve(){int dp[1<<8][8],home=cn,dest=cn+1,b,i,j,nb,t,ans;memset(dp,1,sizeof(dp));dp[1<<home][home]=0;for(b=0;b<1<<ln;b++)for(i=0;i<ln;i++)if(b&1<<i)for(j=0;j<ln;j++)if(~b&1<<j){nb=b|1<<j;t=dp[b][i]+lg[i][j];if(t<dp[nb][j])dp[nb][j]=t;}ans=1e8;for(b=1<<home|1<<dest;b<1<<ln;b++){t=dp[b][dest];for(i=0;i<cn;i++)if(b&1<<i)t-=cake[i];if(t<ans)ans=t;}return ans;}main(){int k,d;int i;for(;scanf("%d%d%d%d",&cn,&wn,&k,&d),cn;){ln=cn+2;wn+=ln;for(i=0;i<cn;i++)scanf("%d",cake+i);memset(wg,1,sizeof(wg));for(;d--;){int a,b,c;a=getid(),b=getid();scanf("%d",&c);wg[a][b]=wg[b][a]=c*k;}for(i=0;i<ln;i++)dijkstra(i);printf("%d\n",solve());}exit(0);}
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | cn,cake[6];wn,wg[106][106];ln,lg[8][8];getid(){char s[9];int r;scanf("%s",s);if(*s=='C')r=atoi(s+1)-1;else if(*s=='H')r=cn;else if(*s=='D')r=cn+1;elser=cn+1+atoi(s+1);return r;}dijkstra(s){int cost[106],d[106]={0},c, |
s209201636 | p00224 | C++ | #include <iostream>
#include <map>
#include <vector>
#define MAX_INT 100000000
using namespace std;
map<string, map<string, int>> data;
map<string, int> cals;
// 再帰関数で使用
map<string, bool> pass;
map<string, int> mins;
int min_value = MAX_INT;
void recursive(string curr, int cal)
{
map<string, int>::iterator it = data[curr].begin();
while (it != data[curr].end())
{
string key = (*it).first;
int value = (*it).second;
if (pass[key] == true) {
++it; continue;
}
int after = data[curr][key] + cal;
if (key[0] != 'C' && after > mins[key]) {
++it; continue;
}
int temp = mins[key];
if (key[0] == 'C') {
after -= cals[key];
pass[key] = true;
}
mins[key] = after;
if (key == "D" && mins["D"] < min_value) {
min_value = mins["D"];
}
recursive(key, after);
if (key[0] == 'C') pass[key] = false;
mins[key] = temp;
++it;
}
}
int main(void)
{
for (;;) {
int m, n, k, d;
// 初期化
min_value = MAX_INT;
scanf("%d %d %d %d", &m, &n, &k, &d);
if (m == 0 && n == 0 && k == 0 && d == 0) {
break;
}
// 標準入力からデータを取得
data.clear();
cals.clear();
for (int i = 0; i < m; i++) {
int temp;
scanf("%d", &temp);
cals["C"+to_string(i+1)] = temp;
}
for (int i = 0; i < d; i++) {
string s, t;
int temp;
cin >> s >> t >> temp;
data[s][t] = temp * k;
data[t][s] = temp * k;
}
// 再帰関数を使うための準備
pass.clear();
mins.clear();
for (int i = 0; i < m; i++) {
pass["C"+to_string(i+1)] = false;
}
for (int i = 0; i < (n + 2); i++) {
switch (i) {
case 0: mins["H"] = MAX_INT; break;
case 1: mins["D"] = MAX_INT; break;
default: mins["L"+to_string(i-1)] = MAX_INT;
}
}
recursive("H", 0);
cout << min_value << endl;
}
return 0;
} | a.cc: In function 'void recursive(std::string, int)':
a.cc:20:37: error: reference to 'data' is ambiguous
20 | map<string, int>::iterator it = data[curr].begin();
| ^~~~
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: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:9:31: note: 'std::map<std::__cxx11::basic_string<char>, std::map<std::__cxx11::basic_string<char>, int> > data'
9 | map<string, map<string, int>> data;
| ^~~~
a.cc:22:18: error: reference to 'data' is ambiguous
22 | while (it != data[curr].end())
| ^~~~
/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:9:31: note: 'std::map<std::__cxx11::basic_string<char>, std::map<std::__cxx11::basic_string<char>, int> > data'
9 | map<string, map<string, int>> data;
| ^~~~
a.cc:31:21: error: reference to 'data' is ambiguous
31 | int after = data[curr][key] + cal;
| ^~~~
/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:9:31: note: 'std::map<std::__cxx11::basic_string<char>, std::map<std::__cxx11::basic_string<char>, int> > data'
9 | map<string, map<string, int>> data;
| ^~~~
a.cc: In function 'int main()':
a.cc:72:9: error: reference to 'data' is ambiguous
72 | data.clear();
| ^~~~
/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:9:31: note: 'std::map<std::__cxx11::basic_string<char>, std::map<std::__cxx11::basic_string<char>, int> > data'
9 | map<string, map<string, int>> data;
| ^~~~
a.cc:84:13: error: reference to 'data' is ambiguous
84 | data[s][t] = temp * k;
| ^~~~
/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:9:31: note: 'std::map<std::__cxx11::basic_string<char>, std::map<std::__cxx11::basic_string<char>, int> > data'
9 | map<string, map<string, int>> data;
| ^~~~
a.cc:85:13: error: reference to 'data' is ambiguous
85 | data[t][s] = temp * k;
| ^~~~
/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:9:31: note: 'std::map<std::__cxx11::basic_string<char>, std::map<std::__cxx11::basic_string<char>, int> > data'
9 | map<string, map<string, int>> data;
| ^~~~
|
s385660039 | p00224 | C++ | #include <iostream>
#include <map>
#include <vector>
#define MAX_INT 100000000
using namespace std;
map<string, map<string, int>> data;
map<string, int> cals;
// 再帰関数で使用
map<string, bool> pass;
map<string, int> mins;
int min_value = MAX_INT;
void recursive(string curr, int cal)
{
map<string, int>::iterator it = data[curr].begin();
while (it != data[curr].end())
{
string key = (*it).first;
int value = (*it).second;
if (pass[key] == true) {
++it; continue;
}
int after = data[curr][key] + cal;
if (key[0] != 'C' && after >= mins[key]) {
++it; continue;
}
int temp = mins[key];
if (key[0] == 'C') {
after -= cals[key];
pass[key] = true;
}
mins[key] = after;
if (key == "D" && mins["D"] < min_value) {
min_value = mins["D"];
}
recursive(key, after);
if (key[0] == 'C') pass[key] = false;
mins[key] = temp;
++it;
}
}
int main(void)
{
for (;;) {
int m, n, k, d;
// 初期化
min_value = MAX_INT;
scanf("%d %d %d %d", &m, &n, &k, &d);
if (m == 0 && n == 0 && k == 0 && d == 0) {
break;
}
// 標準入力からデータを取得
data.clear();
cals.clear();
for (int i = 0; i < m; i++) {
int temp;
scanf("%d", &temp);
cals["C"+to_string(i+1)] = temp;
}
for (int i = 0; i < d; i++) {
string s, t;
int temp;
cin >> s >> t >> temp;
data[s][t] = temp * k;
data[t][s] = temp * k;
}
// 再帰関数を使うための準備
pass.clear();
mins.clear();
for (int i = 0; i < m; i++) {
pass["C"+to_string(i+1)] = false;
}
for (int i = 0; i < (n + 2); i++) {
switch (i) {
case 0: mins["H"] = MAX_INT; break;
case 1: mins["D"] = MAX_INT; break;
default: mins["L"+to_string(i-1)] = MAX_INT;
}
}
recursive("H", 0);
cout << min_value << endl;
}
return 0;
} | a.cc: In function 'void recursive(std::string, int)':
a.cc:20:37: error: reference to 'data' is ambiguous
20 | map<string, int>::iterator it = data[curr].begin();
| ^~~~
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: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:9:31: note: 'std::map<std::__cxx11::basic_string<char>, std::map<std::__cxx11::basic_string<char>, int> > data'
9 | map<string, map<string, int>> data;
| ^~~~
a.cc:22:18: error: reference to 'data' is ambiguous
22 | while (it != data[curr].end())
| ^~~~
/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:9:31: note: 'std::map<std::__cxx11::basic_string<char>, std::map<std::__cxx11::basic_string<char>, int> > data'
9 | map<string, map<string, int>> data;
| ^~~~
a.cc:31:21: error: reference to 'data' is ambiguous
31 | int after = data[curr][key] + cal;
| ^~~~
/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:9:31: note: 'std::map<std::__cxx11::basic_string<char>, std::map<std::__cxx11::basic_string<char>, int> > data'
9 | map<string, map<string, int>> data;
| ^~~~
a.cc: In function 'int main()':
a.cc:72:9: error: reference to 'data' is ambiguous
72 | data.clear();
| ^~~~
/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:9:31: note: 'std::map<std::__cxx11::basic_string<char>, std::map<std::__cxx11::basic_string<char>, int> > data'
9 | map<string, map<string, int>> data;
| ^~~~
a.cc:84:13: error: reference to 'data' is ambiguous
84 | data[s][t] = temp * k;
| ^~~~
/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:9:31: note: 'std::map<std::__cxx11::basic_string<char>, std::map<std::__cxx11::basic_string<char>, int> > data'
9 | map<string, map<string, int>> data;
| ^~~~
a.cc:85:13: error: reference to 'data' is ambiguous
85 | data[t][s] = temp * k;
| ^~~~
/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:9:31: note: 'std::map<std::__cxx11::basic_string<char>, std::map<std::__cxx11::basic_string<char>, int> > data'
9 | map<string, map<string, int>> data;
| ^~~~
|
s807519177 | p00224 | C++ | #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
while (1) {
int M, N, D; long long int K; cin >> M >> N >> K >> D;
if (!M)break;
vector<int>cs(M);
for (int i = 0; i < M; ++i) {
cin >> cs[i];
}
const int land = 0;
const int start = land+N;
const int goal = start + 1;
const int cake = goal + 1;
vector<vector<int>>diss(cake+M, vector<int>(cake+M, 1e6));
for (int i = 0; i < diss.size(); ++i) {
diss[i][i] = 0;
}
for (int i = 0; i < D; ++i) {
string f[2]; cin >> f[0] >> f[1];
int from[2];
for (int j = 0; j < 2; ++j) {
if (f[j] == "H")from[j] = start;
if (f[j] == "D")from[j] = goal;
if (f[j][0] == 'C')from[j] = cake + f[j][1] - '1';
if (f[j][0] == 'L')from[j] = land + f[j][1] - '1';
}
int d; cin >> d;
diss[from[0]][from[1]] = d;
diss[from[1]][from[0]] = d;
}
for (int k = 0; k <= goal; ++k) {
for (int i = 0; i <= goal; ++i) {
for (int j = 0; j <= goal; ++j) {
diss[i][j] = min(diss[i][j], diss[i][k] + diss[k][j]);
}
}
}
for (int i = 0; i < 2 + M; ++i) {
for (int j = 0; j < 2 + M; ++j) {
for (int k = 0; k <= goal; ++k) {
diss[start+i][start + j] = min(diss[start + i][start + j], diss[start + i][k] + diss[k][start + j]);
}
}
}
vector<int>perms(M + 1);
iota(perms.begin(), perms.end(), 1);
int ans = 1e9;
do {
long long int dis = 0;
int nowid = 0;
int next = 0;
while (perms[next] != 1) {
dis += K*diss[start + nowid][start + perms[next]];
dis -= cs[perms[next] - 2];
nowid = perms[next];
next++;
}
dis += K*diss[start + nowid][start + perms[next]];
ans = min(ans, dis);
} while (next_permutation(perms.begin(), perms.end()));
cout << ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:69:34: error: no matching function for call to 'min(int&, long long int&)'
69 | ans = min(ans, dis);
| ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:69:34: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
69 | ans = min(ans, dis);
| ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:69:34: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
69 | ans = min(ans, dis);
| ~~~^~~~~~~~~~
|
s151575266 | p00224 | C++ | #include<bits/stdc++.h>
using namespace std;
#define INF (1<<30)
typedef pair< int , int > P;
typedef pair< int , P > Pi;
int m,n,k,d;
vector<int> cal;
struct Edge {
int to,cost;
Edge(){}
Edge(int to,int cost):to(to),cost(cost){};
};
vector< Edge > Graph[110];
int min_cost[110][1<<6];
int Bellman_Ford(){
int ret = INF;
fill_n(*min_cost,110*(1<<6),INF);
min_cost[0][(1<<m)-1] = true;
queue<Pi> que;
que.push(Pi(0,P(0,(1<<m)-1)));
while(!que.empty()){
Pi p = que.front();
que.pop();
//int cost = p.first;
//int now = p.second.first;
//int bit = p.second.second;
if(p.second.first == 1) ret = min(ret,p.first);
if(min_cost[p.second.first][p.second.second] < p.first) continue;
for(int i=0;i<Graph[p.second.first].size();i++){
Edge e = Graph[p.second.first][i];
int nc = p.first + e.cost*k;
int bit = p.second.second;
if(e.to >= 2 && e.to < 2 + m){
if((bit >> (e.to-2)) & 1){
nc -= cal[e.to-2];
bit &= ~(1 << (e.to-2));
} else continue;
}
if(cost < min_cost[e.to][bit]){
que.push(Pi(nc,P(e.to,bit)));
min_cost[e.to][bit] = nc;
}
}
}
return ret;
}
int judge(string s){
if(s == "H") return 0;
else if(s == "D") return 1;
else if(s[0] == 'C') return atoi(s.substr(1).c_str())+1;
else if(s[0] == 'L') return atoi(s.substr(1).c_str())+m+1;
}
int main(){
while(cin >> m >> n >> k >> d , m){
cal.resize(m);
for(int i=0;i<m;i++) cin >> cal[i];
for(int i=0;i<d;i++){
string s1,s2; int dis;
cin >> s1 >> s2 >> dis;
Graph[judge(s1)].push_back(Edge(judge(s2),dis));
Graph[judge(s2)].push_back(Edge(judge(s1),dis));
}
cout << Bellman_Ford() << endl;
for(int i=0;i<110;i++) Graph[i].clear();
}
} | a.cc: In function 'int Bellman_Ford()':
a.cc:39:10: error: 'cost' was not declared in this scope; did you mean 'cosl'?
39 | if(cost < min_cost[e.to][bit]){
| ^~~~
| cosl
a.cc: In function 'int judge(std::string)':
a.cc:53:1: warning: control reaches end of non-void function [-Wreturn-type]
53 | }
| ^
|
s264672681 | p00224 | C++ | #include <stdio.h>
#include <stdlib.h>
#define INF (10000000)
#define REP(i, n) for (int i = 0; i < (n); i++)
int route[110][110];
int quick[110];
int cake_cal[6];
int k;
void set_route(char start[], char end[], int dist)
{
int s, e;
if (start[0] == 'H'){
s = 0;
}
else if (start[0] == 'D'){
s = 109;
}
else if (start[0] == 'L'){
s = 0;
}
else if (start[0] == 'C'){
s = 100;
}
s += atoi(start + 1);
if (end[0] == 'H'){
e = 0;
}
else if (end[0] == 'D'){
e = 109;
}
else if (end[0] == 'L'){
e = 0;
}
else if (end[0] == 'C'){
e = 100;
}
e += atoi(end + 1);
route[s][e] = route[e][s] = dist;
}
int track_back(int pos, int cost, int cake_cap)
{
int ans = INF;
if (pos == 109){
return (cost);
}
quick[pos] = min(quick[pos], cost);
for (int i = 0; i < 110; i++){
if (route[pos][i] != INF && cost + (route[pos][i] * k) + cake_cap < quick[i]){
if (i >= 101 && i < 109){
int temp = cake_cal[(i % 100) - 1];
cake_cal[(i % 100) - 1] = 0;
ans = min(ans, track_back(i, cost + (route[pos][i] * k) + temp, cake_cap - temp));
cake_cal[(i % 100) - 1] = temp;
}
else {
ans = min(ans, track_back(i, cost + (route[pos][i] * k), cake_cap));
}
}
}
return (ans);
}
int main(void)
{
int n, m, d;
int cake_cap;
int ans;
for (int i = 0; i < 110; i++){
for (int j = 0; j < 110; j++){
route[i][j] = INF;
}
quick[i] = INF;
}
scanf("%d%d%d%d", &m, &n, &k, &d);
cake_cap = 0;
for (int i = 0; i < m; i++){
scanf("%d", &cake_cal[i]);
cake_cal[i] = -cake_cal[i];
cake_cap += cake_cal[i];
}
for (int i = 0; i < d; i++){
char s1[10];
char s2[10];
int dist;
scanf("%s%s%d", s1, s2, &dist);
set_route(s1, s2, dist);
}
ans = track_back(0, 0, cake_cap);
printf("%d\n", ans);
return (0);
} | a.cc: In function 'int track_back(int, int, int)':
a.cc:55:22: error: 'min' was not declared in this scope
55 | quick[pos] = min(quick[pos], cost);
| ^~~
|
s329305320 | p00224 | C++ | #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;
class Edge
{
public:
int to, cost;
Edge(){};
Edge(int to0, int cost0){to = to0; cost = cost0;}
};
void shortestPath(const vector<vector<Edge> >& edges, int start, vector<int>& dist)
{
dist.assign(edges.size(), INT_MAX);
dist[start] = 0;
priority_queue<pair<int,int> ,vector<pair<int,int> >, greater<pair<int,int> > > q;
q.push(make_pair(0, start));
while(!q.empty()){
pair<int, int> p = q.top();
q.pop();
int v = p.second;
if(dist[v] < p.first)
continue;
for(unsigned i=0; i<edges[v].size(); ++i){
Edge e = edges[v][i];
if(dist[v] + e.cost < dist[e.to]){
dist[e.to] = dist[v] + e.cost;
q.push(make_pair(dist[e.to], e.to));
}
}
}
}
int main()
{
for(;;){
int m, n, k, d;
cin >> m >> n >> k >> d;
if(m == 0)
return 0;
vector<int> cake(m);
for(int i=0; i<m; ++i)
cin >> cake[i];
vector<vector<Edge> > edges((m+n+2)*(1<<m), 0);
while(--d >= 0){
vector<string> s(2);
int cost;
cin >> s[0] >> s[1] >> cost;
cost *= k;
vector<int> a(2);
for(int i=0; i<2; ++i){
if(s[i][0] == 'H')
a[i] = 0;
else if(s[i][0] == 'C')
a[i] = s[i][1] - '0';
else if(s[i][0] == 'L')
a[i] = atoi(s[i].substr(1).c_str()) + m;
else
a[i] = m+n+1;
}
for(int k=0; k<2; ++k){
for(int i=0; i<(1<<m); ++i){
if(1 <= a[1] && a[1] <= m && (i & (1<<(a[1]-1))))
continue;
if(1 <= a[1] && a[1] <= m && !(i & (1<<(a[1]-1)))){
int j = i | (1<<(a[1]-1));
edges[i*(m+n+2)+a[0]].push_back(Edge(j*(m+n+2)+a[1], cost-cake[a[1]-1]));
}else
edges[i*(m+n+2)+a[0]].push_back(Edge(i*(m+n+2)+a[1], cost));
}
swap(a[0], a[1]);
}
}
vector<int> dist;
shortestPath(edges, 0, dist);
int ret = INT_MAX;
for(int i=0; i<(1<<m); ++i)
ret = min(ret, dist[(m+n+2)*(i+1)-1]);
cout << ret << endl;
}
} | a.cc: In function 'int main()':
a.cc:62:62: error: no matching function for call to 'std::vector<std::vector<Edge> >::vector(int, int)'
62 | vector<vector<Edge> > edges((m+n+2)*(1<<m), 0);
| ^
In file included from /usr/include/c++/14/vector:66,
from a.cc:7:
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::vector<Edge>; _Alloc = std::allocator<std::vector<Edge> >]'
707 | vector(_InputIterator __first, _InputIterator __last,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66,
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:1:
/usr/include/c++/14/bits/stl_iterator_base_types.h: In substitution of 'template<class _InIter> using std::_RequireInputIter = std::__enable_if_t<((bool)std::is_convertible<typename std::iterator_traits< <template-parameter-1-1> >::iterator_category, std::input_iterator_tag>::value)> [with _InIter = int]':
/usr/include/c++/14/bits/stl_vector.h:705:9: required from here
705 | typename = std::_RequireInputIter<_InputIterator>>
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:252:57: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'
252 | input_iterator_tag>::value>;
| ^~~~~
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::vector<Edge>; _Alloc = std::allocator<std::vector<Edge> >; allocator_type = std::allocator<std::vector<Edge> >]'
678 | vector(initializer_list<value_type> __l,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:678:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<std::vector<Edge> >'
678 | vector(initializer_list<value_type> __l,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<Edge>; _Alloc = std::allocator<std::vector<Edge> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<Edge> >]'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:659:23: note: no known conversion for argument 1 from 'int' to 'std::vector<std::vector<Edge> >&&'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ~~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::vector<Edge>; _Alloc = std::allocator<std::vector<Edge> >; allocator_type = std::allocator<std::vector<Edge> >; std::false_type = std::false_type]'
640 | vector(vector&& __rv, const allocator_type& __m, false_type)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::vector<Edge>; _Alloc = std::allocator<std::vector<Edge> >; allocator_type = std::allocator<std::vector<Edge> >; std::true_type = std::true_type]'
635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<Edge>; _Alloc = std::allocator<std::vector<Edge> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<Edge> >]'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:624:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<std::vector<Edge> >&'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<Edge>; _Alloc = std::allocator<std::vector<Edge> >]'
620 | vector(vector&&) noexcept = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<Edge>; _Alloc = std::allocator<std::vector<Edge> >]'
601 | vector(const vector& __x)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<Edge>; _Alloc = std::allocator<std::vector<Edge> >; size_type = long unsigned int; value_type = std::vector<Edge>; allocator_type = std::allocator<std::vector<Edge> >]'
569 | vector(size_type __n, const value_type& __value,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:569:47: note: no known conversion for argument 2 from 'int' to 'const std::vector<std::vector<Edge> >::value_type&' {aka 'const std::vector<Edge>&'}
569 | vector(size_type __n, const value_type& __value,
| ~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<Edge>; _Alloc = std::allocator<std::vector<Edge> >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<Edge> >]'
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:51: note: no known conversion for argument 2 from 'int' to 'const std::vector<std::vector<Edge> >::allocator_type&' {aka 'const std::allocator<std::vector<Edge> >&'}
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::vector<Edge>; _Alloc = std::allocator<std::vector<Edge> >; allocator_type = std::allocator<std::vector<Edge> >]'
542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::vector<Edge>; _Alloc = std::allocator<std::vector<Edge> >]'
531 | vector() = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate expects 0 arguments, 2 provided
|
s018355729 | p00224 | C++ | #include<iostream>
#include<string>
#include<vector>
#include<stdlib>
using namespace std;
struct edge{
int from,to,cost;
edge(int a,int b,int c){from = a , to = b , cost = c;}
};
int m,n,k,dd;
vector<edge> es;
const int INF=100000;
int d[209];
int cake[9];
int root(string s){
if(s[0]=='H')return 0;
if(s[0]=='D')return 1;
string num = s.substr(1,s.size()-1);
if(s[0]=='C')return 1+atoi(num.c_str());
if(s[0]=='L')return m+1+atoi(num.c_str());
}
void path(int s){
int a,b;
for(a=0;a<209;a++)d[a]=INF;
d[s]=0;
while(true){
bool upd=false;
for(a=0;a<es.size();a++){
edge e=es[a];
if(e.to>1 && e.to<=1+m){
if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost-cake[e.to]){
d[e.to]=d[e.from]+e.cost-cake[e.to];
cake[e.to]=0;
upd=true;
}
}else if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
d[e.to]=d[e.from]+e.cost;
upd=true;
}
}
if(!upd)break;
}
}
int main(void){
int a;
while(1){
cin >> m >> n >> k >> dd;
if(m==0 && n==0 && k==0 && dd==0)break;
es.clear();
for(a=0;a<m;a++){
cin >> cake[a+2];
}
for(a=0;a<dd*2;a+=2){
int b,c,dd;
string s;
string ss;
cin >> s >> ss >> dd;
b=root(s);
c=root(ss);
es.push_back(edge(b,c,dd*k));
es.push_back(edge(c,b,dd*k));
}
path(0);
cout << d[1] << endl;
}
return 0;
} | a.cc:4:9: fatal error: stdlib: No such file or directory
4 | #include<stdlib>
| ^~~~~~~~
compilation terminated.
|
s176925036 | p00224 | C++ | #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>
using namespace std;
#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;
const int INFTY=1<<29;
const double EPS=1e-9;
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
os<<'[';
rep(i,a.size()) os<<(i?" ":"")<<a[i];
return os<<']';
}
int stoi(const string& s)
{
int res=0;
rep(i,s.size())
res=res*10+s[i]-'0';
return res;
}
struct Edge{
int src,dst,weight;
Edge(){}
Edge(int s,int d,int w):src(s),dst(d),weight(w){}
bool operator<(const Edge& e)const{return weight<e.weight;}
bool operator>(const Edge& e)const{return weight>e.weight;}
};
ostream& operator<<(ostream& os,const Edge& e){
return os<<'('<<e.src<<','<<e.dst<<','<<e.weight<<')';
}
bool BellmanFord(const vector<Edge>& es,int size,int begin,vi& dp)
{
bool neg=false;
dp[begin]=0;
rep(k,size){
neg=false;
for(Edge e:es)
if(dp[e.dst]>dp[e.src]+e.weight){
dp[e.dst]=dp[e.src]+e.weight;
neg=true;
}
}
return neg;
}
int main()
{
for(int m,n,k,d;cin>>m>>n>>k>>d,m|n|k|d;){
vi cs(m);
rep(i,m) cin>>cs[i];
int start=2*m+n,goal=start+1,v=goal+1;
vector<Edge> es;
rep(i,1<<m) rep(j,m)
if(!(i>>j&1))
es.emplace_back(i*v+j,(i|1<<j)*v+m+j,-cs[j]);
while(d--){
string src,dst; int dist; cin>>src>>dst>>dist;
int si=-1;
if(src[0]=='H') si=start;
if(src[0]=='D') si=goal;
if(src[0]=='C') si=stoi(src.substr(1))-1;
if(src[0]=='L') si=2*m+stoi(src.substr(1))-1;
int di=-1;
if(dst[0]=='H') di=start;
if(dst[0]=='D') di=goal;
if(dst[0]=='C') di=stoi(dst.substr(1))-1;
if(dst[0]=='L') di=2*m+stoi(dst.substr(1))-1;
rep(i,1<<m){
int si2=si,di2=di;
if(src[0]=='C') si2+=m;
if(dst[0]=='C') di2+=m;
es.emplace_back(i*v+si2,i*v+di,dist*k);
es.emplace_back(i*v+di2,i*v+si,dist*k);
}
}
int size=(1<<m)*v;
vi dp(size,INFTY);
BellmanFord(es,size,start,dp);
int res=INFTY;
rep(i,1<<m)
res=min(res,dp[i*v+goal]);
cout<<res<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:108:48: error: call of overloaded 'stoi(std::__cxx11::basic_string<char>)' is ambiguous
108 | if(src[0]=='C') si=stoi(src.substr(1))-1;
| ~~~~^~~~~~~~~~~~~~~
a.cc:57:5: note: candidate: 'int stoi(const std::string&)'
57 | int stoi(const string& s)
| ^~~~
In file included from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:6:
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
4164 | stoi(const string& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
a.cc:109:52: error: call of overloaded 'stoi(std::__cxx11::basic_string<char>)' is ambiguous
109 | if(src[0]=='L') si=2*m+stoi(src.substr(1))-1;
| ~~~~^~~~~~~~~~~~~~~
a.cc:57:5: note: candidate: 'int stoi(const std::string&)'
57 | int stoi(const string& s)
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
4164 | stoi(const string& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
a.cc:113:48: error: call of overloaded 'stoi(std::__cxx11::basic_string<char>)' is ambiguous
113 | if(dst[0]=='C') di=stoi(dst.substr(1))-1;
| ~~~~^~~~~~~~~~~~~~~
a.cc:57:5: note: candidate: 'int stoi(const std::string&)'
57 | int stoi(const string& s)
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
4164 | stoi(const string& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
a.cc:114:52: error: call of overloaded 'stoi(std::__cxx11::basic_string<char>)' is ambiguous
114 | if(dst[0]=='L') di=2*m+stoi(dst.substr(1))-1;
| ~~~~^~~~~~~~~~~~~~~
a.cc:57:5: note: candidate: 'int stoi(const std::string&)'
57 | int stoi(const string& s)
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
4164 | stoi(const string& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
|
s941916027 | p00225 | Java |
import java.util.Scanner;
public class main{
static String term = new String();
static char t[][];
static int n;
static boolean bt(int m,int cnt){
if(cnt == n-1) {
if(t[0][0] == t[m][1]) return true;
else return false;
}
for(int i=0; i<n; i++){
if(i != m && t[m][1] == t[i][0]){
if(bt(i,cnt+1)) return true;
}
}
return false;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(true){
n = sc.nextInt();
if(n == 0) break;
t = new char[n][2];
for(int i=0; i<n; i++){
term = sc.next();
int last = term.length() - 1;
t[i][0] = term.charAt(0);
t[i][1] = term.charAt(last);
}
if(bt(0,0)) System.out.println("OK");
else System.out.println("NG");
}
}
} | Main.java:5: error: class main is public, should be declared in a file named main.java
public class main{
^
1 error
|
s018603621 | p00225 | Java | import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
void run() {
Scanner in = new Scanner(System.in);
while(true) {
int N = Integer.parseInt(in.next());
if (N == 0) break;
List<String> wordList = new ArrayList<String>();
for(int i = 0; i < N; i++) {
String word = in.next();
wordList.add(word.substring(0, 1));
wordList.add(word.substring(word.length() - 1, word.length()));
}
Collections.sort(wordList);
if(check(wordList)) {
System.out.println("OK");
} else {
System.out.println("NG");
}
}
}
boolean check(List<String> wordList) {
int count = 1;
String word1 = wordList.get(0);
for(int i = 1; i < wordList.size(); i++) {
String word2 = wordList.get(i);
if(word1.equals(word2)) {
count++;
} else {
if(count == 2 || count % 2 != 0) return false;
word1 = word2;
count = 1;
}
}
return true;
}
public static void main(String[] args) {
new Main.run();
}
} | Main.java:54: error: cannot find symbol
new Main.run();
^
symbol: class run
location: class Main
1 error
|
s468352108 | p00225 | Java |
import java.io.*;
import java.util.*;
// 2011/10/19
//@0225 ±Ô½Ê«Â˱
public class Main {
// 檶Æö¶Ìªêv
// ·×ĪÂȪÁÄ¢éÅOK
// C return falseŨµÜ¢
boolean main() throws IOException {
int N = readIntArray()[0];
if (N == 0)
return false; // ¨µÜ¢
List<String> list = new ArrayList<String>();
int[] cnt = new int[26]; // At@xbg26¶ªÌJE^
int[] flag = new int[26]; // 檶¶ÝtO At@xbg26¶ª
for(int i = 0; i < N; i++) {
String s = reader.readLine();
list.add(s);
// char c1 = s.charAt(0); //æª
// char c2 = s.charAt(s.length() - 1); //ö
// cnt[c1 - 'a']++;
// flag[c1 - 'a'] = 1;
// cnt[c2 - 'a']--;
}
// // ·×Ä0ªOK
// boolean dame = false;
// for(int i = 0; i < cnt.length; i++) {
// if (cnt[i] != 0) {
// dame = true;
// break;
// }
// }
//
// if (!dame) {
// // ·×ÄÂȪÁÄ¢é©
// String s = list.get(0);
// char c1 = s.charAt(0); //æª
// char c2 = s.charAt(s.length() - 1); //ö
// flag[c1 - 'a'] = 0;
// for(;;) {
// boolean modify = false;
// for(int i = 0; i < list.size(); i++) {
// s = list.get(i);
// c1 = s.charAt(0); //æª
// c2 = s.charAt(s.length() - 1); //ö
// if (flag[c1 - 'a'] == 0 && flag[c2 - 'a'] != 0) {
// flag[c2 - 'a'] = 0;
// modify = true;
// }
// }
// if (!modify)
// break;
// }
//
// // ·×Ä0ªOK
// for(int i = 0; i < flag.length; i++) {
// if (flag[i] != 0) {
// dame = true;
// break;
// }
// }
// }
// ðÌ\¦
System.out.printf("%s\n", dame ? "NG" : "OK");
return true; // ³íI¹ Ö
}
// private final static boolean DEBUG = true; // debug
private final static boolean DEBUG = false; // release
public static void main(String[] args) throws IOException {
if (DEBUG) {
log = System.out;
// String inputStr = "7\nae\nyw\nga\nkg\nel\nwk\nly\n" + "0\n";
String inputStr = "7\nab\nbc\nca\nde\nef\nfg\ngd\n" + "0\n";
reader = new BufferedReader(new StringReader(inputStr));
}
else {
log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
}
//int N = readIntArray()[0];
for(int i = 0; /*i < N*/; i++) {
boolean b = new Main().main();
if (!b)
break;
}
reader.close();
}
static PrintStream log;
static BufferedReader reader;
// WüÍæè1sªÌXy[XæØèÌ®lðÇÞ
// EOFÌêÍnullðÔ·
private static int[] readIntArray() throws IOException {
String s = reader.readLine();
if (s == null)
return null;
String[] sp = s.split(" ");
int[] a = new int[sp.length];
for(int i = 0; i < sp.length; i++) {
a[i] = Integer.parseInt(sp[i]);
}
return a;
}
} | Main.java:76: error: cannot find symbol
System.out.printf("%s\n", dame ? "NG" : "OK");
^
symbol: variable dame
location: class Main
1 error
|
s591530893 | p00225 | C | #define M 26
P[M],A[M],B[M];
int R(a){return P[a]==a?a:(P[a]=R(P[a]));}
char s[99];main(k,l,x,y){for(;scanf("%d",&l),l;puts(k<M?"NG":"OK")){
for(k=0;k<M;k++)A[k]=B[k]=0,P[k]=k;
for(k=0;k<l;k++)scanf("%s",s),x=*s-97,y=s[strlen(s)-1]-97,A[x]++,B[y]++,P[R(x)]=R(y);
for(d=k=0;k<M;k++){if(abs(A[k]-B[k])||((A[k]|B[k])&&R(*s-97)!=R(k)))break;}
}exit(0);} | main.c:2:1: warning: data definition has no type or storage class
2 | P[M],A[M],B[M];
| ^
main.c:2:1: error: type defaults to 'int' in declaration of 'P' [-Wimplicit-int]
main.c:2:6: error: type defaults to 'int' in declaration of 'A' [-Wimplicit-int]
2 | P[M],A[M],B[M];
| ^
main.c:2:11: error: type defaults to 'int' in declaration of 'B' [-Wimplicit-int]
2 | P[M],A[M],B[M];
| ^
main.c: In function 'R':
main.c:3:5: error: type of 'a' defaults to 'int' [-Wimplicit-int]
3 | int R(a){return P[a]==a?a:(P[a]=R(P[a]));}
| ^
main.c: At top level:
main.c:4:12: error: return type defaults to 'int' [-Wimplicit-int]
4 | char s[99];main(k,l,x,y){for(;scanf("%d",&l),l;puts(k<M?"NG":"OK")){
| ^~~~
main.c: In function 'main':
main.c:4:12: error: type of 'k' defaults to 'int' [-Wimplicit-int]
main.c:4:12: error: type of 'l' defaults to 'int' [-Wimplicit-int]
main.c:4:12: error: type of 'x' defaults to 'int' [-Wimplicit-int]
main.c:4:12: error: type of 'y' defaults to 'int' [-Wimplicit-int]
main.c:4:31: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
4 | char s[99];main(k,l,x,y){for(;scanf("%d",&l),l;puts(k<M?"NG":"OK")){
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | #define M 26
main.c:4:31: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
4 | char s[99];main(k,l,x,y){for(;scanf("%d",&l),l;puts(k<M?"NG":"OK")){
| ^~~~~
main.c:4:31: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:4:48: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
4 | char s[99];main(k,l,x,y){for(;scanf("%d",&l),l;puts(k<M?"NG":"OK")){
| ^~~~
main.c:4:48: note: include '<stdio.h>' or provide a declaration of 'puts'
main.c:6:51: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
6 | for(k=0;k<l;k++)scanf("%s",s),x=*s-97,y=s[strlen(s)-1]-97,A[x]++,B[y]++,P[R(x)]=R(y);
| ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'strlen'
+++ |+#include <string.h>
1 | #define M 26
main.c:6:51: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch]
6 | for(k=0;k<l;k++)scanf("%s",s),x=*s-97,y=s[strlen(s)-1]-97,A[x]++,B[y]++,P[R(x)]=R(y);
| ^~~~~~
main.c:6:51: note: include '<string.h>' or provide a declaration of 'strlen'
main.c:7:13: error: 'd' undeclared (first use in this function)
7 | for(d=k=0;k<M;k++){if(abs(A[k]-B[k])||((A[k]|B[k])&&R(*s-97)!=R(k)))break;}
| ^
main.c:7:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:31: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
7 | for(d=k=0;k<M;k++){if(abs(A[k]-B[k])||((A[k]|B[k])&&R(*s-97)!=R(k)))break;}
| ^~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
+++ |+#include <stdlib.h>
1 | #define M 26
main.c:8:2: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
8 | }exit(0);}
| ^~~~
main.c:8:2: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:8:2: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
main.c:8:2: note: include '<stdlib.h>' or provide a declaration of 'exit'
|
s084940434 | p00225 | C++ | #include <iostream>
#include <string>
#include <utility>
#include <stack>
using namespace std;
bool check(pair<char,char>* words, int num);
int main() {
int num;
char buf[33];
pair<char,char> words[10000];
while(true) {
cin >> num;
if(!num)
break;
for(int i=0; i<num; i++) {
cin >> buf;
words[i].first = buf[0];
words[i].second = buf[strlen(buf)-1];
}
if(check(words,num))
cout << "OK" << endl;
else
cout << "NG" << endl;
}
return 0;
}
bool check(pair<char,char>* words, int num) {
stack<int> searchStack;
bool used[10000];
for(int i=0; i<num; i++) used[i]=false;
searchStack.push(0);
searchStack.pop();
searchStack.push(0);
used[0] = true;
int searchPos = 0;
while(!searchStack.empty()) {
for(int i=searchPos; i<num; i++) {
if(words[searchStack.top()].second == words[i].first && !used[i]) {
searchStack.push(i);
used[i] = true;
searchPos = 0;
break;
} else if(i==num-1) {
searchPos = searchStack.top()+1;
used[searchStack.top()] = false;
searchStack.pop();
break;
}
}
if(searchPos >= num) {
searchPos = searchStack.top() + 1;
used[searchStack.top()] = false;
searchStack.pop();
}
if(searchStack.size() == num) {
if(words[searchStack.top()].second == words[0].first) {
return true;
} else {
searchPos = searchStack.top() + 1;
used[searchStack.top()] = false;
searchStack.pop();
}
}
}
return false;
} | a.cc: In function 'int main()':
a.cc:22:29: error: 'strlen' was not declared in this scope
22 | words[i].second = buf[strlen(buf)-1];
| ^~~~~~
a.cc:5:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <stack>
+++ |+#include <cstring>
5 | using namespace std;
|
s923278617 | p00225 | C++ | #include <iostream>
#include <string>
#include <stack>
using namespace std;
bool check(pair<char,char>* words, int num);
int main() {
int num;
char buf[33];
pair<char,char> words[10000];
while(true) {
cin >> num;
if(!num)
break;
for(int i=0; i<num; i++) {
cin >> buf;
words[i].first = buf[0];
words[i].second = buf[std::strlen(buf)-1];
}
if(check(words,num))
cout << "OK" << endl;
else
cout << "NG" << endl;
}
return 0;
}
bool check(pair<char,char>* words, int num) {
stack<int> searchStack;
bool used[10000];
for(int i=0; i<num; i++) used[i]=false;
searchStack.push(0);
searchStack.pop();
searchStack.push(0);
used[0] = true;
int searchPos = 0;
while(!searchStack.empty()) {
for(int i=searchPos; i<num; i++) {
if(words[searchStack.top()].second == words[i].first && !used[i]) {
searchStack.push(i);
used[i] = true;
searchPos = 0;
break;
} else if(i==num-1) {
searchPos = searchStack.top()+1;
used[searchStack.top()] = false;
searchStack.pop();
break;
}
}
if(searchPos >= num) {
searchPos = searchStack.top() + 1;
used[searchStack.top()] = false;
searchStack.pop();
}
if(searchStack.size() == num) {
if(words[searchStack.top()].second == words[0].first) {
return true;
} else {
searchPos = searchStack.top() + 1;
used[searchStack.top()] = false;
searchStack.pop();
}
}
}
return false;
} | a.cc: In function 'int main()':
a.cc:21:34: error: 'strlen' is not a member of 'std'; did you mean 'mbrlen'?
21 | words[i].second = buf[std::strlen(buf)-1];
| ^~~~~~
| mbrlen
|
s357816086 | p00225 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<cctype>
#include<climits>
#include<bitset>
using namespace std;
#define int long long
int N;
vector<int> e[26];
int graphSize;
int CountVertex(int v, bool isUsed[26])
{
if (isUsed[v]) return 0;
isUsed[v] = true;
int ret = 1;
for (int i = 0; i < e[v].size(); i++)
{
ret += CountVertex(e[v][i], isUsed);
}
return ret;
}
bool IsConnected()
{
for (int i = 0; i < 26; i++)
{
bool isUsed[26] = {};
if (CountVertex(i, isUsed) == graphSize) return true;
}
return false;
}
signed main()
{
while (cin >> N, N)
{
int in[26] = {}, out[26] = {};
bool flag[26] = {};
graphSize = 0;
for (int i = 0; i < 26; i++) e[i].clear();
for (int i = 0; i < N; i++)
{
string s;
cin >> s;
int a = s[0] - 'a', b = s.[s.size() - 1] - 'a';
out[a]++;
in[b]++;
e[a].push_back(b);
e[b].push_back(a);
graphSize += !flag[a] + !flag[b];
flag[a] = true;
flag[b] = true;
}
bool ans = true;
for (int i = 0; i < 26; i++)
{
if (in[i] != out[i]) ans = false;
}
if (ans && IsConnected()) puts("OK");
else puts("NG");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:55:51: error: expected unqualified-id before '[' token
55 | int a = s[0] - 'a', b = s.[s.size() - 1] - 'a';
| ^
|
s789303690 | p00225 | C++ | #include<iostream>
#include<string>
#include<vector>
using namespace std;
string S[10000]; int x, n; char T[10000][2];
//Class.
vector<int> list[100000];
int N, M, E, P;
int match[100000];
bool used[100000];
int x[100000], y[100000];
bool DFS(int V) {
used[V] = true;
for (int i = 0; i < list[V].size(); i++) {
int u = list[V][i]; int w = match[u];
if (w < 0 || !used[w] && DFS(w)) {
match[V] = u;
match[u] = V;
return true;
}
}
return false;
}
int supermatching() {
int r = 0;
memset(match, -1, sizeof(match));
for (int j = 0; j < P; j++) {
if (match[j] < 0) {
memset(used, 0, sizeof(used));
if (DFS(j)) { r++; }
}
}
return r;
}
int main() {
while (true) {
for (int i = 0; i < 10000; i++) { list[i].clear(); }
cin >> n; x = 0;
for (int i = 0; i < n; i++) {
cin >> S[i];
T[i][0] = S[i][0]; T[i][1] = S[i][S[i].size() - 1];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (T[i][0] == T[j][1] && i != j) { list[i].push_back(j + n); }
}
}
if (supermatching() != n) { cout << "NG" << endl; }
else { cout << "No" << endl; }
}
} | a.cc:12:5: error: conflicting declaration 'int x [100000]'
12 | int x[100000], y[100000];
| ^
a.cc:5:22: note: previous declaration as 'int x'
5 | string S[10000]; int x, n; char T[10000][2];
| ^
a.cc: In function 'int supermatching()':
a.cc:29:9: error: 'memset' was not declared in this scope
29 | memset(match, -1, sizeof(match));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<vector>
+++ |+#include <cstring>
4 | using namespace std;
|
s283183790 | p00225 | C++ | #include<iostream>
#include<string>
#include<vector>
using namespace std;
string S[10000]; int n; char T[10000][2];
//Class.
vector<int> list[100000];
int N, M, E, P;
int match[100000];
bool used[100000];
int x[100000], y[100000];
bool DFS(int V) {
used[V] = true;
for (int i = 0; i < list[V].size(); i++) {
int u = list[V][i]; int w = match[u];
if (w < 0 || !used[w] && DFS(w)) {
match[V] = u;
match[u] = V;
return true;
}
}
return false;
}
int supermatching() {
int r = 0;
memset(match, -1, sizeof(match));
for (int j = 0; j < P; j++) {
if (match[j] < 0) {
memset(used, 0, sizeof(used));
if (DFS(j)) { r++; }
}
}
return r;
}
int main() {
while (true) {
for (int i = 0; i < 10000; i++) { list[i].clear(); }
cin >> n; if (!n) { break; }
for (int i = 0; i < n; i++) {
cin >> S[i];
T[i][0] = S[i][0]; T[i][1] = S[i][S[i].size() - 1];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (T[i][0] == T[j][1] && i != j) { list[i].push_back(j + n); }
}
}
if (supermatching() != n) { cout << "NG" << endl; }
else { cout << "No" << endl; }
}
} | a.cc: In function 'int supermatching()':
a.cc:29:9: error: 'memset' was not declared in this scope
29 | memset(match, -1, sizeof(match));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<vector>
+++ |+#include <cstring>
4 | using namespace std;
|
s062167756 | p00225 | C++ | #include<iostream>
#include<string>
#include<map>
using namespace std;
int n, flag; string S, U;
map<string, int>M;
int backtruck(string T, int a) {
if (a == n - 1) {
if (T[1] == U[0]) { flag = 1; }
}
if (flag == 1) { return; }
for (map<string, int>::iterator it = M.begin(); it != M.end(); it++) {
if (T[1] == (*it).first[0] && (*it).second) {
(*it).second--;
backtruck((*it).first, a + 1);
(*it).second++;
}
}
}
int main() {
while (true) {
cin >> n; M.clear();
if (n == 0) { break; }
for (int i = 0; i < n; i++) {
cin >> S;
S = S[0] + S[S.size() - 1];
M[S]++;
}
U = S;
backtruck(S, 0);
if (flag == true) { cout << "OK" << endl; }
else { cout << "NG" << endl; }
}
} | a.cc: In function 'int backtruck(std::string, int)':
a.cc:11:26: error: return-statement with no value, in function returning 'int' [-fpermissive]
11 | if (flag == 1) { return; }
| ^~~~~~
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
19 | }
| ^
|
s074741579 | p00225 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
template<int MV> class DirectedEulerPath {
public:
vector<int> path;
multiset<int> E[MV];
void add_path(int x, int y) { E[x].insert(y); }
void dfs(int cur) {
while (E[cur].size()) {
int tar = *E[cur].begin();
E[cur].erase(E[cur].begin());
dfs(tar);
}
path.push_back(cur);
}
bool GetPath(int s = 0) {
int fo = -1, odd = 0, i, np = 0;
vector<int> deg(MV);
rep(i, 0, MV) {
np += E[i].size();
for (int e : E[i]) --deg[e];
deg[i] += E[i].size();
}
int k = MV - count(deg.begin(), deg.end(), 0);
if (k == 1 || 2 < k) return false;
path.clear();
if (k == 0) {
dfs(s);
}
else {
rep(i, 0, MV) if (1 < deg[i]) return false;
rep(i, 0, MV) if (deg[i] == 1) dfs(i), break;
}
reverse(path.begin(), path.end());
// ??¨?????????????????£??????????????????????????\?????????????????????true?????????
return path.size() == m + 1;
}
};
//-----------------------------------------------------------------
int n;
set<int> sn;
string solve() {
DirectedEulerPath<26> dep;
sn.clear();
rep(i, 0, n) {
string s; cin >> s;
int a = s[0] - 'a';
int b = s[s.length() - 1] - 'a';
dep.add_path(a, b);
sn.insert(a);
sn.insert(b);
}
bool can = dep.GetPath();
// ???????????????????????????
if (!can) return "NG";
for (int i : dep.path) cout << i << " -> "; cout << endl;
// ??????????????????????????????
if (dep.path.front() != dep.path.back()) return "NG";
return "OK";
}
//-----------------------------------------------------------------
int main() {
while (cin >> n) {
if (n == 0) break;
cout << solve() << endl;
}
} | a.cc: In member function 'bool DirectedEulerPath<MV>::GetPath(int)':
a.cc:37:64: error: expected primary-expression before 'break'
37 | rep(i, 0, MV) if (deg[i] == 1) dfs(i), break;
| ^~~~~
a.cc:37:64: error: expected ';' before 'break'
a.cc:41:39: error: 'm' was not declared in this scope; did you mean 'tm'?
41 | return path.size() == m + 1;
| ^
| tm
|
s987875043 | p00225 | C++ | #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<char, char>P;
vector<int>E[10000];
bool used[10000];
int in[10000], out[10000;
void dfs(int u) {
used[u] = true;
for (int v : E[u]) {
if (!used[v])dfs(v);
}
}
int main() {
int n;
while (scanf("%d", &n), n) {
vector<P>v;
memset(used, 0, sizeof(used));
memset(in, 0, sizeof(in));
memset(out, 0, sizeof(out));
rep(i, n) {
E[i].clear();
string s; cin >> s;
v.push_back(P(*s.begin(), *s.rbegin()));
}
rep(i, n)rep(j, n) {
if (i == j)continue;
if (v[i].second == v[j].first) {
E[i].push_back(j);
in[j]++; out[i]++;
}
}
dfs(0);
rep(i, n) {
if (in[i] != out[i] || !used[i]) {
puts("NG"); goto g;
}
}
puts("OK");
g:;
}
} | a.cc:8:25: error: expected ']' before ';' token
8 | int in[10000], out[10000;
| ^
| ]
a.cc: In function 'int main()':
a.cc:22:24: error: 'out' was not declared in this scope
22 | memset(out, 0, sizeof(out));
| ^~~
|
s955012803 | p00225 | C++ | #include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(void) {
while(true) {
int n;
cin>>n;
if(n == 0) break;
vector<int> s(26, 0);
vector<int> e(26, 0);
REP(i, n) {
string gomi;
cin>>gomi;
++c[gomi[0] - 'a'];
++e[gomi[gomi.size() - 1] - 'a'];
}
bool det = true;
REP(i, 26) {
if(c[i] != d[i]) {
det = false;
break;
}
}
if(det) cout<<"OK"<<endl;
else cout<<"NG"<<endl;
}
} | a.cc: In function 'int main()':
a.cc:33:27: error: 'c' was not declared in this scope
33 | ++c[gomi[0] - 'a'];
| ^
a.cc:38:28: error: 'c' was not declared in this scope
38 | if(c[i] != d[i]) {
| ^
a.cc:38:36: error: 'd' was not declared in this scope
38 | if(c[i] != d[i]) {
| ^
|
s627489238 | p00225 | C++ | #include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(void) {
while(true) {
int n;
cin>>n;
if(n == 0) break;
vector<int> s(26, 0);
vector<int> e(26, 0);
REP(i, n) {
string gomi;
cin>>gomi;
++s[gomi[0] - 'a'];
++e[gomi[gomi.size() - 1] - 'a'];
}
bool det = true;
REP(i, 26) {
if(s[i] != d[i]) {
det = false;
break;
}
}
if(det) cout<<"OK"<<endl;
else cout<<"NG"<<endl;
}
} | a.cc: In function 'int main()':
a.cc:38:36: error: 'd' was not declared in this scope
38 | if(s[i] != d[i]) {
| ^
|
s550621465 | p00225 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
int n;
int cnt[26];
bool g[26][26];
bool done[26];
int main() {
while (cin >> n, n) {
memset(cnt, 0, sizeof(cnt));
memset(g, 0, sizeof(g));
memset(done, 0, sizeof(done));
int st = -1;
REP(i, n) {
string str; cin >> str;
int u = *(str.begin()) - 'a';
int v = *--str.end() - 'a';
cnt[u]++; cnt[v]++;
g[u][v] = true;
if (st == -1) st = u;
}
queue<int> que;
que.push(st);
done[st] = true;
while (!que.empty()) {
int now = que.front(); que.pop();
REP(i, 26) if (g[now][i] && !done[i]) {
done[i] = true;
que.push(i);
}
}
bool ans = true;
REP(i, 26) {
if (cnt[i] & 1) ans = false;
if (cnt[i] > 0 && !done[i]) ans = false;
}
puts(ans ? "OK" : "NG");
}
return 0;
}
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
int n;
int cnt[26];
bool g[26][26];
bool done[26];
int main() {
while (cin >> n, n) {
memset(cnt, 0, sizeof(cnt));
memset(g, 0, sizeof(g));
memset(done, 0, sizeof(done));
int st = -1;
REP(i, n) {
string str; cin >> str;
int u = *(str.begin()) - 'a';
int v = *--str.end() - 'a';
cnt[u]++; cnt[v]++;
g[u][v] = true;
if (st == -1) st = u;
}
queue<int> que;
que.push(st);
done[st] = true;
while (!que.empty()) {
int now = que.front(); que.pop();
REP(i, 26) if (g[now][i] && !done[i]) {
done[i] = true;
que.push(i);
}
}
bool ans = true;
REP(i, 26) {
if (cnt[i] & 1) ans = false;
if (cnt[i] > 0 && !done[i]) ans = false;
}
puts(ans ? "OK" : "NG");
}
return 0;
} | a.cc:115:46: error: redefinition of 'template<class A, class B> bool chmax(A&, B)'
115 | template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
| ^~~~~
a.cc:28:46: note: 'template<class A, class B> bool chmax(A&, B)' previously declared here
28 | template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
| ^~~~~
a.cc:116:46: error: redefinition of 'template<class A, class B> bool chmin(A&, B)'
116 | template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
| ^~~~~
a.cc:29:46: note: 'template<class A, class B> bool chmin(A&, B)' previously declared here
29 | template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
| ^~~~~
a.cc:123:10: error: redefinition of 'const ll INF'
123 | const ll INF = 1ll<<29;
| ^~~
a.cc:36:10: note: 'const ll INF' previously defined here
36 | const ll INF = 1ll<<29;
| ^~~
a.cc:124:10: error: redefinition of 'const ll MOD'
124 | const ll MOD = 1000000007;
| ^~~
a.cc:37:10: note: 'const ll MOD' previously defined here
37 | const ll MOD = 1000000007;
| ^~~
a.cc:125:14: error: redefinition of 'const double EPS'
125 | const double EPS = 1e-10;
| ^~~
a.cc:38:14: note: 'const double EPS' previously defined here
38 | const double EPS = 1e-10;
| ^~~
a.cc:127:5: error: redefinition of 'int n'
127 | int n;
| ^
a.cc:40:5: note: 'int n' previously declared here
40 | int n;
| ^
a.cc:128:5: error: redefinition of 'int cnt [26]'
128 | int cnt[26];
| ^~~
a.cc:41:5: note: 'int cnt [26]' previously declared here
41 | int cnt[26];
| ^~~
a.cc:129:6: error: redefinition of 'bool g [26][26]'
129 | bool g[26][26];
| ^
a.cc:42:6: note: 'bool g [26][26]' previously declared here
42 | bool g[26][26];
| ^
a.cc:130:6: error: redefinition of 'bool done [26]'
130 | bool done[26];
| ^~~~
a.cc:43:6: note: 'bool done [26]' previously declared here
43 | bool done[26];
| ^~~~
a.cc:132:5: error: redefinition of 'int main()'
132 | int main() {
| ^~~~
a.cc:45:5: note: 'int main()' previously defined here
45 | int main() {
| ^~~~
|
s346139071 | p00225 | C++ | #include<iostream>
#include<string>
#include<vector>
char str[10000][32];
int n;
char first;
bool isFst = 1;
//øÌ¶©çnÜéPêð`FbN
int isUsed[10000] = {0};
int check(char str[], int num);
using namespace std;
int main()
{
for(;;){
int ok = 0;
scanf("%d",&n);
if(n == 0){
break;
}
for(int i = 0; i < n; i++){
scanf("%s",str[i]);
}
for(int i = 0; i < n; i++){
// printf("õ¶ñ >> %s\n",str[i]);
if(check(str[i], i) == 1){
ok = 1;
break;
}
}
if(ok == 1){
printf("OK\n");
}
else{
printf("NG\n");
}
}
}
int check(char s[], int num)
{
int i;
bool find = 0;
bool Fin = 0;
for(i = 0; i < n; i++){
if(isUsed[i] == 0){
Fin = 0;
break;
}
else{
Fin = 1;
}
}
//øÌ¶ñ©ÌÍgÁÄé
isUsed[num] = 1;
//Åã̶ðchÉi[
char ch = s[strlen(s+1)];
if(Fin == 1 && ch == first){
}
else{
Fin = 0;
}
//±Ì¶ªÂȪêεèÆè®¬
if(isFst == 1){
first = s[0];
isFst = 0;
// printf("%cÉÂȪê΢¢æB\n",first);
}
if(Fin == 1){
if(ch == first){
}
else{
Fin = 0;
}
}
else{
//PêXgÌ©çchÅnÜéPêðõ
for(i = 0; i < n; i++){
if(str[i][0] == ch && i != num && isUsed[i] == 0){
// cout << str[i] << "ÉÂȪéÆv¤"<<endl;
find = 1;
break;
}
}
}
// printf("**********************õÊ********************\n");
// printf("");
if(Fin == 1){
return 1;
}
else if(find == 1){
return check(str[i], i);
}
else{
return 0;
}
} | a.cc: In function 'int check(char*, int)':
a.cc:68:21: error: 'strlen' was not declared in this scope
68 | char ch = s[strlen(s+1)];
| ^~~~~~
a.cc:4:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<vector>
+++ |+#include <cstring>
4 |
|
s874376137 | p00225 | C++ | #include<iostream>
#include<string>
#include<vector>
#include<cstdlib>
char str[10000][32];
int n;
char first;
bool isFst = 1;
//øÌ¶©çnÜéPêð`FbN
int isUsed[10000] = {0};
int check(char str[], int num);
using namespace std;
int main()
{
for(;;){
int ok = 0;
scanf("%d",&n);
if(n == 0){
break;
}
for(int i = 0; i < n; i++){
scanf("%s",str[i]);
}
for(int i = 0; i < n; i++){
// printf("õ¶ñ >> %s\n",str[i]);
if(check(str[i], i) == 1){
ok = 1;
break;
}
}
if(ok == 1){
printf("OK\n");
}
else{
printf("NG\n");
}
}
}
int check(char s[], int num)
{
int i;
bool find = 0;
bool Fin = 0;
for(i = 0; i < n; i++){
if(isUsed[i] == 0){
Fin = 0;
break;
}
else{
Fin = 1;
}
}
//øÌ¶ñ©ÌÍgÁÄé
isUsed[num] = 1;
//Åã̶ðchÉi[
char ch = s[strlen(s+1)];
if(Fin == 1 && ch == first){
}
else{
Fin = 0;
}
//±Ì¶ªÂȪêεèÆè®¬
if(isFst == 1){
first = s[0];
isFst = 0;
// printf("%cÉÂȪê΢¢æB\n",first);
}
if(Fin == 1){
if(ch == first){
}
else{
Fin = 0;
}
}
else{
//PêXgÌ©çchÅnÜéPêðõ
for(i = 0; i < n; i++){
if(str[i][0] == ch && i != num && isUsed[i] == 0){
// cout << str[i] << "ÉÂȪéÆv¤"<<endl;
find = 1;
break;
}
}
}
// printf("**********************õÊ********************\n");
// printf("");
if(Fin == 1){
return 1;
}
else if(find == 1){
return check(str[i], i);
}
else{
return 0;
}
} | a.cc: In function 'int check(char*, int)':
a.cc:69:21: error: 'strlen' was not declared in this scope
69 | char ch = s[strlen(s+1)];
| ^~~~~~
a.cc:5:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include<cstdlib>
+++ |+#include <cstring>
5 |
|
s347999136 | p00225 | C++ | #include <iostream>
#include <string>
#include <queue>
using namespace std;
int table[26][26];
int main(){
while(true){
int n;
cin >> n;
if(n == 0){ break; }
memset(table, 0, sizeof(table));
for(int i = 0; i < n; ++i){
string word;
cin >> word;
++(table[word[0] - 'a'][word[word.size() - 1] - 'a']);
}
bool isNG = false;
bool passed[26] = { false };
for(int i = 0; i < 26; ++i){
int inCount = 0, outCount = 0;
for(int j = 0; j < 26; ++j){
inCount += table[i][j];
outCount += table[j][i];
}
if(inCount != outCount){
isNG = true;
break;
}
if(inCount == 0){ passed[i] = true; }
}
if(isNG){
cout << "NG" << endl;
continue;
}
queue<int> q;
for(int i = 0; i < 26; ++i){
if(!passed[i]){
passed[i] = true;
q.push(i);
break;
}
}
while(!q.empty()){
int front = q.front();
q.pop();
for(int i = 0; i < 26; ++i){
if(table[front][i] && !passed[i]){
passed[i] = true;
q.push(i);
}
}
}
for(int i = 0; i < 26; ++i){
if(!passed[i]){
isNG = true;
break;
}
}
if(isNG){
cout << "NG" << endl;
}else{
cout << "OK" << endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:14:17: error: 'memset' was not declared in this scope
14 | memset(table, 0, sizeof(table));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <queue>
+++ |+#include <cstring>
4 |
|
s253703935 | p00225 | C++ | #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;
int main() {
int n;
while(cin >> n, n) {
vector<int> num(26);
REP(i, n) {
string s;
cin >> s;
num[s[0]-'a']++;
num[s[s.siz()-1]-'a']--;
}
bool f = 1;
REP(i, 26)
if (num[i])
f = 0;
if (f)
cout << "OK" <<endl;
else
cout <<"NG" <<endl;
}
} | a.cc: In function 'int main()':
a.cc:26:15: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'siz'; did you mean 'size'?
26 | num[s[s.siz()-1]-'a']--;
| ^~~
| size
|
s316670339 | p00225 | C++ | #include<iostream>
#include<string.h>
int n;
char** s;
bool* f;
int count1,count2;
char* a;
bool solve(){
a = s[0];
count = 0;
while(true){
count1 = 1;
count2++;
for(int i=1; i<n; i++){
if(f[i]){
count1++;
if(count1 == n && a[1] == s[0][0])
return true;
continue;
}
if(a[1] == s[i][0]){
count2 = 0;
f[i] = true;
a = s[i];
break;
}
}
if(count2 == 2)
return false;
}
}
int main(){
while(true){
std::cin >> n;
if(!n)
return 0;
s = new char*[n];
f = new bool[n];
for(int i=0; i<n; i++){
f[i] = false;
s[i] = new char[33];
std::cin >> s[i];
s[i][1] = s[i][strlen(s[i])-1];
}
if(solve())
std::cout << "OK\n";
else
std::cout << "NG\n";
for(int i=0; i<n; i++)
delete [] s[i];
delete [] s;
}
} | a.cc: In function 'bool solve()':
a.cc:12:9: error: 'count' was not declared in this scope; did you mean 'count2'?
12 | count = 0;
| ^~~~~
| count2
|
s433048373 | p00225 | C++ | #include<iostream>
//#include<map>
using namespace std;
//map<bool*,bool> memo;
int n;
char *f,*l;
string tmp;
bool *tf;
bool DFU(char s, int c){
if(c == 0){
if(s == f[0])
return true;
else
return false;
}
for(int i=1; i<n; i++){
if(tf[i])
continue;
if(f[i] == s){
tf[i] = true;
// if(memo[tf]){
// tf[i] = false;
// continue;
// }
// memo[tf] = true;
if(DFU(l[i], c-1))
return true;
else
tf[i] = false;
}
}
}
int main(){
while(true){
cin >> n;
if(!n)
return 0;
f = new char[n];
l = new char[n];
tf = new bool[n];
for(int i=0; i<n; i++){
cin >> tmp;
f[i] = tmp[0];
l[i] = tmp[tmp.length()-1];
tf[i] = false;
}
if(DFU(l[0],n-1))
cout << "OK\n";
else
cout << "NG\n";
delete[] f;
delete[] l;
delete[] tf;
memo.clear();
}
} | a.cc: In function 'int main()':
a.cc:58:17: error: 'memo' was not declared in this scope
58 | memo.clear();
| ^~~~
a.cc: In function 'bool DFU(char, int)':
a.cc:35:1: warning: control reaches end of non-void function [-Wreturn-type]
35 | }
| ^
|
s827239520 | p00225 | C++ | #include<cstdio>
using namespace std;
bool visit[26],g[26][26];
bool dfs(int v){
visit[v] = true;
bool f = false;
for(int i=0;i<26;i++)
if(g[v][i]){
f = true;
if(!visit[i])dfs(i);
}
return f;
}
int graph_num(void){
int res = 0;
for(int i=0;i<26;i++)
if(!visit[i] && dfs(i))res++;
return res;
}
int main(){
int i,n,pre[26],suf[26],h,t;
while(scanf("%d",&n) && n){
for(i=0;i<26;i++){
visit[i] = false;
pre[i] = suf[i] = 0;
for(int j=0;j<26;j++)g[i][j] = false;
}
for(i=0;i<n;i++){
char s[40];
scanf("%s",s);
int len = strlen(s);
h = s[0]-'a', t = s[len-1]-'a';
pre[h]++;
suf[t]++;
g[h][t] = g[t][h] = true;
}
if(graph_num() != 1)printf("NG\n");
else{
for(i=0;i<26;i++)if(pre[i] != suf[i])break;
if(i==26)printf("OK\n");
else printf("NG\n");
}
}
} | a.cc: In function 'int main()':
a.cc:37:17: error: 'strlen' was not declared in this scope
37 | int len = strlen(s);
| ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include<cstdio>
+++ |+#include <cstring>
2 | using namespace std;
|
s941114195 | p00225 | C++ | #include <iostream>
#include <set>
#include <string>
using namespace std;
int t[26][26];
//m[hid©ç¢ÂÌm[hÉÚ®Â\©
//·ÅÉTõÏÝÌm[hÍÊçÈ¢
int reachableNode(int id,bool *used){
int res = 1;
used[id] = true;
for(int i=0;i<26;i++){
if(t[id][i] > 0 && !used[i]){
res += reachableNode(i,used);
}
}
return res;
}
int main(void){
int n;
while(cin>>n && n){
string s;
int from,to;
set<int> ap;
memset(t,0,sizeof(t));
for(int i=0;i<n;i++){
cin>>s;
from = s[0] - 'a';
to = s[s.length()-1] - 'a';
//©È[vÈOÌÓÍJEg
if(from != to){
t[from][to]++;
}
ap.insert(from);
ap.insert(to);
}
//Xªê¾¯Å é©ÌmF
bool used[26];
memset(used,0,sizeof(used));
int count = reachableNode(from,used);
if(count != ap.size()){
cout<<"NG\n";
continue;
}
//üÆoª¯¶©Ç¤©ÌmF
set<int>::iterator i = ap.begin();
for(;i!=ap.end();i++){
int in=0,out=0;
for(int j=0;j<26;j++){
in += t[j][*i];
out += t[*i][j];
}
if(in != out) break;
}
if(i == ap.end())
cout<<"OK\n";
else
cout<<"NG\n";
}
return 0;
} | a.cc: In function 'int main()':
a.cc:31:5: error: 'memset' was not declared in this scope
31 | memset(t,0,sizeof(t));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <set>
+++ |+#include <cstring>
3 | #include <string>
|
s161537662 | p00225 | C++ | #include <iostream>
#include <cstdlib>
#include <set>
#include <string>
using namespace std;
int t[26][26];
//m[hid©ç¢ÂÌm[hÉÚ®Â\©
//·ÅÉTõÏÝÌm[hÍÊçÈ¢
int reachableNode(int id,bool *used){
int res = 1;
used[id] = true;
for(int i=0;i<26;i++){
if(t[id][i] > 0 && !used[i]){
res += reachableNode(i,used);
}
}
return res;
}
int main(void){
int n;
while(cin>>n && n){
string s;
int from,to;
set<int> ap;
memset(t,0,sizeof(t));
for(int i=0;i<n;i++){
cin>>s;
from = s[0] - 'a';
to = s[s.length()-1] - 'a';
//©È[vÈOÌÓÍJEg
if(from != to){
t[from][to]++;
}
ap.insert(from);
ap.insert(to);
}
//Xªê¾¯Å é©ÌmF
bool used[26];
memset(used,0,sizeof(used));
int count = reachableNode(from,used);
if(count != ap.size()){
cout<<"NG\n";
continue;
}
//üÆoª¯¶©Ç¤©ÌmF
set<int>::iterator i = ap.begin();
for(;i!=ap.end();i++){
int in=0,out=0;
for(int j=0;j<26;j++){
in += t[j][*i];
out += t[*i][j];
}
if(in != out) break;
}
if(i == ap.end())
cout<<"OK\n";
else
cout<<"NG\n";
}
return 0;
} | a.cc: In function 'int main()':
a.cc:32:5: error: 'memset' was not declared in this scope
32 | memset(t,0,sizeof(t));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <set>
+++ |+#include <cstring>
4 | #include <string>
|
s653134894 | p00225 | C++ | #include <iostream>
#include <set>
#include <string>
using namespace std;
int t[26][26];
//ノードidからいくつのノードに移動可能か
//すでに探索済みのノードは通らない
int reachableNode(int id,bool *used){
int res = 1;
used[id] = true;
for(int i=0;i<26;i++){
if(t[id][i] > 0 && !used[i]){
res += reachableNode(i,used);
}
}
return res;
}
int main(void){
int n;
while(cin>>n && n){
string s;
int from,to;
set<int> ap;
memset(t,0,sizeof(t));
for(int i=0;i<n;i++){
cin>>s;
from = s[0] - 'a';
to = s[s.size()-1] - 'a';
//自己ループ以外の辺はカウント
if(from != to){
t[from][to]++;
}
ap.insert(from);
ap.insert(to);
}
//森が一つだけであるかの確認
bool used[26];
memset(used,0,sizeof(used));
int count = reachableNode(from,used);
if(count != ap.size()){
cout<<"NG\n";
continue;
}
//入次数と出次数が同じかどうかの確認
set<int>::iterator i = ap.begin();
for(;i!=ap.end();i++){
int in=0,out=0;
for(int j=0;j<26;j++){
in += t[j][*i];
out += t[*i][j];
}
if(in != out) break;
}
if(i == ap.end())cout<<"OK\n";
else cout<<"NG\n";
}
return 0;
} | a.cc: In function 'int main()':
a.cc:31:5: error: 'memset' was not declared in this scope
31 | memset(t,0,sizeof(t));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <set>
+++ |+#include <cstring>
3 | #include <string>
|
s392590365 | p00225 | C++ | 5
apple
yellow
georgia
king
email
7
apple
yellow
georgia
king
email
wink
lucky
0 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 5
| ^
|
s404478929 | p00225 | C++ | import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
label:for(;;){
int N=cin.nextInt();
if(N==0)break;
int[] node=new int[27];
int[][] edge=new int[27][27];
boolean[] already=new boolean[27];
Arrays.fill(already, true);
for(int i=0;i<N;i++){
String s =cin.next();
char a = s.charAt(0);
char b = s.charAt(s.length()-1);
int aa=a-'a';
int bb=b-'a';
node[aa]++;
node[bb]++;
already[aa]=already[bb]=false;
edge[aa][bb]++;
edge[bb][aa]++;
}
for(int i=0;i<27;i++){
// System.out.println(node[i]);
if(node[i]%2!=0){
System.out.println("NG");
continue label;
}
}
Stack<Integer>stack=new Stack<Integer>();
for(int i=0;i<27;i++){
if(!already[i]){
stack.add(i);
break;
}
}
while(!stack.isEmpty()){
int a = stack.pop();
if(already[a])continue;
already[a]=true;
for(int i=0;i<27;i++){
// if(edge[a][i]>=1){
// int c=edge[a][i];
// edge[a][i]=edge[i][a]=c-1;
if(edge[a][i]>0){
edge[a][i]--;
edge[i][a]--;
stack.push(i);
}
}
}
for(int i=0;i<27;i++){
if(!already[i]){
System.out.println("NG");
continue label;
}
}
System.out.println("OK");
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.Arrays;
| ^~~~~~
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.Scanner;
| ^~~~~~
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 {
| ^~~~~~
|
s037656145 | p00225 | C++ | #include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<sstream>
#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n)
using namespace std;
int in[32];
int out[32];
int main(void){
int n;
char s[128];
while(scanf("%d", &n),n){
rep(i,32) in[i] = out[i] = 0;
vector<int> x[32];
rep(i,n){
scanf("%s", s);
in[s[0]-'a']++;
out[s[strlen(s)-1]-'a']++;
x[s[0]-'a'].push_back(s[strlen(s)-1]-'a');
}
int d = 0;
rep(i,26){
if(in[i] != out[i]){
d++;
printf("%c\n", i+'a');
}
}
if(d == 0){
int use[32];
rep(i,32)use[i] = -1;
queue<char>q;
rep(i,26){
if(x[i].size() > 0){
rep(j, x[i].size()){
use[i] = 0;
q.push(x[i][j]);
}
}
}
while(!q.empty()){
int f = q.front();q.pop();
if(use[f] != -1)continue;
use[f] = 0;
rep(i, x[f].size()){
q.push(x[f][i]);
}
}
bool flg = true;
rep(i,26){
if(use[i] == -1 && x[i].size())
flg = false;
}
if(flg){
puts("OK");
}else{
puts("NG");
}
}
else{
puts("NG");
}
x.clear();
}
return 0;
} | a.cc: In function 'int main()':
a.cc:83:19: error: request for member 'clear' in 'x', which is of non-class type 'std::vector<int> [32]'
83 | x.clear();
| ^~~~~
|
s333962106 | p00225 | C++ | include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<sstream>
#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n)
using namespace std;
int in[32];
int main(void){
int n;
char s[128];
int fi,en
while(scanf("%d", &n),n){
vector<int> x[32];
rep(i,32) in[i] = out[i] = 0;
rep(i,n){
scanf("%s", s);
fi = s[0]-'a';
en = s[strlen(s)-1]-'a'
in[fi]++;
in[en]+--
x[fi].push_back(en);
}
int d = 0;
rep(i,26)
if(in[i] != 0)
d++;
if(d == 0){
int use[32];
rep(i,32)use[i] = -1;
queue<char>q;
rep(i,26){
if(x[i].size() > 0){
use[i] = 0;
rep(j, x[i].size()){
q.push(x[i][j]);
}
break;
}
}
while(!q.empty()){
int f = q.front();q.pop();
if(use[f] != -1)continue;
use[f] = 0;
rep(i, x[f].size()){
q.push(x[f][i]);
}
}
bool flg = true;
rep(i,26){
if(use[i] == -1 && x[i].size())
flg = false;
}
if(flg){
puts("OK");
}else{
puts("NG");
}
}
else{
puts("NG");
}
rep(i,32)x[i].clear();
}
return 0;
} | a.cc:1:1: error: 'include' does not name a type
1 | include<cstdio>
| ^~~~~~~
In file included from /usr/include/c++/14/cmath:45,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/bits/specfun.h:43,
from /usr/include/c++/14/cmath:3906:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
In file included from /usr/include/stdlib.h:32,
from /usr/include/c++/14/bits/std_abs.h:38,
from /usr/include/c++/14/cmath:49:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:65:
/usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type
125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
+++ |+#include <cstddef>
1 | // Types used in iterator implementation -*- C++ -*-
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type
214 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type
225 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_algobase.h:66:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type
112 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
65 | #include <debug/assertions.h>
+++ |+#include <cstddef>
66 | #include <bits/stl_iterator_base_types.h>
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type
118 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_iterator.h:67,
from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/p |
s019398614 | p00226 | C | #include<iostream>
using namespace std;
int main(){
int a,b;
while(cin>>a>>b,a|b){
int c[50]={},z=0,x=0;
for(int i=0;i<4;i++){
if(a%10==b%10)z++;
c[a%10] |= 1;c[b%10] |= 2;
a/=10; b/=10;
}
for(int i=0;i<10;i++){
if(c[i]==3)x++;
}
x-=z;
cout<<z<<' '<<x<<endl;
}
return 0;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s471971483 | p00226 | C | #include<iostream>
using namespace std;
int main(){
int a,b;
while(cin>>a>>b,a|b){
int c[10]={},z=0,x=0;
for(int i=0;i<4;i++){
if(a%10==b%10)z++;
c[a%10] |= 1;c[b%10] |= 2;
a/=10; b/=10;
}
for(int i=0;i<10;i++){
if(c[i]==3)x++;
}
x-=z;
cout<<z<<' '<<x<<endl;
}
return 0;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s751695139 | p00226 | C | #include<iostream>
using namespace std;
int main(){
int a,b;
while(cin>>a>>b,a|b){
int c[10]={},z=0,x=0;
for(int i=0;i<4;i++){
if(a%10==b%10)z++;
c[a%10]/= 1;c[b%10] |= 2;
a/=10;b/=10;
}
for(int i=0;i<10;i++){
if(c[i]==3)x++;
}
x-=z;
cout<<z<<' '<<x<<endl;
}
return 0;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s668448371 | p00226 | C | #include<iostream>
using namespace std;
int main(){
int a,b;
while(cin>>a>>b,a|b){
int c[10]={},d=0,f=0;
for(int i=0;i<4;i++){
if(a%10==b%10)d++;
c[a%10] |=1;
c[b%10] |=2;
a/=10;
b/=10;
}
for(int i=0;i<10;i++){if(c[i]==3)f++;}f-=d;
cout<<d<<' '<<f<<endl;
}
return 0;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s606731116 | p00226 | C | #include<iostream>
using namespace std;
int main(){
int a,b;
while(cin>>a>>b,a|b){
int c[10]={},d=0,f=0;
for(int i=0;i<4;i++){
if(a%10==b%10)d++;
c[a%10] |=1;
c[b%10] |=2;
a/=10;
b/=10;
}
for(int i=0;i<10;i++){
if(c[i]==3)f++;
}
f-=d;
cout<<d<<' '<<f<<endl;
}
return 0;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s423118255 | p00226 | C | #include<iostream>
using namespace std;
int main(){
int a,b;
while(cin>>a>>b,a|b){
int c[10]={},d=0,f=0;
for(int i=0;i<4;i++){
if(a%10==b%10)d++;
c[a%10] |= 1;
c[b%10] |= 2;
a/=10;
b/=10;
}
for(int i=0;i<10;i++){
if(c[i]==3)f++;
}
f-=d;
cout<<d<<' '<<f<<endl;
}
return 0;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s657757038 | p00226 | C | #include<stdio.h> #include<string.h> int main(){char x[6],a[6];int h,b,i,j;while(scanf("%s%s",x,a)!=EOF){if(strcmp(x,"0")==0 && strcmp(a,"0")==0)break;h=b=0;for(i=0;i<4;i++){if(x[i]==a[i])h++;for(j=0;j<4;j++){if(j!=i && x[i]==a[j])b++;}}printf("%d %d\n",h,b);}return 0;} | main.c:1:19: warning: extra tokens at end of #include directive
1 | #include<stdio.h> #include<string.h> int main(){char x[6],a[6];int h,b,i,j;while(scanf("%s%s",x,a)!=EOF){if(strcmp(x,"0")==0 && strcmp(a,"0")==0)break;h=b=0;for(i=0;i<4;i++){if(x[i]==a[i])h++;for(j=0;j<4;j++){if(j!=i && x[i]==a[j])b++;}}printf("%d %d\n",h,b);}return 0;}
| ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s737987932 | p00226 | C++ | #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
while(;;){
int a,b;
cin >> a >> b;
if(a==0&&b==0)return 0;
int x[4],y[4];
for(int i=0;i<4;i++){
x[i]=a%10;
a/=10;
y[i]=b%10;
b/=10;
}
int hit=0,blow=0;
for(int i=0;i<4;i++)if(x[i]==y[i])hit++;
}
for(int i=0;i<4;i++){
for(int j=0;j<4;j++)if(x[i]==y[j])blow++;
}
blow-=hit;
printf("%d %d\n",hit,blow);
} | a.cc: In function 'int main()':
a.cc:6:7: error: expected primary-expression before ';' token
6 | while(;;){
| ^
a.cc:6:7: error: expected ')' before ';' token
6 | while(;;){
| ~^
| )
a.cc:6:9: error: expected primary-expression before ')' token
6 | while(;;){
| ^
a.cc:22:24: error: 'x' was not declared in this scope
22 | for(int j=0;j<4;j++)if(x[i]==y[j])blow++;
| ^
a.cc:22:30: error: 'y' was not declared in this scope
22 | for(int j=0;j<4;j++)if(x[i]==y[j])blow++;
| ^
a.cc:22:35: error: 'blow' was not declared in this scope
22 | for(int j=0;j<4;j++)if(x[i]==y[j])blow++;
| ^~~~
a.cc:24:1: error: 'blow' was not declared in this scope
24 | blow-=hit;
| ^~~~
a.cc:24:7: error: 'hit' was not declared in this scope
24 | blow-=hit;
| ^~~
|
s006011586 | p00226 | C++ | #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
while(;;){
int a,b;
cin >> a >> b;
if(a==0&&b==0)return 0;
int x[4],y[4];
for(int i=0;i<4;i++){
x[i]=a%10;
a/=10;
y[i]=b%10;
b/=10;
}
int hit=0,blow=0;
for(int i=0;i<4;i++)if(x[i]==y[i])hit++;
for(int i=0;i<4;i++){
for(int j=0;j<4;j++)if(x[i]==y[j])blow++;
}
blow-=hit;
printf("%d %d\n",hit,blow);
} | a.cc: In function 'int main()':
a.cc:6:7: error: expected primary-expression before ';' token
6 | while(;;){
| ^
a.cc:6:7: error: expected ')' before ';' token
6 | while(;;){
| ~^
| )
a.cc:6:9: error: expected primary-expression before ')' token
6 | while(;;){
| ^
a.cc:27:2: error: expected '}' at end of input
27 | }
| ^
a.cc:5:1: note: to match this '{'
5 | {
| ^
|
s570143378 | p00226 | C++ | #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
while(;;){
int a,b;
cin >> a >> b;
if(a==0&&b==0)return 0;
int x[4],y[4];
for(int i=0;i<4;i++){
x[i]=a%10;
a/=10;
y[i]=b%10;
b/=10;
}
int hit=0,blow=0;
for(int i=0;i<4;i++)if(x[i]==y[i])hit++;
for(int i=0;i<4;i++){
for(int j=0;j<4;j++)if(x[i]==y[j])blow++;
}
blow-=hit;
printf("%d %d\n",hit,blow);
}
} | a.cc: In function 'int main()':
a.cc:6:7: error: expected primary-expression before ';' token
6 | while(;;){
| ^
a.cc:6:7: error: expected ')' before ';' token
6 | while(;;){
| ~^
| )
a.cc:6:9: error: expected primary-expression before ')' token
6 | while(;;){
| ^
|
s621088550 | p00226 | C++ | #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
while(){
int a,b;
cin >> a >> b;
if(a==0&&b==0)return 0;
int x[4],y[4];
for(int i=0;i<4;i++){
x[i]=a%10;
a/=10;
y[i]=b%10;
b/=10;
}
int hit=0,blow=0;
for(int i=0;i<4;i++)if(x[i]==y[i])hit++;
for(int i=0;i<4;i++){
for(int j=0;j<4;j++)if(x[i]==y[j])blow++;
}
blow-=hit;
printf("%d %d\n",hit,blow);
}
} | a.cc: In function 'int main()':
a.cc:6:7: error: expected primary-expression before ')' token
6 | while(){
| ^
|
s743389405 | p00226 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
int hit,brow;
char a[5],b[5];
for(;;){
hit=0,brow=0;
cin>>a>>b;
if(a[0]=='0'&&b[0]=='0')break;
for(int i=0;i<3;i++){
for(int j=i+1;j<4;j++){
if(a[i]==b[j]||b[i]==a[j])brow++;
}
}
for(int i=0;i<4;i++){
if(a[i]==b[i])hit++;
}
cout<<hit<<" "<<brow<<endl;
} | a.cc: In function 'int main()':
a.cc:21:6: error: expected '}' at end of input
21 | }
| ^
a.cc:5:11: note: to match this '{'
5 | int main(){
| ^
|
s860815991 | p00226 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
int hit,brow;
char a[5],b[5];
for(;;){
hit=0,brow=0;
cin>>a>>b;
if(a[0]=='0'&&a[1]=='\0')break;
for(int i=0;i<3;i++){
for(int j=i+1;j<4;j++){
if(a[i]==b[j]||b[i]==a[j])brow++;
}
}
for(int i=0;i<4;i++){
if(a[i]==b[i])hit++;
}
cout<<hit<<" "<<brow<<endl;
} | a.cc: In function 'int main()':
a.cc:21:6: error: expected '}' at end of input
21 | }
| ^
a.cc:5:11: note: to match this '{'
5 | int main(){
| ^
|
s138803076 | p00226 | C++ | #include<iostream>
#include<string>
using namespace std;
int main(){
//char a[10],b[10];
string a,b;
while(true){
cin>>a>>b;
if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
int x=0,y=0;
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
if(i<j)continue;
if(a[i]==b[j]){
if(i==j)x++;
else y++;
}
}
}
cout<<x<<" "<<y<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:9:51: error: no match for 'operator==' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'int')
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ~^~~
| | |
| | int
| std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::fpos<_StateT>'
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ^
In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::allocator<_CharT>'
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ^
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>'
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ^
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ^
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ^
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ^
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: mismatched types 'const _CharT*' and 'int'
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ^
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3819 | operator==(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: mismatched types 'const _CharT*' and 'std::__cxx11::basic_string<char>'
9 | if(/*strcmp(a,"0")==0&&strcmp(b,"0")==0*/a==0&&b==0)break;
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2558 | operator==(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed:
a.cc:9:53: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'cons |
s014968164 | p00226 | C++ | #include<iostream>
int main(){
int a[4],b[4],i,j,H,B;
while(std::cin>>a[0]){
for(i=0;i<4;i++){
std::cin>>a[i];
}
for(j=0;j<4;j++){
std::cin>>b[j];
}
H=0;
B=0;
for(i=0;i<4;i++){
for(j=0;j<4;j++){
if(a[i]==b[j]){
if(i==j){
H++;
}
else(){
B++;
}
}
}
}
std::cout<< H << " " << B <<std::endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:20:46: error: expected primary-expression before ')' token
20 | else(){
| ^
|
s991304379 | p00226 | C++ | #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main() {
int r, a;
while (cin >> r >> a && r > 0 && a > 0) {
vi d(4, 0), e(4, 0), n(10, 0);
rep(i, 4) {
d[i] = r % 10;
e[i] = a % 10;
n[r % 10]++;
r /= 10;
a /= 10;
}
int b = 0, h = 0;
rep(i, 4) {
if (d[i] == e[i])b++;
else if (n[e[i]] > 0)h++;
}
cout << b << " " << e << endl;
}
} | a.cc: In function 'int main()':
a.cc:51:34: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and 'vi' {aka 'std::vector<int>'})
51 | cout << b << " " << e << endl;
| ~~~~~~~~~~~~~~~~ ^~ ~
| | |
| | vi {aka std::vector<int>}
| std::basic_ostream<char>
In file included from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]'
306 | operator<<(nullptr_t)
| ^~~~~~~~
/usr/include/c++/14/ostream:306:18: note: no known conversion for argument 1 from 'vi' {aka 'std::vector<int>'} to 'std::nullptr_t'
306 | op |
s523542707 | p00226 | C++ | #include<iostream>
#include<string>
using namespace std;
string S, T, U; int a[4], b[4], h, v;
int main() {
while (cin >> S >> T) {
h = 0; b = 0;
if (S == "0") { break; }
for (int i = 0; i < 4; i++) {
U = S[i] + '0';
a[i] = stoi(U) / 10;
}
for (int i = 0; i < 4; i++) {
U = T[i] + '0';
b[i] = stoi(U) / 10;
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (a[i] == b[j]) {
if (i == j) { h++; }
else { v++; }
}
}
}
cout << h << ' ' << v << endl;
}
} | a.cc: In function 'int main()':
a.cc:7:26: error: incompatible types in assignment of 'int' to 'int [4]'
7 | h = 0; b = 0;
| ~~^~~
|
s329181408 | p00226 | C++ | #include<iostream>
#include<string>
using namespace std;
string S, T, U; int a[4], b[4], h, v;
int main() {
while (cin >> S >> T) {
h = 0; b = 0;
if (S == "0") { break; }
for (int i = 0; i < 4; i++) {
U = S[i] + '0';
a[i] = stoi(U) / 10;
}
for (int i = 0; i < 4; i++) {
U = T[i] + '0';
b[i] = stoi(U) / 10;
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (a[i] == b[j]) {
if (i == j) { h++; }
else { v++; }
}
}
}
cout << h << ' ' << v << endl;
}
} | a.cc: In function 'int main()':
a.cc:7:26: error: incompatible types in assignment of 'int' to 'int [4]'
7 | h = 0; b = 0;
| ~~^~~
|
s081969908 | p00226 | C++ | #include <stdio.h>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
char a[4], b[4]; int hit, blow;
int main() {
while (true) {
scanf("%s %s", a, b);
if (strlen(a) == 1 && strlen(b) == 1) break;
hit = 0; blow = 0;
for (int i = 0; i < 4; i++) {
if (a[i] == b[i]) hit++;
for (int j = 0; j < 4; j++) {
if (i != j && a[i] == b[j]) {
blow++; break;
}
}
}
printf("%d %d\n", hit, blow);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:9:21: error: 'strlen' was not declared in this scope
9 | if (strlen(a) == 1 && strlen(b) == 1) break;
| ^~~~~~
a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <algorithm>
+++ |+#include <cstring>
3 | #pragma warning(disable : 4996)
|
s010294745 | p00226 | C++ | #include<iostream>
using namespace std;
int main(){
char qwe[6],ans[6];
int hit,blow,count;
cin >> qwe >> ans;
while(hit == 4){
hit = 0 ;
blow = 0;
for(int i=0; i<4; i++){
for(int g=0; g<4; g++){
if(qwe[i] == ans[g]){
if(i == g)
hit++;
else
blow++;
}
}
}
cout << hit << " " << blow << endl;
count++
}
while(hit == 4 || count == 0){
hit = 0 ;
blow = 0;
for(int i=0; i<4; i++){
for(int g=0; g<4; g++){
if(qwe[i] == ans[g]){
if(i == g)
hit++;
else
blow++;
}
}
}
cout << hit << " " << blow << endl;
count--;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:31:11: error: expected ';' before '}' token
31 | count++
| ^
| ;
32 | }
| ~
|
s150402875 | p00226 | C++ | #include <iostream>
#include <cstring>
using namespace std;
int main(){
int length = 4
char[length+1] taroNomber;
char[length+1] hanakoNomber;
int hitCount = 0;
int blowCount = 0;
while(true){
cin >> taroNomber;
cin >> hanakoNomber;
hitCount = 0;
blowCount = 0;
if(strlen(taroNomber)==1){
break;
}
for(int i=0;i<length;i++){
for(int j=0;j<length;j++){
if(taroNomber[i]==hanakoNomber[j]){
if(i==j){
hitCount++;
break;
}else{
blowCount++;
break;
}
}
}
}
cout << hitCount << ' ' << blowCount << '\n';
}
return 0;
} | a.cc: In function 'int main()':
a.cc:7:9: error: expected ',' or ';' before 'char'
7 | char[length+1] taroNomber;
| ^~~~
a.cc:8:20: error: expected ']' before '+' token
8 | char[length+1] hanakoNomber;
| ^
| ]
a.cc:8:13: error: structured binding declaration cannot have type 'char'
8 | char[length+1] hanakoNomber;
| ^
a.cc:8:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:8:14: error: conflicting declaration 'auto length'
8 | char[length+1] hanakoNomber;
| ^~~~~~
a.cc:6:13: note: previous declaration as 'int length'
6 | int length = 4
| ^~~~~~
a.cc:8:24: error: expected initializer before 'hanakoNomber'
8 | char[length+1] hanakoNomber;
| ^~~~~~~~~~~~
a.cc:12:24: error: 'taroNomber' was not declared in this scope
12 | cin >> taroNomber;
| ^~~~~~~~~~
a.cc:13:24: error: 'hanakoNomber' was not declared in this scope
13 | cin >> hanakoNomber;
| ^~~~~~~~~~~~
|
s721774034 | p00226 | C++ | #include<iostream>
#include<cstring>
using namespace std;
int hit(char* s1,char* s2){
int n=0;
for(int i=0;i<4);i++){
if(s1[i]==s2[i]){
n++:
}
}
return n;
}
int blow(char* s1,char* s2){
int n=0;
for(int i=0;i<4;i++){
if(s1[i]==s2[0]){
n++:
}
if(s1[i]==s2[1]){
n++:
}
if(s1[i]==s2[2]){
n++:
}
if(s1[i]==s2[3]){
n++:
}
}
return n;
}
int main{
char r[5],a[5];
for(int i=0;i<100;i++){
cin>>r;cin>>a;
if(r==0&&a==0){
i=101;
}
else{
cout<<<hit(r,a)<<' '<<blow(r,a)<<endl;
}
}
return 0;
} | a.cc: In function 'int hit(char*, char*)':
a.cc:7:24: error: expected ';' before ')' token
7 | for(int i=0;i<4);i++){
| ^
| ;
a.cc:7:26: error: 'i' was not declared in this scope
7 | for(int i=0;i<4);i++){
| ^
a.cc: In function 'int blow(char*, char*)':
a.cc:19:20: error: expected ';' before ':' token
19 | n++:
| ^
| ;
a.cc:22:20: error: expected ';' before ':' token
22 | n++:
| ^
| ;
a.cc:25:20: error: expected ';' before ':' token
25 | n++:
| ^
| ;
a.cc:28:20: error: expected ';' before ':' token
28 | n++:
| ^
| ;
a.cc: At global scope:
a.cc:34:5: error: cannot declare '::main' to be a global variable
34 | int main{
| ^~~~
a.cc:35:9: error: expected primary-expression before 'char'
35 | char r[5],a[5];
| ^~~~
a.cc:35:9: error: expected '}' before 'char'
a.cc:34:9: note: to match this '{'
34 | int main{
| ^
a.cc:36:9: error: expected unqualified-id before 'for'
36 | for(int i=0;i<100;i++){
| ^~~
a.cc:36:21: error: 'i' does not name a type
36 | for(int i=0;i<100;i++){
| ^
a.cc:36:27: error: 'i' does not name a type
36 | for(int i=0;i<100;i++){
| ^
a.cc:45:1: error: expected unqualified-id before 'return'
45 | return 0;
| ^~~~~~
a.cc:46:1: error: expected declaration before '}' token
46 | }
| ^
|
s117325214 | p00226 | C++ | #include<iostream>
#include<cstring>
using namespace std;
int main()
{
while{
char stra[10], strb[10];
int hit,bro;
cin>>stra>>strb;
for(int i=0;i<4;i++){
if(stra[i]==strb[i]){
hit++;}
for(int j=0;j<4;j++){
if(stra[i]==strb[j])
bro++;}
}
if(stra==0&&strb==0){break;}
bro=bro-hit;
cout<<hit<<' '<<bro<<'\n';
}
return 0;} | a.cc: In function 'int main()':
a.cc:7:6: error: expected '(' before '{' token
7 | while{
| ^
| (
a.cc:7:6: error: expected primary-expression before '{' token
a.cc:7:6: error: expected ')' before '{' token
7 | while{
| ^
| )
|
s598516310 | p00226 | C++ | #include<string>
using namespace std;
int main(){
while(1){
string stra,strb;
cin>>stra>>strb;
int h=0,b=0;
if((stra=="0")&&(strb=="0")){
break;}
for(int i=0;i<4;i++){
if(stra[i]==strb[i]){
h++;
}
for(int j=0;j<4;j++){
if(stra[i]==strb[j]){
b++;
}
}
}
b=b-h;
cout<<h<<' '<<b<<'\n';
}
return 0;
} | a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope
7 | cin>>stra>>strb;
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include<string>
+++ |+#include <iostream>
2 | using namespace std;
a.cc:25:3: error: 'cout' was not declared in this scope
25 | cout<<h<<' '<<b<<'\n';
| ^~~~
a.cc:25:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s746492326 | p00226 | C++ | #include<string>
using namespace std;
int main(){
while(1){
string stra,strb;
cin>>stra>>strb;
int h=0,b=0;
if((stra=="0")&&(strb=="0")){
break;}
for(int i=0;i<4;i++){
if(stra[i]==strb[i]){
h++;
}
for(int j=0;j<4;j++){
if(stra[i]==strb[j]){
b++;
}
}
}
b=b-h;
cout<<h<<' '<<b<<'\n';
}
return 0;
} | a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope
7 | cin>>stra>>strb;
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include<string>
+++ |+#include <iostream>
2 | using namespace std;
a.cc:25:3: error: 'cout' was not declared in this scope
25 | cout<<h<<' '<<b<<'\n';
| ^~~~
a.cc:25:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s898465827 | p00226 | C++ | #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
char buf[10];
int main() {
int a[4], b[4];
while (gets(buf), strcmp(buf, "0 0")) {
char*s = buf;
rep(i, 4) { sscanf(s, "%1d", &a[i]); s += 1; }s += 1;
rep(i, 4) { sscanf(s, "%1d", &b[i]); s += 1; }
int hit = 0, blow = 0;
rep(i, 4)if (a[i] == b[i])hit++;
rep(i, 4) if (find(a, a + 4, b[i]) != a + 4)blow++;
cout << hit << ' ' << blow - hit << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:8:16: error: 'gets' was not declared in this scope; did you mean 'getw'?
8 | while (gets(buf), strcmp(buf, "0 0")) {
| ^~~~
| getw
|
s032903235 | p00226 | C++ | #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
char buf[10];
int main() {
int a[4], b[4];
while (gets_s(buf), strcmp(buf, "0 0")) {
char*s = buf;
rep(i, 4) { sscanf(s, "%1d", &a[i]); s += 1; }s += 1;
rep(i, 4) { sscanf(s, "%1d", &b[i]); s += 1; }
int hit = 0, blow = 0;
rep(i, 4)if (a[i] == b[i])hit++;
rep(i, 4) if (find(a, a + 4, b[i]) != a + 4)blow++;
cout << hit << ' ' << blow - hit << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:8:16: error: 'gets_s' was not declared in this scope; did you mean 'getsid'?
8 | while (gets_s(buf), strcmp(buf, "0 0")) {
| ^~~~~~
| getsid
|
s817025758 | p00226 | C++ | <?php
for( $loop_cnt = 0;12000 > $loop_cnt; $loop_cnt++ )
{
$input = explode(" ", trim(fgets(STDIN)));
if( 0 == $input[0] &&
0 == $input[1]
)
{
break;
}
$r = str_split($input[0]);
$a = str_split($input[1]);
$hit = 0;
$brow = 0;
$loop_r = 0;
foreach( $r as $r_char )
{
$loop_a = 0;
foreach($a as $a_char)
{
if($r_char == $a_char)
{
if($loop_r == $loop_a)
{
$hit++;
}
else
{
$brow++;
}
break;
}
$loop_a++;
}
$loop_r++;
}
echo $hit . " " . $brow . "\n";
}
?>
| a.cc:1:1: error: expected unqualified-id before '<' token
1 | <?php
| ^
a.cc:2:28: error: expected unqualified-id before numeric constant
2 | for( $loop_cnt = 0;12000 > $loop_cnt; $loop_cnt++ )
| ^~~~~
a.cc:2:47: error: '$loop_cnt' does not name a type
2 | for( $loop_cnt = 0;12000 > $loop_cnt; $loop_cnt++ )
| ^~~~~~~~~
a.cc:41:1: error: expected unqualified-id before '?' token
41 | ?>
| ^
|
s033652518 | p00226 | C++ | <?php
for( $loop_cnt = 0;12000 > $loop_cnt; $loop_cnt++ )
{
$input = explode(" ", trim(fgets(STDIN)));
if( 0 == $input[0] &&
0 == $input[1]
)
{
break;
}
$r = str_split($input[0]);
$a = str_split($input[1]);
$hit = 0;
$brow = 0;
$loop_r = 0;
foreach( $r as $r_char )
{
$loop_a = 0;
foreach($a as $a_char)
{
if($r_char == $a_char)
{
if($loop_r == $loop_a)
{
$hit++;
}
else
{
$brow++;
}
break;
}
$loop_a++;
}
$loop_r++;
}
echo $hit . " " . $brow . "\n";
}
?>
| a.cc:1:1: error: expected unqualified-id before '<' token
1 | <?php
| ^
a.cc:2:28: error: expected unqualified-id before numeric constant
2 | for( $loop_cnt = 0;12000 > $loop_cnt; $loop_cnt++ )
| ^~~~~
a.cc:2:47: error: '$loop_cnt' does not name a type
2 | for( $loop_cnt = 0;12000 > $loop_cnt; $loop_cnt++ )
| ^~~~~~~~~
a.cc:41:1: error: expected unqualified-id before '?' token
41 | ?>
| ^
|
s651041115 | p00226 | C++ | #include <iostream>
#include <string>
using namespace std;
int main() {
string r, a;
while(cin >> r >> a , r || a){
int hit = 0, blow = 0;
for(int i=0; i < 4; i++){
for(int j=0; j<4; j++){
if(r[i] == a[j]){
if(i == j){
hit++;
}else{
blow++;
}
}
}
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:7:33: error: no match for 'operator||' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
7 | while(cin >> r >> a , r || a){
| ~ ^~ ~
| | |
| | basic_string<[...]>
| basic_string<[...]>
a.cc:7:33: note: candidate: 'operator||(bool, bool)' (built-in)
7 | while(cin >> r >> a , r || a){
| ~~^~~~
a.cc:7:33: note: no known conversion for argument 2 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'bool'
|
s047245100 | p00226 | C++ | #include <iostream>
#include <string>
using namespace std;
int main() {
string r, a;
while(cin >> r >> a, ans=="0" && forecast=="0"){
int hit = 0, blow = 0;
for(int i=0; i < 4; i++){
for(int j=0; j<4; j++){
if(r[i] == a[j]){
if(i == j){
hit++;
}else{
blow++;
}
}
}
}
cout << hit << " " << blow << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:7:30: error: 'ans' was not declared in this scope; did you mean 'abs'?
7 | while(cin >> r >> a, ans=="0" && forecast=="0"){
| ^~~
| abs
a.cc:7:42: error: 'forecast' was not declared in this scope
7 | while(cin >> r >> a, ans=="0" && forecast=="0"){
| ^~~~~~~~
|
s111498310 | p00226 | C++ | char a[17]="0 0";main(i,j){for(;a[2]=*a=48,scanf("%[^\n]\n",a+5),a[8];puts(a)){for(i=4;++i<9;)for(j=4;++j<9;)a[j+5]-a[i]||a[(i!=j)*2]++;}i=0;} | a.cc:1:22: error: expected constructor, destructor, or type conversion before '(' token
1 | char a[17]="0 0";main(i,j){for(;a[2]=*a=48,scanf("%[^\n]\n",a+5),a[8];puts(a)){for(i=4;++i<9;)for(j=4;++j<9;)a[j+5]-a[i]||a[(i!=j)*2]++;}i=0;}
| ^
|
s006082981 | p00226 | C++ | #include<iostream>
int main(){
while(1){
int a,b;
std::cin>>a>>b;
if(a==0&&b==0)break;
std::vector<int> vec(4);
std::vector<int> vec2(4);
int n=1000;
for(int i=0;i<4;i++){
int x=a/n;
int y=b/n;
vec[i]=x;
vec2[i]=y;
x*=n;
y*=n;
a-=x;
b-=y;
n/=10;
}
int c=0,d=0;
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
if(vec[i]==vec2[j]){
if(i==j)c++;
else d++;
}
}
}
std::cout<<c<<" "<<d<<std::endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:7:22: error: 'vector' is not a member of 'std'
7 | std::vector<int> vec(4);
| ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
1 | #include<iostream>
+++ |+#include <vector>
2 | int main(){
a.cc:7:29: error: expected primary-expression before 'int'
7 | std::vector<int> vec(4);
| ^~~
a.cc:8:22: error: 'vector' is not a member of 'std'
8 | std::vector<int> vec2(4);
| ^~~~~~
a.cc:8:22: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:8:29: error: expected primary-expression before 'int'
8 | std::vector<int> vec2(4);
| ^~~
a.cc:13:25: error: 'vec' was not declared in this scope
13 | vec[i]=x;
| ^~~
a.cc:14:25: error: 'vec2' was not declared in this scope
14 | vec2[i]=y;
| ^~~~
a.cc:24:36: error: 'vec' was not declared in this scope
24 | if(vec[i]==vec2[j]){
| ^~~
a.cc:24:44: error: 'vec2' was not declared in this scope
24 | if(vec[i]==vec2[j]){
| ^~~~
|
s174099973 | p00226 | C++ | #include<iostream>
int main(){
while(1){
int a,b;
std::cin>>a>>b;
if(a==0&&b==0)break;
std::vector<int> vec(4);
std::vector<int> vec2(4);
int n=1000;
for(int i=0;i<4;i++){
int x=a/n;
int y=b/n;
vec[i]=x;
vec2[i]=y;
x*=n;
y*=n;
a-=x;
b-=y;
n/=10;
}
int c=0,d=0;
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
if(vec[i]==vec2[j]){
if(i==j)c++;
else d++;
}
}
}
std::cout<<c<<" "<<d<<std::endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:7:22: error: 'vector' is not a member of 'std'
7 | std::vector<int> vec(4);
| ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
1 | #include<iostream>
+++ |+#include <vector>
2 | int main(){
a.cc:7:29: error: expected primary-expression before 'int'
7 | std::vector<int> vec(4);
| ^~~
a.cc:8:22: error: 'vector' is not a member of 'std'
8 | std::vector<int> vec2(4);
| ^~~~~~
a.cc:8:22: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:8:29: error: expected primary-expression before 'int'
8 | std::vector<int> vec2(4);
| ^~~
a.cc:13:25: error: 'vec' was not declared in this scope
13 | vec[i]=x;
| ^~~
a.cc:14:25: error: 'vec2' was not declared in this scope
14 | vec2[i]=y;
| ^~~~
a.cc:24:36: error: 'vec' was not declared in this scope
24 | if(vec[i]==vec2[j]){
| ^~~
a.cc:24:44: error: 'vec2' was not declared in this scope
24 | if(vec[i]==vec2[j]){
| ^~~~
|
s555113862 | p00226 | C++ | #include<stdio.h>
void main(){
int i,j,hit,blow;
int a,b,d;
int aa[4],bb[4];
while(1){
d=1000;
hit=0;
blow=0;
scanf("%d %d",&a,&b);
if(a==0 && b==0) break;
for(i=0;i<4;i++){
aa[i]=a/d;
a=a%d;
bb[i]=b/d;
b=b%d;
d=d/10;
}
for(i=0;i<4;i++){
if(aa[i]==bb[i]) hit++;
for(j=0;j<4;j++){
if(aa[i]==bb[j]) blow++;
}
}
printf("%d %d\n",hit,blow-hit);
}
} | a.cc:2:1: error: '::main' must return 'int'
2 | void main(){
| ^~~~
|
s364704148 | p00227 | Java | import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Thanksgiving {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
while(s.hasNextLine()) {
int purchaceCnt = s.nextInt();
int canPackCnt = s.nextInt();
s.nextLine();
String[] values = s.nextLine().split(" ");
Integer[] value = new Integer[values.length];
for(int i=0 ; i<values.length ; i++){
value[i] = new Integer(values[i]);
}
// System.out.println(" ");
System.out.println(solve(purchaceCnt, canPackCnt, value));
}
}
public static int solve(int purchaceCnt, int canPackCnt, Integer[] values) {
Arrays.sort(values, Collections.reverseOrder());
int cnt=0;
int value = 0;
for(int i=0 ; i<purchaceCnt ; i++) {
cnt++;
if(cnt==canPackCnt) {
//無料
cnt = 0;
}else {
value += values[i].intValue();
}
}
return value;
}
} | Main.java:6: error: class Thanksgiving is public, should be declared in a file named Thanksgiving.java
public class Thanksgiving {
^
Main.java:17: warning: [removal] Integer(String) in Integer has been deprecated and marked for removal
value[i] = new Integer(values[i]);
^
1 error
1 warning
|
s981526164 | p00227 | Java | import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Thanksgiving {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
while(s.hasNextLine()) {
int purchaceCnt = s.nextInt();
int canPackCnt = s.nextInt();
s.nextLine();
String[] values = s.nextLine().split(" ");
Integer[] value = new Integer[values.length];
for(int i=0 ; i<values.length ; i++){
value[i] = new Integer(values[i]);
}
System.out.println(solve(purchaceCnt, canPackCnt, value));
}
}
public static int solve(int purchaceCnt, int canPackCnt, Integer[] values) {
Arrays.sort(values, Collections.reverseOrder());
int cnt=0;
int value = 0;
for(int i=0 ; i<purchaceCnt ; i++) {
cnt++;
if(cnt==canPackCnt) {
cnt = 0;
}else {
value += values[i].intValue();
}
}
return value;
}
} | Main.java:6: error: class Thanksgiving is public, should be declared in a file named Thanksgiving.java
public class Thanksgiving {
^
Main.java:17: warning: [removal] Integer(String) in Integer has been deprecated and marked for removal
value[i] = new Integer(values[i]);
^
1 error
1 warning
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.