submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s441785582 | p00221 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
void make_pat(int count, char pat[])
{
int d = 0;
pat[0] = '\0';
if (count % 3 == 0){
d = 1;
strcat(pat, "Fizz");
}
if (count % 5 == 0){
d = 1;
strcat(pat, "Buzz");
}
if (d == 0){
itoa(count, pat, 10);
}
}
int main(void)
{
int n; // ¾ñ
int m; // lÌ
char flag[1000];
char in[100];
char pat[100];
while (1){
bool end_flag = false;
memset(flag, 1, 1000);
scanf("%d%d", &m, &n);
if (m == 0 || n == 0){
break;
}
int check = 0;
for (int i = 0; i < n; i++){
scanf("%s", in);
int tmp = check;
while (flag[check] == 0){
check = (check + 1) % m;
if (check == tmp) {
end_flag = true;
break;
}
}
if (end_flag == true){
continue;
}
make_pat(i + 1, pat);
if (strcmp(pat, in) != 0){
flag[check] = 0;
}
check = (check + 1) % m;
}
for (int i = 0; i < m; i++){
if (flag[i] == 1){
printf("%d ", i + 1);
}
}
puts("");
}
return (0);
} | a.cc: In function 'void make_pat(int, char*)':
a.cc:19:17: error: 'itoa' was not declared in this scope
19 | itoa(count, pat, 10);
| ^~~~
|
s963917146 | p00221 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
void make_pat(int count, char pat[])
{
int d = 0;
pat[0] = '\0';
if (count % 3 == 0){
d = 1;
strcat(pat, "Fizz");
}
if (count % 5 == 0){
d = 1;
strcat(pat, "Buzz");
}
if (d == 0){
itoa(count, pat, 10);
}
}
int main(void)
{
int n; // ¾ñ
int m; // lÌ
char flag[1000];
char in[100];
char pat[100];
while (1){
bool end_flag = false;
memset(flag, 1, 1000);
scanf("%d%d", &m, &n);
if (m == 0 || n == 0){
break;
}
int check = 0;
for (int i = 0; i < n; i++){
scanf("%s", in);
int tmp = check;
while (flag[check] == 0){
check = (check + 1) % m;
if (check == tmp) {
end_flag = true;
break;
}
}
if (end_flag == true){
continue;
}
make_pat(i + 1, pat);
if (strcmp(pat, in) != 0){
flag[check] = 0;
}
check = (check + 1) % m;
}
for (int i = 0; i < m; i++){
if (flag[i] == 1){
printf("%d ", i + 1);
}
}
puts("");
}
return (0);
} | a.cc: In function 'void make_pat(int, char*)':
a.cc:19:17: error: 'itoa' was not declared in this scope
19 | itoa(count, pat, 10);
| ^~~~
|
s584284343 | p00221 | C++ | #include<iostream>
struct person{
int num;
struct person *prev;
struct person *next;
};
struct person *head,*p,*now;
int m,n;
char s[10];
void set(){
for(int i=0; i<m; i++){
p[i].num = i+1;
p[i].prev = p+i-1;
p[i].next = p+i+1;
}
p[0].prev = p+m-1;
p[m-1].next = p;
}
void del(struct person *a){
(a->prev)->next = a->next;
(a->next)->prev = a->prev;
if(a == head)
head = a->next;
}
void show(struct person *a){
std::cout << a->num;
if(a->next == head)
return;
else{
std::cout << ' ';
show(a->next);
}
}
int main(){
while(true){
std::cin >> m >> n;
if(!n && !m)
return 0;
p = new struct person[m];
head = p;
now = head;
set();
for(int i=0; i<n; i++){
std::cin >> s;
if(now == now->next){
continue;
}else if((i+1)%15 == 0){
if(strcmp(s,"FizzBuzz") != 0)
del(now);
}else if((i+1)%3 == 0){
if(strcmp(s,"Fizz") != 0)
del(now);
}else if((i+1)%5 == 0){
if(strcmp(s,"Buzz") != 0)
del(now);
}
now = now->next;
}
show(head);
std::cout << std::endl;
delete[] p;
}
} | a.cc: In function 'int main()':
a.cc:54:36: error: 'strcmp' was not declared in this scope
54 | if(strcmp(s,"FizzBuzz") != 0)
| ^~~~~~
a.cc:2:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include<iostream>
+++ |+#include <cstring>
2 |
a.cc:57:36: error: 'strcmp' was not declared in this scope
57 | if(strcmp(s,"Fizz") != 0)
| ^~~~~~
a.cc:57:36: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:60:36: error: 'strcmp' was not declared in this scope
60 | if(strcmp(s,"Buzz") != 0)
| ^~~~~~
a.cc:60:36: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s769250727 | p00221 | C++ | #include<iostream>
#include<string>
#include<sstream>
using namespace std;
int main(){
int m,n,i,p[999],q;
string s;
stringstream t;
while(cin>>m>>n,m|n){
for(i=0;i++<m;)p[i-1]=i;
for(q=m,i=1;n-->0;){
cin>>s;
if(q==1)continue;
t.str("");
if(i%3&&i%5){
t<<i;
}else{
if(!(i%3))t<<"Fizz";
if(!(i%5))t<<"Buzz";
}
if(s!=t.str()){p[(i-1)%m]=-1;q--;}
for(i++;!~p[(i-1)%m];)i++;
}
for(i=0;i<m;i++){
if(!~p[i])continue;
cout<<p[i];
if(q-->0)cout<<" ";
}
cout<<endl;
}}#include<iostream>
#include<string>
#include<sstream>
using namespace std;int main(){int m,n,i,p[999],q;string s;stringstream t;while(cin>>m>>n,m|n){for(i=0;i++<m;)p[i-1]=i;for(q=m,i=1;n-->0;){cin>>s;if(q==1)continue;t.str("");if(i%3&&i%5){t<<i;}else{if(!(i%3))t<<"Fizz";if(!(i%5))t<<"Buzz";}if(s!=t.str()){p[(i-1)%m]=-1;q--;}for(i++;!~p[(i-1)%m];)i++;}for(i=0;i<m;i++){if(!~p[i])continue;cout<<p[i];if(q-->0)cout<<" ";}cout<<endl;}} | a.cc:34:3: error: stray '#' in program
34 | }}#include<iostream>
| ^
a.cc:34:4: error: 'include' does not name a type
34 | }}#include<iostream>
| ^~~~~~~
a.cc:37:25: error: redefinition of 'int main()'
37 | using namespace std;int main(){int m,n,i,p[999],q;string s;stringstream t;while(cin>>m>>n,m|n){for(i=0;i++<m;)p[i-1]=i;for(q=m,i=1;n-->0;){cin>>s;if(q==1)continue;t.str("");if(i%3&&i%5){t<<i;}else{if(!(i%3))t<<"Fizz";if(!(i%5))t<<"Buzz";}if(s!=t.str()){p[(i-1)%m]=-1;q--;}for(i++;!~p[(i-1)%m];)i++;}for(i=0;i<m;i++){if(!~p[i])continue;cout<<p[i];if(q-->0)cout<<" ";}cout<<endl;}}
| ^~~~
a.cc:5:5: note: 'int main()' previously defined here
5 | int main(){
| ^~~~
|
s783175064 | p00221 | C++ | #include<stdio.h>
#include<list>
int main(){
using namespace std;
int i,n,m;
char opn[10],ans[10];
bool ff,bf;
list<int> player;
list<int>::iterator it,nx;
do{
scanf("%d %d",&m,&n);
if(!m&&!n) break;
for(i=0;i<m;i++) player.push_back(i+1);
for(i=0,it=player.begin();i<n&&player.size()>1;i++){
scanf("%s",opn);
ff=(i+1)%3==0,bf=(i+1)%5==0;
if(ff||bf){
sprintf(ans,"%s%s",ff?"Fizz":"",bf?"Buzz":"");
}else{
sprintf(ans,"%d",i+1);
}
if(strcmp(ans,opn)){
it=player.erase(it);
}else{
it++;
}
if(it==player.end()) it=player.begin();
}
it=player.begin();
while(it!=player.end()){
printf("%d",*it);
it++;
if(it!=player.end()) printf(" ");
}
printf("\n");
player.clear();
}while(1);
return 0;
} | a.cc: In function 'int main()':
a.cc:23:10: error: 'strcmp' was not declared in this scope
23 | if(strcmp(ans,opn)){
| ^~~~~~
a.cc:3:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<list>
+++ |+#include <cstring>
3 |
|
s483469047 | p00221 | C++ | #include<cstdio>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
using namespace std;
bool judge(const int x,const char str[]){
char ans[10];
if(x%3 ==0 && x%5 == 0)
strcpy(ans,"FizzBuzz");
else if(x%3==0)
strcpy(ans,"Fizz");
else if(x%5==0)
strcpy(ans,"Buzz");
else
sprintf(ans,"%d",x);
/*
cout << "judge" << endl;
cout << "-" << str << "-" << endl;
cout << "-" << ans << "-" << endl;
*/
if( strcmp(ans,str) )return false;
return true;
}
int main(void){
int m,n;
while(scanf("%d%d", &m, &n) && m != 0 && n != 0){
queue<int> Q;
char str[10];
vector<int> ans;
/*
if(judge(1,"1\0") )
cout << "true" << endl;
else
cout << "false" << endl;
*/
for(int i = 1; i <= m; i++)
Q.push(i);
for(int i = 1; i <= n; i++){
// cout << "top" << Q.front() << endl;
scanf("%s", str);
if( judge(i,str) ){
// cout << "³" << endl;
Q.push(Q.front());
Q.pop();
}else{
Q.pop();
}
}
while(!Q.empty()){
ans.push_back(Q.front());
Q.pop();
}
sort(ans.begin(),ans.end());
for(int i = 0; i < ans.size(); i++){
printf("%d%s",ans[i],i==ans.size()-1?"\n":" ");
}
}
return 0;
} | a.cc: In function 'bool judge(int, const char*)':
a.cc:14:17: error: 'strcpy' was not declared in this scope
14 | strcpy(ans,"FizzBuzz");
| ^~~~~~
a.cc:6:1: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
5 | #include<queue>
+++ |+#include <cstring>
6 |
a.cc:16:17: error: 'strcpy' was not declared in this scope
16 | strcpy(ans,"Fizz");
| ^~~~~~
a.cc:16:17: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:18:17: error: 'strcpy' was not declared in this scope
18 | strcpy(ans,"Buzz");
| ^~~~~~
a.cc:18:17: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:27:13: error: 'strcmp' was not declared in this scope
27 | if( strcmp(ans,str) )return false;
| ^~~~~~
a.cc:27:13: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc: In function 'int main()':
a.cc:63:17: error: 'sort' was not declared in this scope; did you mean 'short'?
63 | sort(ans.begin(),ans.end());
| ^~~~
| short
|
s820613811 | p00221 | C++ | #include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
bool judge(const int x,const char str[]){
char ans[10];
if(x%3 ==0 && x%5 == 0)
strcpy(ans,"FizzBuzz");
else if(x%3==0)
strcpy(ans,"Fizz");
else if(x%5==0)
strcpy(ans,"Buzz");
else
sprintf(ans,"%d",x);
/*
cout << "judge" << endl;
cout << "-" << str << "-" << endl;
cout << "-" << ans << "-" << endl;
*/
if( strcmp(ans,str) )return false;
return true;
}
int main(void){
int m,n;
while(scanf("%d%d", &m, &n) && m != 0 && n != 0){
queue<int> Q;
char str[10];
vector<int> ans;
/*
if(judge(1,"1\0") )
cout << "true" << endl;
else
cout << "false" << endl;
*/
for(int i = 1; i <= m; i++)
Q.push(i);
for(int i = 1; i <= n; i++){
// cout << "top" << Q.front() << endl;
scanf("%s", str);
if( judge(i,str) ){
// cout << "³" << endl;
Q.push(Q.front());
Q.pop();
}else{
Q.pop();
}
}
while(!Q.empty()){
ans.push_back(Q.front());
Q.pop();
}
sort(ans.begin(),ans.end());
for(int i = 0; i < ans.size(); i++){
printf("%d%s",ans[i],i==ans.size()-1?"\n":" ");
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:63:17: error: 'sort' was not declared in this scope; did you mean 'short'?
63 | sort(ans.begin(),ans.end());
| ^~~~
| short
|
s211742005 | p00221 | C++ | #include <stdio.h>
#include <string.h>
void get_correct(int i,char buf[16])
{
if(i % 3 == 0 )
{
if(i% 5 == 0)
{
strcpy(buf,"FizzBuzz");
return;
}
strcpy(buf,"Fizz");
return;
}
if(i%5==0)
{
strcpy(buf,"Buzz");
return;
}
sprintf(buf,"%d",i);
}
int main(void)
{
int m,n;
int pcnt;
while(scanf("%d%d",&m,&n),m!=0 || n!=0)
{
int player[1000];
pcnt=m;
for(int i=0;i<m;i++)
{
player[i]=1;//参加中
}
int cur=0;
for(int i=1;i<=n;)
{
//if(pcnt==1)
if(player[cur]==0)//skipped
{
cur++;
cur%=m;
continue;
}
char str[16];
scanf("%*[ \n]%15[^\n]",str);
char correct[16];
get_correct(i,correct);
//printf("answer=\"%s\"\n",correct);
if(strcmp(str,correct) != 0)
{
player[cur]=0;
pcnt--;
}
else
{
//printf("correct");
}
cur++;
cur%=m;
i++;
}
for(int i=0; i<m;i++)
{
if(player[i])
printf("%d%s",i+1,i==m-1?""," ");
if(i==m-1)puts("");
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:65:48: error: expected ':' before ')' token
65 | printf("%d%s",i+1,i==m-1?""," ");
| ^
| :
a.cc:65:48: error: expected primary-expression before ')' token
|
s884871839 | p00221 | C++ | #include<iostream>
#include<string>
#include<vector>
#include<cstring>
#include<stdlib>
using namespace std;
bool mem[1001];
bool FizzBuzz(int a,string str){
if(str=="FizzBuzz"){
if(a%15==0)return true;
else return false;
}
else if(str=="Fizz"){
if(a%3==0)return true;
else return false;
}
else if(str=="Buzz"){
if(a%5==0)return true;
else return false;
}
else{
const char* ss=str.c_str();
int s=atoi(ss);
if(s==a && a%3!=0 && a%5!=0)return true;
else return false;
}
}
int main(void){
while(1){
int a,b,m,n;
vector<string> str;
cin >> m >> n;
if(m==0 && n==0)break;
fill(mem,mem+m,true);
for(a=1;a<=n;a++){
string s;
cin >> s;
str.push_back(s);
}
int j=1;
for(a=1;a<=n;a++){
if(!FizzBuzz(a,str[a]))mem[j]=false;
bool ch=true;
int jj=j;
while(ch){
if(j<m)j++;
else j=1;
if(jj=j)break;
if(mem[j]==true)ch=false;
}
if(ch==true)break;
}
bool nyu=false;
for(a=1;a<=m;a++){
if(mem[a]==true){
if(nyu==true)printf(" %d",a);
else printf("%d",a);
nyu=true;
}
}
cout << endl;
}
return 0;
} | a.cc:5:9: fatal error: stdlib: No such file or directory
5 | #include<stdlib>
| ^~~~~~~~
compilation terminated.
|
s063149448 | p00221 | C++ | #include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
int main(){
int m , n;
while(cin >> m >> n , m + n){
int p = 1;
int p_num = m;
bool exist[1001];
memset(exist,true,sizeof(exist));
for(int i=1; i<=n; i++){
string com; cin >> com;
bool ok = i%3 != 0 && i%5 != 0 ?
atoi(com.c_str()) == i :
(i%3 == 0 && com == "Fizz") ||
(i%5 == 0 && com == "Buzz") ||
(i%15 == 0 && com == "FizzBuzz");
if(!ok){
exist[p] = false;
p_num--;
}
if(p_num == 1) break;
do{
if(++p > m) p = 1;
} while(!exist[p]);
}
int i = 1;
for(i <= m; i++){
if(exist[i]) cout << i;
}
cout << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:34:20: error: expected ';' before ')' token
34 | for(i <= m; i++){
| ^
| ;
|
s572752266 | p00221 | C++ | while 1:
n = map(int,raw_input().split())
if n[0] == n[1] == 0:
break
m, o = [1 for x in range(n[0])], 0
for x in range(1,n[1]+1):
a = raw_input()
if sum(m) == 1:
pass
elif x % 15 == 0:
if a != "FizzBuzz":
m[o] = 0
elif x % 3 == 0:
if a != "Fizz":
m[o] = 0
elif x % 5 == 0:
if a != "Buzz":
m[o] = 0
else:
if a != str(x):
m[o] = 0
while 1:
o += 1
if sum(m) == 1:
break
elif o == len(m):
o = -1
elif m[o] == 1:
break
for x in range(n[0]):
if m[x] == 1:
print x+1,
print "" | a.cc:1:1: error: expected unqualified-id before 'while'
1 | while 1:
| ^~~~~
|
s523235609 | p00221 | C++ | while 1:
m, n = map(int, raw_input().split())
if not m:
break
p = range(m)
t = 0
for i in range(1, n + 1):
s = raw_input()
if(i % 15 == 0 and s != "FizzBuzz" or
i % 5 == 0 and s != "Buzz" or
i % 3 == 0 and s != "Fizz" or
i % 3 and i % 5 and s != str(i)):
p.pop(t)
else:
t = (t + 1) % len(p)
for i in range(len(p) - 1):
print p[i] + 1,
print p[len(p) - 1] + 1 | a.cc:1:1: error: expected unqualified-id before 'while'
1 | while 1:
| ^~~~~
|
s335522836 | p00221 | C++ | #include <iostream>
#include <string>
using namespace std;
void solve()
{
int m, n;
while(cin >> m >> n, m || n)
{
int count = m;
bool flag[10002];
memset(flag, 1, sizeof(flag));
string ans = "";
for(int i = 1; i <= n; ++i)
{
string speak;
cin >> speak;
if(i % 15 == 0)
{
if(speak != "FizzBuzz")
{
flag[i % m == 0 ? i % m + m : i % m] = false;
--count;
}
}
else if(i % 3 == 0)
{
if(speak != "Fizz")
{
flag[i % m == 0 ? i % m + m : i % m] = false;
--count;
}
}
else if(i % 5 == 0)
{
if(speak != "Buzz")
{
flag[i % m == 0 ? i % m + m : i % m] = false;
--count;
}
}
if(count == 1)
{
for(int j = 1; j <= m; ++j)
{
if(flag[j])
{
cout << j << endl;
goto END;
}
}
}
}
int end_pos = m;
for(int i = m; i >= 1; --i)
{
if(flag[i])
{
end_pos = i;
break;
}
}
for(int i = 1; i < end_pos; ++i)
{
if(flag[i])
{
cout << i << " ";
}
}
cout << end_pos << endl;
END:
;
}
}
int main()
{
solve();
return(0);
} | a.cc: In function 'void solve()':
a.cc:13:17: error: 'memset' was not declared in this scope
13 | memset(flag, 1, sizeof(flag));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | #include <string>
a.cc:72:1: error: jump to label 'END'
72 | END:
| ^~~
a.cc:50:54: note: from here
50 | goto END;
| ^~~
a.cc:55:21: note: crosses initialization of 'int end_pos'
55 | int end_pos = m;
| ^~~~~~~
|
s950411857 | p00221 | C++ | #include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <cctype>
using namespace std;
bool check(int turn, string str, int player)
{
if(turn%3 == 0 && turn%5 == 0){
return str == "FizzBuzz";
} else if(turn%3 == 0){
return str == "Fizz";
} else if(turn%5 == 0){
return str == "Buzz";
}
return all_of(str.begin(), str.end(), isdigit) && atoi(str.c_str()) == turn;
}
int main()
{
int n, m;
string str;
while(cin>>m>>n && n+m){
queue<int> players;
for(int i = 1; i <= m; ++i)
players.push(i);
for(int i = 1; i <= n; ++i){
cin >> str;
int player = players.front();
players.pop();
if(check(i, str, player)){
players.push(player);
}
}
}
return 0;
} | a.cc: In function 'bool check(int, std::string, int)':
a.cc:19:16: error: no matching function for call to 'all_of(std::__cxx11::basic_string<char>::iterator, std::__cxx11::basic_string<char>::iterator, <unresolved overloaded function type>)'
19 | return all_of(str.begin(), str.end(), isdigit) && atoi(str.c_str()) == turn;
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:410:5: note: candidate: 'template<class _IIter, class _Predicate> bool std::all_of(_IIter, _IIter, _Predicate)'
410 | all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
| ^~~~~~
/usr/include/c++/14/bits/stl_algo.h:410:5: note: template argument deduction/substitution failed:
a.cc:19:16: note: couldn't deduce template parameter '_Predicate'
19 | return all_of(str.begin(), str.end(), isdigit) && atoi(str.c_str()) == turn;
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:30:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Predicate> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, bool> std::all_of(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Predicate)'
30 | all_of(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred);
| ^~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:30:1: note: candidate expects 4 arguments, 3 provided
|
s672691197 | p00221 | C++ |
#include<iostream>
#include<string.h>
using namespace std;
int m,n;
char talk[1024],num[200];
int main(){
int i;
while( cin >> m >> n ){
int kill[1000] = {0};
int man = 0;
if( m == 0 && n == 0 )
break;
for( i = 1;i <= n;i++ ){
cin >> talk;
if( i % 15 == 0 )
strcpy( num,"FizzBuzz" );
else if( i % 5 == 0 )
strcpy( num,"Buzz" );
else if( i % 3 == 0 )
strcpy( num,"Fizz" );
else
itoa( i,num,10 );
if( strcmp( talk,num ) != 0 ){
kill[ man ] = 1;
}
int cnt = 0;
do{
man++;
man %= m;
cnt++;
}while( kill[ man ] && cnt < m );
if( cnt == m )
break;
}
int maxsur;
for( i = m-1;i >= 0;i-- ){
if( kill[i] == 0 ){
maxsur = i;
break;
}
}
for( i = 0;i <= maxsur;i++ ){
if( kill[i] == 0 ){
cout << i+1;
if( i < maxsur ){
cout << " ";
}
else{
cout << endl;
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:25:33: error: 'itoa' was not declared in this scope
25 | itoa( i,num,10 );
| ^~~~
|
s932107846 | p00222 | Java | //配列に入れたらTime Limit Exceededでした.
//直しても直してもTime Limit Exceededですよー!
import java.util.*;
public class Main{
static Scanner kbd = new Scanner(System.in);
static boolean[] prime = new boolean[10000001];
public static void main(String[] args){
prepare();
while(true){
int n = kbd.nextInt();
if(n==0) break;
solve(n);
}
}
static void prepare(){
prime[0] = prime[1] = false;
int i=2;
for(; i<prime.length; i++){
prime[i] = prime(i);
}
}
static void solve(int n){
while(!(prime[m] && prime[m-2] && prime[m-6] && prime[m-8])){
n--;
}
System.out.println(n);
}
static boolean prime(int a){
int k = (int)Math.sqrt(a);
for(int i=2; i<=k; i++){
if(a%i == 0) return false;
}
return true;
}
} | Main.java:31: error: cannot find symbol
while(!(prime[m] && prime[m-2] && prime[m-6] && prime[m-8])){
^
symbol: variable m
location: class Main
Main.java:31: error: cannot find symbol
while(!(prime[m] && prime[m-2] && prime[m-6] && prime[m-8])){
^
symbol: variable m
location: class Main
Main.java:31: error: cannot find symbol
while(!(prime[m] && prime[m-2] && prime[m-6] && prime[m-8])){
^
symbol: variable m
location: class Main
Main.java:31: error: cannot find symbol
while(!(prime[m] && prime[m-2] && prime[m-6] && prime[m-8])){
^
symbol: variable m
location: class Main
4 errors
|
s816541700 | p00222 | Java | package springstudy;
import java.util.*;
public class Primenumber {
static final int max=100000;
public static void main(String[] args) {
//*ここから
boolean prime[] = new boolean[max+1];
for(int i=0;i<max;i++)prime[i]=true;
prime[1]=false;
for(int i=2;i<max;i++){
if(prime[i]){
for(int s=i*2;s<=max;s+=i)prime[s]=false;
}
}
//*//ここまでエラトステネスの篩
Scanner n = new Scanner(System.in);
while(true){
int in = n.nextInt();
if(in==0)break;
for(int i=in;i>0;i--){
if(prime[i]==true&&prime[i-8]==true&&prime[i-6]==true&&prime[i-2]){
System.out.println(i);
break;
}
}
}
}
} | Main.java:3: error: class Primenumber is public, should be declared in a file named Primenumber.java
public class Primenumber {
^
1 error
|
s383445727 | p00222 | Java | import java.util.Arrays;
import java.util.Scanner;
public class Main2 {
static int MAX=10000001;
static boolean[] is=new boolean[MAX];
static{
Arrays.fill(is,true);
is[0]=is[1]=false;
for(int i=2;i*i<=is.length;i++){
if(is[i]){
for(int j=i+i;j<is.length;j+=i){
is[j]=false;
}
}
}
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
for(;;){
int n=cin.nextInt();
if(n==0)break;
if(n%2==0)n--;
for(int i=n;i>=13;i-=2){
if(is[i]){
if(is[i-2]&&is[i-6]&&is[i-8]){
System.out.println(i);
break;
}
}
}
}
}
} | Main.java:4: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2 {
^
1 error
|
s240558050 | p00222 | Java | import java.util.*;
public class p0222{
private static final int mx = 10000000;
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n;
boolean[] prime = (new boolean[mx]);
Arrays.fill(prime, true);
prime[0] = prime[1] = false;
for(int i = 2; i < mx; ++i)
if(prime[i])
for(int j = i+i; j < mx; j+=i)
prime[j] = false;
while(sc.hasNext()){
n = sc.nextInt();
if(n == 0) break;
for(int i = n; i >= 13; --i)
if(prime[i-8] && prime[i-6] && prime[i-2] && prime[i]){
System.out.println(i);
break;
}
}
}
} | Main.java:3: error: class p0222 is public, should be declared in a file named p0222.java
public class p0222{
^
1 error
|
s708184986 | p00222 | C | #include<stdio.h>
int main(void)
{
int i,j,n;
char prime[10000001];
for(i = 0;i <= 10000000;i++){
prime[i]='1';
}
for(i = 2;i <= 10000000;i++){
if(prime[i]){
for(j=i+i;j<=10000000;j+=i){
prime[j]='0';
}
}
}
while(scanf("%d",&n),n){
if(n%2==0){
n--;
}
for(i=n;i>=13;i-=2){
if(prime[i]=='1'&&prime[i-2]=='1'&&prime[i-6]=='1'&&prime[i-8]=='1') {
break;
}
}
printf("%d\n",i);
} }
return (0);
} | main.c:35:5: error: expected identifier or '(' before 'return'
35 | return (0);
| ^~~~~~
main.c:36:1: error: expected identifier or '(' before '}' token
36 | }
| ^
|
s017247756 | p00222 | C | #include<stdio.h>
#define M 10000000
char p[M]={1,1};
int main(){
int i,j,n;
for(i=2;i*i<M;i++){
if(p[i])continue;
for(j=i*i;j<M;j+=i)p[j]=1;
}
while(scanf("%d",&n),n){
for(;1;n--){
if(p[n-8]+p[n-6]+p[n-2]+p[n]==0)break;
}
printf("%d\n",n); | main.c: In function 'main':
main.c:14:5: error: expected declaration or statement at end of input
14 | printf("%d\n",n);
| ^~~~~~
main.c:14:5: error: expected declaration or statement at end of input
|
s266732810 | p00222 | C | include<stdio.h>
#include<math.h>
#define N 10000000
int main(){
int n;
int a[N];
int b;
int i, j, p;
int c[N][2];
p = 1;
while (1==1){
scanf("%d", &c[p][0]);
if(c[p][0]!=0)p++;
else break;
}
b = (int)pow(N, 0.5);
a[0] = -1;
for (i = 2; i <= b; i++){
for (j = 2; j <= N/ i; j++){
a[i*j - 1] = -1;
}
}
for (i = 1; i < p; i++){
c[i][1] = 0;
for (j = c[i][0];j>0; j--){
if (a[j - 1] != -1){
if (a[j - 2 - 1] != -1 && a[j - 6 - 1] != -1 && a[j - 8 - 1] != -1){
c[i][1] = j;
j = 0;
}
}
}
printf("%d\n", c[i][1]);
}
return 0;
} | main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
1 | include<stdio.h>
| ^
main.c: In function 'main':
main.c:13:17: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
13 | scanf("%d", &c[p][0]);
| ^~~~~
main.c:3:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
2 | #include<math.h>
+++ |+#include <stdio.h>
3 | #define N 10000000
main.c:13:17: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
13 | scanf("%d", &c[p][0]);
| ^~~~~
main.c:13:17: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:34:17: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
34 | printf("%d\n", c[i][1]);
| ^~~~~~
main.c:34:17: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:34:17: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:34:17: note: include '<stdio.h>' or provide a declaration of 'printf'
|
s541613168 | p00222 | C | include<stdio.h>
#include<math.h>
#define N 1000000
int main(){
int n;
int a[N];
int b;
int i, j, p;
int c[N][2];
p = 1;
while (1==1){
scanf("%d", &c[p][0]);
if(c[p][0]!=0)p++;
else break;
}
b = (int)pow(N, 0.5);
a[0] = -1;
for (i = 2; i <= b; i++){
for (j = 2; j <= N/ i; j++){
a[i*j - 1] = -1;
}
}
for (i = 1; i < p; i++){
c[i][1] = 0;
for (j = c[i][0];j>0; j--){
if (a[j - 1] != -1){
if (a[j - 2 - 1] != -1 && a[j - 6 - 1] != -1 && a[j - 8 - 1] != -1){
c[i][1] = j;
j = 0;
}
}
}
printf("%d\n", c[i][1]);
}
return 0;
} | main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
1 | include<stdio.h>
| ^
main.c: In function 'main':
main.c:13:17: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
13 | scanf("%d", &c[p][0]);
| ^~~~~
main.c:3:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
2 | #include<math.h>
+++ |+#include <stdio.h>
3 | #define N 1000000
main.c:13:17: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
13 | scanf("%d", &c[p][0]);
| ^~~~~
main.c:13:17: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:34:17: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
34 | printf("%d\n", c[i][1]);
| ^~~~~~
main.c:34:17: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:34:17: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:34:17: note: include '<stdio.h>' or provide a declaration of 'printf'
|
s880259989 | p00222 | C | #include<stdio.h>
#include<math.h>
#define N 10000000
int main(){
int n;
int a[N];
int b;
int i, j, p;
int c[N];
int d[N];
p = 1;
while (1==1){
scanf("%d", &c[p][0]);
if(c[p][0]!=0)p++;
else break;
}
b = (int)pow(N, 0.5);
a[0] = -1;
for (i = 2; i <= b; i++){
for (j = 2; j <= N/ i; j++){
a[i*j - 1] = -1;
}
}
for (i = 1; i < p; i++){
c[i] = 0;
for (j = c[i];j>0; j--){
if (a[j - 1] != -1){
if (a[j - 2 - 1] != -1 && a[j - 6 - 1] != -1 && a[j - 8 - 1] != -1){
d[i] = j;
j = 0;
}
}
}
printf("%d\n", d[i]);
}
return 0;
} | main.c: In function 'main':
main.c:14:34: error: subscripted value is neither array nor pointer nor vector
14 | scanf("%d", &c[p][0]);
| ^
main.c:15:24: error: subscripted value is neither array nor pointer nor vector
15 | if(c[p][0]!=0)p++;
| ^
|
s084089763 | p00222 | C | #include<stdio.h>
#include<math.h>
#define N 10000000
int main(){
int *a;
int b;
int i, j, p;
int c[1000];
int d[1000];
a = new int[N];
p = 1;
while (1==1){
scanf("%d", &c[p]);
if(c[p]!=0)p++;
else break;
}
b = (int)pow(N, 0.5);
a[0] = -1;
for (i = 2; i <= b; i++){
for (j = 2; j <= N/ i; j++){
a[i*j - 1] = -1;
}
}
for (i = 1; i < p; i++){
for (j = c[i];j>0; j--){
if (a[j - 1] != -1){
if (a[j - 2 - 1] != -1 && a[j - 6 - 1] != -1 && a[j - 8 - 1] != -1){
d[i] = j;
j = 0;
}
}
}
printf("%d\n", d[i]);
}
delete[] a;
return 0;
} | main.c: In function 'main':
main.c:11:13: error: 'new' undeclared (first use in this function)
11 | a = new int[N];
| ^~~
main.c:11:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:11:16: error: expected ';' before 'int'
11 | a = new int[N];
| ^~~~
| ;
main.c:36:9: error: 'delete' undeclared (first use in this function)
36 | delete[] a;
| ^~~~~~
main.c:36:16: error: expected expression before ']' token
36 | delete[] a;
| ^
|
s059754085 | p00222 | C | N=1e7,a['aaaa'];main(i,j){for(i=j=2;i*i<N;a[i]||j>N?j=++i:a[j+=i]++);for(;i=~scanf("%d",&N);N&&printf("%d\n",N))for(;a[N]+a[N-2]+a[N-6]+a[N-8]&&N--;);} | main.c:1:1: warning: data definition has no type or storage class
1 | N=1e7,a['aaaa'];main(i,j){for(i=j=2;i*i<N;a[i]||j>N?j=++i:a[j+=i]++);for(;i=~scanf("%d",&N);N&&printf("%d\n",N))for(;a[N]+a[N-2]+a[N-6]+a[N-8]&&N--;);}
| ^
main.c:1:1: error: type defaults to 'int' in declaration of 'N' [-Wimplicit-int]
main.c:1:9: warning: multi-character character constant [-Wmultichar]
1 | N=1e7,a['aaaa'];main(i,j){for(i=j=2;i*i<N;a[i]||j>N?j=++i:a[j+=i]++);for(;i=~scanf("%d",&N);N&&printf("%d\n",N))for(;a[N]+a[N-2]+a[N-6]+a[N-8]&&N--;);}
| ^~~~~~
main.c:1:7: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
1 | N=1e7,a['aaaa'];main(i,j){for(i=j=2;i*i<N;a[i]||j>N?j=++i:a[j+=i]++);for(;i=~scanf("%d",&N);N&&printf("%d\n",N))for(;a[N]+a[N-2]+a[N-6]+a[N-8]&&N--;);}
| ^
main.c:1:17: error: return type defaults to 'int' [-Wimplicit-int]
1 | N=1e7,a['aaaa'];main(i,j){for(i=j=2;i*i<N;a[i]||j>N?j=++i:a[j+=i]++);for(;i=~scanf("%d",&N);N&&printf("%d\n",N))for(;a[N]+a[N-2]+a[N-6]+a[N-8]&&N--;);}
| ^~~~
main.c: In function 'main':
main.c:1:17: error: type of 'i' defaults to 'int' [-Wimplicit-int]
main.c:1:17: error: type of 'j' defaults to 'int' [-Wimplicit-int]
main.c:1:78: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
1 | N=1e7,a['aaaa'];main(i,j){for(i=j=2;i*i<N;a[i]||j>N?j=++i:a[j+=i]++);for(;i=~scanf("%d",&N);N&&printf("%d\n",N))for(;a[N]+a[N-2]+a[N-6]+a[N-8]&&N--;);}
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | N=1e7,a['aaaa'];main(i,j){for(i=j=2;i*i<N;a[i]||j>N?j=++i:a[j+=i]++);for(;i=~scanf("%d",&N);N&&printf("%d\n",N))for(;a[N]+a[N-2]+a[N-6]+a[N-8]&&N--;);}
main.c:1:78: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
1 | N=1e7,a['aaaa'];main(i,j){for(i=j=2;i*i<N;a[i]||j>N?j=++i:a[j+=i]++);for(;i=~scanf("%d",&N);N&&printf("%d\n",N))for(;a[N]+a[N-2]+a[N-6]+a[N-8]&&N--;);}
| ^~~~~
main.c:1:78: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:1:96: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
1 | N=1e7,a['aaaa'];main(i,j){for(i=j=2;i*i<N;a[i]||j>N?j=++i:a[j+=i]++);for(;i=~scanf("%d",&N);N&&printf("%d\n",N))for(;a[N]+a[N-2]+a[N-6]+a[N-8]&&N--;);}
| ^~~~~~
main.c:1:96: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:1:96: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:1:96: note: include '<stdio.h>' or provide a declaration of 'printf'
|
s098323469 | p00222 | C |
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class Main {
int INF = 1 << 28;
final int N = 10000001;
boolean prime[];
LinkedList<Integer> maxp;
int[] p4;
void run() {
Scanner sc = new Scanner(System.in);
prime = new boolean[N];
maxp = new LinkedList<Integer>();
prime();
for(;;) {
int val = sc.nextInt();
if(val == 0) break;
int l = 0; int r = p4.length-1;
while(l<=r) {
int c = (l + r) / 2;
if( p4[c] < val ) l = c+1;
else if(p4[c] > val) r = c-1;
else {
l = c;
break;
}
}
// debug(p4);
if(l>p4.length-1)System.out.println(p4[r]);
else if(r<0) System.out.println(p4[l]);
else System.out.println(min(p4[l],p4[r]));
}
}
void prime() {
prime[0] = prime[1] = true;
for(int i=2;i<N;i++) if(!prime[i]){
if(i-8>=0 && (!prime[i-8] && !prime[i-6] && !prime[i-2])) {
maxp.add(i);
// debug(i);
}
for(int j=i*2;j<N;j+=i) prime[j] = true;
}
p4 = new int[maxp.size()];
int size = maxp.size();
for(int i=0;i<size;i++) p4[i] = maxp.removeFirst();
}
public static void main(String[] args) {
new Main().run();
}
void debug(Object... os) {
System.err.println(Arrays.deepToString(os));
}
} | main.c:2:1: error: unknown type name 'import'
2 | import java.util.*;
| ^~~~~~
main.c:2:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
2 | import java.util.*;
| ^
main.c:3:7: error: expected ';' before 'static'
3 | import static java.lang.Math.*;
| ^~~~~~~
| ;
main.c:3:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
3 | import static java.lang.Math.*;
| ^
main.c:4:7: error: expected ';' before 'static'
4 | import static java.util.Arrays.*;
| ^~~~~~~
| ;
main.c:4:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
4 | import static java.util.Arrays.*;
| ^
main.c:6:1: error: unknown type name 'public'
6 | public class Main {
| ^~~~~~
main.c:6:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Main'
6 | public class Main {
| ^~~~
|
s931201399 | p00222 | C++ | #include<bits/stdc++.h>
using namespace std;
int prime(int x) {
if (x < 2)return 0;
else if (x == 2) return 1;
if (x % 2 == 0) return 0;
for (int i = 3; i*i <=x; i += 2) {
if (x%i == 0) return 0;
}
return 1;
}
int main() {
int x;
while (cin>>x)) {
for(int i=x; i>=13; i--){
if (prime(i) && prime(i - 2) && prime(i - 6) && prime(i - 8)) {
printf("%d\n",i);
break;
}
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:14:23: error: expected primary-expression before ')' token
14 | while (cin>>x)) {
| ^
|
s963040269 | p00222 | C++ | #include<bits/stdc++.h>
using namespace std;
void prime() {
if (x < 2)return 0;
else if (x == 2) return 1;
if (x % 2 == 0) return 0;
for (int i = 3; i*i <=x; i += 2) {
if (x%i == 0) return 0;
}
return 1;
}
int main() {
int x;
while (cin>>x) {
prime();
if(!x)return 0;
for(int i=x; i>=13; i--){
if (prime(i) && prime(i - 2) && prime(i - 6) && prime(i - 8)) {
cout<<i<<endl;
break;
}
}
}
return 0;
}
| a.cc: In function 'void prime()':
a.cc:4:13: error: 'x' was not declared in this scope
4 | if (x < 2)return 0;
| ^
a.cc:4:26: error: return-statement with a value, in function returning 'void' [-fpermissive]
4 | if (x < 2)return 0;
| ^
a.cc:5:33: error: return-statement with a value, in function returning 'void' [-fpermissive]
5 | else if (x == 2) return 1;
| ^
a.cc:6:13: error: 'x' was not declared in this scope
6 | if (x % 2 == 0) return 0;
| ^
a.cc:6:32: error: return-statement with a value, in function returning 'void' [-fpermissive]
6 | if (x % 2 == 0) return 0;
| ^
a.cc:7:31: error: 'x' was not declared in this scope
7 | for (int i = 3; i*i <=x; i += 2) {
| ^
a.cc:8:38: error: return-statement with a value, in function returning 'void' [-fpermissive]
8 | if (x%i == 0) return 0;
| ^
a.cc:10:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
10 | return 1;
| ^
a.cc: In function 'int main()':
a.cc:18:34: error: too many arguments to function 'void prime()'
18 | if (prime(i) && prime(i - 2) && prime(i - 6) && prime(i - 8)) {
| ~~~~~^~~
a.cc:3:6: note: declared here
3 | void prime() {
| ^~~~~
a.cc:18:46: error: too many arguments to function 'void prime()'
18 | if (prime(i) && prime(i - 2) && prime(i - 6) && prime(i - 8)) {
| ~~~~~^~~~~~~
a.cc:3:6: note: declared here
3 | void prime() {
| ^~~~~
a.cc:18:34: error: could not convert 'prime()' from 'void' to 'bool'
18 | if (prime(i) && prime(i - 2) && prime(i - 6) && prime(i - 8)) {
| ~~~~~^~~
a.cc:18:46: error: could not convert 'prime()' from 'void' to 'bool'
18 | if (prime(i) && prime(i - 2) && prime(i - 6) && prime(i - 8)) {
| ~~~~~^~~~~~~
a.cc:18:62: error: too many arguments to function 'void prime()'
18 | if (prime(i) && prime(i - 2) && prime(i - 6) && prime(i - 8)) {
| ~~~~~^~~~~~~
a.cc:3:6: note: declared here
3 | void prime() {
| ^~~~~
a.cc:18:78: error: too many arguments to function 'void prime()'
18 | if (prime(i) && prime(i - 2) && prime(i - 6) && prime(i - 8)) {
| ~~~~~^~~~~~~
a.cc:3:6: note: declared here
3 | void prime() {
| ^~~~~
|
s145299339 | p00222 | C++ | public class Main{
static int N = 10000001;
public void run(java.io.InputStream in, java.io.PrintStream out){
java.util.Scanner sc = new java.util.Scanner(in);
int[] p;
int pn, i, n, a;
p = new int[N / 6];
pn = getprime(p);
for(;;){
n = sc.nextInt();
if(n == 0)break;
a = 13;
for(i = 6;p[i] <= n && i < pn;i++){
if(p[i] - p[i-1] == 2 && p[i] - p[i-2] == 6 && p[i] - p[i-3] == 8){
a = p[i];
}
}
out.println(a);
}
sc.close();
}
public static void main(String[] args){
(new Main()).run(System.in, System.out);
}
private static int getprime(int[] p){
int i, j, count = 0;
boolean[] e;
e = new boolean[N];
e[0] = true; e[1] = true;
for(i = 2;i < N;i++)if(!e[i]){
p[count++] = i;
for(j = i * 2;j < N;j+=i)e[j] = true;
}
return count;
}
} | a.cc:1:1: error: expected unqualified-id before 'public'
1 | public class Main{
| ^~~~~~
|
s874091658 | p00222 | C++ | #include<iostream>
#include<vector>
using namespace std;
vector<int> prime;
void sieve(int n){
vector<bool> is_prime(n, 1);
prime.push_back(1);
for (int i = 2; i <= n; i++) {
if(is_prime[i] == false)continue;
prime.push_back(i);
for (int j = i; j <= n; j+=i) is_prime[j] = false;
}
}
int main(int argc, char *argv[]){
sieve((int)1e7 + 100);
int n;
while(std::cin >> n, n){
int start = upper_bound(prime.begin(), prime.end(), n) -
prime.begin();
start--;
// std::cout << "n:" << n << std::endl;
// std::cout << "start:" << start << std::endl;
// std::cout << "prime:" << prime[start] << std::endl;
for (int i = start; i >= 0; i--) {
int a = prime[i];
if(prime[i - 1] == a - 2 &&
prime[i - 2] == a - 6 &&
prime[i - 3] == a - 8){
std::cout << prime[i] << std::endl;
break;
}
}
//std::cout << std::endl;
}
return 0;
} | a.cc: In function 'int main(int, char**)':
a.cc:19:17: error: 'upper_bound' was not declared in this scope
19 | int start = upper_bound(prime.begin(), prime.end(), n) -
| ^~~~~~~~~~~
|
s384177526 | p00222 | C++ | #include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<bool> dp, searched;
bool is_prime(int n)
{
if (searched[n])
{
return dp[n];
}
return isprime(n, 2);
}
bool isprime(int n, int k)
{
if (n < k * k)
{
searched[n] = true;
dp[n] = true;
return true;
}
if (n % k == 0)
{
searched[n] = true;
dp[n] = false;
return false;
}
if (k > 2)
{
return is_prime(n, k + 2);
}
return is_prime(n, k + 1);
}
int main()
{
int N;
dp = searched = vector<bool>(10000001, false);
while (true)
{
cin >> N;
if (N == 0) { break; }
int Ans = 1145141919;
if (N % 2 == 0)
{
N -= 1;
}
for (int i = N; ; i -= 2)
{
if (is_prime(i - 8) && is_prime(i - 6) && is_prime(i - 2) && is_prime(i))
{
Ans = i; break;
}
}
cout << Ans << endl;
}
return 0;
} | a.cc: In function 'bool is_prime(int)':
a.cc:16:16: error: 'isprime' was not declared in this scope; did you mean 'is_prime'?
16 | return isprime(n, 2);
| ^~~~~~~
| is_prime
a.cc: In function 'bool isprime(int, int)':
a.cc:41:32: error: too many arguments to function 'bool is_prime(int)'
41 | return is_prime(n, k + 2);
| ~~~~~~~~^~~~~~~~~~
a.cc:9:6: note: declared here
9 | bool is_prime(int n)
| ^~~~~~~~
a.cc:44:24: error: too many arguments to function 'bool is_prime(int)'
44 | return is_prime(n, k + 1);
| ~~~~~~~~^~~~~~~~~~
a.cc:9:6: note: declared here
9 | bool is_prime(int n)
| ^~~~~~~~
|
s205157879 | p00222 | C++ | #include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<bool> dp, searched;
bool is_prime(int n)
{
if (searched[n])
{
return dp[n];
}
return isprime(n, 2);
}
bool isprime(int n, int k)
{
if (n < k * k)
{
searched[n] = true;
dp[n] = true;
return true;
}
if (n % k == 0)
{
searched[n] = true;
dp[n] = false;
return false;
}
if (k > 2)
{
return isprime(n, k + 2);
}
return isprime(n, k + 1);
}
int main()
{
int N;
dp = searched = vector<bool>(10000001, false);
while (true)
{
cin >> N;
if (N == 0) { break; }
int Ans = 1145141919;
if (N % 2 == 0)
{
N -= 1;
}
for (int i = N; ; i -= 2)
{
if (is_prime(i - 8) && is_prime(i - 6) && is_prime(i - 2) && is_prime(i))
{
Ans = i; break;
}
}
cout << Ans << endl;
}
return 0;
} | a.cc: In function 'bool is_prime(int)':
a.cc:16:16: error: 'isprime' was not declared in this scope; did you mean 'is_prime'?
16 | return isprime(n, 2);
| ^~~~~~~
| is_prime
|
s318194195 | p00222 | C++ | #include <iostream>
using namespace std;
int main(){
int x=100000;
bool isPrime[x];
isPrime[0]=isPrime[1]=false;
for(int i=2; i<x; i++)
isPrime[i]=true;
for(int i=2; i*i<x; i++){
if(isPrime[i]){
for(int j=i*i; j<x;j+=i)
isPrime[j]=false;
}
}
int n;
int ans=0;
while(true){
cin >> n;
if(n==0)
break;
for(int i=0; i<=n; i++){
if(isPrime[i]){
if(isPrime[i-2]){
if(isPrime[i-6]){
if(isPrime[i-8])
ans=i;
}
}
}
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:37:10: error: expected '}' at end of input
37 | }
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s216613933 | p00222 | C++ | #include <iostream>
using namespace std;
int main(){
int x=100000;
bool isPrime[x];
isPrime[0]=isPrime[1]=false;
for(int i=2; i<x; i++)
isPrime[i]=true;
for(int i=2; i*i<x; i++){
if(isPrime[i]){
for(int j=i*i; j<x;j+=i)
isPrime[j]=false;
}
}
int n;
int ans=0;
while(true){
cin >> n;
if(n==0)
break;
for(int i=0; i<=n; i++){
if(isPrime[i]){
if(isPrime[i-2]){
if(isPrime[i-6]){
if(isPrime[i-8])
ans=i;
}
}
}
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:37:10: error: expected '}' at end of input
37 | }
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s811855443 | p00222 | C++ | #include <iostream>
using namespace std;
bool isPrime(int n){
if(n<=1)
return false;
for(int i=2; i*i<=n; i++){
if(n%i==0)
return false;
}
return true;
}
int main(){
int n;
int ans;
while(true){
ans=0;
cin >> n;
if(n==0)
break;
int i=n;
while(i>=13){
if(isPrime(i)&&isPrime(i-2)&&isPrime(i-6)&&isPrime(i-8))
ans=i;
if(ans!=0)
break;
i--;
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:37:10: error: expected '}' at end of input
37 | }
| ^
a.cc:16:11: note: to match this '{'
16 | int main(){
| ^
|
s202394359 | p00222 | C++ | #include<iostream>
using namespace std;
int main(){
int n, count=0;
int temp = 0;
int maxn = 0;
int sosuu[3] = { 0 };
cin >> n;
while (n != 0){
for (int i = 2; i <= n - 8; i++){
for (int l = 2; l < i; l++){
if (i%l == 0) count++;
}
if (count == 0) {
temp = i;
sosuu[0] = temp + 2;
sosuu[1] = temp + 6;
sosuu[2] = temp + 8;
if (sosuu[2]>maxn){
for (int i1 = 0; i1 < 3; i1++){
for (int l1 = 2; l1 < sosuu[i1]; l1++){
if (sosuu[i1] % l1 == 0) count++;
}if (count != 0) break;
}if (count == 0){
if (maxn < sosuu[2]) maxn = sosuu[2];
}
}
}
count = 0;
}
cout << maxn << endl;
cin >> n;
} | a.cc: In function 'int main()':
a.cc:33:10: error: expected '}' at end of input
33 | }
| ^
a.cc:3:11: note: to match this '{'
3 | int main(){
| ^
|
s101946740 | p00222 | 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"
bool isso(long long int a) {
if (a == 1 || a == 0)return false;
for (long long int i = 2; i*i <= a; ++i) {
if ((a%i)) {
}
else {
return false;
}
}
return true;
}
int main() {
while (1) {
int N; cin >> N;
if (!N)break;
int num = N;
while (num % 6 != 1)num--;
while (1) {
if (isso(num) && isso(num - 2) && isso(num - 6) && isso(num - 8)) {
cout << num << endl;
break;
}
num-=6;
}
mp.clear();
}
return 0;
} | a.cc: In function 'int main()':
a.cc:37:17: error: 'mp' was not declared in this scope
37 | mp.clear();
| ^~
|
s994714317 | p00222 | 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"
long long int powmod(long long int a, long long int b, const int mod) {
assert(b >= 0);
if (b == 0)return 1;
if (b == 1)return a;
long long int ans = 1;
long long int aa = powmod(a, b / 2, mod);
ans *= aa*aa;
ans %= mod;
if (b % 2)ans *= a;
ans %= mod;
return ans;
}
const int k = 12;
//?´???°??????
bool mirror_rabin(const long long int n) {
if (a == 1 || a == 0)return false;
for (long long int i = 2; i*i <= a; ++i) {
if ((a%i)) {
}
else {
return false;
}
}
return true;
}
bool isso(long long int a) {
if (a == 1 || a == 0)return false;
for (long long int i = 2; i*i <= a; ++i) {
if ((a%i)) {
}
else {
return false;
}
}
return true;
}
int main() {
while (1) {
int N; cin >> N;
if (!N)break;
int num = N;
if (num < 19) {
cout << 13 << endl;
}
else {
while (num % 30 != 19)num--;
while (1) {
if (mirror_rabin(num) && mirror_rabin(num - 2) && mirror_rabin(num - 6) && mirror_rabin(num - 8)) {
cout << num << endl;
break;
}
num -= 30;
}
}
}
return 0;
} | a.cc: In function 'bool mirror_rabin(long long int)':
a.cc:29:13: error: 'a' was not declared in this scope
29 | if (a == 1 || a == 0)return false;
| ^
a.cc:30:42: error: 'a' was not declared in this scope
30 | for (long long int i = 2; i*i <= a; ++i) {
| ^
|
s159051330 | p00222 | C++ | #include <stdio.h>
int prime(int);
int main()
{
int n, sw;
scanf("%d", &n);
while (n > 0) {
sw = 0;
while (sw == 0) {
if (prime(n) > 0) {
if (prime(n-2) > 0) {
if (prime(n-6) > 0) {
if (prime(n-8) > 0)
sw = 1;
}
}
}
if (sw > 0)
break;
else
n--;
}
printf("%d\n", n);
scanf("%d", &n);
}
return 0;
} | /usr/bin/ld: /tmp/ccLX2eHT.o: in function `main':
a.cc:(.text+0x37): undefined reference to `prime(int)'
/usr/bin/ld: a.cc:(.text+0x4d): undefined reference to `prime(int)'
/usr/bin/ld: a.cc:(.text+0x63): undefined reference to `prime(int)'
/usr/bin/ld: a.cc:(.text+0x79): undefined reference to `prime(int)'
collect2: error: ld returned 1 exit status
|
s609501966 | p00222 | C++ | #include <iostream>
using namespace std;
void prime(bool is_prime[]){
is_prime[0]=is_prime[1]=false;
for(int i=2; i<1000000; i++){
is_prime[i]=true;
}
for(int i=2; i*i<1000000; i++){
if(is_prime[i]){
for(int j=i*i; j<1000000; j+=i){
is_prime[j]=false;
}
}
}
};
int main(){
bool is_prime[1000000];
prime(is_prime);
}
while(true){
int a;
cin>>a;
if(a==0)
break;
int ans=0;
for(int i=a; i>=13; i--){
if(is_prime[i]){
if(is_prime[i-2]){
if(is_prime[i-6]){
if(is_prime[i-8]){
ans=i;
break;
}
}
}
}
}
cout<<ans<<endl;
}
return 0;
} | a.cc:25:9: error: expected unqualified-id before 'while'
25 | while(true){
| ^~~~~
a.cc:46:9: error: expected unqualified-id before 'return'
46 | return 0;
| ^~~~~~
a.cc:47:1: error: expected declaration before '}' token
47 | }
| ^
|
s060066081 | p00222 | C++ | #include<iostream>
using namespace std;
int main()
{
bool is_prime[10000001];
is_prime[0]=is_prime[1]=false;
for(int i=2;i<10000001;i++){
is_prime[i]=true;
}
for(int i=2;i*i<100000011;i++){
if(is_prime[i]){
for(int j=i*i;j<10000001j+=i){
is_prime[j]=false;
}
}
}
while(true){
int n;
cin>>n;
if(n==0)
break;
for(int i=n;i>12;i--){
if(is_prime[i]&&is_prime[i-2]&&is_prime[i-6]&&is_prime[i-8]){
cout<<i<<endl;
break;
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:16:40: error: invalid operands of types 'int' and '__complex__ int' to binary 'operator<'
16 | for(int j=i*i;j<10000001j+=i){
| ~^~~~~~~~~~
| | |
| | __complex__ int
| int
a.cc:16:53: error: expected ';' before ')' token
16 | for(int j=i*i;j<10000001j+=i){
| ^
| ;
|
s282179091 | p00222 | C++ |
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;
ll n;
ll arr[10000010],ans[10000010];
void Eratosthenes() {
for (ll i = 0; i <= 10000010; i++)arr[i] = 1;
for (ll i = 2; i <= sqrt(10000010); i++) {
if (arr[i]) {
for (ll j = 0; i*(j + 2) <= 10000010; j++)
arr[i*(j + 2)] = 0;
}
}
ll pre_prime = 0;
for (ll i = 13; i <= 10000010; i++) {
if (arr[i] && arr[i-2] && arr[i-6] && arr[i-8]) {
ans[i] = i;
pre_prime = i;
}
else ans[i] = pre_prime;
}
} | /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
|
s437595152 | p00222 | C++ |
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;
ll arr[10000010];
void Eratosthenes() {
memset(arr, 1, sizeof(arr));
for (ll i = 2; i <= sqrt(10000010); i++) {
if (arr[i]) {
for (ll j = 0; i*(j + 2) <= 10000010; j++)
arr[i*(j + 2)] = 0;
}
}
}
int main()
{
int n;
Eratosthenes();
while (cin >> n, n) {
int i = n;
while (!(arr[i] && arr[i - 2] && arr[i - 6] && arr[i - 8]))i--;
cout << i << endl;
}
return 0;
} | a.cc: In function 'void Eratosthenes()':
a.cc:31:9: error: 'memset' was not declared in this scope
31 | memset(arr, 1, sizeof(arr));
| ^~~~~~
a.cc:16:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
15 | #include<iterator>
+++ |+#include <cstring>
16 |
|
s693053737 | p00222 | C++ |
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;
ll arr[10000010];
void Eratosthenes() {
memset(arr, 1, sizeof(arr));
for (ll i = 2; i <= sqrt(10000010); i++) {
if (arr[i]) {
for (ll j = 0; i*(j + 2) <= 10000010; j++)
arr[i*(j + 2)] = 0;
}
}
}
int main()
{
int n;
Eratosthenes();
while (cin >> n, n) {
int i = n;
while (!(arr[i] && arr[i - 2] && arr[i - 6] && arr[i - 8]))i--;
cout << i << endl;
}
return 0;
} | a.cc: In function 'void Eratosthenes()':
a.cc:31:9: error: 'memset' was not declared in this scope
31 | memset(arr, 1, sizeof(arr));
| ^~~~~~
a.cc:16:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
15 | #include<iterator>
+++ |+#include <cstring>
16 |
|
s797524338 | p00222 | C++ | #define MAX 10000000
int p[MAX];
int four[1000];
int main(void)
{
int i,j,f=0;
//ツ倍ツ青板づーツ渉慊外
for(i=2 ; i<=MAX/2 ; i++){
for(j=2 ; i*j<=MAX ; j++){
if(p[i*j] == 0)
p[i*j] = 1;
}
}
for(i=3 ; i < MAX-7 ; i+=2){
if(p[i] == 0 && p[i+2]==0 && p[i+6]==0 && p[i+8]==0)
{
four[f++]=i+8;
// printf("%d\n",i+8);
}
}
for(;scanf("%d",&j),j;)
{
for(i=0 ;four[i]<=j; i++);
printf("%d\n",four[i-1]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:23:8: error: 'scanf' was not declared in this scope
23 | for(;scanf("%d",&j),j;)
| ^~~~~
a.cc:26:7: error: 'printf' was not declared in this scope
26 | printf("%d\n",four[i-1]);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | #define MAX 10000000
|
s891281046 | p00222 | C++ | #include<iostream>
#include <algorithm>
using namespace std;
#define MAX_LIST 10000000
int main(){
//bool *prime=(bool *)malloc(sizeof(bool)*MAX_LIST);
bool prime[MAX_LIST];
for(int i=0;i<MAX_LIST;i++){
prime[i]=1;
}
prime[0]=prime[1]=0;
for(int i=0;i*i<MAX_LIST;i++){
if(prime[i]==1){
for(int j=i*2;j<MAX_LIST;j=j+i){
prime[j]=0;
}
}
}
//int *primelist=(int *)malloc(sizeof(int)*MAX_LIST);
/*
int primelist[MAX_LIST];
int j=0;
for(int i=0;i<MAX_LIST;i++){
if(prime[i]==1){
primelist[j]=i;
j++;
}
}
}*/
//int *prime_num=(int*)malloc(sizeof(int)*MAX_LIST);
/*
int prime_num[MAX_LIST];
prime_num[0]=1;
for(int i=1;i<MAX_LIST;i++){
prime_num[i]=prime_num[i-1]+prime[i];
}*/
/*
int n;
while(cin>>n,n){
int ans=0;
int s;
int num=MAX_LIST-1;
for(int i=num;i>0;i--){
if(primelist[i]>n){
}else{
if((primelist[i]-primelist[i-1]==2)
&&(primelist[i-2]-primelist[i-3]==2)
&&(primelist[i-1]-primelist[i-2]==4)){
ans=primelist[i];
break;
}
}
}
cout<<ans<<endl;
}/*
return 0;
} | a.cc:40:9: error: unterminated comment
40 | /*
| ^
a.cc: In function 'int main()':
a.cc:21:10: error: expected '}' at end of input
21 | }
| ^
a.cc:8:11: note: to match this '{'
8 | int main(){
| ^
|
s122605532 | p00222 | C++ | //テ・ツ崢崚」ツ?、テ・ツュツ静ァツエツ?ヲツ閉ーテ」ツ?ョテ・ツ、ツァテ」ツ?催」ツ?陛」ツつ津ゥツ?催・ツ按療」ツ?ォテ・ツ?・テ」ツつ古」ツ?淌」ツつ欝ime Limit Exceededテ」ツ?ァテ」ツ?療」ツ??
//テァツ崢エテ」ツ?療」ツ?ヲテ」ツつづァツ崢エテ」ツ?療」ツ?ヲテ」ツつ5ime Limit Exceeded___テ」ツδ嘉」ツδ?」ツδ愿」ツ?ァテ」ツ??
//テ」ツつィテ」ツδゥテ」ツつケテ」ツδ暗」ツδ?」ツδ催」ツつケテ」ツ?ョテァツッツゥテ」ツつ津」ツ?凖」ツ?」テ」ツ?凝」ツつ甘・ツソツ佚」ツつ古」ツ?ヲテ」ツ??」ツ?セテ」ツ?療」ツ?淌」ツ??
// Respect2Dテ」ツ?陛」ツつ禿」ツ?ョテ」ツつウテ」ツδ。テ」ツδウテ」ツδ暗」ツつ津ィツヲツ凝」ツ?ヲテヲツーツ療」ツ?古」ツ?、テ」ツ?催」ツ?セテ」ツ?療」ツ?淌」ツ??
import java.util.*;
public class Main{
static Scanner kbd = new Scanner(System.in);
static int[] prime = new int[10000001];
// 0:テヲツ慊ェテ・ツ按、テ・ツョツ?
// 1:テァツエツ?ヲツ閉ー
// -1:テァツエツ?ヲツ閉ーテ」ツ?ァテ」ツ?ッテ」ツ?ェテ」ツ??
public static void main(String[] args){
prepare();
while(true){
int n = kbd.nextInt();
if(n==0) break;
solve(n);
}
}
static void prepare(){
prime[0] = prime[1] = -1;
int i=2;
for(; i<prime.length; i++){
if(prime[i] == 0){
prime[i] = 1;
for(int j=i+i; j<prime.length; j+=i) prime[j]=-1;
}
}
}
static void solve(int n){
while(!(prime[n]==1 && prime[n-2]==1 && prime[n-6]==1 && prime[n-8]==1)){
n--;
}
System.out.println(n);
}
/*
static boolean prime(int a){
int k = (int)Math.sqrt(a);
for(int l=2; l<=k; l++){
if(a%l == 0) return false;
}
return true;
}
*/
} | a.cc:6:1: error: 'import' does not name a type
6 | import java.util.*;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: expected unqualified-id before 'public'
7 | public class Main{
| ^~~~~~
|
s178747492 | p00222 | C++ | cout << n << " " << p[idx] << endl; | a.cc:1:9: error: 'cout' does not name a type
1 | cout << n << " " << p[idx] << endl;
| ^~~~
|
s967803875 | p00222 | C++ | #include <iostream>
#include <cmath>
using namespace std;
bool flag[10000001];
int main(){
int n;
for(int i=0;i <= 1000000;i++){
if(i<=1)flag[i]=false;
else flag[i]=true;
}
for(int i=2;i <= 1001 ;i++){
if(flag[i]==true){
for(int j=i*2 ; j<=1000000 ; j=j+i){
flag[j] = false;
}
}
}
while(cin>>n,n){
forint i=n;i!=0;i--){
cout<<"*"<<i<<endl;
if(flag[i]&&flag[i-2]&&flag[i-6]&&flag[i-8]){
cout<<i<<endl;
break;
}
}
}
} | a.cc: In function 'int main()':
a.cc:20:9: error: 'forint' was not declared in this scope; did you mean 'rint'?
20 | forint i=n;i!=0;i--){
| ^~~~~~
| rint
a.cc:20:20: error: 'i' was not declared in this scope
20 | forint i=n;i!=0;i--){
| ^
|
s000029819 | p00222 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
#define MAX_N 10000000
int prime[MAX_N];
bool is_prime[MAX_N+1];
int sieve(int n){
int p=0;
memset(is_prime,true,sizeof(is_prime));
is_prime[0]=is_prime[1]=false;
for(int i=2;i<=n;i++){
if(is_prime[i]){
prime[p++]=i;
for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
}
}
return p;
}
int main(){
int n;
sieve(MAX_N);
while(cin>>n,n){
int ans=13;
for(int i=13;i<=n;i++){
if(is_prime[i-8]&&is_prime[i-6]&&is_prime[i-2]&&is_prime[i])
ans=i;
}
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int sieve(int)':
a.cc:11:9: error: 'memset' was not declared in this scope
11 | memset(is_prime,true,sizeof(is_prime));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<algorithm>
+++ |+#include <cstring>
3 | using namespace std;
|
s052079336 | p00222 | C++ | #include<iostream>
char p[10000001];
void sieve()
{
memset( p, 1, sizeof( p ) );
p[0] = p[1] = 0;
for( int i = 2; i <= 10000000; ++i )
if( p[i] )
for( int j = i * 2; j <= 10000000; j += i )
p[j] = 0;
return;
}
int main()
{
sieve();
int n;
while( std::cin >> n, n )
{
while( true )
{
if( p[n] && p[n-2] && p[n-6] && p[n-8] )
{
std::cout << n << std::endl;
break;
}
--n;
}
}
return 0;
} | a.cc: In function 'void sieve()':
a.cc:7:9: error: 'memset' was not declared in this scope
7 | memset( p, 1, sizeof( p ) );
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include<iostream>
+++ |+#include <cstring>
2 |
|
s500270726 | p00222 | C++ | import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = 0,maxPQ = 0;
while(sc.hasNext()){
n = sc.nextInt();
if(n==0) break;
boolean[] check = new boolean[n];
System.out.println(checkPrime(check));
}
}
static int checkPrime(boolean[] check){ // テ・ツ崢崚」ツ?、テ・ツュツ静ァツエツ?ヲツ閉ーテ」ツつ津ィツソツ氾」ツ??
for(int i = 1;i*i<check.length;i++){ // テ」ツ?敕」ツつ古」ツ?古ァツエツ?ヲツ閉ーテ」ツ??」ツ?」テ」ツ?淌」ツつ嘉」ツ?敕」ツ?ョテ・ツ?催ヲツ閉ーテ」ツつ断alseテ」ツ?ォテ」ツ?凖」ツつ?
if(!primeNum(i+1)) notPrime(check,i+1);
}
for(int i = check.length-1;i>=0;i--){ // trueテ」ツつ津」ツ?ソテ」ツ?、テ」ツ?妥」ツ?淌」ツつ嘉」ツ?敕」ツ?ョテ、ツクツ凝」ツ?ィテ」ツ?凝」ツつづィツヲツ凝」ツ?ヲテ」ツ?{kテ」ツ??」ツ?」テ」ツ?淌」ツつ嘉」ツ?敕」ツつ古」ツ?古ヲツ慊?・ツ、ツァテ」ツ?ョテヲツ閉ーテ」ツ??」ツ?療ィツソツ氾」ツ?療」ツ?。テ」ツつε」ツ??
if(!check[i] && !check[i-2] && !check[i-6] && !check[i-8]){
return i+1;
}
}
return 0; // テ、ツサツョ
}
static boolean primeNum(int num){ // テァツエツ?ヲツ閉ーテ」ツつ津ヲツ閉ーテ」ツ?暗」ツつ?
int count=0;
for(int i = 1;i<=num;i++){
if(num%i==0) count++;
}
return count==2?false:true;
}
static void notPrime(boolean[] check,int n){ // テァツエツ?ヲツ閉ーテ」ツ??」ツ?」テ」ツ?淌ヲツ閉ーテ」ツ?ョテ・ツ?催ヲツ閉ーテ」ツつ稚rueテ」ツ?ォ
for(int i = 2;i*n<check.length;i++){
check[(n*i)-1] = true;
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.Scanner;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
3 | public class Main{
| ^~~~~~
|
s799171942 | p00223 | Java |
import java.io.IOException;
import java.util.Arrays;
import java.util.NavigableSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;
import lombok.Data;
import scala.inline;
import scala.collection.parallel.immutable.ParIterable;
public class Main {
public static void main(String[] args) throws IOException {
new Main().run();
}
private void run() throws IOException {
Scanner scanner = new Scanner(System.in);
while (true) {
int w = scanner.nextInt();
int h = scanner.nextInt();
if ((w | h) == 0)
break;
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
int d = scanner.nextInt();
Pair kazuyuki = new Pair(b, a);
Pair takayuki = new Pair(d, c);
boolean[][] map = new boolean[h + 2][w + 2];
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
map[i][j] = scanner.nextInt() == 0;
}
}
PriorityQueue<Pair> pq = new PriorityQueue<Pair>();
int dis = dist(takayuki, kazuyuki);
pq.add(new Pair(takayuki.y, takayuki.x, kazuyuki.y, kazuyuki.x, 0,
dis));
String ans = "NA";
boolean[][] tb = new boolean[h + 2][w + 2];
boolean[][] kb = new boolean[h + 2][w + 2];
int[][][][] costs = new int[h + 2][w + 2][h + 2][w + 2];
for (int[][][] aaa : costs)
for (int[][] aa : aaa)
for (int[] cos : aa)
Arrays.fill(cos, 1 << 24);
while (!pq.isEmpty()) {
Pair pair = pq.poll();
if (pair.cost == 100)
continue;
if (pair.y == pair.dy && pair.x == pair.dx) {
flag = true;
ans = String.valueOf(pair.cost);
break;
}
tb[pair.y][pair.x] = true;
kb[pair.dy][pair.dx] = true;
if (costs[pair.y][pair.x][pair.dy][pair.dx] < pair.md) {
continue;
} else {
costs[pair.y][pair.x][pair.dy][pair.dx] = pair.md;
}
for (int i = 0; i < 4; i++) {
int nty = pair.y + move[i][0];
int ntx = pair.x + move[i][1];
int nky = pair.dy + move[i][2];
int nkx = pair.dx + move[i][3];
if (!map[nty][ntx]) {
nty = pair.y;
ntx = pair.x;
}
if (!map[nky][nkx]) {
nky = pair.dy;
nkx = pair.dx;
}
if (tb[nty][ntx] && kb[nky][nkx])
continue;
int newdis = dist(new Pair(nty, ntx), new Pair(nky, nkx));
pq.add(new Pair(nty, ntx, nky, nkx, pair.cost + 1,
pair.cost + 1 + newdis));
}
}
System.out.println(ans);
}
}
int[][] move = { { -1, 0, 1, 0 }, { 0, -1, 0, 1 }, { 1, 0, -1, 0 },
{ 0, 1, 0, -1 } };
int dist(Pair a, Pair b) {
return Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
}
class Pair implements Comparable<Pair> {
int y;
int x;
int dy;
int dx;
int cost;
int md;
public Pair(int y, int x, int dy, int dx, int cost, int md) {
super();
this.y = y;
this.x = x;
this.dy = dy;
this.dx = dx;
this.cost = cost;
this.md = md;
}
public Pair(int y, int x) {
super();
this.y = y;
this.x = x;
}
@Override
public int compareTo(Pair o) {
if (this.md == o.md)
return this.cost - o.cost;
return this.md - o.md;
}
}
} | Main.java:9: error: package lombok does not exist
import lombok.Data;
^
Main.java:10: error: package scala does not exist
import scala.inline;
^
Main.java:11: error: package scala.collection.parallel.immutable does not exist
import scala.collection.parallel.immutable.ParIterable;
^
Main.java:55: error: cannot find symbol
flag = true;
^
symbol: variable flag
location: class Main
4 errors
|
s602206230 | p00223 | Java | import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class Main{
Scanner sc=new Scanner(System.in);
int INF=1<<28;
double EPS=1e-9;
int m, n;
R r0;
int[][] a;
void run(){
/*
byte[][][][] d=new byte[50][50][50][50];
boolean[][][][] b=new boolean[50][50][50][50];*/
for(;;){
m=sc.nextInt();
n=sc.nextInt();
if((m|n)==0){
break;
}
int tx=sc.nextInt()-1;
int ty=sc.nextInt()-1;
int kx=sc.nextInt()-1;
int ky=sc.nextInt()-1;
r0=new R(tx, ty, kx, ky);
a=new int[n][m];
for(int j=0; j<n; j++){
for(int i=0; i<m; i++){
a[j][i]=sc.nextInt();
}
}
solve();
}
}
void solve(){
LinkedList<R> que=new LinkedList<R>();
boolean[][][][] visited=new boolean[n][m][n][m];
byte[][][][] d=new byte[n][m][n][m];
// que.offer(new R)
int[] dx={0, 0, -1, 1};
int[] dy={-1, 1, 0, 0};
que.offer(r0);
for(; !que.isEmpty();){
R r=que.poll();
// debug(r.tx, r.ty, r.kx, r.ky, d[r.ty][r.tx][r.ky][r.kx]);
if(d[r.ty][r.tx][r.ky][r.kx]>=100){
println("NA");
return;
}
if(r.tx==r.kx&&r.ty==r.ky){
println(d[r.ty][r.tx][r.ky][r.kx]+"");
return;
}
for(int i=0; i<4; i++){
int tx2=min(max(r.tx+dx[i], 0), m-1);
int ty2=min(max(r.ty+dy[i], 0), n-1);
int kx2=min(max(r.kx-dx[i], 0), m-1);
int ky2=min(max(r.ky-dy[i], 0), n-1);
if(a[ty2][tx2]==1){
tx2=r.tx;
ty2=r.ty;
}
if(a[ky2][kx2]==1){
kx2=r.kx;
ky2=r.ky;
}
if(!visited[ty2][tx2][ky2][kx2]){
visited[ty2][tx2][ky2][kx2]=true;
que.offer(new R(tx2, ty2, kx2, ky2));
d[ty2][tx2][ky2][kx2]=d[r.ty][r.tx][r.ky][r.kx]+1;
}
}
}
println("NA");
}
class R{
int tx, ty, kx, ky;
R(int tx, int ty, int kx, int ky){
this.tx=tx;
this.ty=ty;
this.kx=kx;
this.ky=ky;
}
}
void debug(Object... os){
System.err.println(Arrays.deepToString(os));
}
void print(String s){
System.out.print(s);
}
void println(String s){
System.out.println(s);
}
public static void main(String[] args){
// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
new Main().run();
}
} | Main.java:82: error: incompatible types: possible lossy conversion from int to byte
d[ty2][tx2][ky2][kx2]=d[r.ty][r.tx][r.ky][r.kx]+1;
^
1 error
|
s258451628 | p00223 | C | 6 6
2 4
6 2
0 0 0 0 1 0
0 1 0 0 0 0
0 1 0 0 0 0
0 0 0 1 0 0
0 0 0 0 0 1
0 0 0 0 0 0
3 3
1 1
3 3
0 0 0
0 1 0
0 0 0
0 0 | main.c:1:1: error: expected identifier or '(' before numeric constant
1 | 6 6
| ^
|
s892366901 | p00223 | C | #include<stdio.h>
#include<queue>
using namespace std;
queue<int> tx, ty, kx, ky;
int d[50][50];
void move(void);
void clean(void);
int main(void)
{
int x, y, X, Y,i,j;
while (1) {
for (i = 0; i < 50; i++) {
for (j = 0; j < 50; j++) {
d[i][j] = 1;
}
}
scanf("%d %d", &X, &Y); //????????????
if (X == 0 && Y == 0) break;
scanf("%d %d", &x, &y); //????????????
tx.push(x); ty.push(y);
scanf("%d %d", &x, &y); //????????????
kx.push(x); ky.push(y);
for (i = 1; i <= Y; i++) {
for (j = 1; j <= X; j++) {
scanf("%d", &d[i][j]);
}
}
move();
clean();
}
return 0;
}
void move()
{
int cnt = 0,count=0,s=4;
int m[4][4]={-1,1,0,0, //taka y
0,0,-1,1, //taka x
1,-1,0,0, //kazu y
0,0,1,-1}; //kazu x
while (1) {
if (tx.back() == kx.back() && ty.back() == ky.back()) {
printf("A%d\n", count);
break;
}
if (d[ty.front() + m[0][cnt%4]][tx.front() + m[1][cnt%4]] == 0) { //?????????
tx.push(tx.front() + m[1][cnt%4]);
ty.push(ty.front() + m[0][cnt%4]);
}
else if (d[ty.front() + m[0][cnt%4]][tx.front() + m[1][cnt%4]] == 1) {
tx.push(tx.front());
ty.push(ty.front());
}
if (d[ky.front() + m[2][cnt%4]][kx.front() + m[3][cnt%4]] == 0) { //?????????
kx.push(kx.front() + m[3][cnt%4]);
ky.push(ky.front() + m[2][cnt%4]);
}
else if (d[ky.front() + m[2][cnt%4]][kx.front() + m[3][cnt%4]] == 1) {
kx.push(kx.front());
ky.push(ky.front());
}
cnt++;
if(cnt == s){
count++;
s = s * s;
cnt = 0;
printf("\nQQQ\n");
}
//printf("%d ??????x.%d y.%d ??????x.%d y.%d\n",cnt%4, tx.back(),ty.back(), kx.back(),ky.back());
//printf("X %d %d\nY %d %d",kx.front(),m[3][cnt%4],ky.front(),m[2][cnt%4]);
if (tx.back() == kx.back() && ty.back() == ky.back()) {
printf("%d\n", count+1);
break;
}
if(cnt % 4 == 0 && cnt !=0){
tx.pop(); ty.pop(); kx.pop(); ky.pop();
}
if (count >= 100) {
printf("NA\n");
break;
}
}
}
void clean(void)
{
while (!tx.empty()) {
tx.pop();
}
while (!ty.empty()) {
ty.pop();
}
while (!kx.empty()) {
kx.pop();
}
while (!ky.empty()) {
ky.pop();
}
} | main.c:2:9: fatal error: queue: No such file or directory
2 | #include<queue>
| ^~~~~~~
compilation terminated.
|
s579839628 | p00223 | C | #include <iostream>
#include <queue>
using namespace std;
const int INF = 1000000;
int H,W;
class Point{
public:
int tx;
int ty;
int kx;
int ky;
int f;
void set(int a,int b,int c,int d,int f){
tx = a;
ty = b;
kx = c;
ky = d;
this->f = f;
}
};
int is_out_of_area(int y,int x){
return x < 1 || x > W || y < 1 || H > H;
}
int main(){
char F[52][52];
int D[52][52];
int tx,ty,kx,ky;
int counter = 0;
while(1){
cin >> W >> H;
if(W == 0 && H == 0)
break;
cin >> tx >> ty >> kx >> ky;
for(int y=0;y<=H+1;y++){
for(int x=0;x<=W+1;x++){
F[y][x] = 1;
}
}
for(int y=1;y<=H;y++){
for(int x=1;x<=W;x++){
D[y][x] = INF;
int a;
cin >> a;
F[y][x] = a;
}
}
queue<Point> qa;
Point p;
p.set(tx,ty,kx,ky,0);
qa.push(p);
D[p.ty][p.tx] = 0;
while(1){
if(qa.empty()){
cout << "NA" << endl;
break;
}
p = qa.front();
qa.pop();
if(p.f >= 100){
cout << "NA" << endl;
break;
}
if(p.tx == p.kx && p.ty == p.ky){
cout << p.f << endl;
break;
}
if(D[p.ty-1][p.tx] == INF && D[p.ky+1][p.kx] == INF){
if(!((is_out_of_area(p.ty-1,p.tx) || F[p.ty-1][p.tx]) && (is_out_of_area(p.ky+1,p.kx) || F[p.ky+1][p.kx]))){
if(F[p.ty-1][p.tx] || is_out_of_area(p.ty-1,p.tx)){
Point q;
q.set(p.tx,p.ty,p.kx,p.ky+1,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else if(is_out_of_area(p.ky+1,p.kx) || F[p.ky+1][p.kx]){
Point q;
q.set(p.tx,p.ty-1,p.kx,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else {
Point q;
q.set(p.tx,p.ty-1,p.kx,p.ky+1,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
if(D[p.ty+1][p.tx] == INF && D[p.ky-1][p.kx] == INF){
if(!((is_out_of_area(p.ty+1,p.tx) || F[p.ty+1][p.tx]) && (is_out_of_area(p.ky-1,p.kx) || F[p.ky-1][p.kx]))){
if(F[p.ty+1][p.tx] || is_out_of_area(p.ty+1,p.tx)){
Point q;
q.set(p.tx,p.ty,p.kx,p.ky-1,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else if(is_out_of_area(p.ky-1,p.kx) || F[p.ky-1][p.kx]){
Point q;
q.set(p.tx,p.ty+1,p.kx,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else {
Point q;
q.set(p.tx,p.ty+1,p.kx,p.ky-1,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
if(D[p.ty][p.tx-1] == INF && D[p.ky][p.kx+1] == INF){
if(!((is_out_of_area(p.ty,p.tx-1) || F[p.ty][p.tx-1]) && (is_out_of_area(p.ky,p.kx+1) || F[p.ky][p.kx+1]))){
if(F[p.ty][p.tx-1] || is_out_of_area(p.ty,p.tx-1)){
Point q;
q.set(p.tx,p.ty,p.kx+1,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else if(is_out_of_area(p.ky,p.kx+1) || F[p.ky][p.kx+1]){
Point q;
q.set(p.tx-1,p.ty,p.kx,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else {
Point q;
q.set(p.tx-1,p.ty,p.kx+1,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
if(D[p.ty][p.tx+1] == INF && D[p.ky][p.kx-1] == INF){
if(!((is_out_of_area(p.ty,p.tx+1) || F[p.ty][p.tx+1]) && (is_out_of_area(p.ky,p.kx-1) || F[p.ky][p.kx-1]))){
if(F[p.ty][p.tx+1] || is_out_of_area(p.ty,p.tx+1)){
Point q;
q.set(p.tx,p.ty,p.kx-1,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else if(is_out_of_area(p.ky,p.kx-1) || F[p.ky][p.kx-1]){
Point q;
q.set(p.tx+1,p.ty,p.kx,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else {
Point q;
q.set(p.tx+1,p.ty,p.kx-1,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
counter++;
/* if(D[p.ty-1][p.tx] == INF && D[p.ky+1][p.kx] == INF){
if(is_out_of_area(p.ty-1,p.tx) == 0 || is_out_of_area(p.ky+1,p.kx) == 0){
if(F[p.ty-1][p.tx] == 0 || F[p.ky+1][p.kx] == 0){
Point q;
q.set(p.tx,p.ty-1,p.kx,p.ky+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
if(D[p.ty+1][p.tx] == INF && D[p.ky-1][p.kx] == INF){
if(is_out_of_area(p.ty-1,p.tx) == 0 || is_out_of_area(p.ky+1,p.kx) == 0){
if(F[p.ty+1][p.tx] == 0 || F[p.ky-1][p.kx] == 0){
Point q;
q.set(p.tx,p.ty+1,p.kx,p.ky-1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
if(D[p.ty][p.tx-1] == INF && D[p.ky][p.kx+1] == INF){
if(is_out_of_area(p.ty,p.tx) == 0 || is_out_of_area(p.ky,p.kx) == 0){
if(F[p.ty][p.tx-1] == 0 || F[p.ky][p.kx+1] == 0){
Point q;
q.set(p.tx-1,p.ty,p.kx+1,p.ky);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
if(D[p.ty][p.tx+1] == INF && D[p.ky][p.kx-1] == INF){
if(is_out_of_area(p.ty,p.tx+1) == 0 || is_out_of_area(p.ky,p.kx-1) == 0){
if(F[p.ty][p.tx+1] == 0 || F[p.ky][p.kx-1] == 0){
Point q;
q.set(p.tx+1,p.ty,p.kx-1,p.ky);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
*/
}
}
return 0;
}
| main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s202559424 | p00223 | C | #include <iostream>
#include <queue>
using namespace std;
const int INF = 1000000;
int H,W;
class Point{
public:
int tx;
int ty;
int kx;
int ky;
int f;
void set(int a,int b,int c,int d,int f){
tx = a;
ty = b;
kx = c;
ky = d;
this->f = f;
}
};
int is_out_of_area(int y,int x){
return x < 1 || x > W || y < 1 || H > H;
}
int main(){
char F[52][52];
int D[52][52];
int tx,ty,kx,ky;
int counter = 0;
while(1){
cin >> W >> H;
if(W == 0 && H == 0)
break;
cin >> tx >> ty >> kx >> ky;
for(int y=0;y<=H+1;y++){
for(int x=0;x<=W+1;x++){
F[y][x] = 1;
}
}
for(int y=1;y<=H;y++){
for(int x=1;x<=W;x++){
D[y][x] = INF;
int a;
cin >> a;
F[y][x] = a;
}
}
queue<Point> qa;
Point p;
p.set(tx,ty,kx,ky,0);
qa.push(p);
D[p.ty][p.tx] = 0;
while(1){
if(qa.empty()){
cout << "NA" << endl;
break;
}
p = qa.front();
qa.pop();
if(p.f >= 100){
cout << "NA" << endl;
break;
}
if(p.tx == p.kx && p.ty == p.ky){
cout << p.f << endl;
break;
}
if(D[p.ty-1][p.tx] == INF && D[p.ky+1][p.kx] == INF){
if(!((is_out_of_area(p.ty-1,p.tx) || F[p.ty-1][p.tx]) && (is_out_of_area(p.ky+1,p.kx) || F[p.ky+1][p.kx]))){
if(F[p.ty-1][p.tx] || is_out_of_area(p.ty-1,p.tx)){
Point q;
q.set(p.tx,p.ty,p.kx,p.ky+1,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else if(is_out_of_area(p.ky+1,p.kx) || F[p.ky+1][p.kx]){
Point q;
q.set(p.tx,p.ty-1,p.kx,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else {
Point q;
q.set(p.tx,p.ty-1,p.kx,p.ky+1,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
if(D[p.ty+1][p.tx] == INF && D[p.ky-1][p.kx] == INF){
if(!((is_out_of_area(p.ty+1,p.tx) || F[p.ty+1][p.tx]) && (is_out_of_area(p.ky-1,p.kx) || F[p.ky-1][p.kx]))){
if(F[p.ty+1][p.tx] || is_out_of_area(p.ty+1,p.tx)){
Point q;
q.set(p.tx,p.ty,p.kx,p.ky-1,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else if(is_out_of_area(p.ky-1,p.kx) || F[p.ky-1][p.kx]){
Point q;
q.set(p.tx,p.ty+1,p.kx,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else {
Point q;
q.set(p.tx,p.ty+1,p.kx,p.ky-1,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
if(D[p.ty][p.tx-1] == INF && D[p.ky][p.kx+1] == INF){
if(!((is_out_of_area(p.ty,p.tx-1) || F[p.ty][p.tx-1]) && (is_out_of_area(p.ky,p.kx+1) || F[p.ky][p.kx+1]))){
if(F[p.ty][p.tx-1] || is_out_of_area(p.ty,p.tx-1)){
Point q;
q.set(p.tx,p.ty,p.kx+1,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else if(is_out_of_area(p.ky,p.kx+1) || F[p.ky][p.kx+1]){
Point q;
q.set(p.tx-1,p.ty,p.kx,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else {
Point q;
q.set(p.tx-1,p.ty,p.kx+1,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
if(D[p.ty][p.tx+1] == INF && D[p.ky][p.kx-1] == INF){
if(!((is_out_of_area(p.ty,p.tx+1) || F[p.ty][p.tx+1]) && (is_out_of_area(p.ky,p.kx-1) || F[p.ky][p.kx-1]))){
if(F[p.ty][p.tx+1] || is_out_of_area(p.ty,p.tx+1)){
Point q;
q.set(p.tx,p.ty,p.kx-1,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else if(is_out_of_area(p.ky,p.kx-1) || F[p.ky][p.kx-1]){
Point q;
q.set(p.tx+1,p.ty,p.kx,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
} else {
Point q;
q.set(p.tx+1,p.ty,p.kx-1,p.ky,p.f+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
counter++;
/* if(D[p.ty-1][p.tx] == INF && D[p.ky+1][p.kx] == INF){
if(is_out_of_area(p.ty-1,p.tx) == 0 || is_out_of_area(p.ky+1,p.kx) == 0){
if(F[p.ty-1][p.tx] == 0 || F[p.ky+1][p.kx] == 0){
Point q;
q.set(p.tx,p.ty-1,p.kx,p.ky+1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
if(D[p.ty+1][p.tx] == INF && D[p.ky-1][p.kx] == INF){
if(is_out_of_area(p.ty-1,p.tx) == 0 || is_out_of_area(p.ky+1,p.kx) == 0){
if(F[p.ty+1][p.tx] == 0 || F[p.ky-1][p.kx] == 0){
Point q;
q.set(p.tx,p.ty+1,p.kx,p.ky-1);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
if(D[p.ty][p.tx-1] == INF && D[p.ky][p.kx+1] == INF){
if(is_out_of_area(p.ty,p.tx) == 0 || is_out_of_area(p.ky,p.kx) == 0){
if(F[p.ty][p.tx-1] == 0 || F[p.ky][p.kx+1] == 0){
Point q;
q.set(p.tx-1,p.ty,p.kx+1,p.ky);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
if(D[p.ty][p.tx+1] == INF && D[p.ky][p.kx-1] == INF){
if(is_out_of_area(p.ty,p.tx+1) == 0 || is_out_of_area(p.ky,p.kx-1) == 0){
if(F[p.ty][p.tx+1] == 0 || F[p.ky][p.kx-1] == 0){
Point q;
q.set(p.tx+1,p.ty,p.kx-1,p.ky);
qa.push(q);
D[q.ty][q.tx] = D[p.ty][p.tx] + 1;
}
}
}
*/
}
}
return 0;
}
| main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s069627826 | p00223 | C | #include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
const int INF = 1001001001;
struct Data
{
int ty, tx, ky, kx, c;
Data(int ty, int tx, int ky, int kx, int c) : ty(ty), tx(tx), ky(ky), kx(kx), c(c){}
};
bool visited[50][50][50][50];
int main()
{
int w, h;
while(scanf("%d%d", &w, &h), w){
rep(i, h) rep(j, w) rep(k, h) rep(l, w)
visited[i][j][k][l] = false;
int ty, tx, ky, kx;
scanf("%d%d%d%d", &tx, &ty, &kx, &ky);
int depart[50][50];
rep(i, h) rep(j, w)
scanf("%d", &depart[i][j]);
queue<Data> Q;
Q.push(Data(ty-1, tx-1, ky-1, kx-1, 0));
int ans = -1;
while(!Q.empty()){
Data d = Q.front();
Q.pop();
if(d.ty==d.ky && d.tx==d.kx){
ans = d.c;
break;
}
if(visited[d.ty][d.tx][d.ky][d.kx])
continue;
visited[d.ty][d.tx][d.ky][d.kx] = true;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};
rep(i, 4){
int pty = d.ty + dy[i];
int ptx = d.tx + dx[i];
if(pty<0 || h<=pty || ptx<0 || w<=ptx || depart[pty][ptx]){
pty = d.ty;
ptx = d.tx;
}
int pky = d.ky - dy[i];
int pkx = d.kx - dx[i];
if(pky<0 || h<=pky || pkx<0 || w<=pkx || depart[pky][pkx]){
pky = d.ky;
pkx = d.kx;
}
if(d.c+1 < 100)
Q.push(Data(pty, ptx, pky, pkx, d.c+1));
}
}
if(ans == -1)
puts("NA");
else
printf("%d\n", ans);
}
return 0;
} | main.c:1:10: fatal error: algorithm: No such file or directory
1 | #include <algorithm>
| ^~~~~~~~~~~
compilation terminated.
|
s519285730 | 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
| |
s240682969 | p00223 | C++ | #include<iostream>
#include<queue>
#include<map>
using namespace std;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
class state{
public:
int tx;
int ty;
int kx;
int ky;
};
int main() {
int W, H, tx, ty, kx, ky;
bool d[52][52];
map<state,bool> m;
state num;
state copy;
while (true) {
cin >> W >> H;
if (W == 0)break;
for (int i = 0; i < H+2; i++) {
for (int j = 0; j < W+2; j++) {
d[i][j] = 1;
}
}
cin >> tx >> ty >> kx >> ky;
for (int i = 1; i < H + 1; i++) {
for (int j = 1; j < W + 1; j++) {
cin >> d[j][i];
}
}
num.tx = tx;
num.ty = ty;
num.kx = kx;
num.ky = ky;
queue<state> q;
q.push(num);
int qsize = q.size();
int loopcount = 0;
while (!q.empty()) {
num = q.front();
q.pop();
if (qsize == 0) {
qsize = q.size()+1;
loopcount++;
if (loopcount == 100) {
cout << "NA" << endl;
break;
}
}
qsize--;
m[num] = true;
if (num.tx == num.kx && num.ty == num.ky) {
cout << loopcount << endl;
break;
}
for (int i = 0; i < 4; i++) {
if (!d[num.tx + dx[i]][num.ty + dy[i]]) {
copy.tx = num.tx + dx[i];
copy.ty = num.ty + dy[i];
}
if (!d[num.kx - dx[i]][num.ky - dy[i]]) {
copy.kx = num.kx - dx[i];
copy.ky = num.ky - dy[i];
}
if (!m[copy]) {
q.push(copy);
}
}
if (q.empty()) {
cout << "NA" << endl;
}
}
}
return 0;
}
| In file included from /usr/include/c++/14/string:49,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = state]':
/usr/include/c++/14/bits/stl_map.h:511:32: required from 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = state; _Tp = bool; _Compare = std::less<state>; _Alloc = std::allocator<std::pair<const state, bool> >; mapped_type = bool; key_type = state]'
511 | if (__i == end() || key_comp()(__k, (*__i).first))
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
a.cc:54:9: required from here
54 | m[num] = true;
| ^
/usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const state' and 'const state')
405 | { return __x < __y; }
| ~~~~^~~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note: 'const state' is not derived from 'const std::reverse_iterator<_Iterator>'
405 | { return __x < __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note: 'const state' is not derived from 'const std::reverse_iterator<_Iterator>'
405 | { return __x < __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note: 'const state' is not derived from 'const std::move_iterator<_IteratorL>'
405 | { return __x < __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note: 'const state' is not derived from 'const std::move_iterator<_IteratorL>'
405 | { return __x < __y; }
| ~~~~^~~~~
|
s434784458 | p00223 | C++ | #include <iostream>
#include <queue>
using namespace std;
const unsigned char INF = 255;
int H,W;
bool F[52][52];
unsigned char D[52][52][52][52];
class Point{
public:
int tx;
int ty;
int kx;
int ky;
void set(int a,int b,int c,int d){
tx = a;
ty = b;
kx = c;
ky = d;
}
};
int is_out_of_area(int y,int x){
return x < 1 || x > W || y < 1 || y > H;
}
int main(){
queue<Point> qa;
Point p;
int a,tx,ty,kx,ky;
int inc_ty,inc_ky,inc_ky,inc_kx;
while(1){
cin >> W >> H;
if(W == 0 && H == 0)
break;
cin >> tx >> ty >> kx >> ky;
for(int y=0;y<=H+1;y++){
for(int x=0;x<=W+1;x++){
F[y][x] = 1;
}
}
for(int y=1;y<=H;y++){
for(int x=1;x<=W;x++){
cin >> a;
F[y][x] = a;
for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){
D[y][x][i][j] = INF;
}
}
}
}
p.set(tx,ty,kx,ky);
qa.push(p);
D[p.ty][p.tx][p.ky][p.kx] = 0;
int counter=0;
while(1){
if(qa.empty()){
cout << "NA" <<endl;
break;
}
p = qa.front();
qa.pop();
cout << p.tx << ',' << p.ty << ',' << p.kx << ',' << p.ky << ',' << (int)D[p.ty][p.tx][p.ky][p.kx] << endl;
if(D[p.ty][p.tx][p.ky][p.kx] >= 100){
cout << "NA" << endl;
break;
}
if(p.tx == p.kx && p.ty == p.ky){
cout << (int)D[p.ty][p.tx][p.ky][p.kx] << endl;
break;
}
counter++;
if(D[p.ty-1][p.tx][p.ky+1][p.kx] == INF){
inc_ty = -1 ; _ky = 1;
if(is_out_of_area(p.ty-1,p.tx) || F[p.ty-1][p.tx]){
inc_ty = 0;
}
if(is_out_of_area(p.ky+1,p.kx) || F[p.ky+1][p.kx]){
inc_ky = 0;
}
if(inc_ty || inc_ky){
Point q;
q.set(p.tx,p.ty + inc_ty,p.kx,p.ky+inc_ky);
qa.push(q);
D[p.ty + inc_ty][p.tx][p.ky + inc_ky][p.kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
if(D[p.ty+1][p.tx][p.ky-1][p.kx] == INF){
inc_ty = 1; inc_ky = -1;
if(is_out_of_area(p.ty+1,p.tx) || F[p.ty+1][p.tx]){
inc_ty = 0;
}
if(is_out_of_area(p.ky-1,p.kx) || F[p.ky-1][p.kx]){
inc_ky = 0;
}
if(inc_ty || inc_ky){
Point q;
q.set(p.tx,p.ty + inc_ty,p.kx,p.ky+inc_ky);
qa.push(q);
D[p.ty + inc_ty][p.tx][p.ky + inc_ky][p.kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
if(D[p.ty][p.tx-1][p.ky][p.kx+1] == INF){
inc_tx = -1 ; inc_kx = 1;
if(is_out_of_area(p.ty,p.tx + inc_tx) || F[p.ty][p.tx + inc_tx]){
inc_tx = 0;
}
if(is_out_of_area(p.ky,p.kx + inc_kx) || F[p.ky][p.kx + inc_kx]){
inc_kx = 0;
}
if(inc_tx || inc_kx){
Point q;
q.set(p.tx + inc_tx,p.ty,p.kx + inc_kx,p.ky);
qa.push(q);
D[p.ty][p.tx + inc_tx][p.ky][p.kx + inc_kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
if(D[p.ty][p.tx+1][p.ky][p.kx-1] == INF){
inc_tx = 1 ; inc_kx = -1;
if(is_out_of_area(p.ty,p.tx + inc_tx) || F[p.ty][p.tx + inc_tx]){
inc_tx = 0;
}
if(is_out_of_area(p.ky,p.kx + inc_kx) || F[p.ky][p.kx + inc_kx]){
inc_kx = 0;
}
if(inc_tx || inc_kx){
Point q;
q.set(p.tx + inc_tx,p.ty,p.kx + inc_kx,p.ky);
qa.push(q);
D[p.ty][p.tx + inc_tx][p.ky][p.kx + inc_kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
}
while(!qa.empty()){
qa.pop();
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:32:21: error: redeclaration of 'int inc_ky'
32 | int inc_ty,inc_ky,inc_ky,inc_kx;
| ^~~~~~
a.cc:32:14: note: 'int inc_ky' previously declared here
32 | int inc_ty,inc_ky,inc_ky,inc_kx;
| ^~~~~~
a.cc:80:26: error: '_ky' was not declared in this scope; did you mean 'ky'?
80 | inc_ty = -1 ; _ky = 1;
| ^~~
| ky
a.cc:116:11: error: 'inc_tx' was not declared in this scope; did you mean 'inc_kx'?
116 | inc_tx = -1 ; inc_kx = 1;
| ^~~~~~
| inc_kx
a.cc:133:12: error: 'inc_tx' was not declared in this scope; did you mean 'inc_kx'?
133 | inc_tx = 1 ; inc_kx = -1;
| ^~~~~~
| inc_kx
|
s432566476 | p00223 | C++ | #include <iostream>
#include <queue>
using namespace std;
const unsigned char INF = 255;
int H,W;
bool F[52][52];
unsigned char D[52][52][52][52];
class Point{
public:
int tx;
int ty;
int kx;
int ky;
void set(int a,int b,int c,int d){
tx = a;
ty = b;
kx = c;
ky = d;
}
};
int is_out_of_area(int y,int x){
return x < 1 || x > W || y < 1 || y > H;
}
int main(){
queue<Point> qa;
Point p;
int a,tx,ty,kx,ky;
int inc_ty,inc_ky,inc_ky,inc_kx;
while(1){
cin >> W >> H;
if(W == 0 && H == 0)
break;
cin >> tx >> ty >> kx >> ky;
for(int y=0;y<=H+1;y++){
for(int x=0;x<=W+1;x++){
F[y][x] = 1;
}
}
for(int y=1;y<=H;y++){
for(int x=1;x<=W;x++){
cin >> a;
F[y][x] = a;
for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){
D[y][x][i][j] = INF;
}
}
}
}
p.set(tx,ty,kx,ky);
qa.push(p);
D[p.ty][p.tx][p.ky][p.kx] = 0;
int counter=0;
while(1){
if(qa.empty()){
cout << "NA" <<endl;
break;
}
p = qa.front();
qa.pop();
cout << p.tx << ',' << p.ty << ',' << p.kx << ',' << p.ky << ',' << (int)D[p.ty][p.tx][p.ky][p.kx] << endl;
if(D[p.ty][p.tx][p.ky][p.kx] >= 100){
cout << "NA" << endl;
break;
}
if(p.tx == p.kx && p.ty == p.ky){
cout << (int)D[p.ty][p.tx][p.ky][p.kx] << endl;
break;
}
counter++;
if(D[p.ty-1][p.tx][p.ky+1][p.kx] == INF){
inc_ty = -1 ; inc_ky = 1;
if(is_out_of_area(p.ty-1,p.tx) || F[p.ty-1][p.tx]){
inc_ty = 0;
}
if(is_out_of_area(p.ky+1,p.kx) || F[p.ky+1][p.kx]){
inc_ky = 0;
}
if(inc_ty || inc_ky){
Point q;
q.set(p.tx,p.ty + inc_ty,p.kx,p.ky+inc_ky);
qa.push(q);
D[p.ty + inc_ty][p.tx][p.ky + inc_ky][p.kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
if(D[p.ty+1][p.tx][p.ky-1][p.kx] == INF){
inc_ty = 1; inc_ky = -1;
if(is_out_of_area(p.ty+1,p.tx) || F[p.ty+1][p.tx]){
inc_ty = 0;
}
if(is_out_of_area(p.ky-1,p.kx) || F[p.ky-1][p.kx]){
inc_ky = 0;
}
if(inc_ty || inc_ky){
Point q;
q.set(p.tx,p.ty + inc_ty,p.kx,p.ky+inc_ky);
qa.push(q);
D[p.ty + inc_ty][p.tx][p.ky + inc_ky][p.kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
if(D[p.ty][p.tx-1][p.ky][p.kx+1] == INF){
inc_tx = -1 ; inc_kx = 1;
if(is_out_of_area(p.ty,p.tx + inc_tx) || F[p.ty][p.tx + inc_tx]){
inc_tx = 0;
}
if(is_out_of_area(p.ky,p.kx + inc_kx) || F[p.ky][p.kx + inc_kx]){
inc_kx = 0;
}
if(inc_tx || inc_kx){
Point q;
q.set(p.tx + inc_tx,p.ty,p.kx + inc_kx,p.ky);
qa.push(q);
D[p.ty][p.tx + inc_tx][p.ky][p.kx + inc_kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
if(D[p.ty][p.tx+1][p.ky][p.kx-1] == INF){
inc_tx = 1 ; inc_kx = -1;
if(is_out_of_area(p.ty,p.tx + inc_tx) || F[p.ty][p.tx + inc_tx]){
inc_tx = 0;
}
if(is_out_of_area(p.ky,p.kx + inc_kx) || F[p.ky][p.kx + inc_kx]){
inc_kx = 0;
}
if(inc_tx || inc_kx){
Point q;
q.set(p.tx + inc_tx,p.ty,p.kx + inc_kx,p.ky);
qa.push(q);
D[p.ty][p.tx + inc_tx][p.ky][p.kx + inc_kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
}
while(!qa.empty()){
qa.pop();
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:32:21: error: redeclaration of 'int inc_ky'
32 | int inc_ty,inc_ky,inc_ky,inc_kx;
| ^~~~~~
a.cc:32:14: note: 'int inc_ky' previously declared here
32 | int inc_ty,inc_ky,inc_ky,inc_kx;
| ^~~~~~
a.cc:116:11: error: 'inc_tx' was not declared in this scope; did you mean 'inc_kx'?
116 | inc_tx = -1 ; inc_kx = 1;
| ^~~~~~
| inc_kx
a.cc:133:12: error: 'inc_tx' was not declared in this scope; did you mean 'inc_kx'?
133 | inc_tx = 1 ; inc_kx = -1;
| ^~~~~~
| inc_kx
|
s299735751 | p00223 | C++ | #include <iostream>
#include <queue>
using namespace std;
const unsigned char INF = 255;
int H,W;
bool F[52][52];
unsigned char D[52][52][52][52];
class Point{
public:
int tx;
int ty;
int kx;
int ky;
void set(int a,int b,int c,int d){
tx = a;
ty = b;
kx = c;
ky = d;
}
};
int is_out_of_area(int y,int x){
return x < 1 || x > W || y < 1 || y > H;
}
int main(){
queue<Point> qa;
Point p;
int a,tx,ty,kx,ky;
int inc_ty,inc_ky,inc_ky,inc_kx;
while(1){
cin >> W >> H;
if(W == 0 && H == 0)
break;
cin >> tx >> ty >> kx >> ky;
for(int y=0;y<=H+1;y++){
for(int x=0;x<=W+1;x++){
F[y][x] = 1;
}
}
for(int y=1;y<=H;y++){
for(int x=1;x<=W;x++){
cin >> a;
F[y][x] = a;
for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){
D[y][x][i][j] = INF;
}
}
}
}
p.set(tx,ty,kx,ky);
qa.push(p);
D[p.ty][p.tx][p.ky][p.kx] = 0;
int counter=0;
while(1){
if(qa.empty()){
cout << "NA" <<endl;
break;
}
p = qa.front();
qa.pop();
cout << p.tx << ',' << p.ty << ',' << p.kx << ',' << p.ky << ',' << (int)D[p.ty][p.tx][p.ky][p.kx] << endl;
if(D[p.ty][p.tx][p.ky][p.kx] >= 100){
cout << "NA" << endl;
break;
}
if(p.tx == p.kx && p.ty == p.ky){
cout << (int)D[p.ty][p.tx][p.ky][p.kx] << endl;
break;
}
counter++;
if(D[p.ty-1][p.tx][p.ky+1][p.kx] == INF){
inc_ty = -1 ; inc_ky = 1;
if(is_out_of_area(p.ty-1,p.tx) || F[p.ty-1][p.tx]){
inc_ty = 0;
}
if(is_out_of_area(p.ky+1,p.kx) || F[p.ky+1][p.kx]){
inc_ky = 0;
}
if(inc_ty || inc_ky){
Point q;
q.set(p.tx,p.ty + inc_ty,p.kx,p.ky+inc_ky);
qa.push(q);
D[p.ty + inc_ty][p.tx][p.ky + inc_ky][p.kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
if(D[p.ty+1][p.tx][p.ky-1][p.kx] == INF){
inc_ty = 1; inc_ky = -1;
if(is_out_of_area(p.ty+1,p.tx) || F[p.ty+1][p.tx]){
inc_ty = 0;
}
if(is_out_of_area(p.ky-1,p.kx) || F[p.ky-1][p.kx]){
inc_ky = 0;
}
if(inc_ty || inc_ky){
Point q;
q.set(p.tx,p.ty + inc_ty,p.kx,p.ky+inc_ky);
qa.push(q);
D[p.ty + inc_ty][p.tx][p.ky + inc_ky][p.kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
if(D[p.ty][p.tx-1][p.ky][p.kx+1] == INF){
inc_tx = -1 ; inc_kx = 1;
if(is_out_of_area(p.ty,p.tx + inc_tx) || F[p.ty][p.tx + inc_tx]){
inc_tx = 0;
}
if(is_out_of_area(p.ky,p.kx + inc_kx) || F[p.ky][p.kx + inc_kx]){
inc_kx = 0;
}
if(inc_tx || inc_kx){
Point q;
q.set(p.tx + inc_tx,p.ty,p.kx + inc_kx,p.ky);
qa.push(q);
D[p.ty][p.tx + inc_tx][p.ky][p.kx + inc_kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
if(D[p.ty][p.tx+1][p.ky][p.kx-1] == INF){
inc_tx = 1 ; inc_kx = -1;
if(is_out_of_area(p.ty,p.tx + inc_tx) || F[p.ty][p.tx + inc_tx]){
inc_tx = 0;
}
if(is_out_of_area(p.ky,p.kx + inc_kx) || F[p.ky][p.kx + inc_kx]){
inc_kx = 0;
}
if(inc_tx || inc_kx){
Point q;
q.set(p.tx + inc_tx,p.ty,p.kx + inc_kx,p.ky);
qa.push(q);
D[p.ty][p.tx + inc_tx][p.ky][p.kx + inc_kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
}
while(!qa.empty()){
qa.pop();
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:32:21: error: redeclaration of 'int inc_ky'
32 | int inc_ty,inc_ky,inc_ky,inc_kx;
| ^~~~~~
a.cc:32:14: note: 'int inc_ky' previously declared here
32 | int inc_ty,inc_ky,inc_ky,inc_kx;
| ^~~~~~
a.cc:116:11: error: 'inc_tx' was not declared in this scope; did you mean 'inc_kx'?
116 | inc_tx = -1 ; inc_kx = 1;
| ^~~~~~
| inc_kx
a.cc:133:12: error: 'inc_tx' was not declared in this scope; did you mean 'inc_kx'?
133 | inc_tx = 1 ; inc_kx = -1;
| ^~~~~~
| inc_kx
|
s610825364 | p00223 | C++ | #include <iostream>
#include <queue>
using namespace std;
const unsigned char INF = 255;
int H,W;
bool F[52][52];
unsigned char D[52][52][52][52];
class Point{
public:
int tx;
int ty;
int kx;
int ky;
void set(int a,int b,int c,int d){
tx = a;
ty = b;
kx = c;
ky = d;
}
};
int is_out_of_area(int y,int x){
return x < 1 || x > W || y < 1 || y > H;
}
int main(){
queue<Point> qa;
Point p;
int a,tx,ty,kx,ky;
int inc_ty,inc_ky,inc_ty,inc_kx;
while(1){
cin >> W >> H;
if(W == 0 && H == 0)
break;
cin >> tx >> ty >> kx >> ky;
for(int y=0;y<=H+1;y++){
for(int x=0;x<=W+1;x++){
F[y][x] = 1;
}
}
for(int y=1;y<=H;y++){
for(int x=1;x<=W;x++){
cin >> a;
F[y][x] = a;
for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){
D[y][x][i][j] = INF;
}
}
}
}
p.set(tx,ty,kx,ky);
qa.push(p);
D[p.ty][p.tx][p.ky][p.kx] = 0;
int counter=0;
while(1){
if(qa.empty()){
cout << "NA" <<endl;
break;
}
p = qa.front();
qa.pop();
cout << p.tx << ',' << p.ty << ',' << p.kx << ',' << p.ky << ',' << (int)D[p.ty][p.tx][p.ky][p.kx] << endl;
if(D[p.ty][p.tx][p.ky][p.kx] >= 100){
cout << "NA" << endl;
break;
}
if(p.tx == p.kx && p.ty == p.ky){
cout << (int)D[p.ty][p.tx][p.ky][p.kx] << endl;
break;
}
counter++;
if(D[p.ty-1][p.tx][p.ky+1][p.kx] == INF){
inc_ty = -1 ; inc_ky = 1;
if(is_out_of_area(p.ty-1,p.tx) || F[p.ty-1][p.tx]){
inc_ty = 0;
}
if(is_out_of_area(p.ky+1,p.kx) || F[p.ky+1][p.kx]){
inc_ky = 0;
}
if(inc_ty || inc_ky){
Point q;
q.set(p.tx,p.ty + inc_ty,p.kx,p.ky+inc_ky);
qa.push(q);
D[p.ty + inc_ty][p.tx][p.ky + inc_ky][p.kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
if(D[p.ty+1][p.tx][p.ky-1][p.kx] == INF){
inc_ty = 1; inc_ky = -1;
if(is_out_of_area(p.ty+1,p.tx) || F[p.ty+1][p.tx]){
inc_ty = 0;
}
if(is_out_of_area(p.ky-1,p.kx) || F[p.ky-1][p.kx]){
inc_ky = 0;
}
if(inc_ty || inc_ky){
Point q;
q.set(p.tx,p.ty + inc_ty,p.kx,p.ky+inc_ky);
qa.push(q);
D[p.ty + inc_ty][p.tx][p.ky + inc_ky][p.kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
if(D[p.ty][p.tx-1][p.ky][p.kx+1] == INF){
inc_tx = -1 ; inc_kx = 1;
if(is_out_of_area(p.ty,p.tx + inc_tx) || F[p.ty][p.tx + inc_tx]){
inc_tx = 0;
}
if(is_out_of_area(p.ky,p.kx + inc_kx) || F[p.ky][p.kx + inc_kx]){
inc_kx = 0;
}
if(inc_tx || inc_kx){
Point q;
q.set(p.tx + inc_tx,p.ty,p.kx + inc_kx,p.ky);
qa.push(q);
D[p.ty][p.tx + inc_tx][p.ky][p.kx + inc_kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
if(D[p.ty][p.tx+1][p.ky][p.kx-1] == INF){
inc_tx = 1 ; inc_kx = -1;
if(is_out_of_area(p.ty,p.tx + inc_tx) || F[p.ty][p.tx + inc_tx]){
inc_tx = 0;
}
if(is_out_of_area(p.ky,p.kx + inc_kx) || F[p.ky][p.kx + inc_kx]){
inc_kx = 0;
}
if(inc_tx || inc_kx){
Point q;
q.set(p.tx + inc_tx,p.ty,p.kx + inc_kx,p.ky);
qa.push(q);
D[p.ty][p.tx + inc_tx][p.ky][p.kx + inc_kx] = D[p.ty][p.tx][p.ky][p.kx] + 1;
}
}
}
while(!qa.empty()){
qa.pop();
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:32:21: error: redeclaration of 'int inc_ty'
32 | int inc_ty,inc_ky,inc_ty,inc_kx;
| ^~~~~~
a.cc:32:7: note: 'int inc_ty' previously declared here
32 | int inc_ty,inc_ky,inc_ty,inc_kx;
| ^~~~~~
a.cc:116:11: error: 'inc_tx' was not declared in this scope; did you mean 'inc_kx'?
116 | inc_tx = -1 ; inc_kx = 1;
| ^~~~~~
| inc_kx
a.cc:133:12: error: 'inc_tx' was not declared in this scope; did you mean 'inc_kx'?
133 | inc_tx = 1 ; inc_kx = -1;
| ^~~~~~
| inc_kx
|
s745340223 | p00223 | C++ | #include <iostream>
#include <queue>
using namespace std;
int H,W;
class Point{
public:
int tx; //タカユキの座標
int ty;
int kx; //カズユキの座標
int ky;
int d; //ターン回数
void set(int a,int b,int c,int d){
tx = a;
ty = b;
kx = c;
ky = d;
}
};
int is_out_of_area(int y,int x) //座標が範囲内か確認する関数
{
return x < 1 || x > W || y < 1 || y > H;
}
int main(){
while(1){
bool F[52][52]; //障害物
bool D[52][52][52][52]; //探索済みかの判定用
Point p;
int tx,ty,kx,ky;
queue<Point> qa;
cin >> W >> H;
if(W == 0 && H == 0)
break;
cin >> tx >> ty >> kx >> ky;
for(int y=0;y<=H+1;y++){
for(int x=0;x<=W+1;x++){
F[y][x] = 1;
}
}
for(int y=1;y<=H;y++){
for(int x=1;x<=W;x++){
int a;
cin >> a;
F[y][x] = a;
for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){
D[y][x][i][j] = 1; //1:未探索 , 0:探索済み
}
}
}
}
p.set(tx,ty,kx,ky);
p.d = 0;
qa.push(p);
while(1){
if(qa.empty()){
cout << "NA" <<endl;
break;
}
p = qa.front();
qa.pop();
if(p.d >= 100){
cout << "NA" << endl;
break;
}
if(p.tx == p.kx && p.ty == p.ky){
cout << p.d << endl;
break;
}
if(D[p.ty-1][p.tx][p.ky+1][p.kx]){ //タカユキの y 座標を-1, カズユキを+1 同様の if 文が下に四つ続く
int inc_ty = -1 , inc_ky = 1;
if(is_out_of_area(p.ty-1,p.tx) || F[p.ty-1][p.tx]){ //範囲外または障害物にあたったならば移動しない
inc_ty = 0;
}
if(is_out_of_area(p.ky+1,p.kx) || F[p.ky+1][p.kx]){ //範囲外または障害物にあたったならば移動しない
inc_ky = 0;
}
}
if(inc_ty || inc_ky){ //どちらかが動ける状態であったならキューにプッシュ
Point q;
q.set(p.tx,p.ty + inc_ty,p.kx,p.ky+inc_ky);
q.d = p.d + 1;
qa.push(q);
D[p.ty + inc_ty][p.tx][p.ky + inc_ky][p.kx] = 0;
}
if(D[p.ty+1][p.tx][p.ky-1][p.kx]){
int inc_ty = 1 , inc_ky = -1;
if(is_out_of_area(p.ty+1,p.tx) || F[p.ty+1][p.tx]){inc_ty = 0;
}
if(is_out_of_area(p.ky-1,p.kx) || F[p.ky-1][p.kx]){
inc_ky = 0;
}
}
if(inc_ty || inc_ky){
Point q;
q.set(p.tx,p.ty + inc_ty,p.kx,p.ky+inc_ky);
q.d = p.d + 1;
qa.push(q);
D[p.ty + inc_ty][p.tx][p.ky + inc_ky][p.kx] = 0;
}
if(D[p.ty][p.tx-1][p.ky][p.kx+1]){
int inc_tx = -1 , inc_kx = 1;
if(is_out_of_area(p.ty,p.tx + inc_tx) || F[p.ty][p.tx + inc_tx]){
inc_tx = 0;
}
if(is_out_of_area(p.ky,p.kx + inc_kx) || F[p.ky][p.kx + inc_kx]){
inc_kx = 0;
}
if(inc_tx || inc_kx){
Point q;
q.set(p.tx + inc_tx,p.ty,p.kx + inc_kx,p.ky);
q.d = p.d + 1;
qa.push(q);
D[p.ty][p.tx + inc_tx][p.ky][p.kx + inc_kx] = 0;
}
}
if(D[p.ty][p.tx+1][p.ky][p.kx-1]){
int inc_tx = 1 , inc_kx = -1;
if(is_out_of_area(p.ty,p.tx + inc_tx) || F[p.ty][p.tx + inc_tx]){
inc_tx = 0;
}
if(is_out_of_area(p.ky,p.kx + inc_kx) || F[p.ky][p.kx + inc_kx]){
inc_kx = 0;
}
}
if(inc_tx || inc_kx){
Point q;
q.set(p.tx + inc_tx,p.ty,p.kx + inc_kx,p.ky);
q.d = p.d + 1;
qa.push(q);
D[p.ty][p.tx + inc_tx][p.ky][p.kx + inc_kx] = 0;
}
}
while(!qa.empty()){
qa.pop();
} //キューの残りカスを消去
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:79:10: error: 'inc_ty' was not declared in this scope; did you mean 'ino_t'?
79 | if(inc_ty || inc_ky){ //どちらかが動ける状態であったならキューにプッシュ
| ^~~~~~
| ino_t
a.cc:79:20: error: 'inc_ky' was not declared in this scope
79 | if(inc_ty || inc_ky){ //どちらかが動ける状態であったならキューにプッシュ
| ^~~~~~
a.cc:94:10: error: 'inc_ty' was not declared in this scope; did you mean 'ino_t'?
94 | if(inc_ty || inc_ky){
| ^~~~~~
| ino_t
a.cc:94:20: error: 'inc_ky' was not declared in this scope
94 | if(inc_ty || inc_ky){
| ^~~~~~
a.cc:126:10: error: 'inc_tx' was not declared in this scope; did you mean 'ino_t'?
126 | if(inc_tx || inc_kx){
| ^~~~~~
| ino_t
a.cc:126:20: error: 'inc_kx' was not declared in this scope
126 | if(inc_tx || inc_kx){
| ^~~~~~
|
s584298387 | p00223 | C++ | const int dx[][4] = {{1, 0, -1, 0}, {-1, 0, 1, 0}};
const int dy[][4] = {{0, 1, 0, -1}, {0, -1, 0, 1}};
int X, Y;
bool map[50][50];
bool passed[50][50][50][50];
struct P
{
int tx, ty;
int kx, ky;
int cost;
P(int _tx, int _ty, int _kx, int _ky, int _cost) : tx(_tx), ty(_ty), kx(_kx), ky(_ky), cost(_cost) {};
};
bool check(int x, int y)
{
return x < 0 || x >= X || y < 0 || y >= Y || map[y][x];
}
int main()
{
int tx, ty, kx, ky, ans;
while(cin >> X >> Y, X|Y)
{
ans = -1;
memset(passed, 0, sizeof passed);
queue<P> que;
cin >> tx >> ty >> kx >> ky;
tx--, ty--, kx--, ky--;
for(int i = 0; i < Y; i++)
for(int j = 0; j < X; j++)
cin >> map[i][j];
passed[tx][ty][kx][ky] = true;
for(que.push(P(tx, ty, kx, ky, 0)); !que.empty(); que.pop())
{
P p = que.front();
if(p.cost >= 100)
break;
if(p.tx == p.kx && p.ty == p.ky)
{
ans = p.cost;
break;
}
for(int i = 0; i < 4; i++)
{
int mtx = p.tx + dx[0][i], mty = p.ty + dy[0][i];
int mkx = p.kx + dx[1][i], mky = p.ky + dy[1][i];
if(check(mtx, mty))
mtx = p.tx, mty = p.ty;
if(check(mkx, mky))
mkx = p.kx, mky = p.ky;
if(passed[mtx][mty][mkx][mky])
continue;
passed[mtx][mty][mkx][mky] = true;
que.push(P(mtx, mty, mkx, mky, p.cost + 1));
}
}
if(ans == -1)
puts("NA");
else
cout << ans << endl;
}
}
| a.cc: In function 'int main()':
a.cc:26:11: error: 'cin' was not declared in this scope
26 | while(cin >> X >> Y, X|Y)
| ^~~
a.cc:29:9: error: 'memset' was not declared in this scope
29 | memset(passed, 0, sizeof passed);
| ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
+++ |+#include <cstring>
1 | const int dx[][4] = {{1, 0, -1, 0}, {-1, 0, 1, 0}};
a.cc:30:9: error: 'queue' was not declared in this scope
30 | queue<P> que;
| ^~~~~
a.cc:30:16: error: expected primary-expression before '>' token
30 | queue<P> que;
| ^
a.cc:30:18: error: 'que' was not declared in this scope
30 | queue<P> que;
| ^~~
a.cc:72:13: error: 'puts' was not declared in this scope
72 | puts("NA");
| ^~~~
a.cc:74:13: error: 'cout' was not declared in this scope
74 | cout << ans << endl;
| ^~~~
a.cc:74:28: error: 'endl' was not declared in this scope
74 | cout << ans << endl;
| ^~~~
|
s556654710 | p00223 | C++ | const int dx[][4] = {{1, 0, -1, 0}, {-1, 0, 1, 0}};
const int dy[][4] = {{0, 1, 0, -1}, {0, -1, 0, 1}};
int X, Y;
bool map[50][50];
bool passed[50][50][50][50];
struct P
{
int tx, ty;
int kx, ky;
int cost;
P(int _tx, int _ty, int _kx, int _ky, int _cost) : tx(_tx), ty(_ty), kx(_kx), ky(_ky), cost(_cost) {};
};
bool check(int x, int y)
{
return x < 0 || x >= X || y < 0 || y >= Y || map[y][x];
}
int main()
{
int tx, ty, kx, ky, ans;
while(cin >> X >> Y, X|Y)
{
ans = -1;
memset(passed, 0, sizeof passed);
queue<P> que;
cin >> tx >> ty >> kx >> ky;
tx--, ty--, kx--, ky--;
for(int i = 0; i < Y; i++)
for(int j = 0; j < X; j++)
cin >> map[i][j];
passed[tx][ty][kx][ky] = true;
for(que.push(P(tx, ty, kx, ky, 0)); !que.empty(); que.pop())
{
P p = que.front();
if(p.cost >= 100)
break;
if(p.tx == p.kx && p.ty == p.ky)
{
ans = p.cost;
break;
}
for(int i = 0; i < 4; i++)
{
int mtx = p.tx + dx[0][i], mty = p.ty + dy[0][i];
int mkx = p.kx + dx[1][i], mky = p.ky + dy[1][i];
if(check(mtx, mty))
mtx = p.tx, mty = p.ty;
if(check(mkx, mky))
mkx = p.kx, mky = p.ky;
if(passed[mtx][mty][mkx][mky])
continue;
passed[mtx][mty][mkx][mky] = true;
que.push(P(mtx, mty, mkx, mky, p.cost + 1));
}
}
if(ans == -1)
puts("NA");
else
cout << ans << endl;
}
}
| a.cc: In function 'int main()':
a.cc:26:11: error: 'cin' was not declared in this scope
26 | while(cin >> X >> Y, X|Y)
| ^~~
a.cc:29:9: error: 'memset' was not declared in this scope
29 | memset(passed, 0, sizeof passed);
| ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
+++ |+#include <cstring>
1 | const int dx[][4] = {{1, 0, -1, 0}, {-1, 0, 1, 0}};
a.cc:30:9: error: 'queue' was not declared in this scope
30 | queue<P> que;
| ^~~~~
a.cc:30:16: error: expected primary-expression before '>' token
30 | queue<P> que;
| ^
a.cc:30:18: error: 'que' was not declared in this scope
30 | queue<P> que;
| ^~~
a.cc:72:13: error: 'puts' was not declared in this scope
72 | puts("NA");
| ^~~~
a.cc:74:13: error: 'cout' was not declared in this scope
74 | cout << ans << endl;
| ^~~~
a.cc:74:28: error: 'endl' was not declared in this scope
74 | cout << ans << endl;
| ^~~~
|
s194373120 | p00223 | C++ | #include <iostream>
#include <queue>
#include <map>
#include <string>
const int dx[][4] = {{1, 0, -1, 0}, {-1, 0, 1, 0}};
const int dy[][4] = {{0, 1, 0, -1}, {0, -1, 0, 1}};
int X, Y;
bool map[50][50];
bool passed[50][50][50][50];
struct P
{
int tx, ty;
int kx, ky;
int cost;
P(int _tx, int _ty, int _kx, int _ky, int _cost) : tx(_tx), ty(_ty), kx(_kx), ky(_ky), cost(_cost) {};
};
bool check(int x, int y)
{
return x < 0 || x >= X || y < 0 || y >= Y || map[y][x];
}
int main()
{
int tx, ty, kx, ky, ans;
while(cin >> X >> Y, X|Y)
{
ans = -1;
memset(passed, 0, sizeof passed);
queue<P> que;
cin >> tx >> ty >> kx >> ky;
tx--, ty--, kx--, ky--;
for(int i = 0; i < Y; i++)
for(int j = 0; j < X; j++)
cin >> map[i][j];
passed[tx][ty][kx][ky] = true;
for(que.push(P(tx, ty, kx, ky, 0)); !que.empty(); que.pop())
{
P p = que.front();
if(p.cost >= 100)
break;
if(p.tx == p.kx && p.ty == p.ky)
{
ans = p.cost;
break;
}
for(int i = 0; i < 4; i++)
{
int mtx = p.tx + dx[0][i], mty = p.ty + dy[0][i];
int mkx = p.kx + dx[1][i], mky = p.ky + dy[1][i];
if(check(mtx, mty))
mtx = p.tx, mty = p.ty;
if(check(mkx, mky))
mkx = p.kx, mky = p.ky;
if(passed[mtx][mty][mkx][mky])
continue;
passed[mtx][mty][mkx][mky] = true;
que.push(P(mtx, mty, mkx, mky, p.cost + 1));
}
}
if(ans == -1)
puts("NA");
else
cout << ans << endl;
}
}
| a.cc: In function 'int main()':
a.cc:32:11: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
32 | while(cin >> X >> Y, X|Y)
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:35:9: error: 'memset' was not declared in this scope
35 | memset(passed, 0, sizeof passed);
| ^~~~~~
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 | #include <string>
a.cc:36:9: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
36 | queue<P> que;
| ^~~~~
| std::queue
In file included from /usr/include/c++/14/queue:66,
from a.cc:2:
/usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here
96 | class queue
| ^~~~~
a.cc:36:16: error: expected primary-expression before '>' token
36 | queue<P> que;
| ^
a.cc:36:18: error: 'que' was not declared in this scope
36 | queue<P> que;
| ^~~
a.cc:80:13: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
80 | cout << ans << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:80:28: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
80 | cout << ans << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s637659016 | p00223 | C++ | #include <iostream>
#include <queue>
#include <map>
#include <string>
using namespace std;
const int dx[][4] = {{1, 0, -1, 0}, {-1, 0, 1, 0}};
const int dy[][4] = {{0, 1, 0, -1}, {0, -1, 0, 1}};
int X, Y;
bool map[50][50];
bool passed[50][50][50][50];
struct P
{
int tx, ty;
int kx, ky;
int cost;
P(int _tx, int _ty, int _kx, int _ky, int _cost) : tx(_tx), ty(_ty), kx(_kx), ky(_ky), cost(_cost) {};
};
bool check(int x, int y)
{
return x < 0 || x >= X || y < 0 || y >= Y || map[y][x];
}
int main()
{
int tx, ty, kx, ky, ans;
while(cin >> X >> Y, X|Y)
{
ans = -1;
memset(passed, 0, sizeof passed);
queue<P> que;
cin >> tx >> ty >> kx >> ky;
tx--, ty--, kx--, ky--;
for(int i = 0; i < Y; i++)
for(int j = 0; j < X; j++)
cin >> map[i][j];
passed[tx][ty][kx][ky] = true;
for(que.push(P(tx, ty, kx, ky, 0)); !que.empty(); que.pop())
{
P p = que.front();
if(p.cost >= 100)
break;
if(p.tx == p.kx && p.ty == p.ky)
{
ans = p.cost;
break;
}
for(int i = 0; i < 4; i++)
{
int mtx = p.tx + dx[0][i], mty = p.ty + dy[0][i];
int mkx = p.kx + dx[1][i], mky = p.ky + dy[1][i];
if(check(mtx, mty))
mtx = p.tx, mty = p.ty;
if(check(mkx, mky))
mkx = p.kx, mky = p.ky;
if(passed[mtx][mty][mkx][mky])
continue;
passed[mtx][mty][mkx][mky] = true;
que.push(P(mtx, mty, mkx, mky, p.cost + 1));
}
}
if(ans == -1)
puts("NA");
else
cout << ans << endl;
}
}
| a.cc: In function 'bool check(int, int)':
a.cc:27:50: error: reference to 'map' is ambiguous
27 | return x < 0 || x >= X || y < 0 || y >= Y || map[y][x];
| ^~~
In file included from /usr/include/c++/14/map:63,
from a.cc:3:
/usr/include/c++/14/bits/stl_map.h:102:11: note: candidates are: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
102 | class map
| ^~~
a.cc:13:6: note: 'bool map [50][50]'
13 | bool map[50][50];
| ^~~
a.cc: In function 'int main()':
a.cc:36:9: error: 'memset' was not declared in this scope
36 | memset(passed, 0, sizeof passed);
| ^~~~~~
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 | #include <string>
a.cc:44:24: error: reference to 'map' is ambiguous
44 | cin >> map[i][j];
| ^~~
/usr/include/c++/14/bits/stl_map.h:102:11: note: candidates are: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
102 | class map
| ^~~
a.cc:13:6: note: 'bool map [50][50]'
13 | bool map[50][50];
| ^~~
|
s560078839 | p00223 | C++ | #include <iostream>
#include <queue>
#include <cstring>
using namespace std;
int H,W;
bool F[52][52]; //障害物
bool D[52][52][52][52]; //探索済みかの判定用
int inc_tx[4] = {1,-1,0,0};
int inc_ty[4] = {0,0,1,-1};
int inc_kx[4] = {-1,1,0,0};
int inc_ky[4] = {0,0,-1,1};
class Point{
public:
int tx; //タカユキの座標
int ty;
int kx; //カズユキの座標
int ky;
int d; //ターン回数
void set(int a,int b,int c,int d){
tx = a;
ty = b;
kx = c;
ky = d;
}
};
bool is_out_of_area(int y,int x) //座標が範囲内か確認する関数
{
return x < 1 || x > W || y < 1 || y > H || F[y][x];
}
int main(){
while(1){
Point p,q;
int tx,ty,kx,ky;
queue<Point> qa;
cin >> W >> H;
if(W == 0 && H == 0)
break;
cin >> tx >> ty >> kx >> ky;
memset(F,1,sizeof(F));
for(int y=1;y<=H;y++){
for(int x=1;x<=W;x++){
cin >> F[y][x];
}
}
memset(D,1,sizeof(D));
p.set(tx,ty,kx,ky);
D[ty][tx][ky][kx] = 0;
p.d = 0;
qa.push(p);
while(1){
int inc_tx,inc_ty,inc_kx,inc_ky;
if(qa.empty()){
cout << "NA" <<endl;
break;
}
p = qa.front();
qa.pop();
if(p.d >= 100){
cout << "NA" << endl;
break;
}
if(p.tx == p.kx && p.ty == p.ky){
cout << p.d << endl;
break;
}
for(int i=0;i<4;i++){
q.tx = p.tx + inc_tx[i]; q.ty = p.ty + inc_ty[i];
q.kx = p.kx + inc_kx[i]; q.ky = p.ky + inc_ky[i];
if(D[q.ty][q.tx][q.ky][q.kx]){
if(is_out_of_area(q.ty ,q.tx) == 0 || is_out_of_area(q.ky ,q.kx) == 0){
if(is_out_of_area(q.ty ,q.tx)){
q.ty = p.ty; q.tx = p.tx;
}
if(is_out_of_area(q.ky ,q.kx)){
q.ky = p.ky; q.kx = p.kx;
}
q.d = p.d + 1;
qa.push(q);
D[q.ty][q.tx][q.ky][q.kx] = 0;
}
}
}
}
while(!qa.empty()){
qa.pop();
} //キューの残りカスを消去
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:74:29: error: invalid types 'int[int]' for array subscript
74 | q.tx = p.tx + inc_tx[i]; q.ty = p.ty + inc_ty[i];
| ^
a.cc:74:54: error: invalid types 'int[int]' for array subscript
74 | q.tx = p.tx + inc_tx[i]; q.ty = p.ty + inc_ty[i];
| ^
a.cc:75:29: error: invalid types 'int[int]' for array subscript
75 | q.kx = p.kx + inc_kx[i]; q.ky = p.ky + inc_ky[i];
| ^
a.cc:75:54: error: invalid types 'int[int]' for array subscript
75 | q.kx = p.kx + inc_kx[i]; q.ky = p.ky + inc_ky[i];
| ^
|
s592951166 | p00223 | C++ | #include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
struct State{
int tx, ty, kx, ky;
State(int tx, int ty, int kx, int ky) : tx(tx), ty(ty), kx(kx), ky(ky) {}
};
#define MAX 51
#define INF 1e9
int H, W, tx, ty, kx, ky;
int field[MAX][MAX];
const int ttx[] = {-1,0,0,1};
const int tty[] = {0,-1,1,0};
const int kkx[] = {1,0,0,-1};
const int kky[] = {0,1,-1,0};
bool inField(int y, int x){
return 0 <= y && y < H && 0 <= x && x < W;
}
int bfs(){
bool vis[MAX][MAX][MAX][MAX];
memset(vis, false, sizeof(vis));
vis[ty][tx][ky][kx] = true;
queue<State> Q;
Q.push(State(tx,ty,kx,ky));
queue<int> cnt;
cnt.push(0);
int res = INF;
while(!Q.empty()){
State s = Q.front(); Q.pop();
int _cnt = cnt.front(); cnt.pop();
if(_cnt == 100) break;
if(s.tx == s.kx && s.ty == s.ky){
res = min(res, _cnt);
break;
}
for(int i = 0 ; i < 4 ; i++){
int ntx = s.tx + ttx[i], nty = s.ty + tty[i];
int nkx = s.kx + kkx[i], nky = s.ky + kky[i];
if(!inField(nty, ntx) || field[nty][ntx] == 1){
ntx = s.tx, nty = s.ty;
}
if(!inField(nky, nkx) || field[nky][nkx] == 1){
nkx = s.kx, nky = s.ky;
}
if(vis[nty][ntx][nky][nkx]) continue;
vis[nty][ntx][nky][nkx] = true;
Q.push(State(ntx, nty, nkx, nky));
cnt.push(_cnt+1);
}
}
return res;
}
int main(){
while(cin >> W >> H, (W | H)){
cin >> tx >> ty >> kx >> ky;
tx--, ty--, kx--, ky--;
for(int i = 0 ; i < H ; i++){
for(int j = 0 ; j < W ; j++){
cin >> field[i][j];
}
}
int res = bfs();
if(res == INF){
cout << "NA" << endl;
}else{
cout << res << endl;
}
}
return 0;
} | a.cc: In function 'int bfs()':
a.cc:28:3: error: 'memset' was not declared in this scope
28 | memset(vis, false, sizeof(vis));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <algorithm>
+++ |+#include <cstring>
4 |
|
s941481438 | p00223 | C++ | #include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
struct Data{
int x1,y1,x2,y2,cnt;
Data(){}
Data(int x1,int y1,int x2,int y2,int cnt):
x1(x1),y1(y1),x2(x2),y2(y2),cnt(cnt){}
};
bool memo[50][50][50][50];
int dx[] = {0,1,-1,0}, dy[] = {1,0,0,-1};
int main() {
int x,y;
while(scanf("%d%d",&x,&y),(x|y)) {
int tx,ty;
int kx,ky;
scanf("%d%d",&tx,&ty);
scanf("%d%d",&kx,&ky);
tx--;ty--;kx--;ky--;
int stage[51][51];
for(int i = 0; i < y; i++) {
for(int j = 0; j < x; j++) {
scanf("%d",&stage[i][j]);
}
}
memset(memo,0,sizeof(memo));
queue<Data> Q;
Q.push(Data(tx,ty,kx,ky,0));
int ans = -1;
while(!Q.empty()) {
Data d = Q.front();Q.pop();
if(d.cnt >= 100) break;
if(d.x1 == d.x2 && d.y1 == d.y2) {
ans = d.cnt;
break;
}
if(memo[d.x1][d.y1][d.x2][d.y2]) continue;
memo[d.x1][d.y1][d.x2][d.y2] = true;
for(int i = 0; i < 4; i++) {
bool flg1 = false,flg2 = false;
int nx1 = dx[i] + d.x1, ny1 = dy[i] + d.y1;
int nx2 = dx[3-i] + d.x2, ny2 = dy[3-i] + d.y2;
if(nx1 < 0 || nx1 >= x || ny1 < 0 || ny1 >= y || stage[ny1][nx1] == 1) flg1 = true;
if(nx2 < 0 || nx2 >= x || ny2 < 0 || ny2 >= y || stage[ny2][nx2] == 1) flg2 = true;
if(!(flg1 | flg2)) {
Q.push(Data(nx1,ny1,nx2,ny2,d.cnt + 1));
}
if(!flg1 && flg2) {
Q.push(Data(nx1,ny1,d.x2,d.y2,d.cnt+1));
}
if(flg1 && !flg2) {
Q.push(Data(d.x1,d.y1,nx2,ny2,d.cnt+1));
}
}
}
if(ans == -1) puts("NA");
else printf("%d\n",ans);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:28:17: error: 'memset' was not declared in this scope
28 | memset(memo,0,sizeof(memo));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include<queue>
+++ |+#include <cstring>
5 | using namespace std;
|
s893107113 | p00223 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
using namespace std;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
struct Data
{
int tx,ty,kx,ky,cost;
Data(int tx,int ty,int kx,int ky,int cost) : tx(tx),ty(ty),kx(kx),ky(ky),cost(cost) {}
};
int main()
{
int x,y;
while(cin >> x >> y)
{
if(x == 0 && y == 0) break;
int tx,ty,kx,ky;
cin >> tx >> ty >> kx >> ky;
tx--;
ty--;
kx--;
ky--; | a.cc: In function 'int main()':
a.cc:37:22: error: expected '}' at end of input
37 | ky--;
| ^
a.cc:28:9: note: to match this '{'
28 | {
| ^
a.cc:37:22: error: expected '}' at end of input
37 | ky--;
| ^
a.cc:25:1: note: to match this '{'
25 | {
| ^
|
s419986115 | p00223 | C++ | #include<iostream>
#include<queue>
using namespace std;
int x,y,tx,ty,kx,ky,cou;
int mas[111][111];
int ans=0;
bool used[111][111][111][111];
int dx[]={-1,0,0,1};
int dy[]={0,-1,1,0};
struct P{
int tx,ty,kx,ky,cou;
P(int tx,int ty,int kx,int ky,int cou):tx(tx),ty(ty),kx(kx),ky(ky),cou(cou){}
};
int bfs();
int main(){
while(1){
cin >> x >> y;
if(x==0 && y==0) break;
memset(used,false,sizeof(used));
cin >> tx >> ty;
cin >> kx >> ky;
for(int i=0;i<y;i++){
for(int j=0;j<x;j++){
cin >> mas[i][j];
}
}
ans = bfs();
if(ans==-1) cout << "NA" << endl;
else cout << ans << endl;
}
}
int bfs(){
queue<P> que;
que.push(P(tx-1,ty-1,kx-1,ky-1,0));
used[tx-1][ty-1][kx-1][ky-1] = true;
while(!que.empty()){
P p=que.front();
if(p.tx==p.kx && p.ty==p.ky) return p.cou;
else if(p.cou>=100) return -1;
for(int i=0;i<4;i++){
int ntx=p.tx+dx[i];
int nty=p.ty+dy[i];
int nkx=p.kx+dx[3-i];
int nky=p.ky+dy[3-i];
if(ntx<0 || ntx>=x || nty<0 || nty>=y || mas[nty][ntx]==1){
ntx=p.tx;
nty=p.ty;
}
if(nkx<0 || nkx>=x || nky<0 || nky>=y || mas[nky][nkx]==1){
nkx=p.kx;
nky=p.ky;
}
if(used[ntx][nty][nkx][nky]==false){
que.push(P(ntx,nty,nkx,nky,p.cou+1));
used[ntx][nty][nkx][nky] = true;
}
}
que.pop();
}
return -1;
} | a.cc: In function 'int main()':
a.cc:21:5: error: 'memset' was not declared in this scope
21 | memset(used,false,sizeof(used));
| ^~~~~~
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 | using namespace std;
|
s586286707 | p00223 | C++ | #include<iostream>
#include<utility>
#include<complex>
#include<queue>
using namespace std;
typedef complex<int> P;
int X, Y;
bool field[54][54];
const P dx[4] = { P(1, 0), P(0, 1), P(-1, 0), P(0, -1) };
struct Node {
int rap;
P tak, kaz;
};
bool in_room(P p) {
int x = p.real(), y = p.imag();
return (0 <= x && x < X && 0 <= y && y < Y && !field[x][y]);
}
int main() {
while (cin >> X >> Y and X) {
int tx, ty, kx, ky;
cin >> tx >> ty >> kx >> ky;
P tak(--tx, --ty), kaz(--kx, --ky);
for (int y = 0; y < Y; y++) {
for (int x = 0; x < X; x++) {
cin >> field[x][y];
}
}
queue<Node> que;
que.push((Node){tak, kaz});
bool found = false;
while (!que.empty()) {
Node node = que.front(); que.pop();
if (node.tak == node.kaz) {
cout << "HOGE" << endl;
found = true;
break;
}
for (int i = 0; i < 4; i++) {
Node new_node{node.rap+1, node.tak+dx[i], node.kaz-dx[i]};
if (!in_room(new_node.tak)) new_node.tak = node.tak;
if (!in_room(new_node.kaz)) new_node.kaz = node.kaz;
que.push(new_node);
}
}
if (not found) {
cout << "NA" << endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:35:21: error: cannot convert 'P' {aka 'std::complex<int>'} to 'int' in initialization
35 | que.push((Node){tak, kaz});
| ^~~
| |
| P {aka std::complex<int>}
|
s517686840 | p00223 | C++ | #include <iostream>
#include <queue>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
bool mem[52][52][52][52] = {{{{}}}};
struct S{
int a,b,c,d,t;
};
int dx[4] = {-1,0,1,0};
int dy[4] = {0,1,0,-1};
void init() {
memset(mem,0,sizeof(mem));
}
int main(){
int x, y, tx, ty, kx, ky, k;
while(cin >> x >> y, (x || y)) {
int b[52][52] = {};
init();
cin >> tx >> ty >> kx >> ky;
rep(i,y) {
rep(j,x) {
cin >> k;
b[i+1][j+1] = 1-k;
}
}
queue<S> q;
S s = {tx,ty,kx,ky,0};
q.push(s);
while(!q.empty()) {
S s = q.front();
if(q.front().t >= 100) break;
if(s.a==s.c&&s.b==s.d) break;
q.pop();
if(mem[s.a][s.b][s.c][s.d]++) continue;
rep(i,4) {
int na = s.a+dx[i], nb = s.b+dy[i], nc = s.c+dx[(i+2)%4], nd = s.d+dy[(i+2)%4];
if(!b[nb][na]&&!b[nd][nc]) continue;
if(!b[nb][na]) na = s.a, nb = s.b;
if(!b[nd][nc]) nc = s.c, nd = s.d;
S ns = {na, nb, nc, nd, s.t+1};
q.push(ns);
}
}
if(q.empty()) cout << "NA" << endl;
else if(q.front().t >= 100) cout << "NA" << endl;
else cout << q.front().t << endl;
}
} | a.cc: In function 'void init()':
a.cc:13:9: error: 'memset' was not declared in this scope
13 | memset(mem,0,sizeof(mem));
| ^~~~~~
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 | #define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
a.cc: In function 'int main()':
a.cc:35:50: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
35 | if(mem[s.a][s.b][s.c][s.d]++) continue;
| ~~~~~~~~~~~~~~~~~~~~~~^
|
s129946883 | p00223 | C++ | #include <queue>
#include <vector>
#include <iostream>
#define INF (1 << 25)
using namespace std;
vector<vector<vector<vector<int> > > > dp;
vector<vector<int> > M;
int H, W, sx1, sy1, sx2, sy2;
const int dx[4] = { 0, 1, 0, -1 };
const int dy[4] = { 1, 0, -1, 0 };
int bfs()
{
dp = vector<vector<vector<vector<int> > > >(H, vector<vector<vector<int> > >(W, vector<vector<int> >(H, vector<int>(W, INF)))); dp[sy1][sx1][sy2][sx2] = 0;
queue<pair<pair<pair<int, int>, pair<int, int> >, int> > que; que.push(make_pair(make_pair(make_pair(sx1, sy1), make_pair(sx2, sy2)), 0));
while(!que.empty())
{
int x1 = que.front().first.first.first;
int y1 = que.front().first.first.second;
int x2 = que.front().first.second.first;
int y2 = que.front().first.second.second;
int turn = que.front().second;
que.pop();
for(int dir = 0; dir < 4; dir++)
{
int tx1 = x1 + dx[dir]; if(tx1 < 0 || tx1 > W) { tx1 -= dx[dir]; }
int ty1 = y1 + dy[dir]; if(ty1 < 0 || ty1 > H) { ty1 -= dy[dir]; }
int tx2 = x2 - dx[dir]; if(tx2 < 0 || tx2 > W) { tx2 += dx[dir]; }
int ty2 = y2 - dy[dir]; if(ty2 < 0 || ty2 > H) { ty2 += dy[dir]; }
if(M[ty1][tx1] == 1) { tx1 -= dx[dir]; ty1 -= dy[dir]; }
if(M[ty2][tx2] == 1) { tx2 += dx[dir]; ty2 += dy[dir]; }
if(tx1 == tx2 && ty1 == ty2) { return turn + 1; }
if(dp[ty1][tx1][ty2][tx2] == INF)
{
dp[ty1][tx1][ty2][tx2] = turn + 1;
que.push(make_pair(make_pair(make_pair(tx1, ty1), make_pair(tx2, ty2)), turn + 1);
}
}
}
return -1;
}
int main()
{
while(true)
{
cin >> W >> H;
if(H == 0 && W == 0) { break; }
M = vector<vector<int> >(H, vector<int>(W));
cin >> sx1 >> sy1 >> sx2 >> sy2;
sx1--; sy1--; sx2--; sy2--;
for(int i = 0; i < H; i++)
{
for(int j = 0; j < W; j++)
{
cin >> M[i][j];
}
}
int Ans = bfs();
cout << (Ans == -1 ? "NA" : Ans) << endl;
}
return 0;
} | a.cc: In function 'int bfs()':
a.cc:51:98: error: expected ')' before ';' token
51 | que.push(make_pair(make_pair(make_pair(tx1, ty1), make_pair(tx2, ty2)), turn + 1);
| ~ ^
| )
a.cc: In function 'int main()':
a.cc:83:28: error: operands to '?:' have different types 'const char*' and 'int'
83 | cout << (Ans == -1 ? "NA" : Ans) << endl;
| ~~~~~~~~~~^~~~~~~~~~~~
|
s641805922 | p00223 | C++ | State(int a,int b,int c,int d):a(a),b(b),c(c),d(d){};
};
int h,w;
int table[51][51],memo[51][51][51][51];
int Y[4]={-1,0,1,0};
int X[4]={0,1,0,-1};
bool in(int a,int b){
if(a<0 || b<0 || h<=a || w<=b)return false;
return true;
}
void init(){
for(int i=0;i<51;i++)
for(int j=0;j<51;j++)
for(int k=0;k<51;k++)
for(int l=0;l<51;l++)memo[i][j][k][l]=inf;
}
int main()
{
int a,b,c,d;
while(1){
cin>>w>>h;
if(h+w==0)break;
cin>>b>>a>>d>>c;
a--;b--;c--;d--;
for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>table[i][j];
init();
queue<State> q;
q.push(State(a,b,c,d));
memo[a][b][c][d]=0;
int ans=inf;
while(!q.empty()){
State u=q.front();
q.pop();
if(u.a==u.c && u.b==u.d){
ans=min(memo[u.a][u.b][u.c][u.d],ans);
continue;
}
if(memo[u.a][u.b][u.c][u.d]>=100)continue;
for(int i=0;i<4;i++){
int A=u.a+Y[i],B=u.b+X[i],C=u.c+Y[(i+2)%4],D=u.d+X[(i+2)%4];
if(table[A][B] || !in(A,B)){
A=u.a;
B=u.b;
}
if(table[C][D] || !in(C,D)){
C=u.c;
D=u.d;
}
if(memo[A][B][C][D]>memo[u.a][u.b][u.c][u.d]+1){
q.push(State(A,B,C,D));
memo[A][B][C][D]=memo[u.a][u.b][u.c][u.d]+1;
}
}
}
if(ans>=100)cout<<"NA"<<endl;
else cout<<ans<<endl;
}
return 0;
} | a.cc:1:3: error: ISO C++ forbids declaration of 'State' with no type [-fpermissive]
1 | State(int a,int b,int c,int d):a(a),b(b),c(c),d(d){};
| ^~~~~
a.cc: In function 'int State(int, int, int, int)':
a.cc:1:34: error: only constructors take member initializers
1 | State(int a,int b,int c,int d):a(a),b(b),c(c),d(d){};
| ^
a.cc:1:54: warning: no return statement in function returning non-void [-Wreturn-type]
1 | State(int a,int b,int c,int d):a(a),b(b),c(c),d(d){};
| ^
a.cc: At global scope:
a.cc:2:1: error: expected declaration before '}' token
2 | };
| ^
a.cc: In function 'void init()':
a.cc:18:47: error: 'inf' was not declared in this scope; did you mean 'int'?
18 | for(int l=0;l<51;l++)memo[i][j][k][l]=inf;
| ^~~
| int
a.cc: In function 'int main()':
a.cc:25:5: error: 'cin' was not declared in this scope; did you mean 'in'?
25 | cin>>w>>h;
| ^~~
| in
a.cc:32:5: error: 'queue' was not declared in this scope
32 | queue<State> q;
| ^~~~~
a.cc:32:18: error: 'q' was not declared in this scope
32 | queue<State> q;
| ^
a.cc:36:13: error: 'inf' was not declared in this scope; did you mean 'int'?
36 | int ans=inf;
| ^~~
| int
a.cc:38:12: error: expected ';' before 'u'
38 | State u=q.front();
| ^~
| ;
a.cc:41:10: error: 'u' was not declared in this scope
41 | if(u.a==u.c && u.b==u.d){
| ^
a.cc:42:13: error: 'min' was not declared in this scope; did you mean 'main'?
42 | ans=min(memo[u.a][u.b][u.c][u.d],ans);
| ^~~
| main
a.cc:46:15: error: 'u' was not declared in this scope
46 | if(memo[u.a][u.b][u.c][u.d]>=100)continue;
| ^
a.cc:49:15: error: 'u' was not declared in this scope
49 | int A=u.a+Y[i],B=u.b+X[i],C=u.c+Y[(i+2)%4],D=u.d+X[(i+2)%4];
| ^
a.cc:50:21: error: 'B' was not declared in this scope
50 | if(table[A][B] || !in(A,B)){
| ^
a.cc:54:18: error: 'C' was not declared in this scope
54 | if(table[C][D] || !in(C,D)){
| ^
a.cc:54:21: error: 'D' was not declared in this scope
54 | if(table[C][D] || !in(C,D)){
| ^
a.cc:58:20: error: 'B' was not declared in this scope
58 | if(memo[A][B][C][D]>memo[u.a][u.b][u.c][u.d]+1){
| ^
a.cc:58:23: error: 'C' was not declared in this scope
58 | if(memo[A][B][C][D]>memo[u.a][u.b][u.c][u.d]+1){
| ^
a.cc:58:26: error: 'D' was not declared in this scope
58 | if(memo[A][B][C][D]>memo[u.a][u.b][u.c][u.d]+1){
| ^
a.cc:64:17: error: 'cout' was not declared in this scope
64 | if(ans>=100)cout<<"NA"<<endl;
| ^~~~
a.cc:64:29: error: 'endl' was not declared in this scope
64 | if(ans>=100)cout<<"NA"<<endl;
| ^~~~
a.cc:65:10: error: 'cout' was not declared in this scope
65 | else cout<<ans<<endl;
| ^~~~
a.cc:65:21: error: 'endl' was not declared in this scope
65 | else cout<<ans<<endl;
| ^~~~
|
s674891291 | p00223 | C++ | #include<queue>
#include<iostream>
#include<algorithm>
#include <conio.h>
using namespace std;
struct maigo{
int x[2];// ????????????[0]???????????????[1]
int y[2];// ????????????[0]???????????????[1]
int count = 1;
};
int main(){
queue<maigo> q;
int tx, ty; int kx, ky;
int **depart, X, Y;
int flag = 0, a = 0;
cin >> X >> Y;
while (X != 0 && Y != 0){
depart = new int*[Y + 2];
for (int i = 0; i < Y + 2; i++){
depart[i] = new int[X + 2];
}
for (int i = 0; i < Y + 2; i++){
for (int l = 0; l < X + 2; l++){
depart[i][l] = 3;
}
}
cin >> tx >> ty;
cin >> kx >> ky;
for (int i = 1; i < Y + 1; i++){
for (int l = 1; l < X + 1; l++){
cin >> depart[i][l];
}
}
maigo temp;
temp.x[0] = tx; temp.y[0] = ty;
temp.x[1] = kx; temp.y[1] = ky;
q.push(temp);
while (!q.empty() && flag == 0){
maigo t = q.front();
q.pop();
int dx1[4] = { 1, 0, -1, 0 }; int dx2[4] = { 0, 1, 0, -1 };
for (int i = 0; i < 4; i++){
if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] == 0 &&
depart[t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] == 0){
depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] = -1;
depart[t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] = -1;
if (t.x[0] + dx1[i] == t.x[1] + dx1[i] * (-1) &&
t.y[0] + dx2[i] == t.y[1] + dx2[i] * (-1)){
cout << t.count << endl;
flag = 1;
}
maigo into;
into.x[0] = t.x[0] + dx1[i], into.y[0] = t.y[0] + dx2[i];
into.x[1] = t.x[1] + dx1[i] * (-1), into.y[1] = t.y[1] + dx2[i] * (-1);
into.count = t.count + 1;
if (into.count >= 100){
flag = 1;
a = 1;
}
q.push(into);
}
}
}if (a == 1||flag == 0) {
cout << "NA" << endl;
}while (!q.empty()) q.pop();
a = 0; flag = 0;
cin >> X >> Y;
}
return 0;
} | a.cc:4:10: fatal error: conio.h: No such file or directory
4 | #include <conio.h>
| ^~~~~~~~~
compilation terminated.
|
s337423349 | p00223 | C++ | #include<queue>
#include<iostream>
#include<algorithm>
#include <conio.h>
using namespace std;
struct maigo{
int x[2];
int y[2];
int count = 1;
};
int main(){
queue<maigo> q;
int tx, ty; int kx, ky;
int **depart, X, Y;
int flag = 0, a = 0;
cin >> X >> Y;
while (X != 0 && Y != 0){
depart = new int*[Y + 2];
for (int i = 0; i < Y + 2; i++){
depart[i] = new int[X + 2];
}
for (int i = 0; i < Y + 2; i++){
for (int l = 0; l < X + 2; l++){
depart[i][l] = 3;
}
}
cin >> tx >> ty;
cin >> kx >> ky;
for (int i = 1; i < Y + 1; i++){
for (int l = 1; l < X + 1; l++){
cin >> depart[i][l];
}
}
maigo temp;
temp.x[0] = tx; temp.y[0] = ty;
temp.x[1] = kx; temp.y[1] = ky;
q.push(temp);
while (!q.empty() && flag == 0){
maigo t = q.front();
q.pop();
int dx1[4] = { 1, 0, -1, 0 }; int dx2[4] = { 0, 1, 0, -1 };
for (int i = 0; i < 4; i++){
if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] == 0 &&
depart[t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] == 0){
depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] = -1;
depart[t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] = -1;
if (t.x[0] + dx1[i] == t.x[1] + dx1[i] * (-1) &&
t.y[0] + dx2[i] == t.y[1] + dx2[i] * (-1)){
cout << t.count << endl;
flag = 1;
}
maigo into;
into.x[0] = t.x[0] + dx1[i], into.y[0] = t.y[0] + dx2[i];
into.x[1] = t.x[1] + dx1[i] * (-1), into.y[1] = t.y[1] + dx2[i] * (-1);
into.count = t.count + 1;
if (into.count >= 100){
flag = 1;
a = 1;
}
q.push(into);
}
}
}if (a == 1||flag == 0) {
cout << "NA" << endl;
}while (!q.empty()) q.pop();
a = 0; flag = 0;
cin >> X >> Y;
}
return 0;
} | a.cc:4:10: fatal error: conio.h: No such file or directory
4 | #include <conio.h>
| ^~~~~~~~~
compilation terminated.
|
s228151119 | p00223 | C++ | #include<queue>
#include<iostream>
#include<algorithm>
#include <conio.h>
using namespace std;
struct maigo{
int x[2];// ????????????[0]???????????????[1]
int y[2];// ????????????[0]???????????????[1]
int count;
};
int main(){
queue<maigo> q;
int tx, ty; int kx, ky;
int **depart, X, Y;
int flag = 0, a = 0;
cin >> X >> Y;
while (X != 0 && Y != 0){
depart = new int*[Y + 2];
for (int i = 0; i < Y + 2; i++){
depart[i] = new int[X + 2];
}
for (int i = 0; i < Y + 2; i++){
for (int l = 0; l < X + 2; l++){
depart[i][l] = 3;
}
}
cin >> tx >> ty;
cin >> kx >> ky;
for (int i = 1; i < Y + 1; i++){
for (int l = 1; l < X + 1; l++){
cin >> depart[i][l];
}
}
maigo temp;
temp.x[0] = tx; temp.y[0] = ty;
temp.x[1] = kx; temp.y[1] = ky;
temp.count = 1;
q.push(temp);
while (!q.empty() && flag == 0){
maigo t = q.front();
q.pop();
int dx1[4] = { 1, 0, -1, 0 }; int dx2[4] = { 0, 1, 0, -1 };
for (int i = 0; i < 4; i++){
if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] == 0 &&
depart[t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] == 0){
depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] = -1;
depart[t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] = -1;
if (t.x[0] + dx1[i] == t.x[1] + dx1[i] * (-1) &&
t.y[0] + dx2[i] == t.y[1] + dx2[i] * (-1)){
cout << t.count << endl;
flag = 1;
}
maigo into;
into.x[0] = t.x[0] + dx1[i], into.y[0] = t.y[0] + dx2[i];
into.x[1] = t.x[1] + dx1[i] * (-1), into.y[1] = t.y[1] + dx2[i] * (-1);
into.count = t.count + 1;
if (into.count >= 100){
flag = 1;
a = 1;
}
q.push(into);
}
}
}if (a == 1||flag == 0) {
cout << "NA" << endl;
}while (!q.empty()) q.pop();
a = 0; flag = 0;
cin >> X >> Y;
}
return 0;
} | a.cc:4:10: fatal error: conio.h: No such file or directory
4 | #include <conio.h>
| ^~~~~~~~~
compilation terminated.
|
s984652352 | p00223 | C++ | #include<iostream>
#include<algorithm>
#include <conio.h>
using namespace std;
struct maigo{
int x[2];// ????????????[0]???????????????[1]
int y[2];// ????????????[0]???????????????[1]
int count;
};
int main(){
queue<maigo> q;
int tx, ty; int kx, ky;
int **depart, X, Y;
int flag = 0, a = 0;
cin >> X >> Y;
while (X != 0 && Y != 0){
depart = new int*[Y + 2];
for (int i = 0; i < Y + 2; i++){
depart[i] = new int[X + 2];
}
for (int i = 0; i < Y + 2; i++){
for (int l = 0; l < X + 2; l++){
depart[i][l] = 3;
}
}
cin >> tx >> ty;
cin >> kx >> ky;
for (int i = 1; i < Y + 1; i++){
for (int l = 1; l < X + 1; l++){
cin >> depart[i][l];
}
}
maigo temp;
temp.x[0] = tx; temp.y[0] = ty;
temp.x[1] = kx; temp.y[1] = ky;
temp.count = 1;
q.push(temp);
while (!q.empty() && flag == 0){
maigo t = q.front();
q.pop();
int dx1[4] = { 1, 0, -1, 0 }; int dx2[4] = { 0, 1, 0, -1 };
for (int i = 0; i < 4; i++){
if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] == 0 &&
depart[t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] == 0){
depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] = -1;
depart[t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] = -1;
if (t.x[0] + dx1[i] == t.x[1] + dx1[i] * (-1) &&
t.y[0] + dx2[i] == t.y[1] + dx2[i] * (-1)){
cout << t.count << endl;
flag = 1;
}
maigo into;
into.x[0] = t.x[0] + dx1[i], into.y[0] = t.y[0] + dx2[i];
into.x[1] = t.x[1] + dx1[i] * (-1), into.y[1] = t.y[1] + dx2[i] * (-1);
into.count = t.count + 1;
if (into.count >= 100){
flag = 1;
a = 1;
}
q.push(into);
}
}
}if (a == 1||flag == 0) {
cout << "NA" << endl;
}while (!q.empty()) q.pop();
a = 0; flag = 0;
cin >> X >> Y;
}
return 0;
} | a.cc:3:10: fatal error: conio.h: No such file or directory
3 | #include <conio.h>
| ^~~~~~~~~
compilation terminated.
|
s357250029 | p00223 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
struct maigo{
int x[2];// ????????????[0]???????????????[1]
int y[2];// ????????????[0]???????????????[1]
int count;
};
int main(){
queue<maigo> q;
int tx, ty; int kx, ky;
int **depart, X, Y;
int flag = 0, a = 0;
cin >> X >> Y;
while (X != 0 && Y != 0){
depart = new int*[Y + 2];
for (int i = 0; i < Y + 2; i++){
depart[i] = new int[X + 2];
}
for (int i = 0; i < Y + 2; i++){
for (int l = 0; l < X + 2; l++){
depart[i][l] = 3;
}
}
cin >> tx >> ty;
cin >> kx >> ky;
for (int i = 1; i < Y + 1; i++){
for (int l = 1; l < X + 1; l++){
cin >> depart[i][l];
}
}
maigo temp;
temp.x[0] = tx; temp.y[0] = ty;
temp.x[1] = kx; temp.y[1] = ky;
temp.count = 1;
q.push(temp);
while (!q.empty() && flag == 0){
maigo t = q.front();
q.pop();
int dx1[4] = { 1, 0, -1, 0 }; int dx2[4] = { 0, 1, 0, -1 };
for (int i = 0; i < 4; i++){
if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] == 0 &&
depart[t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] == 0){
depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] = -1;
depart[t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] = -1;
if (t.x[0] + dx1[i] == t.x[1] + dx1[i] * (-1) &&
t.y[0] + dx2[i] == t.y[1] + dx2[i] * (-1)){
cout << t.count << endl;
flag = 1;
}
maigo into;
into.x[0] = t.x[0] + dx1[i], into.y[0] = t.y[0] + dx2[i];
into.x[1] = t.x[1] + dx1[i] * (-1), into.y[1] = t.y[1] + dx2[i] * (-1);
into.count = t.count + 1;
if (into.count >= 100){
flag = 1;
a = 1;
}
q.push(into);
}
}
}if (a == 1||flag == 0) {
cout << "NA" << endl;
}while (!q.empty()) q.pop();
a = 0; flag = 0;
cin >> X >> Y;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:10:9: error: 'queue' was not declared in this scope
10 | queue<maigo> q;
| ^~~~~
a.cc:3:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
2 | #include<algorithm>
+++ |+#include <queue>
3 | using namespace std;
a.cc:10:20: error: expected primary-expression before '>' token
10 | queue<maigo> q;
| ^
a.cc:10:22: error: 'q' was not declared in this scope
10 | queue<maigo> q;
| ^
|
s984906899 | p00223 | C++ | #include<iostream>
#include<queue>
using namespace std;
struct l{
int tx;
int ty;
int kx;
int ky;
int cnt;
};
queue<l> p;
int ps[50505050]={};
int main(){
int x,y,tlx,tly,klx,kly,d[50][50],i,j,cl,tmx[4]={0,1,0,-1},tmy[4]={-1,0,1,0},kmx[4]={0,-1,0,1},kmy[4]={1,0,-1,0},k,z;
l v;
while(1){
cin>>x>>y;
if(x==0&&y==0)break;
cin>>tlx>>tly;
cin>>klx>>kly;
for(i=0;i<y;i++){
for(j=0;j<x;j++){
cin>>d[i][j];
}
}
v.tx=tlx-1;
v.ty=tly-1;
v.kx=klx-1;
v.ky=kly-1;
v.cnt=0;
p.push(v);
while(1){
tlx=p.front().tx;
tly=p.front().ty;
klx=p.front().kx;
kly=p.front().ky;
cl=p.front().cnt;
p.pop();
if(tlx==klx&&tly==kly||cl>=100){
while(!p.empty()){
p.pop();
}
for(i=0;i<50505050;i++){
ps[i]=0;
}
break;
}
if(ps[tlx*1000000+tly*10000+klx*100+kly]==1){
if (!p.empty())
continue;
else
break;
}
else{
ps[tlx*1000000+tly*10000+klx*100+kly]=1;
}
for(i=0;i<4;i++){
if(d[tly+tmy[i]][tlx+tmx[i]]==0&&(tlx+tmx[i])>=0&&(tlx+tmx[i])<x&&(tly+tmy[i])>=0&&(tly+tmy[i])<y){
v.tx=tlx+tmx[i];
v.ty=tly+tmy[i];
}
else{
v.tx=tlx;
v.ty=tly;
}
if(d[kly+kmy[i]][klx+kmx[i]]==0&&(klx+kmx[i])>=0&&(klx+kmx[i])<x&&(kly+kmy[i])>=0&&(kly+kmy[i])<y){
v.kx=klx+kmx[i];
v.ky=kly+kmy[i];
}
else{
v.kx=klx;
v.ky=kly;
}
v.cnt=cl+1;
p.push(v);
}
}
if(tlx==klx&&tly==kly&&cl!=0){
cout<<cl<<endl;
}
else{
cout<<"NA"<<endl;
}
}
????????????return 0;
} | a.cc: In function 'int main()':
a.cc:86:1: error: expected primary-expression before '?' token
86 | ????????????return 0;
| ^
a.cc:86:2: error: expected primary-expression before '?' token
86 | ????????????return 0;
| ^
a.cc:86:3: error: expected primary-expression before '?' token
86 | ????????????return 0;
| ^
a.cc:86:4: error: expected primary-expression before '?' token
86 | ????????????return 0;
| ^
a.cc:86:5: error: expected primary-expression before '?' token
86 | ????????????return 0;
| ^
a.cc:86:6: error: expected primary-expression before '?' token
86 | ????????????return 0;
| ^
a.cc:86:7: error: expected primary-expression before '?' token
86 | ????????????return 0;
| ^
a.cc:86:8: error: expected primary-expression before '?' token
86 | ????????????return 0;
| ^
a.cc:86:9: error: expected primary-expression before '?' token
86 | ????????????return 0;
| ^
a.cc:86:10: error: expected primary-expression before '?' token
86 | ????????????return 0;
| ^
a.cc:86:11: error: expected primary-expression before '?' token
86 | ????????????return 0;
| ^
a.cc:86:12: error: expected primary-expression before '?' token
86 | ????????????return 0;
| ^
a.cc:86:13: error: expected primary-expression before 'return'
86 | ????????????return 0;
| ^~~~~~
a.cc:86:13: error: expected ':' before 'return'
86 | ????????????return 0;
| ^~~~~~
| :
a.cc:86:13: error: expected primary-expression before 'return'
86 | ????????????return 0;
| ^~~~~~
a.cc:86:13: error: expected ':' before 'return'
86 | ????????????return 0;
| ^~~~~~
| :
a.cc:86:13: error: expected primary-expression before 'return'
86 | ????????????return 0;
| ^~~~~~
a.cc:86:13: error: expected ':' before 'return'
86 | ????????????return 0;
| ^~~~~~
| :
a.cc:86:13: error: expected primary-expression before 'return'
86 | ????????????return 0;
| ^~~~~~
a.cc:86:13: error: expected ':' before 'return'
86 | ????????????return 0;
| ^~~~~~
| :
a.cc:86:13: error: expected primary-expression before 'return'
86 | ????????????return 0;
| ^~~~~~
a.cc:86:13: error: expected ':' before 'return'
86 | ????????????return 0;
| ^~~~~~
| :
a.cc:86:13: error: expected primary-expression before 'return'
86 | ????????????return 0;
| ^~~~~~
a.cc:86:13: error: expected ':' before 'return'
86 | ????????????return 0;
| ^~~~~~
| :
a.cc:86:13: error: expected primary-expression before 'return'
86 | ????????????return 0;
| ^~~~~~
a.cc:86:13: error: expected ':' before 'return'
86 | ????????????return 0;
| ^~~~~~
| :
a.cc:86:13: error: expected primary-expression before 'return'
86 | ????????????return 0;
| ^~~~~~
a.cc:86:13: error: expected ':' before 'return'
86 | ????????????return 0;
| ^~~~~~
| :
a.cc:86:13: error: expected primary-expression before 'return'
86 | ????????????return 0;
| ^~~~~~
a.cc:86:13: error: expected ':' before 'return'
86 | ????????????return 0;
| ^~~~~~
| :
a.cc:86:13: error: expected primary-expression before 'return'
86 | ????????????return 0;
| ^~~~~~
a.cc:86:13: error: expected ':' before 'return'
86 | ????????????return 0;
| ^~~~~~
| :
a.cc:86:13: error: expected primary-expression before 'return'
86 | ????????????return 0;
| ^~~~~~
a.cc:86:13: error: expected ':' before 'return'
86 | ????????????return 0;
| ^~~~~~
| :
a.cc:86:13: error: expected primary-expression before 'return'
86 | ????????????return 0;
| ^~~~~~
a.cc:86:13: error: expected ':' before 'return'
86 | ????????????return 0;
| ^~~~~~
| :
a.cc:86:13: error: expected primary-expression before 'return'
86 | ????????????return 0;
| ^~~~~~
|
s491029126 | p00223 | C++ | #include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
int same[51][51][51][51];
struct maigo{
int x[2];// ????????????[0]???????????????[1]
int y[2];// ????????????[0]???????????????[1]
int count;
};
int main(){
queue<maigo> q;
int tx, ty; int kx, ky;
int **depart, X, Y;
int flag = 0, a = 0;
int c = 0;
int f = 0;
cin >> X >> Y;
while (X != 0 && Y != 0){
for (int i = 0; i < 51; i++){
for (int l = 0; l < 51; l++){
for (int i1 = 0; i1 < 51; i1++){
for (int l1 = 0; l1 < 51; l1++){
same[i][l][i1][l1] = 0;
}
}
}
}
depart = new int*[Y + 2];
for (int i = 0; i < Y + 2; i++){
depart[i] = new int[X + 2];
}
for (int i = 0; i < Y + 2; i++){
for (int l = 0; l < X + 2; l++){
depart[i][l] = 3;
}
}
cin >> tx >> ty;
cin >> kx >> ky;
for (int i = 1; i < Y + 1; i++){
for (int l = 1; l < X + 1; l++){
cin >> depart[i][l];
}
}
maigo temp;
temp.x[0] = tx; temp.y[0] = ty;
temp.x[1] = kx; temp.y[1] = ky;
temp.count = 1;
q.push(temp);
while (!q.empty() && flag == 0){
maigo t = q.front();
maigo into;
q.pop();
if (t.count >= 100){
a = 1; flag = 1;
break;
}
int dx1[4] = { 1, 0, -1, 0 }; int dx2[4] = { 0, 1, 0, -1 };
for (int i = 0; i < 4; i++){
if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] == 0 &&
depart[t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] == 0 &&
same[t.x[0] + dx1[i]][t.y[0] + dx2[i]][t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)]==0){
if (t.x[0] + dx1[i] == t.x[1] + dx1[i] * (-1) &&
t.y[0] + dx2[i] == t.y[1] + dx2[i] * (-1)){
cout << t.count << endl;
flag = 1;
}
into.x[0] = t.x[0] + dx1[i], into.y[0] = t.y[0] + dx2[i];
into.x[1] = t.x[1] + dx1[i] * (-1), into.y[1] = t.y[1] + dx2[i] * (-1);
same[t.x[0] + dx1[i]][t.y[0] + dx2[i]][t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] = 1;
into.count = t.count + 1;
q.push(into);
}
if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] == 0 && //???????????? ok ???????????? no ?????´???
depart[t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] != 0 &&
same[t.x[0] + dx1[i]][t.y[0] + dx2[i]][t.x[1]][t.y[1]] == 0){
if (t.x[0] + dx1[i] == t.x[1] &&
t.y[0] + dx2[i] == t.y[1]){
cout << t.count << endl;
flag = 1;
}
into.x[0] = t.x[0] + dx1[i], into.y[0] = t.y[0] + dx2[i];
into.x[1] = t.x[1], into.y[1] = t.y[1];
same[t.x[0] + dx1[i]][t.y[0] + dx2[i]][t.x[1]][t.y[1]] = 1;
into.count = t.count + 1;
q.push(into);
}
if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] != 0 && //???????????? no??????????????? yes????????´???
depart[t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] == 0 &&
same[t.x[0]][t.y[0]][t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] == 0){
if (t.x[0] == t.x[1] + dx1[i] * (-1) &&
????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
cout << t.count << endl;
flag = 1;
}???
into.x[0] = t.x[0], into.y[0] = t.y[0];
into.x[1] = t.x[1] + dx1[i] * (-1), into.y[1] = t.y[1] + dx2[i] * (-1);
same[t.x[0]][t.y[0]][t.x[1] + dx1[i] * (-1)][t.y[1] + dx2[i] * (-1)] = 1;
into.count = t.count + 1;
q.push(into);
}
}
}if (a == 1 || flag == 0) {
cout << "NA" << endl;
}while (!q.empty()) q.pop();
a = 0; flag = 0;
cin >> X >> Y;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:97:1: error: expected primary-expression before '?' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
a.cc:97:2: error: expected primary-expression before '?' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
a.cc:97:3: error: expected primary-expression before '?' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
a.cc:97:4: error: expected primary-expression before '?' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
a.cc:97:5: error: expected primary-expression before '?' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
a.cc:97:6: error: expected primary-expression before '?' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
a.cc:97:7: error: expected primary-expression before '?' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
a.cc:97:8: error: expected primary-expression before '?' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
a.cc:97:9: error: expected primary-expression before '?' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
a.cc:97:89: error: expected ':' before ')' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
| :
a.cc:97:89: error: expected primary-expression before ')' token
a.cc:97:89: error: expected ':' before ')' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
| :
a.cc:97:89: error: expected primary-expression before ')' token
a.cc:97:89: error: expected ':' before ')' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
| :
a.cc:97:89: error: expected primary-expression before ')' token
a.cc:97:89: error: expected ':' before ')' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
| :
a.cc:97:89: error: expected primary-expression before ')' token
a.cc:97:89: error: expected ':' before ')' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
| :
a.cc:97:89: error: expected primary-expression before ')' token
a.cc:97:89: error: expected ':' before ')' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
| :
a.cc:97:89: error: expected primary-expression before ')' token
a.cc:97:89: error: expected ':' before ')' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
| :
a.cc:97:89: error: expected primary-expression before ')' token
a.cc:97:89: error: expected ':' before ')' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
| :
a.cc:97:89: error: expected primary-expression before ')' token
a.cc:97:89: error: expected ':' before ')' token
97 | ????????? t.y[0] == t.y[1] + dx2[i] * (-1)){
| ^
| :
a.cc:97:89: error: expected primary-expression before ')' token
a.cc:100:42: error: expected primary-expression before '?' token
100 | }???
| ^
a.cc:100:43: error: expected primary-expression before '?' token
100 | }???
| ^
a.cc:100:44: error: expected primary-expression before '?' token
100 | }???
| ^
a.cc:101:79: error: expected ':' before ';' token
101 | into.x[0] = t.x[0], into.y[0] = t.y[0];
| ^
| :
a.cc:101:79: error: expected primary-expression before ';' token
a.cc:101:79: error: expected ':' before ';' token
101 | into.x[0] = t.x[0], into.y[0] = t.y[0];
| ^
| :
a.cc:101:79: error: expected primary-expression before ';' token
a.cc:101:79: error: expected ':' before ';' token
101 | into.x[0] = t.x[0], into.y[0] = t.y[0];
| ^
| :
a.cc:101:79: error: expected primary-expression before ';' token
|
s057579020 | p00223 | C++ | #include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
bool same[52][52][52][52] = { 0 };
queue<maigo> q;
struct maigo{
int x[2];// ????????????[0]???????????????[1]
int y[2];// ????????????[0]???????????????[1]
int count;
};
int main(){
int tx, ty; int kx, ky;
int **depart, X, Y;
int flag = 0, a = 0;
int c = 0;
int f = 0;
cin >> X >> Y;
while (X != 0 && Y != 0){
depart = new int*[Y + 2];
for (int i = 0; i < Y + 2; i++){
depart[i] = new int[X + 2];
}
for (int i = 0; i < Y + 2; i++){
for (int l = 0; l < X + 2; l++){
depart[i][l] = 3;
}
}
cin >> tx >> ty;
cin >> kx >> ky;
for (int i = 1; i < Y + 1; i++){
for (int l = 1; l < X + 1; l++){
cin >> depart[i][l];
}
}
maigo temp;
temp.x[0] = tx; temp.y[0] = ty;
temp.x[1] = kx; temp.y[1] = ky;
temp.count = 1;
q.push(temp);
while (!q.empty() && flag == 0){
maigo t = q.front();
maigo into;
q.pop();
same[t.x[0]][t.y[0]][t.x[1]][t.y[1]] = 1;
if (t.count >= 100) break;
int dx1[4] = { 1, 0, -1, 0 }; int dx2[4] = { 0, 1, 0, -1 };
for (int i = 0; i < 4; i++){
if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] == 0 &&
depart[t.x[1] - dx1[i]][t.y[1] - dx2[i]] == 0 &&
same[t.x[0] + dx1[i]][t.y[0] + dx2[i]][t.x[1] - dx1[i]][t.y[1] - dx2[i]] == 0){
if (t.x[0] + dx1[i] == t.x[1] - dx1[i] &&
t.y[0] + dx2[i] == t.y[1] - dx2[i]){
cout << t.count << endl;
flag = 1;
}
into.x[0] = t.x[0] + dx1[i], into.y[0] = t.y[0] + dx2[i];
into.x[1] = t.x[1] - dx1[i], into.y[1] = t.y[1] - dx2[i];
into.count = t.count + 1;
q.push(into);
}
if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] == 0 && //???????????? ok ???????????? no ?????´???
depart[t.x[1] - dx1[i]][t.y[1] - dx2[i]] != 0 &&
same[t.x[0] + dx1[i]][t.y[0] + dx2[i]][t.x[1]][t.y[1]] == 0){
if (t.x[0] + dx1[i] == t.x[1] &&
t.y[0] + dx2[i] == t.y[1]){
cout << t.count << endl;
flag = 1;
}
into.x[0] = t.x[0] + dx1[i], into.y[0] = t.y[0] + dx2[i];
into.x[1] = t.x[1], into.y[1] = t.y[1];
into.count = t.count + 1;
q.push(into);
}
if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] != 0 && //???????????? no??????????????? yes????????´???
depart[t.x[1] - dx1[i]][t.y[1] - dx2[i]] == 0 &&
same[t.x[0]][t.y[0]][t.x[1] - dx1[i]][t.y[1] - dx2[i] == 0]){
if (t.x[0] == t.x[1] - dx1[i] &&
t.y[0] == t.y[1] - dx2[i]){
cout << t.count << endl;
flag = 1;
}
into.x[0] = t.x[0], into.y[0] = t.y[0];
into.x[1] = t.x[1] - dx1[i], into.y[1] = t.y[1] - dx2[i];
into.count = t.count + 1;
q.push(into);
}
}
}if (flag == 0) {
cout << "NA" << endl;
}while (!q.empty()) q.pop();
flag = 0;
fill(same[0][0][0], same[52][0][0], 0);
cin >> X >> Y;
}
return 0;
} | a.cc:6:7: error: 'maigo' was not declared in this scope
6 | queue<maigo> q;
| ^~~~~
a.cc:6:12: error: template argument 1 is invalid
6 | queue<maigo> q;
| ^
a.cc:6:12: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:40:19: error: request for member 'push' in 'q', which is of non-class type 'int'
40 | q.push(temp);
| ^~~~
a.cc:41:27: error: request for member 'empty' in 'q', which is of non-class type 'int'
41 | while (!q.empty() && flag == 0){
| ^~~~~
a.cc:42:37: error: request for member 'front' in 'q', which is of non-class type 'int'
42 | maigo t = q.front();
| ^~~~~
a.cc:44:27: error: request for member 'pop' in 'q', which is of non-class type 'int'
44 | q.pop();
| ^~~
a.cc:61:43: error: request for member 'push' in 'q', which is of non-class type 'int'
61 | q.push(into);
| ^~~~
a.cc:75:43: error: request for member 'push' in 'q', which is of non-class type 'int'
75 | q.push(into);
| ^~~~
a.cc:88:43: error: request for member 'push' in 'q', which is of non-class type 'int'
88 | q.push(into);
| ^~~~
a.cc:93:28: error: request for member 'empty' in 'q', which is of non-class type 'int'
93 | }while (!q.empty()) q.pop();
| ^~~~~
a.cc:93:39: error: request for member 'pop' in 'q', which is of non-class type 'int'
93 | }while (!q.empty()) q.pop();
| ^~~
|
s392354064 | p00223 | C++ | #include<stdio.h>
#include<iostream>
#include<queue>
using namespace std;
struct oza{
int x;
int y;
};
int A[52][52][52][52];
int main(){
oza k;
oza t;
queue<oza> ka;
queue<oza> ta;
queue<int> Z;
int w,h,b;
int d=0,c=0,i=0,j=0,l=-1,D[52][52];
int tx[4]={ 1, 0,-1,0 };
int kx[4]={-1, 0, 1,0 };
int ty[4]={ 0, 1, 0,-1 };
int ky[4]={ 0, -1, 0,1};
scanf("%d %d",&w,&h);
while(w!=0&&h!=0){
memset(A,0,sizeof(A));
for(i=0;i<=h+1;i++){
for(j=0;j<=w+1;j++){
D[i][j]=1;
}
}
scanf("%d %d",&t.x,&t.y);
scanf("%d %d",&k.x,&k.y);
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
scanf("%d",&D[i][j]);
}
}
ta.push(t);
ka.push(k);
Z.push(c);
if(t.x==k.x&&t.y==k.y){
d=-1;
}
while(d!=-1){
l++;
if(l==4){
l=0;
t=ta.front();
k=ka.front();
ka.pop();
ta.pop();
Z.pop();
A[t.x][t.y][k.x][k.y]=1;
}
if(c==100||Z.empty()){
printf("NA");
break;
}
t=ta.front();
k=ka.front();
c=Z.front();
t.x=t.x+tx[l];
t.y=t.y+ty[l];
k.x=k.x+kx[l];
k.y=k.y+ky[l];
if(D[t.x][t.y]==1){
t.x=t.x-tx[l];
t.y=t.y-ty[l];
}
if(D[k.x][k.y]==1){
k.x=k.x-kx[l];
k.y=k.y-ky[l];
}
if(A[t.x][t.y][k.x][k.y]==1){
continue;
}
ta.push(t);
ka.push(k);
c=c+1;
Z.push(c);
if(t.x==k.x&&t.y==k.y){
printf("%d\n",Z.back());
break;
}
}
while(!ka.empty()){
ka.pop();
ta.pop();
Z.pop();
}
c=0;
l=-1;
scanf("%d %d",&w,&h);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:9: error: 'memset' was not declared in this scope
24 | memset(A,0,sizeof(A));
| ^~~~~~
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 | using namespace std;
|
s441263792 | p00223 | C++ | #include<stdio.h>
#include<iostream>
#include<queue>
using namespace std;
struct oza{
int x;
int y;
};
int A[52][52][52][52];
int main(){
oza k;
oza t;
queue<oza> ka;
queue<oza> ta;
queue<int> Z;
int w,h,b;
int d=0,c=0,i=0,j=0,l=-1,D[52][52];
int tx[4]={ 1, 0,-1,0 };
int kx[4]={-1, 0, 1,0 };
int ty[4]={ 0, 1, 0,-1 };
int ky[4]={ 0, -1, 0,1};
scanf("%d %d",&w,&h);
while(w!=0&&h!=0){
memset(A,0,sizeof(A));
for(i=0;i<=h+1;i++){
for(j=0;j<=w+1;j++){
D[i][j]=1; //??¨????????????????????\??????
}
}
scanf("%d %d",&t.x,&t.y);
scanf("%d %d",&k.x,&k.y);
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
scanf("%d",&D[i][j]);
}
}
ta.push(t);
ka.push(k);
Z.push(c);
if(t.x==k.x&&t.y==k.y){
d=-1;
}
while(d!=-1){
l++;
if(l==4){
l=0;
t=ta.front();
k=ka.front();
ka.pop();
ta.pop();
Z.pop();
A[t.x][t.y][k.x][k.y]=1;
}
if(c==100||Z.empty()){
printf("NA");
break;
}
// ?????\????????????????????¨?????¨??????
t=ta.front();
k=ka.front();
c=Z.front();
t.x=t.x+tx[l];
t.y=t.y+ty[l];
k.x=k.x+kx[l];
k.y=k.y+ky[l];
if(D[t.x][t.y]==1){
t.x=t.x-tx[l];
t.y=t.y-ty[l];
}
if(D[k.x][k.y]==1){
k.x=k.x-kx[l];
k.y=k.y-ky[l];
}
if(A[t.x][t.y][k.x][k.y]==1){
continue;
}
ta.push(t);
ka.push(k);
c=c+1;
Z.push(c);
if(t.x==k.x&&t.y==k.y){
printf("%d\n",Z.back());
break;
}
}
while(!ka.empty()){
ka.pop();
ta.pop();
Z.pop();
}
c=0;
l=-1;
scanf("%d %d",&w,&h);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:9: error: 'memset' was not declared in this scope
24 | memset(A,0,sizeof(A));
| ^~~~~~
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 | using namespace std;
|
s223025594 | p00223 | C++ | #include<stdio.h>
#include<iostream>
#include<queue>
using namespace std;
struct oza{
int x;
int y;
};
int A[52][52][52][52];
int main(){
oza k;
oza t;
queue<oza> ka;
queue<oza> ta;
queue<int> Z;
int w,h,b;
int d=0,c=0,i=0,j=0,l=-1,D[52][52];
int tx[4]={ 1, 0,-1,0 };
int kx[4]={-1, 0, 1,0 };
int ty[4]={ 0, 1, 0,-1 };
int ky[4]={ 0, -1, 0,1};
scanf("%d %d",&w,&h);
while(w!=0&&h!=0){
memset(A,0,sizeof(A));
for(i=0;i<=h+1;i++){
for(j=0;j<=w+1;j++){
D[i][j]=1; //??¨????????????????????\??????
}
}
scanf("%d %d",&t.x,&t.y);
scanf("%d %d",&k.x,&k.y);
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
scanf("%d",&D[i][j]);
}
}
ta.push(t);
ka.push(k);
Z.push(c);
if(t.x==k.x&&t.y==k.y){
d=-1;
}
while(d!=-1){
l++;
if(l==4){
l=0;
t=ta.front();
k=ka.front();
ka.pop();
ta.pop();
Z.pop();
A[t.x][t.y][k.x][k.y]=1;
}
if(c==100||Z.empty()){
printf("NA");
break;
}
// ?????\????????????????????¨?????¨??????
t=ta.front();
k=ka.front();
c=Z.front();
t.x=t.x+tx[l];
t.y=t.y+ty[l];
k.x=k.x+kx[l];
k.y=k.y+ky[l];
if(D[t.x][t.y]==1){
t.x=t.x-tx[l];
t.y=t.y-ty[l];
}
if(D[k.x][k.y]==1){
k.x=k.x-kx[l];
k.y=k.y-ky[l];
}
if(A[t.x][t.y][k.x][k.y]==1){
continue;
}
ta.push(t);
ka.push(k);
c=c+1;
Z.push(c);
if(t.x==k.x&&t.y==k.y){
printf("%d\n",Z.back());
break;
}
}
while(!ka.empty()){
ka.pop();
ta.pop();
Z.pop();
}
c=0;
l=-1;
scanf("%d %d",&w,&h);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:9: error: 'memset' was not declared in this scope
24 | memset(A,0,sizeof(A));
| ^~~~~~
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 | using namespace std;
|
s065925505 | p00223 | C++ | #include<stdio.h>
#include<iostream>
#include<queue>
#include<string.h>
using namespace std;
struct oza{
int x;
int y;
};
int A[50][50][50][50];
int main(){
oza k;
oza t;
queue<oza> ka;
queue<oza> ta;
queue<int> Z;
int w,h,b;
int d=0,c=0,i=0,j=0,l=-1,D[52][52];
int tx[4]={ 1, 0,-1,0 };
int kx[4]={-1, 0, 1,0 };
int ty[4]={ 0, 1, 0,-1 };
int ky[4]={ 0, -1, 0,1};
scanf("%d %d",&w,&h);
while(w!=0&&h!=0){
memset(A,0,sizeof(A));
for(i=0;i<=h+1;i++){
for(j=0;j<=w+1;j++){
D[i][j]=1; //??¨????????????????????\??????
}
}
scanf("%d %d",&t.x,&t.y);
scanf("%d %d",&k.x,&k.y);
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
scanf("%d",&D[i][j]);
}
}
ta.push(t);
ka.push(k);
// Z.push(c);
if(t.x==k.x&&t.y==k.y){
d=-1;
}
while(d!=-1){
l++;
if(l==4){
l=0;
t=ta.front();
k=ka.front();
ka.pop();
ta.pop();
Z.pop();
A[t.x][t.y][k.x][k.y]=1;
}
//if(Z.back()==100||Z.empty()){
// printf("NA");
//break;
}
t=ta.front();
k=ka.front();
c=Z.front();
t.x=t.x+tx[l];
t.y=t.y+ty[l];
k.x=k.x+kx[l];
k.y=k.y+ky[l];
if(D[t.x][t.y]==1){
t.x=t.x-tx[l];
t.y=t.y-ty[l];
}
if(D[k.x][k.y]==1){
k.x=k.x-kx[l];
k.y=k.y-ky
[l];
}
if(A[t.x][t.y][k.x][k.y]==1){
continue;
}
ta.push(t);
ka.push(k);
c=c+1;
Z.push(c);
if(t.x==k.x&&t.y==k.y){
printf("%d\n",Z.back());
break;
}
}
while(!ka.empty()){
ka.pop();
ta.pop();
//Z.pop();
}
c=0;
l=-1;
scanf("%d %d",&w,&h);
}
return 0;
} | a.cc:104:9: error: expected unqualified-id before 'return'
104 | return 0;
| ^~~~~~
a.cc:106:1: error: expected declaration before '}' token
106 | }
| ^
|
s601209731 | p00223 | C++ | #include<stdio.h>
#include<iostream>
#include<queue>
#include<string.h>
using namespace std;
struct oza{
int x;
int y;
};
int A[50][50][50][50];
int main(){
oza k;
oza t;
queue<oza> ka;
queue<oza> ta;
queue<int> Z;
int w,h,b;
int d=0,c=0,i=0,j=0,l=-1,D[52][52];
int tx[4]={ 1, 0,-1,0 };
int kx[4]={-1, 0, 1,0 };
int ty[4]={ 0, 1, 0,-1 };
int ky[4]={ 0, -1, 0,1};
scanf("%d %d",&w,&h);
while(w!=0&&h!=0){
memset(A,0,sizeof(A));
for(i=0;i<=h+1;i++){
for(j=0;j<=w+1;j++){
D[i][j]=1; //??¨????????????????????\??????
}
}
scanf("%d %d",&t.x,&t.y);
scanf("%d %d",&k.x,&k.y);
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
scanf("%d",&D[i][j]);
}
}
ta.push(t);
ka.push(k);
Z.push(c);
if(t.x==k.x&&t.y==k.y){
d=-1;
}
while(d!=-1){
l++;
if(l==4){
l=0;
t=ta.front();
k=ka.front();
ka.pop();
ta.pop();
Z.pop();
A[t.x][t.y][k.x][k.y]=1;
}
if(Z.back()==100||Z.empty()){
printf("NA");
break;
}
t=ta.front();
k=ka.front();
c=Z.front();
t.x=t.x+tx[l];
t.y=t.y+ty[l];
k.x=k.x+kx[l];
k.y=k.y+ky[l];
if(D[t.x][t.y]==1){
t.x=t.x-tx[l];
t.y=t.y-ty[l];
}
if(D[k.x][k.y]==1){
k.x=k.x-kx[l];
k.y=k.y-ky[l];
}
if(A[t.x][t.y][k.x][k.y]==1){
#include<stdio.h>
#include<iostream>
#include<queue>
#include<string.h>
using namespace std;
struct PP{
int kx;
int ky;
int tx;
int ty;
int Z;
};
int A[50][50][50][50];
int main(){
PP S;
queue<PP> P;
int w,h;
int d=0,i=0,j=0,l=-1,D[52][52];
int tx[4]={ 1, 0,-1,0 };
int kx[4]={-1, 0, 1,0 };
int ty[4]={ 0, 1, 0,-1 };
int ky[4]={ 0, -1, 0,1};
scanf("%d %d",&w,&h);
while(w!=0&&h!=0){
memset(A,0,sizeof(A));
for(i=0;i<=h+1;i++){
for(j=0;j<=w+1;j++){
D[i][j]=1;
}
}
scanf("%d %d",&S.tx,&S.ty);
scanf("%d %d",&S.kx,&S.ky);
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
scanf("%d",&D[i][j]);
}
}
S.Z=0;
P.push(S);
if(S.tx==S.kx&&S.ty==S.ky){
d=-1;
printf("%d\n",S.Z);
}
while(d!=-1){
l++;
if(l==4){
l=0;
S=P.front();
P.pop();
if(P.empty()){
printf("NA\n");
break;
}
}
S=P.front();
S.tx=S.tx+tx[l];
S.ty=S.ty+ty[l];
S.kx=S.kx+kx[l];
S.ky=S.ky+ky[l];
if(A[S.tx][S.ty][S.kx][S.ky]==1){
continue;
}
A[S.tx][S.ty][S.kx][S.ky]=1;
if(D[S.tx][S.ty]==1){
S.tx=S.tx-tx[l];
S.ty=S.ty-ty[l];
}
if(D[S.kx][S.ky]==1){
S.kx=S.kx-kx[l];
S.ky=S.ky-ky[l];
}
S.Z++;
P.push(S);
if(S.tx==S.kx&&S.ty==S.ky){
printf("%d\n",S.Z);
break;
}
if(S.Z==100){
printf("NA\n");
break;
}
}
while(!P.empty()){
P.pop();
}
l=-1;
scanf("%d %d",&w,&h);
}
return 0;
}
#include<stdio.h>
#include<iostream>
#include<queue>
#include<string.h>
using namespace std;
struct PP{
int kx;
int ky;
int tx;
int ty;
int Z;
};
int A[52][52][52][52];
int main(){
PP S;
queue<PP> P;
int w,h;
int d=0,i=0,j=0,l=-1,D[52][52];
int tx[4]={ 1, 0,-1,0 };
int kx[4]={-1, 0, 1,0 };
int ty[4]={ 0, 1, 0,-1 };
int ky[4]={ 0, -1, 0,1};
scanf("%d %d",&w,&h);
while(w!=0||h!=0){
memset(A,0,sizeof(A));
for(i=0;i<=h+1;i++){
for(j=0;j<=w+1;j++){
D[i][j]=1;
}
}
scanf("%d %d",&S.tx,&S.ty);
scanf("%d %d",&S.kx,&S.ky);
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
scanf("%d",&D[i][j]);
}
}
S.Z=0;
P.push(S);
if(S.tx==S.kx&&S.ty==S.ky){
d=-1;
printf("%d\n",S.Z);
}
while(d!=-1){
l++;
if(l==4){
l=0;
S=P.front();
P.pop();
if(P.empty()){
printf("NA\n");
break;
}
}
S=P.front();
S.tx=S.tx+tx[l];
S.ty=S.ty+ty[l];
S.kx=S.kx+kx[l];
S.ky=S.ky+ky[l];
if(A[S.tx][S.ty][S.kx][S.ky]==1){
continue;
}
A[S.tx][S.ty][S.kx][S.ky]=1;
if(D[S.tx][S.ty]==1){
S.tx=S.tx-tx[l];
S.ty=S.ty-ty[l];
}
if(D[S.kx][S.ky]==1){
S.kx=S.kx-kx[l];
S.ky=S.ky-ky[l];
}
S.Z++;
P.push(S);
if(S.tx==S.kx&&S.ty==S.ky){
printf("%d\n",S.Z);
break;
}
if(S.Z==100){
printf("NA\n");
break;
}
}
while(!P.empty()){
P.pop();
}
l=-1;
scanf("%d %d",&w,&h);
}
return 0;
}
#include<stdio.h>
#include<queue>
#include<iostream>
#include<string.h>
using namespace std;
struct PP{
int kx;
int ky;
int tx;
int ty;
int Z;
};
int A[54][54][54][54];
int main(){
PP S;
queue<PP> P;
int w,h;
int d=0,i=0,j=0,l=-1,D[55][55];
int tx[4]={ 1, 0,-1,0 };
int kx[4]={-1, 0, 1,0 };
int ty[4]={ 0, 1, 0,-1 };
int ky[4]={ 0, -1, 0,1};
scanf("%d %d",&w,&h);
while(w!=0||h!=0){
memset(A,0,sizeof(A));
for(i=0;i<=h+1;i++){
for(j=0;j<=w+1;j++){
D[i][j]=1;
}
}
scanf("%d %d",&S.tx,&S.ty);
scanf("%d %d",&S.kx,&S.ky);
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
scanf("%d",&D[i][j]);
}
}
S.Z=0;
P.push(S);
if(S.tx==S.kx&&S.ty==S.ky){
d=-1;
printf("%d\n",S.Z);
}
while(d!=-1){
l++;
if(l==4){
l=0;
S=P.front();
P.pop();
if(P.empty()){
printf("NA\n");
break;
}
}
S=P.front();
S.tx=S.tx+tx[l];
S.ty=S.ty+ty[l];
S.kx=S.kx+kx[l];
S.ky=S.ky+ky[l];
if(A[S.tx][S.ty][S.kx][S.ky]==1){
continue;
}
A[S.tx][S.ty][S.kx][S.ky]=1;
if(D[S.ty][S.tx]==1){
S.tx=S.tx-tx[l];
S.ty=S.ty-ty[l];
}
if(D[S.ky][S.kx]==1){
S.kx=S.kx-kx[l];
S.ky=S.ky-ky[l];
}
S.Z++;
P.push(S);
if(S.tx==S.kx&&S.ty==S.ky){
printf("%d\n",S.Z);
break;
}
if(S.Z==100){
printf("NA\n");
break;
}
}
while(!P.empty()){
P.pop();
}
l=-1;
scanf("%d %d",&w,&h);
}
return 0;
}
44444444444444444444444444444444444444444444444444444444444444 continue;
}
ta.push(t);
ka.push(k);
c=c+1;
Z.push(c);
if(t.x==k.x&&t.y==k.y){
printf("%d\n",Z.back());
break;
}
}
while(!ka.empty()){
ka.pop();
ta.pop();
Z.pop();
}
c=0;
l=-1;
scanf("%d %d",&w,&h);
}
return 0;
} | a.cc:488:1: warning: integer constant is too large for its type
488 | 44444444444444444444444444444444444444444444444444444444444444 continue;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:126:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
126 | int main(){
| ^~
a.cc:126:9: note: remove parentheses to default-initialize a variable
126 | int main(){
| ^~
| --
a.cc:126:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:126:11: error: a function-definition is not allowed here before '{' token
126 | int main(){
| ^
a.cc:217:8: error: redefinition of 'struct main()::PP'
217 | struct PP{
| ^~
a.cc:118:8: note: previous definition of 'struct main()::PP'
118 | struct PP{
| ^~
a.cc:224:5: error: conflicting declaration 'int A [52][52][52][52]'
224 | int A[52][52][52][52];
| ^
a.cc:125:5: note: previous declaration as 'int A [50][50][50][50]'
125 | int A[50][50][50][50];
| ^
a.cc:225:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
225 | int main(){
| ^~
a.cc:225:9: note: remove parentheses to default-initialize a variable
225 | int main(){
| ^~
| --
a.cc:225:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:225:11: error: a function-definition is not allowed here before '{' token
225 | int main(){
| ^
a.cc:325:8: error: redefinition of 'struct main()::PP'
325 | struct PP{
| ^~
a.cc:118:8: note: previous definition of 'struct main()::PP'
118 | struct PP{
| ^~
a.cc:332:5: error: conflicting declaration 'int A [54][54][54][54]'
332 | int A[54][54][54][54];
| ^
a.cc:125:5: note: previous declaration as 'int A [50][50][50][50]'
125 | int A[50][50][50][50];
| ^
a.cc:333:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
333 | int main(){
| ^~
a.cc:333:9: note: remove parentheses to default-initialize a variable
333 | int main(){
| ^~
| --
a.cc:333:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:333:11: error: a function-definition is not allowed here before '{' token
333 | int main(){
| ^
a.cc:488:64: error: expected ';' before 'continue'
488 | 44444444444444444444444444444444444444444444444444444444444444 continue;
| ^~~~~~~~~~
| ;
|
s916590225 | p00223 | C++ | #include<stdio.h>
#include<iostream>
#include<queue>
#include<string.h>
#include<cstring>
using namespace std;
struct oza{
int x;
int y;
};
int A[50][50][50][50];
int main(){
oza k;
oza t;
queue<oza> ka;
queue<oza> ta;
queue<int> Z;
int w,h,b;
int d=0,c=0,i=0,j=0,l=-1,D[52][52];
int tx[4]={ 1, 0,-1,0 };
int kx[4]={-1, 0, 1,0 };
int ty[4]={ 0, 1, 0,-1 };
int ky[4]={ 0, -1, 0,1};
scanf("%d %d",&w,&h);
while(w!=0&&h!=0){
memset(A,0,sizeof(A));
for(i=0;i<=h+1;i++){
for(j=0;j<=w+1;j++){
D[i][j]=1; //??¨????????????????????\??????
}
}
scanf("%d %d",&t.x,&t.y);
scanf("%d %d",&k.x,&k.y);
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
scanf("%d",&D[i][j]);
}
}
ta.push(t);
ka.push(k);
Z.push(c);
if(t.x==k.x&&t.y==k.y){
d=-1;
}
while(d!=-1){
l++;
if(l==4){
l=0;
t=ta.front();
k=ka.front();
ka.pop();
ta.pop();
Z.pop();
A[t.x][t.y][k.x][k.y]=1;
}
if(Z.back()==100||Z.empty()){
printf("NA");
break;
}
t=ta.front();
k=ka.front();
c=Z.front();
t.x=t.x+tx[l];
t.y=t.y+ty[l];
k.x=k.x+kx[l];
k.y=k.y+ky[l];
if(D[t.x][t.y]==1){
t.x=t.x-tx[l];
t.y=t.y-ty[l];
}
if(D[k.x][k.y]==1){
k.x=k.x-kx[l];
k.y=k.y-ky[l];
}
if(A[t.x][t.y][k.x][k.y]==1){
#include<stdio.h>
#include<iostream>
#include<queue>
#include<string.h>
using namespace std;
struct PP{
int kx;
int ky;
int tx;
int ty;
int Z;
};
int A[50][50][50][50];
int main(){
PP S;
queue<PP> P;
int w,h;
int d=0,i=0,j=0,l=-1,D[52][52];
int tx[4]={ 1, 0,-1,0 };
int kx[4]={-1, 0, 1,0 };
int ty[4]={ 0, 1, 0,-1 };
int ky[4]={ 0, -1, 0,1};
scanf("%d %d",&w,&h);
while(w!=0&&h!=0){
memset(A,0,sizeof(A));
for(i=0;i<=h+1;i++){
for(j=0;j<=w+1;j++){
D[i][j]=1;
}
}
scanf("%d %d",&S.tx,&S.ty);
scanf("%d %d",&S.kx,&S.ky);
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
scanf("%d",&D[i][j]);
}
}
S.Z=0;
P.push(S);
if(S.tx==S.kx&&S.ty==S.ky){
d=-1;
printf("%d\n",S.Z);
}
while(d!=-1){
l++;
if(l==4){
l=0;
S=P.front();
P.pop();
if(P.empty()){
printf("NA\n");
break;
}
}
S=P.front();
S.tx=S.tx+tx[l];
S.ty=S.ty+ty[l];
S.kx=S.kx+kx[l];
S.ky=S.ky+ky[l];
if(A[S.tx][S.ty][S.kx][S.ky]==1){
continue;
}
A[S.tx][S.ty][S.kx][S.ky]=1;
if(D[S.tx][S.ty]==1){
S.tx=S.tx-tx[l];
S.ty=S.ty-ty[l];
}
if(D[S.kx][S.ky]==1){
S.kx=S.kx-kx[l];
S.ky=S.ky-ky[l];
}
S.Z++;
P.push(S);
if(S.tx==S.kx&&S.ty==S.ky){
printf("%d\n",S.Z);
break;
}
if(S.Z==100){
printf("NA\n");
break;
}
}
while(!P.empty()){
P.pop();
}
l=-1;
scanf("%d %d",&w,&h);
}
return 0;
}
#include<stdio.h>
#include<iostream>
#include<queue>
#include<string.h>
using namespace std;
struct PP{
int kx;
int ky;
int tx;
int ty;
int Z;
};
int A[52][52][52][52];
int main(){
PP S;
queue<PP> P;
int w,h;
int d=0,i=0,j=0,l=-1,D[52][52];
int tx[4]={ 1, 0,-1,0 };
int kx[4]={-1, 0, 1,0 };
int ty[4]={ 0, 1, 0,-1 };
int ky[4]={ 0, -1, 0,1};
scanf("%d %d",&w,&h);
while(w!=0||h!=0){
memset(A,0,sizeof(A));
for(i=0;i<=h+1;i++){
for(j=0;j<=w+1;j++){
D[i][j]=1;
}
}
scanf("%d %d",&S.tx,&S.ty);
scanf("%d %d",&S.kx,&S.ky);
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
scanf("%d",&D[i][j]);
}
}
S.Z=0;
P.push(S);
if(S.tx==S.kx&&S.ty==S.ky){
d=-1;
printf("%d\n",S.Z);
}
while(d!=-1){
l++;
if(l==4){
l=0;
S=P.front();
P.pop();
if(P.empty()){
printf("NA\n");
break;
}
}
S=P.front();
S.tx=S.tx+tx[l];
S.ty=S.ty+ty[l];
S.kx=S.kx+kx[l];
S.ky=S.ky+ky[l];
if(A[S.tx][S.ty][S.kx][S.ky]==1){
continue;
}
A[S.tx][S.ty][S.kx][S.ky]=1;
if(D[S.tx][S.ty]==1){
S.tx=S.tx-tx[l];
S.ty=S.ty-ty[l];
}
if(D[S.kx][S.ky]==1){
S.kx=S.kx-kx[l];
S.ky=S.ky-ky[l];
}
S.Z++;
P.push(S);
if(S.tx==S.kx&&S.ty==S.ky){
printf("%d\n",S.Z);
break;
}
if(S.Z==100){
printf("NA\n");
break;
}
}
while(!P.empty()){
P.pop();
}
l=-1;
scanf("%d %d",&w,&h);
}
return 0;
}
#include<stdio.h>
#include<queue>
#include<iostream>
#include<string.h>
using namespace std;
struct PP{
int kx;
int ky;
int tx;
int ty;
int Z;
};
int A[54][54][54][54];
int main(){
PP S;
queue<PP> P;
int w,h;
int d=0,i=0,j=0,l=-1,D[55][55];
int tx[4]={ 1, 0,-1,0 };
int kx[4]={-1, 0, 1,0 };
int ty[4]={ 0, 1, 0,-1 };
int ky[4]={ 0, -1, 0,1};
scanf("%d %d",&w,&h);
while(w!=0||h!=0){
memset(A,0,sizeof(A));
for(i=0;i<=h+1;i++){
for(j=0;j<=w+1;j++){
D[i][j]=1;
}
}
scanf("%d %d",&S.tx,&S.ty);
scanf("%d %d",&S.kx,&S.ky);
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
scanf("%d",&D[i][j]);
}
}
S.Z=0;
P.push(S);
if(S.tx==S.kx&&S.ty==S.ky){
d=-1;
printf("%d\n",S.Z);
}
while(d!=-1){
l++;
if(l==4){
l=0;
S=P.front();
P.pop();
if(P.empty()){
printf("NA\n");
break;
}
}
S=P.front();
S.tx=S.tx+tx[l];
S.ty=S.ty+ty[l];
S.kx=S.kx+kx[l];
S.ky=S.ky+ky[l];
if(A[S.tx][S.ty][S.kx][S.ky]==1){
continue;
}
A[S.tx][S.ty][S.kx][S.ky]=1;
if(D[S.ty][S.tx]==1){
S.tx=S.tx-tx[l];
S.ty=S.ty-ty[l];
}
if(D[S.ky][S.kx]==1){
S.kx=S.kx-kx[l];
S.ky=S.ky-ky[l];
}
S.Z++;
P.push(S);
if(S.tx==S.kx&&S.ty==S.ky){
printf("%d\n",S.Z);
break;
}
if(S.Z==100){
printf("NA\n");
break;
}
}
while(!P.empty()){
P.pop();
}
l=-1;
scanf("%d %d",&w,&h);
}
return 0;
}
44444444444444444444444444444444444444444444444444444444444444 continue;
}
ta.push(t);
ka.push(k);
c=c+1;
Z.push(c);
if(t.x==k.x&&t.y==k.y){
printf("%d\n",Z.back());
break;
}
}
while(!ka.empty()){
ka.pop();
ta.pop();
Z.pop();
}
c=0;
l=-1;
scanf("%d %d",&w,&h);
}
return 0;
} | a.cc:489:1: warning: integer constant is too large for its type
489 | 44444444444444444444444444444444444444444444444444444444444444 continue;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:127:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
127 | int main(){
| ^~
a.cc:127:9: note: remove parentheses to default-initialize a variable
127 | int main(){
| ^~
| --
a.cc:127:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:127:11: error: a function-definition is not allowed here before '{' token
127 | int main(){
| ^
a.cc:218:8: error: redefinition of 'struct main()::PP'
218 | struct PP{
| ^~
a.cc:119:8: note: previous definition of 'struct main()::PP'
119 | struct PP{
| ^~
a.cc:225:5: error: conflicting declaration 'int A [52][52][52][52]'
225 | int A[52][52][52][52];
| ^
a.cc:126:5: note: previous declaration as 'int A [50][50][50][50]'
126 | int A[50][50][50][50];
| ^
a.cc:226:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
226 | int main(){
| ^~
a.cc:226:9: note: remove parentheses to default-initialize a variable
226 | int main(){
| ^~
| --
a.cc:226:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:226:11: error: a function-definition is not allowed here before '{' token
226 | int main(){
| ^
a.cc:326:8: error: redefinition of 'struct main()::PP'
326 | struct PP{
| ^~
a.cc:119:8: note: previous definition of 'struct main()::PP'
119 | struct PP{
| ^~
a.cc:333:5: error: conflicting declaration 'int A [54][54][54][54]'
333 | int A[54][54][54][54];
| ^
a.cc:126:5: note: previous declaration as 'int A [50][50][50][50]'
126 | int A[50][50][50][50];
| ^
a.cc:334:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
334 | int main(){
| ^~
a.cc:334:9: note: remove parentheses to default-initialize a variable
334 | int main(){
| ^~
| --
a.cc:334:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:334:11: error: a function-definition is not allowed here before '{' token
334 | int main(){
| ^
a.cc:489:64: error: expected ';' before 'continue'
489 | 44444444444444444444444444444444444444444444444444444444444444 continue;
| ^~~~~~~~~~
| ;
|
s436782388 | p00223 | C++ | #include<iostream>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
#define P pair<int,int>
using namespace std;
int dx[4] = { -1,0,0,1 }, dy[4] = { 0,-1,1,0 };
int main() {
int a, b;
while (cin >> a >> b, a | b) {
int c, d, e, f;
cin >> c >> d >> e >> f;
c--; d--; e--; f--;
bool ba[50][50];
int k[50][50];
memset(k, -1, sizeof(k));
for (int g = 0; g < a; g++) {
for (int h = 0; h < b; h++) {
cin >> ba[g][h];
}
}
if ((((c - e) & 1) == 0) && (((d - f) & 1) == 0)) {
queue<P>Q;
if(!ba[c][d]&&!ba[e][f]) Q.push(P(c, d));
k[c][d] = 0;
while (Q.size()) {
P o = Q.front(); Q.pop();
cout << o.first << " " << o.second << endl;
for (int i = 0; i < 4; i++) {
int x = dx[i],y=dy[i];
if (o.first + x >= 0 && o.first + x < a&&o.second + y >= 0 && o.second + y < b) {
if (c + e - (o.first + x) >= 0 && c + e - (o.first + x) < a&&d + f - (o.second + y) >= 0 && d + f - (o.second + y) < b) {
if (!ba[o.first + x][o.second + y] && !ba[c + e - (o.first + x)][d + f - (o.second + y)] && k[o.first + x][o.second + y] == -1) {
Q.push(P(o.first + x, o.second + y));
k[o.first + x][o.second + y] = k[o.first][o.second] + 1;
}
}
}
}
}
if (k[(c + e) / 2][(d + f) / 2] == -1)puts("NA");
else cout << k[(c + e) / 2][(d + f) / 2] << endl;
}
else puts("NA");
}
} | a.cc: In function 'int main()':
a.cc:18:17: error: 'memset' was not declared in this scope
18 | memset(k, -1, sizeof(k));
| ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
5 | #include<queue>
+++ |+#include <cstring>
6 | #define P pair<int,int>
|
s044903795 | p00223 | C++ | #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<queue>
#define P pair<int,int>
using namespace std;
bool c[52][52];
int d[52][52];
int x[4] = { -1,0,0,1 }, y[4] = { 0,-1,1,0 };
int main() {
int a, b;
while (cin >> a >> b, a | b) {
memset(c, true, sizeof(c));
memset(d,-1,sizeof(d));
int e, f, g, h; cin >> e >> f >> g >> h;
for (int i = 0; i < b; i++) {
for (int j = 0; j < a; j++) {
cin >> c[j + 1][i + 1];
}
}
if (((e + g) & 1) == ((f + h) & 1)) {
queue<P>Q;
Q.push(P(e,f));
d[e][f] = 0;
while (Q.size()) {
P o = Q.front(); Q.pop();
for (int i = 0; i < 4; i++) {
if (!c[o.first + x[i]][o.second + y[i]]&&!c[e+g-(o.first + x[i])][f+h-(o.second + y[i])]&& d[o.first + x[i]][o.second + y[i]] ==-1) {
d[o.first + x[i]][o.second + y[i]] = d[o.first][o.second] + 1;
Q.push(P(o.first + x[i], o.second + y[i]));
}
}
}
if (d[(e + g) / 2][(f + h) / 2] == -1)puts("NA");
else cout << d[(e + g) / 2][(f + h) / 2] << endl;
}
else puts("NA");
}
} | a.cc: In function 'int main()':
a.cc:15:17: error: 'memset' was not declared in this scope
15 | memset(c, true, sizeof(c));
| ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
5 | #include<queue>
+++ |+#include <cstring>
6 | #define P pair<int,int>
|
s155728855 | p00223 | C++ | #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<queue>
#define P pair<int,int>
using namespace std;
bool c[52][52];
int d[52][52];
int x[4] = { -1,0,0,1 }, y[4] = { 0,-1,1,0 };
int main() {
int a, b;
while (cin >> a >> b, a | b) {
memset(c, true, sizeof(c));
memset(d,-1,sizeof(d));
int e, f, g, h; cin >> e >> f >> g >> h;
for (int i = 0; i < b; i++) {
for (int j = 0; j < a; j++) {
cin >> c[j + 1][i + 1];
}
}
if (((e + g) & 1) == ((f + h) & 1)) {
queue<P>Q;
Q.push(P(e,f));
d[e][f] = 0;
while (Q.size()) {
P o = Q.front(); Q.pop();
for (int i = 0; i < 4; i++) {
if (!c[o.first + x[i]][o.second + y[i]]&&!c[e+g-(o.first + x[i])][f+h-(o.second + y[i])]&& d[o.first + x[i]][o.second + y[i]] ==-1) {
d[o.first + x[i]][o.second + y[i]] = d[o.first][o.second] + 1;
Q.push(P(o.first + x[i], o.second + y[i]));
}
}
}
if (d[(e + g) / 2][(f + h) / 2] == -1|| d[(e + g) / 2][(f + h) / 2]>99)puts("NA");
else cout << d[(e + g) / 2][(f + h) / 2] << endl;
}
else puts("NA");
}
} | a.cc: In function 'int main()':
a.cc:15:17: error: 'memset' was not declared in this scope
15 | memset(c, true, sizeof(c));
| ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
5 | #include<queue>
+++ |+#include <cstring>
6 | #define P pair<int,int>
|
s474287739 | p00223 | C++ | #include<iostream>
#include<string>
#include<vector>
#include<queue>
#define p pair<int,int>
#define P pair<p,p>
using namespace std;
int a[50][50][50][50];
int x[4] = { -1,0,0,1 }, y[4] = { 0,-1,1,0 };
int S[50][50];
signed main() {
int b, c;
while (cin >> c >> b, b | c) {
memset(a, 0x3f, sizeof(a));
int d, e, f, g; cin >> e >> d >> g >> f; d--; e--; f--; g--;
a[d][e][f][g] = 0;
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
scanf("%d", &S[i][j]);
}
}
queue<P>Q;
Q.push(P(p(d,e),p(f,g)));
while (Q.size()) {
P t = Q.front(); Q.pop();
for (int i = 0; i < 4; i++) {
int j = 3 - i;
p n, m; n = t.first; m = t.second;
n.first += x[i]; n.second += y[i];
m.first += x[j]; m.second += y[j];
if (n.first < 0 || n.first >= b || n.second < 0 || n.second >= c||S[n.first][n.second]==1) {
n.first -= x[i]; n.second -= y[i];
}
if (m.first < 0 || m.first >= b || m.second < 0 || m.second >= c||S[m.first][m.second]==1) {
m.first -= x[j]; m.second -= y[j];
}
if (a[n.first][n.second][m.first][m.second] == 1061109567) {
a[n.first][n.second][m.first][m.second] = a[t.first.first][t.first.second][t.second.first][t.second.second]+1;
Q.push(P(p(n.first,n.second),p(m.first,m.second)));
}
}
}
int MIN = 100;
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
MIN = min(MIN, a[i][j][i][j]);
}
}
if (MIN == 100)puts("NA");
else cout << MIN << endl;
}
} | a.cc: In function 'int main()':
a.cc:15:17: error: 'memset' was not declared in this scope
15 | memset(a, 0x3f, sizeof(a));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include<queue>
+++ |+#include <cstring>
5 | #define p pair<int,int>
|
s745156610 | p00223 | C++ | #include<iostream>
#include<string>
#include<vector>
#include<queue>
#define p pair<int,int>
#define P pair<p,p>
using namespace std;
int a[50][50][50][50];
int x[4] = { -1,0,0,1 }, y[4] = { 0,-1,1,0 };
int S[50][50];
signed main() {
int b, c;
while (cin >> c >> b, b | c) {
memset(a, 0x3f, sizeof(a));
int d, e, f, g; cin >> e >> d >> g >> f; d--; e--; f--; g--;
a[d][e][f][g] = 0;
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
scanf("%d", &S[i][j]);
}
}
queue<P>Q;
Q.push(P(p(d,e),p(f,g)));
while (Q.size()) {
P t = Q.front(); Q.pop();
if (a[t.first.first][t.first.second][t.second.first][t.second.second] >= 100)break;
if (t.first.first == t.second.first&&t.first.second == t.second.second) {
cout << a[t.first.first][t.first.second][t.second.first][t.second.second] << endl;
goto l;
}
for (int i = 0; i < 4; i++) {
int j = 3 - i;
p n, m; n = t.first; m = t.second;
n.first += x[i]; n.second += y[i];
m.first += x[j]; m.second += y[j];
if (n.first < 0 || n.first >= b || n.second < 0 || n.second >= c||S[n.first][n.second]==1) {
n.first -= x[i]; n.second -= y[i];
}
if (m.first < 0 || m.first >= b || m.second < 0 || m.second >= c||S[m.first][m.second]==1) {
m.first -= x[j]; m.second -= y[j];
}
if (a[n.first][n.second][m.first][m.second] == 1061109567) {
a[n.first][n.second][m.first][m.second] = a[t.first.first][t.first.second][t.second.first][t.second.second]+1;
Q.push(P(p(n.first,n.second),p(m.first,m.second)));
}
}
}
puts("NA");
l:;
}
} | a.cc: In function 'int main()':
a.cc:15:17: error: 'memset' was not declared in this scope
15 | memset(a, 0x3f, sizeof(a));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include<queue>
+++ |+#include <cstring>
5 | #define p pair<int,int>
|
s072629500 | p00223 | C++ | #include <bits/stdc++.h>
using namespace std;
int table[51][51];
bool memo[51][51][51][51];
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;
tx--;ty--;kx--;ky--;
for(int i=0;i<51;i++){
for(int j=0;j<51;j++){
table[i][j] = 1;
for(int k=0;k<51;k++){
for(int r=0;r<51;r++){
memo[i][j][k][r] = false;
}
}
}
}
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
//scanf(" %d",&table[i][j]);
cin >> table[i][j];
}
}
if(table[v[0]][v[1]] == 1 || table[v[2]][v[3]] == 1){
cout << "NA" << endl;
continue;
}
/*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;
q.push(v);
bool check = false;
while(!q.empty()){
v = q.front(); q.pop();
if(v[4] >= 100){
break;
}
/*if(v[0] >= w || v[1] >= h || v[2] >= w || v[3] >= h || v[0] < 0 || v[1] < 0 || v[2] < 0 || v[3] < 0 || table[v[0]][v[1]] == 1 || table[v[2]][v[3]] == 1){
continue;
}*/
if(memo[v[0]][v[1]][v[2]][v[3]]){
continue;
}
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]++;
vector<int> before(5);
for(int i=0;i<5;i++){
before[i] = v[i];
}
v[0]--; v[2]++;
if(v[0] > 0 && v[2] < w && table[v[0]][v[1]] == 0 && table[v[2]][v[3]] == 0) {
q.push(v);
}
for(int i=0;i<5;i++){
v[i] = before[i];
}
v[0]++; v[2]--;
if(v[2] > 0 && v[0] < w && table[v[0]][v[1]] == 0 && table[v[2]][v[3]] == 0) {
q.push(v);
}
for(int i=0;i<5;i++){
v[i] = before[i];
}
v[1]++; v[3]--;
if(v[3] > 0 && v[1] < h && table[v[0]][v[1]] == 0 && table[v[2]][v[3]] == 0) {
q.push(v);
}
for(int i=0;i<5;i++){
v[i] = before[i];
}
v[1]--; v[3]++;
if(v[1] > 0 && v[3] < h && table[v[0]][v[1]] == 0 && table[v[2]][v[3]] == 0) {
q.push(v);
}
/*if(v[0] >= w || v[1] >= h || v[2] >= w || v[3] >= h || v[0] < 0 || v[1] < 0 || v[2] < 0 || v[3] < 0 || table[v[0]][v[1]] == 1 || table[v[2]][v[3]] == 1){
}else {
q.push(v);
}*/
}
if(!check){
cout << "NA" << endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:46:18: error: 'v' was not declared in this scope
46 | if(table[v[0]][v[1]] == 1 || table[v[2]][v[3]] == 1){
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.