submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s236554317 | p00723 | C++ | #include <cstdio>
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
using namespace std;
#define rev(s) (vector<char>((s).rbegin(), (s).rend()))
#define HASH_SIZE 2011
#define a 1049
int hash(vector<char> str)
{
int n = 0;
int pow = 1;
for (unsigned int i = 0; i < str.size(); i++) {
n += (pow * (str[i] - 'a')) % HASH_SIZE;
pow *= 26;
pow %= HASH_SIZE;
}
return n % HASH_SIZE;
}
class hash_table {
public:
vector<vector<char> > h;
bool operator[](vector<char> str) {
int key = hash(str);
//cout << string(str.begin(), str.end()) << ":" << key << endl;
for (int i = 0; i < HASH_SIZE; i++) {
if (h[key].empty()) {
h[key] = str;
return true;
} else if (str == h[key]) {
return false;
} else {
//printf("hit!\n");
key = (key * key + a) % HASH_SIZE;
}
}
//printf("!!\n");
h[key] = str;
return true;
}
hash_table():h(HASH_SIZE) {}
};
vector<char>operator+(const vector<char>& lhs, const vector<char>& rhs)
{
vector<char> result = lhs;
result.insert(result.end(), rhs.begin(), rhs.end());
return result;
}
int getline(char* str)
{
char c;
int idx = 0;
while ((c = getchar()) != EOF) {
//printf("%d\n", idx);
if (c == '\n') {break;}
str[idx++] = c;
//printf("%c\n", str[idx - 1]);
}
return idx;
}
int main() {
int N;
scanf("%d ", &N);
hash_table bag;
char str[100];
while (N--) {
//gets(str);
fgets(str, 100, stdin);
if (strchr(str, '\n') != NULL) {
a[strlen(a) - 1] = '\0';
} else {
while(getchar() != '\n');
}
//int end = getline(str);
//if (N == 3) {printf("hoge\n");}
int end;
for (end = 0; str[end] != '\0'; end++);
bag.h.clear();
bag.h.resize(HASH_SIZE);
int c = 0;
vector<char> s = vector<char>(str, str + end - 1);
/*
printf("%d\n", s.size());
for (int i = 0; i < s.size(); i++) {
printf("%c", s[i]);
}
printf("\n");
*/
bag[s];
c++;
if (bag[rev(s)]) {c++;}
for (int i=1; i< end; i++) {
vector<char> head(str, str + i);
vector<char> tail(str + i, str + end - 1);
//if (bag[head + tail]) c++;
reverse(head.begin(), head.end());
if (bag[head + tail]) c++;
if (bag[tail + head]) c++;
reverse(tail.begin(), tail.end());
if (bag[head + tail]) c++;
reverse(head.begin(), head.end());
if (bag[head + tail]) c++;
if (bag[tail + head]) c++;
reverse(tail.begin(), tail.end());
if (bag[tail + head]) c++;
}
printf("%d\n", c);
}
return 0;
} | a.cc: In member function 'bool hash_table::operator[](std::vector<char>)':
a.cc:32:15: error: reference to 'hash' is ambiguous
32 | int key = hash(str);
| ^~~~
In file included from /usr/include/c++/14/string_view:50,
from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
59 | struct hash;
| ^~~~
a.cc:16:5: note: 'int hash(std::vector<char>)'
16 | int hash(vector<char> str)
| ^~~~
a.cc: In function 'int main()':
a.cc:14:11: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
14 | #define a 1049
| ^~~~
| |
| int
a.cc:81:16: note: in expansion of macro 'a'
81 | a[strlen(a) - 1] = '\0';
| ^
In file included from /usr/include/c++/14/cstring:43,
from a.cc:8:
/usr/include/string.h:407:35: note: initializing argument 1 of 'size_t strlen(const char*)'
407 | extern size_t strlen (const char *__s)
| ~~~~~~~~~~~~^~~
a.cc:81:8: error: invalid types 'int[size_t {aka long unsigned int}]' for array subscript
81 | a[strlen(a) - 1] = '\0';
| ^
|
s458542626 | p00723 | C++ | #include <cstdio>
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;
#define rev(s) (vector<char>((s).rbegin(), (s).rend()))
#define HASH_SIZE 2011
#define a 1049
int hash(vector<char> str)
{
int n = 0;
int pow = 1;
for (unsigned int i = 0; i < str.size(); i++) {
n += (pow * (str[i] - 'a')) % HASH_SIZE;
pow *= 26;
pow %= HASH_SIZE;
}
return n % HASH_SIZE;
}
class hash_table {
public:
vector<vector<char> > h;
bool operator[](vector<char> str) {
int key = hash(str);
//cout << string(str.begin(), str.end()) << ":" << key << endl;
for (int i = 0; i < HASH_SIZE; i++) {
if (h[key].empty()) {
h[key] = str;
return true;
} else if (str == h[key]) {
return false;
} else {
//printf("hit!\n");
key = (key * key + a) % HASH_SIZE;
}
}
//printf("!!\n");
h[key] = str;
return true;
}
hash_table():h(HASH_SIZE) {}
};
vector<char>operator+(const vector<char>& lhs, const vector<char>& rhs)
{
vector<char> result = lhs;
result.insert(result.end(), rhs.begin(), rhs.end());
return result;
}
int getline(char* str)
{
char c;
int idx = 0;
while ((c = getchar()) != EOF) {
//printf("%d\n", idx);
if (c == '\n') {break;}
str[idx++] = c;
//printf("%c\n", str[idx - 1]);
}
return idx;
}
int main() {
int N;
scanf("%d ", &N);
hash_table bag;
char str[100];
while (N--) {
//gets(str);
fgets(str, 100, stdin);
if (strchr(str, '\n') != NULL) {
str[strlen(str) - 1] = '\0';
} else {
while(getchar() != '\n');
}
//int end = getline(str);
//if (N == 3) {printf("hoge\n");}
int end;
for (end = 0; str[end] != '\0'; end++);
bag.h.clear();
bag.h.resize(HASH_SIZE);
int c = 0;
vector<char> s = vector<char>(str, str + end - 1);
/*
printf("%d\n", s.size());
for (int i = 0; i < s.size(); i++) {
printf("%c", s[i]);
}
printf("\n");
*/
bag[s];
c++;
if (bag[rev(s)]) {c++;}
for (int i=1; i< end; i++) {
vector<char> head(str, str + i);
vector<char> tail(str + i, str + end - 1);
//if (bag[head + tail]) c++;
reverse(head.begin(), head.end());
if (bag[head + tail]) c++;
if (bag[tail + head]) c++;
reverse(tail.begin(), tail.end());
if (bag[head + tail]) c++;
reverse(head.begin(), head.end());
if (bag[head + tail]) c++;
if (bag[tail + head]) c++;
reverse(tail.begin(), tail.end());
if (bag[tail + head]) c++;
}
printf("%d\n", c);
}
return 0;
} | a.cc: In member function 'bool hash_table::operator[](std::vector<char>)':
a.cc:31:15: error: reference to 'hash' is ambiguous
31 | int key = hash(str);
| ^~~~
In file included from /usr/include/c++/14/string_view:50,
from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
59 | struct hash;
| ^~~~
a.cc:15:5: note: 'int hash(std::vector<char>)'
15 | int hash(vector<char> str)
| ^~~~
a.cc: In function 'int main()':
a.cc:79:9: error: 'strchr' was not declared in this scope
79 | if (strchr(str, '\n') != NULL) {
| ^~~~~~
a.cc:8:1: note: 'strchr' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
7 | #include <algorithm>
+++ |+#include <cstring>
8 |
a.cc:80:11: error: 'strlen' was not declared in this scope
80 | str[strlen(str) - 1] = '\0';
| ^~~~~~
a.cc:80:11: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s064071527 | p00723 | C++ | #include<iostream>
#include<string>
#include<set>
using namespace std;
int main(){
int m;cin>>m;
string train;
for(;cin>>train;){
set<string>st;
for(int i=1;i<train.size();i++){
string t1=train.substr(0,i),t2=train.substr(i);
st.insert(t1+t2);st.insert(t2+t1);
reverse(t1.begin(),t1.end());
st.insert(t1+t2);st.insert(t2+t1);
reverse(t2.begin(),t2.end());
st.insert(t1+t2);st.insert(t2+t1);
reverse(t1.begin(),t1.end());
st.insert(t1+t2);st.insert(t2+t1);
}
cout<<st.size()<<endl;
}
cout<<endl;
} | a.cc: In function 'int main()':
a.cc:13:25: error: 'reverse' was not declared in this scope
13 | reverse(t1.begin(),t1.end());
| ^~~~~~~
|
s628478319 | p00723 | C++ | // 2006à\IB ñÔÌÒ¬p[gII
#include <iostream>
#include <string>
#include <set>
using namespace std;
inline string reverse(string s){
reverse(s.begin(), s.end());
return s;
}
int main(){
int t; cin >> t;
while(t--){
string s; cin >> s;
set<string> S;
S.insert(s);
S.insert(reverse(s));
int n = s.size();
for(int i=1;i<n-1;i++){
string a = s.substr(0,i);
string b = s.substr(i);
string ra = reverse(a);
string rb = reverse(b);
S.insert( a +rb);
S.insert(ra + b);
S.insert(ra +rb);
S.insert( b + a);
S.insert( b +ra);
S.insert(rb + a);
}
cout << S.size() << endl;
}
} | a.cc: In function 'std::string reverse(std::string)':
a.cc:9:24: error: could not convert 's.std::__cxx11::basic_string<char>::begin()' from 'std::__cxx11::basic_string<char>::iterator' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
9 | reverse(s.begin(), s.end());
| ~~~~~~~^~
| |
| std::__cxx11::basic_string<char>::iterator
|
s445862466 | p00723 | C++ | #include <iostream>
#include <set>
#include <string>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define sz size()
int m;
string s;
int main(){
cin>>m;
while(cin>>s){
set<string> S;
rep(i,s.sz-1){
string t=s.substr(0,i+1),u=s.substr(i+1);
rep(j,2){
rep(k,2){
S.insert(t+u);
S.insert(u+t);
reverse(t.begin(),t.end());
}
reverse(u.begin(),u.end());
}
}
cout<<S.sz<<endl;
}
} | a.cc: In function 'int main()':
a.cc:23:41: error: 'reverse' was not declared in this scope
23 | reverse(t.begin(),t.end());
| ^~~~~~~
a.cc:25:33: error: 'reverse' was not declared in this scope
25 | reverse(u.begin(),u.end());
| ^~~~~~~
|
s120053882 | p00723 | C++ | #include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
#include<string>
#include<cstring>
using namespace std;
int main(){
int n;
string s;
string s1,s2;
map<string,bool> Index;
cin >> n;
while(n-- > 0){
cin >> s;
for(int i=1;i<s.length();i++){
s1 = s.substr(0,i);
s2 = s.substr(i,s.length()-i);
//cout <<s1 << " " << s2 << endl;
Index[s1+s2] = true;
Index[s2+s1] = true;
reverse(s1.begin(),s1.end()) ;
Index[s1+s2] = true;
Index[s2+s1] = true;
reverse(s1.begin(),s1.end()) ;
reverse(s2.begin(),s2.end()) ;
Index[s1+s2] = true;
Index[s2+s1] = true;
reverse(s1.begin(),s1.end()) ;
Index[s1+s2] = true;
Index[s2+s1] = true;
}
cout<< Index.size() << endl;
Index.clear();
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:10: error: 'reverse' was not declared in this scope
24 | reverse(s1.begin(),s1.end()) ;
| ^~~~~~~
|
s055672570 | p00723 | C++ | #include <iostream>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
int main(){
int i,j=0,n;
for(cin>>n;j<n;j++){
string s;cin>>s;map<string> m;
for(i=1;i<s.length();i++){
string s1=s.substr(0,i),s2=s.substr(i),r1=s1,r2=s2;
reverse(r1.begin(),r1.end());
reverse(r2.begin(),r2.end());
m[s1+s2]=1;
m[s1+s2]=1;
m[r1+s2]=1;
m[s1+r2]=1;
m[r1+r2]=1;
m[s2+s1]=1;
m[r2+s1]=1;
m[s2+r1]=1;
m[r2+r1]=1;
}
cout<<m.size()<<endl;
}
} | a.cc: In function 'int main()':
a.cc:9:43: error: wrong number of template arguments (1, should be at least 2)
9 | string s;cin>>s;map<string> m;
| ^
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: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
102 | class map
| ^~~
a.cc:14:26: error: no match for 'operator[]' (operand types are 'int' and 'std::__cxx11::basic_string<char>')
14 | m[s1+s2]=1;
| ^
a.cc:15:26: error: no match for 'operator[]' (operand types are 'int' and 'std::__cxx11::basic_string<char>')
15 | m[s1+s2]=1;
| ^
a.cc:16:26: error: no match for 'operator[]' (operand types are 'int' and 'std::__cxx11::basic_string<char>')
16 | m[r1+s2]=1;
| ^
a.cc:17:26: error: no match for 'operator[]' (operand types are 'int' and 'std::__cxx11::basic_string<char>')
17 | m[s1+r2]=1;
| ^
a.cc:18:26: error: no match for 'operator[]' (operand types are 'int' and 'std::__cxx11::basic_string<char>')
18 | m[r1+r2]=1;
| ^
a.cc:19:26: error: no match for 'operator[]' (operand types are 'int' and 'std::__cxx11::basic_string<char>')
19 | m[s2+s1]=1;
| ^
a.cc:20:26: error: no match for 'operator[]' (operand types are 'int' and 'std::__cxx11::basic_string<char>')
20 | m[r2+s1]=1;
| ^
a.cc:21:26: error: no match for 'operator[]' (operand types are 'int' and 'std::__cxx11::basic_string<char>')
21 | m[s2+r1]=1;
| ^
a.cc:22:26: error: no match for 'operator[]' (operand types are 'int' and 'std::__cxx11::basic_string<char>')
22 | m[r2+r1]=1;
| ^
a.cc:24:25: error: request for member 'size' in 'm', which is of non-class type 'int'
24 | cout<<m.size()<<endl;
| ^~~~
|
s274334159 | p00723 | C++ | #include<iostream>
#include<set>
#include<vector>
#include<string>
using namespace std;
vector<string> solve(string s,int st){
vector<string> ans;
string s1 = s.substr(0,st);
string s2 = s.substr(st,s.size()-st);
// 両方正
ans.push_back(s1+s2);
ans.push_back(s2+s1);
reverse(s1.begin(),s1.end());
//s1が逆
ans.push_back(s1+s2);
ans.push_back(s2+s1);
reverse(s2.begin(),s2.end());
//両方逆
ans.push_back(s1+s2);
ans.push_back(s2+s1);
reverse(s1.begin(),s1.end());
//s2が逆
ans.push_back(s1+s2);
ans.push_back(s2+s1);
return ans;
}
int main(){
int n;
cin >> n;
for(int i=0;i<n;i++){
set<string> s;
string buf;
cin >> buf;
for(int j=1;j<buf.size();j++){
vector<string> buf2 = solve(buf,j);
for(int k=0;k<buf2.size();k++){
s.insert(buf2[k]);
}
}
cout << s.size() << endl;
}
} | a.cc: In function 'std::vector<std::__cxx11::basic_string<char> > solve(std::string, int)':
a.cc:18:9: error: 'reverse' was not declared in this scope
18 | reverse(s1.begin(),s1.end());
| ^~~~~~~
|
s098513796 | p00723 | C++ | // AOJ 1142
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(void)
{
int m;
cin >> m;
while (m--){
string str;
map <string, int> mydata;
cin >> str;
for (int i = 1; i < (int)str.length(); i++){
string first = str.substr(0, i);
string second = str.substr(i, (int)str.length() - i);
string frev = first; reverse(frev.begin(), frev.end());
string srev = second; reverse(srev.begin(), srev.end());
// cout << first << " " << second << endl;
// そのまま+そのまま
mydata[first + second]++;
// はんてん+そのまま
mydata[frev + second]++;
// そのまま+はんてん
mydata[first + srev]++;
// はんてん+はんてん
mydata[frev + srev]++;
// いれかえする
// そのまま+そのまま
mydata[second + first]++;
// そのまま+はんてん
mydata[second + frev]++;
// はんてん+そのまま
mydata[srev + first]++;
// はんてん+はんてん
mydata[srev + frev]++;
}
cout << mydata.size() << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:20:46: error: 'reverse' was not declared in this scope
20 | string frev = first; reverse(frev.begin(), frev.end());
| ^~~~~~~
|
s816648391 | p00723 | C++ | include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int main(){
int n;
cin >> n;
while(n--){
string s;
cin >> s;
set<string> ans;
string a, b;
for(int i = 0 ; i < s.size() ; i++){
a = s.substr(0, i);
b = s.substr(i);
ans.insert(a+b);
ans.insert(b+a);
reverse(a.begin(), a.end());
ans.insert(a+b);
ans.insert(b+a);
reverse(b.begin(), b.end());
ans.insert(a+b);
ans.insert(b+a);
reverse(a.begin(), a.end());
ans.insert(a+b);
ans.insert(b+a);
}
cout << ans.size() << endl;
}
return 0;
}
| a.cc:1:1: error: 'include' does not name a type
1 | include <iostream>
| ^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared
295 | template <typename _Tp, size_t = sizeof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared
984 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope
1451 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
63 | #include <bits/version.h>
+++ |+#include <cstddef>
64 |
/usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid
1451 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared
1453 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope
1454 | struct extent<_Tp[_Size], 0>
| ^~~~~
/usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid
1454 | struct extent<_Tp[_Size], 0>
| ^
/usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~
/usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid
1455 | : public integral_constant<size_t, _Size> { };
| ^
/usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid
/usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared
1457 | template<typename _Tp, unsigned _Uint, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope
1458 | struct extent<_Tp[_Size], _Uint>
| ^~~~~
/usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid
1458 | struct extent<_Tp[_Size], _Uint>
| ^
/usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope
1463 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid
1463 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type
1857 | { static constexpr size_t __size = sizeof(_Tp); };
| ^~~~~~
/usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~~~~
/usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~
/usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp'
1860 | struct __select;
| ^~~~~~~~
/usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared
1862 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^~~
/usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^
/usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared
1866 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| ^~~
/usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
|
s395378582 | p00723 | C++ | #include <iostream>
#include <string>
#include <set>
using namespace std;
int main(void){
int n;
string str,sub1,sub2;
cin >> n;
for(int i=0;i<n;i++){
set<string> val;
cin >> str;
for(int j=1;j<str.length();j++){
sub2=str.substr(j);
sub1=str.substr(0,j);
val.insert(sub1+sub2);
val.insert(sub2+sub1);
reverse(sub2.begin(),sub2.end());
val.insert(sub1+sub2);
val.insert(sub2+sub1);
reverse(sub1.begin(),sub1.end());
reverse(sub2.begin(),sub2.end());
val.insert(sub1+sub2);
val.insert(sub2+sub1);
reverse(sub2.begin(),sub2.end());
val.insert(sub1+sub2);
val.insert(sub2+sub1);
}
cout << val.size() << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:23:25: error: 'reverse' was not declared in this scope
23 | reverse(sub2.begin(),sub2.end());
| ^~~~~~~
|
s691275675 | p00723 | C++ | #include <stdio.h>
#include <algorithm>
#include <string>
#include <set>
#include <iostream>
int main( void ) {
int M;
char S[73];
typedef set<string> set_t;
scanf( "%d", &M );
while ( M-- ) {
scanf( "%s", S );
set_t all;
all.insert( S );
for ( size_t i = 1; i < S.size(); i++ ) {
string L = S;
L.resize( i );
string R = S.substr( i );
string L2 = L, R2 = R;
reverse( L2.begin(), L2.end() );
reverse( R2.begin(), R2.end() );
all.insert( R + L );
all.insert( R + L2 );
all.insert( R2 + L );
all.insert( R2 + L2 );
all.insert( L + R );
all.insert( L + R2 );
all.insert( L2 + R );
all.insert( L2 + R2 );
}
printf( "%d", all.size() );
}
return 0;
} | a.cc: In function 'int main()':
a.cc:12:17: error: 'set' does not name a type
12 | typedef set<string> set_t;
| ^~~
a.cc:20:17: error: 'set_t' was not declared in this scope
20 | set_t all;
| ^~~~~
a.cc:21:17: error: 'all' was not declared in this scope; did you mean 'atoll'?
21 | all.insert( S );
| ^~~
| atoll
a.cc:23:43: error: request for member 'size' in 'S', which is of non-class type 'char [73]'
23 | for ( size_t i = 1; i < S.size(); i++ ) {
| ^~~~
a.cc:25:25: error: 'string' was not declared in this scope
25 | string L = S;
| ^~~~~~
a.cc:25:25: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
from a.cc:3:
/usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string'
77 | typedef basic_string<char> string;
| ^~~~~~
/usr/include/c++/14/string:76:11: note: 'std::pmr::string'
76 | using string = basic_string<char>;
| ^~~~~~
a.cc:26:25: error: 'L' was not declared in this scope
26 | L.resize( i );
| ^
a.cc:27:31: error: expected ';' before 'R'
27 | string R = S.substr( i );
| ^~
| ;
a.cc:29:31: error: expected ';' before 'L2'
29 | string L2 = L, R2 = R;
| ^~~
| ;
a.cc:30:34: error: 'L2' was not declared in this scope
30 | reverse( L2.begin(), L2.end() );
| ^~
a.cc:30:25: error: 'reverse' was not declared in this scope; did you mean 'std::reverse'?
30 | reverse( L2.begin(), L2.end() );
| ^~~~~~~
| std::reverse
In file included from /usr/include/c++/14/algorithm:86,
from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:249:1: note: 'std::reverse' declared here
249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
| ^~~~~~~
a.cc:31:34: error: 'R2' was not declared in this scope
31 | reverse( R2.begin(), R2.end() );
| ^~
a.cc:33:37: error: 'R' was not declared in this scope
33 | all.insert( R + L );
| ^
|
s215675148 | p00724 | C++ | //Tue Dec 22 22:01:34 JST 2009
#include<set>
#include<iostream>
#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
int dx[]={0,1,1,0,-1,-1};
int dy[]={-1,-1,0,1,1,0};
#define CONNECT true
#define UNCONNECT false
#define CANMOVE true
#define CANNOTMOVE false
class state{
public:
int len;
int x[8],y[8];
int cnt;
int path[8];
bool is_connected(int me,int you){
if ( x[me]==x[you]){
if ( y[me]-1 == y[you] || y[me]+1 == y[you] || y[me]==y[you])return CONNECT;
}else if ( x[me]+1 == x[you]){
if (y[me] ==y[you] || y[me]-1==y[you])return CONNECT;
}else if ( x[me]-1==x[you]){
if (y[me] ==y[you] || y[me]+1 == y[you])return CONNECT;
}
return UNCONNECT;
}
bool can_good_pos(int cur){
rep(i,cur-1){
if ( is_connected(cur,i)==CONNECT)return false;//
}
if (cur==0 || is_connected(cur,cur-1)==CONNECT)return true;//
return false;
}
void make_next(int now,queue<state>&Q,set<state>&S,bool flag,set<pair<int,int> > & NG){
if ( now == len){
if ( S.find((*this))==S.end()){
cnt++;
S.insert(*this);
Q.push(*this);
cnt--;
}
return;
}
//don't move
if (can_good_pos(now) ){
path[now]=-1;
make_next(now+1,Q,S,CANMOVE,NG);
}
if ( flag == CANNOTMOVE)return;//
rep(i,6){
x[now]+=dx[i];
y[now]+=dy[i];
path[now]=i;
if (NG.find(mp(x[now],y[now])) == NG.end() && can_good_pos(now)){
make_next(now+1,Q,S,CANNOTMOVE,NG);//
}
x[now]-=dx[i];
y[now]-=dy[i];
}
}
bool operator<(const state & a)const{
rep(i,len){
if ( x[i]!=a.x[i])return x[i]<a.x[i];
if ( y[i]!=a.y[i])return y[i]<a.y[i];
}
return false;
}
};
int bfs(state ini,int dx,int dy,set<pair<int,int> > &NG){
queue<state> Q;
set<state> S;
Q.push(ini);
S.insert(ini);
while(!Q.empty()){
state now = Q.front();
Q.pop();
if (20<cnt+(max(now.x[0],dx)-min(now.x[0],dy)+
max(now.y[0],dy)-min(now.y[0],dy))/2)continue;
if ( now.x[0]==dx && now.y[0]==dy){
return now.cnt;
}
now.make_next(0,Q,S,CANMOVE,NG);
}
return -1;
}
main(){
int n,m,dx,dy;
while(cin>>n && n){
state ini;
set<pair<int,int> > NG;
ini.len=n;
ini.cnt=0;
rep(i,n)cin>>ini.x[i]>>ini.y[i];
cin>>m;
rep(i,m){
int f,s;
cin>>f>>s;
NG.insert(mp(f,s));
}
cin>>dx>>dy;
cout << bfs(ini,dx,dy,NG)<<endl;
}
return false;
} | a.cc: In function 'int bfs(state, int, int, std::set<std::pair<int, int> >&)':
a.cc:97:8: error: 'cnt' was not declared in this scope; did you mean 'int'?
97 | if (20<cnt+(max(now.x[0],dx)-min(now.x[0],dy)+
| ^~~
| int
a.cc: At global scope:
a.cc:108:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
108 | main(){
| ^~~~
|
s460342830 | p00724 | C++ | #include <iostream>
#include <set>
#include <vector>
using namespace std;
char dx[] = {0,1,1,0,-1,-1};
char dy[] = {-1,-1,0,1,1,0};
set< vector<int> > prev;
vector< vector<int> > cur, next;
int x[8], y[8], u[100], v[100], n, k, X, Y, ans;
void move(int step, int pos){
if(ans != 20) return;
if(pos >= n) {
for(int i=0;i<n;i++)
for(int j=i+2;j<n;j++)
for(int k=0;k<6;k++)
if(x[i]+dx[k]==x[j]&&y[i]+dy[k]==y[j]) return;
vector<int> v;
for(int i=0;i<n;i++) v.push_back(x[i]), v.push_back(y[i]);
if(x[0]==X&&y[0]==Y) ans = step;
if(prev.find(v) == prev.end()){
prev.insert(v);
next.push_back(v);
}
return;
}
int px = x[pos], py = y[pos];
for(int i=0;i<6;i++){
int nx = x[pos]+dx[i], ny = y[pos]+dy[i];
bool check = false, flagF = false, flagB = false;
if(pos == 0 && step+max(abs(X-nx),abs(Y-ny)) > 19) continue;
if(pos == 1 && step+max(abs(X-x[0]),abs(Y-y[0]))+abs(max(abs(X-nx),abs(Y-ny))-1) > 19) continue;
for(int j=0;j<min(pos+1,n);j++){
if(j==pos) continue;
if(x[j]==nx&&y[j]==ny) check = true;
}
if(check) continue;
if(pos>0){
for(int k=0;k<6;k++)
if(x[pos-1]+dx[k] == nx && y[pos-1]+dy[k] == ny) flagF = true;
if(!flagF) continue;
}
if(pos<n-1){
for(int k=0;k<6;k++)
if(x[pos+1]+dx[k] == nx && y[pos+1]+dy[k] == ny) flagB = true;
if(!flagB) continue;
}
for(int j=0;j<k&&!check;j++)
if(u[j] == nx && v[j] == ny) check = true;
if(check) continue;
x[pos] = nx, y[pos] = ny;
move(step, pos+2);
x[pos] = px, y[pos] = py;
}
move(step, pos+1);
}
int main(){
set< vector<int> >::iterator it;
while(cin >> n, n){
for(int i=0;i<n;i++) cin >> x[i] >> y[i];
cin >> k;
for(int i=0;i<k;i++) cin >> u[i] >> v[i];
cin >> X >> Y;
ans = 20;
vector<int> v;
for(int i=0;i<n;i++) v.push_back(x[i]), v.push_back(y[i]);
prev.clear(); cur.clear();
prev.insert(v); cur.push_back(v);
for(int i=1;ans==20&&i<=19;i++){
next.clear();
for(int k=0;k<cur.size();k++){
for(int j=0;j<n;j++) x[j] = cur[k][2*j], y[j] = cur[k][2*j+1];
move(i, 0);
}
cur = next;
}
cout << ans << endl;
}
} | a.cc: In function 'void move(int, int)':
a.cc:24:20: error: reference to 'prev' is ambiguous
24 | if(prev.find(v) == prev.end()){
| ^~~~
In file included from /usr/include/c++/14/string:47,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:10:20: note: 'std::set<std::vector<int> > prev'
10 | set< vector<int> > prev;
| ^~~~
a.cc:24:36: error: reference to 'prev' is ambiguous
24 | if(prev.find(v) == prev.end()){
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:10:20: note: 'std::set<std::vector<int> > prev'
10 | set< vector<int> > prev;
| ^~~~
a.cc:25:25: error: reference to 'prev' is ambiguous
25 | prev.insert(v);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:10:20: note: 'std::set<std::vector<int> > prev'
10 | set< vector<int> > prev;
| ^~~~
a.cc:26:25: error: reference to 'next' is ambiguous
26 | next.push_back(v);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:11:28: note: 'std::vector<std::vector<int> > next'
11 | vector< vector<int> > cur, next;
| ^~~~
a.cc: In function 'int main()':
a.cc:72:17: error: reference to 'prev' is ambiguous
72 | prev.clear(); cur.clear();
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:10:20: note: 'std::set<std::vector<int> > prev'
10 | set< vector<int> > prev;
| ^~~~
a.cc:73:17: error: reference to 'prev' is ambiguous
73 | prev.insert(v); cur.push_back(v);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:10:20: note: 'std::set<std::vector<int> > prev'
10 | set< vector<int> > prev;
| ^~~~
a.cc:75:25: error: reference to 'next' is ambiguous
75 | next.clear();
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:11:28: note: 'std::vector<std::vector<int> > next'
11 | vector< vector<int> > cur, next;
| ^~~~
a.cc:80:31: error: reference to 'next' is ambiguous
80 | cur = next;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:11:28: note: 'std::vector<std::vector<int> > next'
11 | vector< vector<int> > cur, next;
| ^~~~
|
s502945986 | p00724 | C++ | #include <iostream>
#include <set>
#include <vector>
using namespace std;
char dx[] = {0,1,1,0,-1,-1};
char dy[] = {-1,-1,0,1,1,0};
set< vector<int> > prev;
vector< vector<int> > cur, next;
int x[8], y[8], u[100], v[100], n, k, X, Y, ans;
void move(int step, int pos){
if(ans != 20) return;
if(pos >= n) {
for(int i=0;i<n;i++)
for(int j=i+2;j<n;j++)
for(int k=0;k<6;k++)
if(x[i]+dx[k]==x[j]&&y[i]+dy[k]==y[j]) return;
vector<int> v;
for(int i=0;i<n;i++) v.push_back(x[i]), v.push_back(y[i]);
if(x[0]==X&&y[0]==Y) ans = step;
if(!prev.count(v)){
prev.insert(v);
next.push_back(v);
}
return;
}
int px = x[pos], py = y[pos];
for(int i=0;i<6;i++){
int nx = x[pos]+dx[i], ny = y[pos]+dy[i];
bool check = false, flagF = false, flagB = false;
if(pos == 0 && step+max(abs(X-nx),abs(Y-ny)) > 19) continue;
if(pos == 1 && step+max(abs(X-x[0]),abs(Y-y[0]))+abs(max(abs(X-nx),abs(Y-ny))-1) > 19) continue;
for(int j=0;j<min(pos+1,n);j++){
if(j==pos) continue;
if(x[j]==nx&&y[j]==ny) check = true;
}
if(check) continue;
if(pos>0){
for(int k=0;k<6;k++)
if(x[pos-1]+dx[k] == nx && y[pos-1]+dy[k] == ny) flagF = true;
if(!flagF) continue;
}
if(pos<n-1){
for(int k=0;k<6;k++)
if(x[pos+1]+dx[k] == nx && y[pos+1]+dy[k] == ny) flagB = true;
if(!flagB) continue;
}
for(int j=0;j<k&&!check;j++)
if(u[j] == nx && v[j] == ny) check = true;
if(check) continue;
x[pos] = nx, y[pos] = ny;
move(step, pos+2);
x[pos] = px, y[pos] = py;
}
move(step, pos+1);
}
int main(){
set< vector<int> >::iterator it;
while(cin >> n, n){
for(int i=0;i<n;i++) cin >> x[i] >> y[i];
cin >> k;
for(int i=0;i<k;i++) cin >> u[i] >> v[i];
cin >> X >> Y;
ans = 20;
vector<int> v;
for(int i=0;i<n;i++) v.push_back(x[i]), v.push_back(y[i]);
prev.clear(); cur.clear();
prev.insert(v); cur.push_back(v);
for(int i=1;ans==20&&i<=19;i++){
next.clear();
for(int k=0;k<cur.size();k++){
for(int j=0;j<n;j++) x[j] = cur[k][2*j], y[j] = cur[k][2*j+1];
move(i, 0);
}
cur = next;
}
cout << ans << endl;
}
} | a.cc: In function 'void move(int, int)':
a.cc:24:21: error: reference to 'prev' is ambiguous
24 | if(!prev.count(v)){
| ^~~~
In file included from /usr/include/c++/14/string:47,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:10:20: note: 'std::set<std::vector<int> > prev'
10 | set< vector<int> > prev;
| ^~~~
a.cc:25:25: error: reference to 'prev' is ambiguous
25 | prev.insert(v);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:10:20: note: 'std::set<std::vector<int> > prev'
10 | set< vector<int> > prev;
| ^~~~
a.cc:26:25: error: reference to 'next' is ambiguous
26 | next.push_back(v);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:11:28: note: 'std::vector<std::vector<int> > next'
11 | vector< vector<int> > cur, next;
| ^~~~
a.cc: In function 'int main()':
a.cc:72:17: error: reference to 'prev' is ambiguous
72 | prev.clear(); cur.clear();
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:10:20: note: 'std::set<std::vector<int> > prev'
10 | set< vector<int> > prev;
| ^~~~
a.cc:73:17: error: reference to 'prev' is ambiguous
73 | prev.insert(v); cur.push_back(v);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:10:20: note: 'std::set<std::vector<int> > prev'
10 | set< vector<int> > prev;
| ^~~~
a.cc:75:25: error: reference to 'next' is ambiguous
75 | next.clear();
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:11:28: note: 'std::vector<std::vector<int> > next'
11 | vector< vector<int> > cur, next;
| ^~~~
a.cc:80:31: error: reference to 'next' is ambiguous
80 | cur = next;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:11:28: note: 'std::vector<std::vector<int> > next'
11 | vector< vector<int> > cur, next;
| ^~~~
|
s621536293 | p00724 | C++ | #include<queue>
using namespace std;
int vx[]={ 1, 1, 0, 0,-1,-1};
int vy[]={ 0,-1, 1,-1, 1, 0};
struct P{
int x,y;
};
int n,k;
struct Snake{
int step;
P body[8];
bool operator<(const Snake&b)const{
for(int i=0;i<n;i++){
if(body[i].x!=b.body[i].x)return body[i].x<b.body[i].x;
if(body[i].y!=b.body[i].y)return body[i].y<b.body[i].y;
}
return false;
}
P& operator[](int i){
return body[i];
}
};
queue<Snake> que;
int X,Y;
int ans;
P rock[100];
Snake body;
set<Snake> s;
int distance(){
int dis, dx=X-body[0].x, dy=Y-body[0].y;
if(dx*dy<0)dis= abs(dx)<abs(dy)? abs(dy):abs(dx);
else dis= abs(dx)+abs(dy);
return dis;
}
inline bool overlap(P &a,P &b){
return a.x==b.x && a.y==b.y;
}
bool neibor(P &a,P &b){
int dx=a.x-b.x;
int dy=a.y-b.y;
return abs(dx)+abs(dy)<=1
|| abs(dx)==1 && -dx==dy;
}
bool is_dead(int no){
for(int i=0;i<no-1;i++){
if(neibor(body[no], body[i])){
return true;
}
}
return false;
}
bool on_rock(int no){
for(int i=0;i<k;i++){
if(rock[i].x==body[no].x && rock[i].y==body[no].y)
return true;
}
return false;
}
void search(int step);
bool move(int no){
if(no==1||no==2)if(ans-body.step <= distance())return false;
for(int i=0;i<6;i++){
body[no].x+=vx[i];
body[no].y+=vy[i];
if(!is_dead(no) && !on_rock(no)
&& (no==0 ||neibor(body[no-1],body[no]) && !overlap(body[no-1],body[no]))
&& (n<=no+1||neibor(body[no],body[no+1]) && !overlap(body[no],body[no+1])) ){
if(no+2<n){if(move(no+2))return true;}
else {
if(X==body[0].x && Y==body[0].y)return true;
body.step++;
if(s.find(body)==s.end()){
s.insert(body);
que.push(body);
}
body.step--;
}
}
body[no].x-=vx[i];
body[no].y-=vy[i];
}
if(!is_dead(no) ){
if(no+1<n){if(move(no+1))return true;}
else {
if(X==body[0].x && Y==body[0].y)return true;
body.step++;
if(s.find(body)==s.end()){
s.insert(body);
que.push(body);
}
body.step--;
}
}
return false;
}
main(){
while(cin>>n,n){
s.clear();
while(!que.empty())que.pop();
body.step=0;
for(int i=0;i<n;i++){
cin>>body[i].x>>body[i].y;
}
cin>>k;
for(int i=0;i<k;i++){
cin>>rock[i].x>>rock[i].y;
}
cin>>X>>Y;
ans=20;
que.push(body);
while(!que.empty()){
body=que.front();
que.pop();
if(ans-body.step <= distance())continue;
if(body.step==20-1)break;
if(move(0)){
ans= body.step+1;
break;
}
}
cout<<ans<<endl;
}
} | a.cc:28:1: error: 'set' does not name a type
28 | set<Snake> s;
| ^~~
a.cc: In function 'int distance()':
a.cc:31:25: error: 'abs' was not declared in this scope; did you mean 'ans'?
31 | if(dx*dy<0)dis= abs(dx)<abs(dy)? abs(dy):abs(dx);
| ^~~
| ans
a.cc:32:19: error: 'abs' was not declared in this scope; did you mean 'ans'?
32 | else dis= abs(dx)+abs(dy);
| ^~~
| ans
a.cc: In function 'bool neibor(P&, P&)':
a.cc:41:16: error: 'abs' was not declared in this scope; did you mean 'ans'?
41 | return abs(dx)+abs(dy)<=1
| ^~~
| ans
a.cc: In function 'bool move(int)':
a.cc:72:36: error: 's' was not declared in this scope
72 | if(s.find(body)==s.end()){
| ^
a.cc:87:28: error: 's' was not declared in this scope
87 | if(s.find(body)==s.end()){
| ^
a.cc: At global scope:
a.cc:96:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
96 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:97:15: error: 'cin' was not declared in this scope
97 | while(cin>>n,n){
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include<queue>
+++ |+#include <iostream>
2 | using namespace std;
a.cc:98:17: error: 's' was not declared in this scope
98 | s.clear();
| ^
a.cc:122:17: error: 'cout' was not declared in this scope
122 | cout<<ans<<endl;
| ^~~~
a.cc:122:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:122:28: error: 'endl' was not declared in this scope
122 | cout<<ans<<endl;
| ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
1 | #include<queue>
+++ |+#include <ostream>
2 | using namespace std;
|
s239805803 | p00724 | C++ | #include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<queue>
#include<complex>
#include<set>
using namespace std;
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)
const int INF = 1000000000;
typedef complex<int> pii;
typedef vector<pii> VP;
class Hexwamp{
public:
VP x;
VP getForm(){
VP ret(x.size());
rep(i,x.size())ret[i] = x[i]-x[0];
return ret;
}
};
map<vector<int>, pii> move;
vector<int> mk(int a,int b,int c,int d,int e,int f){
vector<int> ret(6);
ret[0]=a; ret[1]=b; ret[2]=c; ret[3]=d; ret[4]=e; ret[5]=f;
return ret;
}
void setmove(){
move[mk(0,0,1,0,1,1)]=pii(0,1);
move[mk(0,0,1,0,2,-1)]=pii(1,-1);
move[mk(0,0,1,-1,2,-1)]=pii(1,0);
move[mk(0,0,1,-1,1,-2)]=pii(0,-1);
move[mk(0,0,0,-1,1,-2)]=pii(1,-1);
move[mk(0,0,0,-1,-1,-1)]=pii(-1,0);
move[mk(0,0,-1,0,-1,-1)]=pii(0,-1);
move[mk(0,0,-1,0,-2,1)]=pii(-1,1);
move[mk(0,0,-1,1,-2,1)]=pii(-1,0);
move[mk(0,0,-1,1,-1,2)]=pii(0,1);
move[mk(0,0,0,1,-1,2)]=pii(-1,1);
move[mk(0,0,0,1,1,1)]=pii(1,0);
}
pii getMove(pii a, pii b, pii c){
pii st = a;
a-=st; b-=st; c-=st;
pii ret = move[mk(a.real(),a.imag(), b.real(),b.imag(), c.real(),c.imag())];
if(ret.real()==0 && ret.imag()==0)return b+st;
return ret+st;
}
map<vector<int>, pii> move2;
vector<int> mk2(int a,int b,int c,int d,int e){
vector<int> ret(5);
ret[0]=a; ret[1]=b; ret[2]=c; ret[3]=d; ret[4]=e;
return ret;
}
void setmove2(){
move2[mk2(0,0,1,0,0)]=pii(1,-1);
move2[mk2(0,0,1,0,1)]=pii(0,1);
move2[mk2(0,0,1,-1,0)]=pii(1,0);
move2[mk2(0,0,1,-1,1)]=pii(0,-1);
move2[mk2(0,0,0,-1,0)]=pii(1,-1);
move2[mk2(0,0,0,-1,1)]=pii(-1,0);
move2[mk2(0,0,-1,0,0)]=pii(0,-1);
move2[mk2(0,0,-1,0,1)]=pii(-1,1);
move2[mk2(0,0,-1,1,0)]=pii(-1,0);
move2[mk2(0,0,-1,1,1)]=pii(0,1);
move2[mk2(0,0,0,1,0)]=pii(-1,1);
move2[mk2(0,0,0,1,1)]=pii(1,0);
}
pii getMove2(pii a, pii b,int c){
pii st = a;
a-=st; b-=st;
pii ret = move2[mk2(a.real(),a.imag(), b.real(),b.imag(), c)];
if(ret.real()==0 && ret.imag()==0)return b+st;
return ret+st;
}
void init(){
setmove();
setmove2();
}
class piicomp{
public:
bool operator()(const pii& a, const pii& b)const{
if(a.real()==b.real())return a.imag()<b.imag();
return a.real()<b.real();
}
};
class VPcomp{
public:
bool operator()(const VP& a, const VP& b)const{
if(a.size()!=b.size())return a.size()<b.size();
rep(i,a.size())if(a[i]!=b[i])return piicomp()(a[i],b[i]);
return false;
}
};
int main(){
init();
/*
VP a;
a.push_back(pii(1,0));
VP b;
b.push_back(pii(1,0));
b.push_back(pii(2,1));
printf("%d\n",VPcomp()(a,b));
return 0;*/
A:;
int n;
cin>>n;
if(n==0)return 0;
Hexwamp wamp;
rep(i,n){
int a,b;
cin>>a>>b;
wamp.x.push_back(pii(a,b));
}
int m;
cin>>m;
map<pii,int,piicomp()> rock;
rep(i,m){
int a,b;
cin>>a>>b;
rock[pii(a,b)]=1;
}
int enx,eny;
cin>>enx>>eny;
map<pii,int,piicomp()> ok;
typedef pair<pii,int> fa;
queue<fa> queque;
queque.push(fa(pii(enx,eny),0));
while(1){
if(queque.empty())break;
fa u = queque.front();
queque.pop();
if(ok[u.first]==1)continue;
ok[u.first]=1;
if(u.second>20)continue;
pii d[]={pii(1,0),pii(1,-1),pii(0,-1),pii(-1,0),pii(-1,1),pii(0,1)};
rep(i,6){
queque.push(fa(u.first+d[i],u.second+1));
}
}
typedef pair<Hexwamp,int> P;
queue<P> que;
que.push(P(wamp,0));
map<VP,int,VPcomp()> visit;
map<VP,vector<VP>,VPcomp()> memo;
while(1){
if(que.empty())break;
P u = que.front();
que.pop();
Hexwamp h = u.first;
VP body = h.x;
VP form = h.getForm();
if(ok.find(body[0])==ok.end())continue;
if(visit[body]==1)continue;
visit[body]=1;
if(body[0].real()==enx && body[0].imag()==eny){
printf("%d\n",u.second);
break;
}
/*
printf("body %d| ",u.second);
rep(i,body.size())cout<<body[i]<<" ";puts("");
*/
/*
printf("form %d| ",u.second);
rep(i,body.size())cout<<form[i]<<" ";puts("");
*/
vector<VP> moves = memo[form];
if(moves.size()==0){
for(int i=1;i<(1<<form.size());i++){
bool flg=true;
for(int j=0;j<form.size()-1;j++){
if((i&(1<<j))>0 && (i&(1<<(j+1)))>0)flg=false;
}
if(!flg)continue;
VP copy = form;
for(int j=1;j<form.size()-1;j++){
if((i&(1<<j))>0){
pii next = getMove(form[j-1],form[j],form[j+1]);
if(next == form[j])flg=false;
copy[j] = next;
}
}
if(!flg)continue;
//for(int j=0;j<form.size();j++)printf("%d",((i&(1<<j))>0));puts("");
map<VP,int,VPcomp> ves;
VP aa(2);
for(int j=0;j<2;j++){
for(int k=0;k<2;k++){
pii next1 = getMove2(form[1],form[0],j);
pii next2 = getMove2(form[form.size()-2],form[form.size()-1],k);
if((i&(1<<0))==0)next1 = form[0];
if((i&(1<<(form.size()-1)))==0)next2 = form[form.size()-1];
aa[0]=next1; aa[1]=next2;
if(ves[aa]==1)continue;
ves[aa]=1;
copy[0] = next1;
copy[form.size()-1] = next2;
moves.push_back(copy);
copy[0] = form[0];
copy[form.size()-1] = form[form.size()-1];
//printf("moves | ");
//rep(p,copy.size())cout<<copy[p]<<" ";puts("");
}
}
}
for(int i=0;i<moves.size();i++){
bool flg = true;
pii d[]={pii(1,0),pii(1,-1),pii(0,-1),pii(-1,0),pii(-1,1),pii(0,1)};
for(int j=0;j<moves[i].size();j++){
int count = 0;
for(int k=0;k<moves[i].size();k++){
rep(p,6){
if(moves[i][j]+d[p]==moves[i][k])count++;
}
}
if((j==0 || j==moves[i].size()-1)&&count>1)flg=false;
if(count>2)flg=false;
}
if(!flg){
moves.erase(moves.begin()+i);
i--;
}
}
memo[form]=moves;
}
//puts("");
/*
rep(j,moves.size()){
printf("moves %d| ",u.second);
rep(i,body.size())cout<<moves[j][i]<<" ";puts("");
}puts("");
*/
rep(i,moves.size()){
Hexwamp next;
next.x = VP(moves[i].size());
bool flg = true;
rep(j,moves[i].size()){
next.x[j] = moves[i][j]+body[0];
if(rock.find(next.x[j])!=rock.end())flg=false;
}
if(!flg)continue;
que.push(P(next,u.second+1));
}
}
goto A;
} | a.cc: In function 'void setmove()':
a.cc:38:9: error: reference to 'move' is ambiguous
38 | move[mk(0,0,1,0,1,1)]=pii(0,1);
| ^~~~
In file included from /usr/include/c++/14/algorithm:86,
from a.cc:6:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41:
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:31:23: note: 'std::map<std::vector<int>, std::complex<int> > move'
31 | map<vector<int>, pii> move;
| ^~~~
a.cc:39:9: error: reference to 'move' is ambiguous
39 | move[mk(0,0,1,0,2,-1)]=pii(1,-1);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:31:23: note: 'std::map<std::vector<int>, std::complex<int> > move'
31 | map<vector<int>, pii> move;
| ^~~~
a.cc:41:9: error: reference to 'move' is ambiguous
41 | move[mk(0,0,1,-1,2,-1)]=pii(1,0);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:31:23: note: 'std::map<std::vector<int>, std::complex<int> > move'
31 | map<vector<int>, pii> move;
| ^~~~
a.cc:42:9: error: reference to 'move' is ambiguous
42 | move[mk(0,0,1,-1,1,-2)]=pii(0,-1);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:31:23: note: 'std::map<std::vector<int>, std::complex<int> > move'
31 | map<vector<int>, pii> move;
| ^~~~
a.cc:44:9: error: reference to 'move' is ambiguous
44 | move[mk(0,0,0,-1,1,-2)]=pii(1,-1);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:31:23: note: 'std::map<std::vector<int>, std::complex<int> > move'
31 | map<vector<int>, pii> move;
| ^~~~
a.cc:45:9: error: reference to 'move' is ambiguous
45 | move[mk(0,0,0,-1,-1,-1)]=pii(-1,0);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:31:23: note: 'std::map<std::vector<int>, std::complex<int> > move'
31 | map<vector<int>, pii> move;
| ^~~~
a.cc:47:9: error: reference to 'move' is ambiguous
47 | move[mk(0,0,-1,0,-1,-1)]=pii(0,-1);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:31:23: note: 'std::map<std::vector<int>, std::complex<int> > move'
31 | map<vector<int>, pii> move;
| ^~~~
a.cc:48:9: error: reference to 'move' is ambiguous
48 | move[mk(0,0,-1,0,-2,1)]=pii(-1,1);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:31:23: note: 'std::map<std::vector<int>, std::complex<int> > move'
31 | map<vector<int>, pii> move;
| ^~~~
a.cc:50:9: error: reference to 'move' is ambiguous
50 | move[mk(0,0,-1,1,-2,1)]=pii(-1,0);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class |
s056267730 | p00724 | C++ | #include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <exception>
#include <queue>
#include <set>
#include <cmath>
using namespace std;
struct coordinate {
coordinate() { x = 0; y = 0; }
coordinate(int X, int Y) {
x = X; y = Y;
}
coordinate operator+(const int & a) const { // {{{
coordinate ret(x,y);
if(a < 0 || 6 < a)
throw exception();
switch(a) {
case 0:
break;
case 1:
ret.y--; break;
case 2:
ret.y--; ret.x++; break;
case 3:
ret.x++; break;
case 4:
ret.y++; break;
case 5:
ret.x--; ret.y++; break;
case 6:
ret.x--;
}
return ret; // }}}
}
int direction(coordinate a) { // {{{
int diff_x, diff_y;
diff_x = a.x - x;
diff_y = a.y - y;
if(diff_x < -1 || diff_x > 1 || diff_y < -1 || diff_x > 1)
throw exception();
if(diff_x == 0 && diff_y == 0)
return 0;
else if(diff_x == 0 && diff_y == -1)
return 1;
else if(diff_x == 1 && diff_y == -1)
return 2;
else if(diff_x == 1 && diff_y == 0)
return 3;
else if(diff_x == 0 && diff_y == 1)
return 4;
else if(diff_x == -1 && diff_y == 1)
return 5;
else if(diff_x == -1 && diff_y == 0)
return 6;
else
throw exception(); // }}}
}
bool operator==(const coordinate a) const {
return (x == a.x) && (y == a.y);
}
bool operator<(const coordinate a) const {
if(x != a.x)
return x < a.x;
return y < a.y;
}
};
bool adjoin(coordinate a, coordinate b) {
int x, y;
x = a.x - b.x;
y = a.y - b.y;
if(x < -1 || 1 < x || y < -1 || 1 < y)
return false;
if((x == 1 && y == 1) || (x == -1 && y == -1))
return false;
return true;
}
struct snake {
coordinate head; // head;
int geometry;
snake() {};
snake(coordinate h, int geo) {
head = h; geometry = geo;
}
};
int encode_snake_geometory(vector<coordinate> v) {
int ret = 0;
for(int i = 0; i < v.size() - 1; i++) {
ret |= v[i].direction(v[i + 1]) << (3 * i);
}
return ret;
}
vector<coordinate> decode_snake_geometory(int n, coordinate c) {
vector<coordinate> ret;
ret.push_back(c);
for(int i = 0; (n >> (3 * i)) & 7; i++) {
ret.push_back(ret[i] + ((n >> (3 * i)) & 7));
}
return ret;
}
map<int, vector<pair<int,int> > > snake_transform; // first:geometory, second:(first:geometory, second:head move)
bool save(vector<coordinate> geometory) {
for(int i = 0; i < geometory.size(); i++) {
for(int j = i + 2; j < geometory.size(); j++) {
/*
try {
geometory[i].direction(geometory[j]);
return false;
}
catch(exception e) {
}
*/
if(adjoin(geometory[i], geometory[j]))
return false;
}
}
return true;
}
vector<vector<coordinate> > next_geometory_result;
vector<coordinate> next_geometory_search_table;
int next_geometory_head_move;
int next_geometory_from;
void next_geometory(vector<coordinate> geometory, int indx, bool prev_move) {
if(indx >= geometory.size()) {
if(save(next_geometory_search_table)) {
next_geometory_result.push_back(next_geometory_search_table);
snake_transform[next_geometory_from].push_back(pair<int,int>(encode_snake_geometory(next_geometory_search_table), next_geometory_head_move));
}
return;
}
if(!prev_move) {
for(int i = 1; i <= 6; i++) {
coordinate c = geometory[indx];
c = c + i;
if(indx == 0)
next_geometory_head_move = i;
/*
try {
if(indx > 0)
c.direction(geometory[indx - 1]);
if(indx < geometory.size() - 1)
c.direction(geometory[indx + 1]);
next_geometory_search_table.push_back(c);
next_geometory(geometory, indx + 1, true);
next_geometory_search_table.pop_back();
}
catch (exception e){
}
*/
bool flag0, flag1;
flag0 = flag1 = true;
if(indx > 0) {
flag0 = adjoin(c, geometory[indx - 1]);
}
if(indx < geometory.size() - 1) {
flag1 = adjoin(c, geometory[indx + 1]);
}
if(flag0 && flag1) {
next_geometory_search_table.push_back(c);
next_geometory(geometory, indx + 1, true);
next_geometory_search_table.pop_back();
}
}
}
if(indx == 0)
next_geometory_head_move = 0;
next_geometory_search_table.push_back(geometory[indx]);
next_geometory(geometory, indx + 1, false);
next_geometory_search_table.pop_back();
}
void make_table(int n) {
vector<coordinate> geometory;
for(int i = 0; i < n; i++) {
geometory.push_back(coordinate(0, i));
}
queue<int> q;
q.push(encode_snake_geometory(geometory));
while(!q.empty()) {
int g;
g = q.front(); q.pop();
if(snake_transform.find(g) == snake_transform.end()) {
/* debug
vector<coordinate> tmp;
tmp = decode_snake_geometory(g, coordinate(0,0));
for(int i = 0; i < tmp.size(); i++)
cout << "(" << tmp[i].x << ", " << tmp[i].y << ") ";
cout << endl;
debug */
next_geometory_from = g;
next_geometory_result.clear();
next_geometory_search_table.clear();
next_geometory(decode_snake_geometory(g, coordinate(0,0)), 0, false);
for(int i = 0; i < next_geometory_result.size(); i++) {
q.push(encode_snake_geometory(next_geometory_result[i]));
}
}
}
}
/* input value */
int snake_nodes;
vector<coordinate> snake;
int rock_num;
vector<coordinate> rock;
coordinate scientist;
/* input process */
bool input() {
cin >> snake_nodes;
if(!snake_nodes)
return false;
for(int i = 0; i < snake_nodes; i++) {
int x, y;
cin >> x >> y;
snake.push_back(coordinate(x,y));
}
cin >> rock_num;
for(int i = 0; i < rock_num; i++) {
int x, y;
cin >> x >> y;
rock.push_back(coordinate(x,y));
}
int x, y;
cin >> x >> y;
scientist = coordinate(x,y);
return true;
}
void init() {
snake.clear();
rock.clear();
snake_transform.clear();
next_geometory_result.clear();
next_geometory_search_table.clear();
}
int solve() {
set<pair<int,coordinate> > moved;
queue<pair<int,coordinate> > q;
q.push(pair<int,coordinate>(encode_snake_geometory(snake), snake[0]));
int count = 0;
while(true) {
queue<pair<int,coordinate> > next_q;
while(!q.empty()) {
pair<int,coordinate> tmp;
int g;
vector<pair<int,int> > next;
tmp = q.front(); q.pop();
if(tmp.second == scientist)
return count;
if(moved.find(tmp) != moved.end()) {
continue;
}
if(abs(tmp.second.x - scientist.x) + abs(tmp.second.y - scientist.y) > 20 - count) {
continue;
}
moved.insert(tmp);
next = snake_transform[tmp.first];
for(int i = 0; i < next.size(); i++) {
vector<coordinate> s;
s = decode_snake_geometory(next[i].first, tmp.second + next[i].second);
for(int j = 0; j < s.size(); j++) {
for(int k = 0; k < rock.size(); k++) {
if(s[j] == rock[k]) {
goto fail0;
}
}
}
next_q.push(pair<int,coordinate>(encode_snake_geometory(s), s[0]));
fail0:;
}
}
q = next_q;
count++;
}
return -1;
}
int main() {
init();
while(input()) {
make_table(snake_nodes);
cout << solve() << endl;
init();
}
} | a.cc: In constructor 'coordinate::coordinate()':
a.cc:13:24: error: 'x' was not declared in this scope
13 | coordinate() { x = 0; y = 0; }
| ^
a.cc:13:31: error: 'y' was not declared in this scope; did you mean 'yn'?
13 | coordinate() { x = 0; y = 0; }
| ^
| yn
a.cc: In constructor 'coordinate::coordinate(int, int)':
a.cc:15:17: error: 'x' was not declared in this scope
15 | x = X; y = Y;
| ^
a.cc:15:24: error: 'y' was not declared in this scope
15 | x = X; y = Y;
| ^
a.cc: In member function 'coordinate coordinate::operator+(const int&) const':
a.cc:19:32: error: 'x' was not declared in this scope
19 | coordinate ret(x,y);
| ^
a.cc:19:34: error: 'y' was not declared in this scope; did you mean 'yn'?
19 | coordinate ret(x,y);
| ^
| yn
a.cc:28:37: error: 'struct coordinate' has no member named 'y'
28 | ret.y--; break;
| ^
a.cc:30:37: error: 'struct coordinate' has no member named 'y'
30 | ret.y--; ret.x++; break;
| ^
a.cc:30:46: error: 'struct coordinate' has no member named 'x'
30 | ret.y--; ret.x++; break;
| ^
a.cc:32:37: error: 'struct coordinate' has no member named 'x'
32 | ret.x++; break;
| ^
a.cc:34:37: error: 'struct coordinate' has no member named 'y'
34 | ret.y++; break;
| ^
a.cc:36:37: error: 'struct coordinate' has no member named 'x'
36 | ret.x--; ret.y++; break;
| ^
a.cc:36:46: error: 'struct coordinate' has no member named 'y'
36 | ret.x--; ret.y++; break;
| ^
a.cc:38:37: error: 'struct coordinate' has no member named 'x'
38 | ret.x--;
| ^
a.cc: In member function 'int coordinate::direction(coordinate)':
a.cc:46:28: error: 'struct coordinate' has no member named 'x'
46 | diff_x = a.x - x;
| ^
a.cc:46:32: error: 'x' was not declared in this scope
46 | diff_x = a.x - x;
| ^
a.cc:47:28: error: 'struct coordinate' has no member named 'y'
47 | diff_y = a.y - y;
| ^
a.cc:47:32: error: 'y' was not declared in this scope; did you mean 'yn'?
47 | diff_y = a.y - y;
| ^
| yn
a.cc: In member function 'bool coordinate::operator==(coordinate) const':
a.cc:71:25: error: 'x' was not declared in this scope
71 | return (x == a.x) && (y == a.y);
| ^
a.cc:71:32: error: 'const struct coordinate' has no member named 'x'
71 | return (x == a.x) && (y == a.y);
| ^
a.cc:71:39: error: 'y' was not declared in this scope; did you mean 'yn'?
71 | return (x == a.x) && (y == a.y);
| ^
| yn
a.cc:71:46: error: 'const struct coordinate' has no member named 'y'
71 | return (x == a.x) && (y == a.y);
| ^
a.cc: In member function 'bool coordinate::operator<(coordinate) const':
a.cc:75:20: error: 'x' was not declared in this scope
75 | if(x != a.x)
| ^
a.cc:75:27: error: 'const struct coordinate' has no member named 'x'
75 | if(x != a.x)
| ^
a.cc:76:38: error: 'const struct coordinate' has no member named 'x'
76 | return x < a.x;
| ^
a.cc:77:24: error: 'y' was not declared in this scope; did you mean 'yn'?
77 | return y < a.y;
| ^
| yn
a.cc:77:30: error: 'const struct coordinate' has no member named 'y'
77 | return y < a.y;
| ^
a.cc: In function 'bool adjoin(coordinate, coordinate)':
a.cc:83:15: error: 'struct coordinate' has no member named 'x'
83 | x = a.x - b.x;
| ^
a.cc:83:21: error: 'struct coordinate' has no member named 'x'
83 | x = a.x - b.x;
| ^
a.cc:84:15: error: 'struct coordinate' has no member named 'y'
84 | y = a.y - b.y;
| ^
a.cc:84:21: error: 'struct coordinate' has no member named 'y'
84 | y = a.y - b.y;
| ^
a.cc: In function 'int solve()':
a.cc:283:43: error: 'struct coordinate' has no member named 'x'
283 | if(abs(tmp.second.x - scientist.x) + abs(tmp.second.y - scientist.y) > 20 - count) {
| ^
a.cc:283:57: error: 'struct coordinate' has no member named 'x'
283 | if(abs(tmp.second.x - scientist.x) + abs(tmp.second.y - scientist.y) > 20 - count) {
| ^
a.cc:283:77: error: 'struct coordinate' has no member named 'y'
283 | if(abs(tmp.second.x - scientist.x) + abs(tmp.second.y - scientist.y) > 20 - count) {
| ^
a.cc:283:91: error: 'struct coordinate' has no member named 'y'
283 | if(abs(tmp.second.x - scientist.x) + abs(tmp.second.y - scientist.y) > 20 - count) {
| ^
|
s476976053 | p00724 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
struct Solver{
int n;
static const int dx[6] = { 0, 1, 1, 0, -1, -1};
static const int dy[6] = {-1, -1, 0, 1, 1, 0};
int get_r(int fx, int fy, int tx, int ty){
// return r such that fx + dx[r] == tx and fy + dy[r] == ty
int ddx = tx - fx;
int ddy = ty - fy;
for(int r = 0; r < 6; r++){
if(dx[r] == ddx && dy[r] == ddy) {
return r;
}
}
return -1;
}
typedef tuple<int, int, vector<int>> state;
set< vector<int> > validset;
map< vector<int>, vector<state> > nextstate;
void make_validset(){
for(int s = 0; s < (1 << (3 * (n - 1))); s++){
vector<int> x, y;
vector<int> rv(n - 1);
REP(i, n - 1) rv[i] = (s >> (3 * i) & 7);
// rは6以下
REP(i, n - 1) if(rv[i] >= 6) goto fail;
// 各頂点の座標を計算する
x.push_back(0); y.push_back(0);
REP(i, n - 1) x.push_back(x.back() + dx[ rv[i] ]);
REP(i, n - 1) y.push_back(y.back() + dy[ rv[i] ]);
// 本来隣り合っている以外の節が隣の窪みに来たらしぬ
REP(i, n) REP(j, n) if(abs(i - j) >= 2 && get_r(x[i], y[i], x[j], y[j]) != -1) goto fail;
// 同じくぼみには入らない
REP(i, n) REP(j, n) if(abs(i - j) >= 1 && x[i] == x[j] && y[i] == y[j]) goto fail;
// 大丈夫
validset.insert(rv);
fail:;
}
}
void make_nextstate(){
for(const vector<int>& rv : validset){
// print(rv);
vector<int> x, y;
x.push_back(0); y.push_back(0);
REP(i, n - 1) x.push_back(x.back() + dx[ rv[i] ]);
REP(i, n - 1) y.push_back(y.back() + dy[ rv[i] ]);
function<void(int)> rec = [&](int k){
if(k >= n){
vector<int> nrv;
REP(i, n - 1) nrv.push_back(get_r(x[i], y[i], x[i + 1], y[i + 1]));
if(validset.count(nrv)) {
nextstate[rv].push_back(make_tuple(x[0], y[0], nrv));
}
}else{
if(k - 1 < 0 || get_r(x[k - 1], y[k - 1], x[k], y[k]) >= 0){
rec(k + 1);
}
for(int r = 0; r < 6; r++){
x[k] += dx[r];
y[k] += dy[r];
if((k - 1 < 0 || get_r(x[k - 1], y[k - 1], x[k], y[k]) >= 0) &&
(k + 1 >= n || get_r(x[k], y[k], x[k + 1], y[k + 1]) >= 0) ){
rec(k + 2);
}
x[k] -= dx[r];
y[k] -= dy[r];
}
}
};
rec(0);
assert(x[0] == 0 && y[0] == 0);
}
}
Solver(int n_) : n(n_) {
make_validset();
make_nextstate();
}
int init_x[8], init_y[8];
int goal_x, goal_y;
set< pair<int, int> > rock;
void input(){
REP(i, n) cin >> init_x[i] >> init_y[i];
int k;
cin >> k;
while(k--){
int x, y;
cin >> x >> y;
rock.insert(make_pair(x, y));
}
cin >> goal_x >> goal_y;
}
void print(const vector<int>& v){
printf("{");
REP(i, v.size()){
printf("%d", v[i]);
if(i + 1 == v.size()) cout << "}" << endl;
else cout << ", ";
}
}
void print(state s){
printf("n = %d bx = %d by = %d rv = ", n, get<0>(s), get<1>(s));
print(get<2>(s));
vector<int> x, y;
x.push_back(get<0>(s));
y.push_back(get<1>(s));
REP(i, n - 1) x.push_back(x.back() + dx[ get<2>(s)[i] ]);
REP(i, n - 1) y.push_back(y.back() + dy[ get<2>(s)[i] ]);
printf("x = "); print(x);
printf("y = "); print(y);
}
int solve(){
vector<int> init_rv;
REP(i, n - 1) {
init_rv.push_back(get_r(init_x[i], init_y[i], init_x[i + 1], init_y[i + 1]));
}
assert(validset.count(init_rv));
assert(nextstate.count(init_rv));
state init(init_x[0], init_y[0], init_rv);
map<state, int> cost;
queue<state> que;
cost[init] = 0;
que.push(init);
while(!que.empty()){
state s = que.front(); que.pop();
int c = cost[s];
int bx = get<0>(s);
int by = get<1>(s);
vector<int> rv = get<2>(s);
assert(rv.size() == n - 1);
bool ng = false;
if(rock.count(make_pair(bx, by))) ng = true;
for(int i = 0, x = bx, y = by; i < n - 1; i++){
x += dx[ rv[i] ];
y += dy[ rv[i] ];
if(rock.count(make_pair(x, y))) ng = true;
}
if(ng) continue;
// print(s);
if(bx == goal_x && by == goal_y){
return c;
}
if(max(abs(bx - goal_x), abs(by - goal_y)) + c >= 21) continue;
for(state ns : nextstate[rv]){
state nexts(bx + get<0>(ns), by + get<1>(ns), get<2>(ns));
if(cost.count(nexts)) continue;
cost[nexts] = c + 1;
que.push(nexts);
}
}
return -1;
}
};
int main(){
int n;
while(cin >> n && n > 0){
Solver solver(n);
solver.input();
cout << solver.solve() << endl;
}
return 0;
} | a.cc:9:22: error: 'constexpr' needed for in-class initialization of static data member 'const int Solver::dx [6]' of non-integral type [-fpermissive]
9 | static const int dx[6] = { 0, 1, 1, 0, -1, -1};
| ^~
a.cc:10:22: error: 'constexpr' needed for in-class initialization of static data member 'const int Solver::dy [6]' of non-integral type [-fpermissive]
10 | static const int dy[6] = {-1, -1, 0, 1, 1, 0};
| ^~
|
s942380748 | p00725 | Java | import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int w, h;
int x, y;
while(true){
w = sc.nextInt();
h = sc.nextInt();
if(w == 0 && h == 0)
break;
Game game = new Game(w, h);
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
game.map[i][j] = sc.nextInt();
}
}
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
if(game.map[i][j] == 2){
game.move(i, j, 0);
}
}
}
System.out.println(game.answer <= 10 ? game.answer : -1);
}
}
}
public class Game{
int answer = 11;
int w, h;
int[][] map;
int[] dx = new int[]{1, 0, -1, 0};
int[] dy = new int[]{0, 1, 0, -1};
Game(int iw, int ih){
w = iw;
h = ih;
map = new int[h][w];
}
void move(int x, int y, int k){
for(int i = 0; i < 4; i++){
if(x+dx[i] < 0 || x+dx[i] >= h || y+dy[i] < 0 || y+dy[i] >= w)
continue;
if(map[x+dx[i]][y+dy[i]] != 1){
switch(i){
case 0:
moveDown(x, y, k);
break;
case 1:
moveRight(x, y, k);
break;
case 2:
moveUp(x, y, k);
break;
case 3:
moveLeft(x, y, k);
break;
}
}
}
}
void moveDown(int x, int y, int k){
while(true){
x = x + dx[0];
y = y + dy[0];
if(map[x][y] == 3){
if(++k < answer)
answer = k;
break;
}
if(x == h-1)
break;
if(map[x+dx[0]][y+dy[0]] == 1){
map[x+dx[0]][y+dy[0]] = 0;
move(x, y, ++k);
break;
}
}
}
void moveRight(int x, int y, int k){
while(true){
x = x + dx[1];
y = y + dy[1];
if(map[x][y] == 3){
k++;
if(k < answer)
answer = k;
break;
}
if(y == w-1)
break;
if(map[x+dx[1]][y+dy[1]] == 1){
map[x+dx[1]][y+dy[1]] = 0;
move(x, y, ++k);
break;
}
}
}
void moveUp(int x, int y, int k){
while(true){
x = x + dx[2];
y = y + dy[2];
if(map[x][y] == 3){
k++;
if(k < answer)
answer = k;
break;
}
if(x == 0)
break;
if(map[x+dx[2]][y+dy[2]] == 1){
map[x+dx[2]][y+dy[2]] = 0;
move(x, y, ++k);
break;
}
}
}
void moveLeft(int x, int y, int k){
while(true){
x = x + dx[3];
y = y + dy[3];
if(map[x][y] == 3){
k++;
if(k < answer)
answer = k;
break;
}
if(y == 0)
break;
if(map[x+dx[3]][y+dy[3]] == 1){
map[x+dx[3]][y+dy[3]] = 0;
move(x, y, ++k);
break;
}
}
}
} | Main.java:31: error: class Game is public, should be declared in a file named Game.java
public class Game{
^
1 error
|
s161153052 | p00725 | Java | import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int w, h;
int x = 0, y = 0;
while(true){
w = sc.nextInt();
h = sc.nextInt();
if(w == 0 && h == 0)
break;
Game game = new Game(w, h);
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
game.map[i][j] = sc.nextInt();
if(game.map[i][j] == 2){
x = i;
y = j;
}
}
}
game.search(x, y, 0);
System.out.println(game.answer <= 10 ? game.answer : -1);
}
}
}
public class Game{
int answer = 11;
int w, h;
int[][] map;
int[][] v = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
Game(int iw, int ih){
w = iw;
h = ih;
map = new int[h][w];
}
void search(int x, int y, int k){
for(int i = 0; i < v.length; i++){
int p = x, q = y;
p += v[i][0];
q += v[i][1];
if(p < 0 || p >= h || q < 0 || q >= w)
continue;
if(map[p][q] == 1)
continue;
p -= v[i][0];
q -= v[i][1];
while(true){
p += v[i][0];
q += v[i][1];
if(p < 0 || p >= h || q < 0 || q >= w)
break;
if(map[p][q] == 1){
map[p][q] = 0;
p -= v[i][0];
q -= v[i][1];
search(p, q, k+1);
map[p][q] = 1;
}
if(map[p][q] == 3){
if(k+1 < answer)
answer = k + 1;
break;
}
}
}
}
} | Main.java:27: error: class Game is public, should be declared in a file named Game.java
public class Game{
^
1 error
|
s612799001 | p00725 | Java | import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int w, h;
int x, y;
while(true){
x = 0;
y = 0;
w = sc.nextInt();
h = sc.nextInt();
if(w == 0 && h == 0)
break;
Game game = new Game(w, h);
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
game.map[i][j] = sc.nextInt();
if(game.map[i][j] == 2){
x = i;
y = j;
}
}
}
game.search(x, y, 0);
System.out.println(game.answer <= 10 ? game.answer : -1);
}
}
}
public class Game{
int answer = 11;
int w, h;
int[][] map;
int[][] v = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
Game(int iw, int ih){
w = iw;
h = ih;
map = new int[h][w];
}
void search(int x, int y, int k){
if(k >= answer)
return;
int p, q;
for(int i = 0; i < v.length; i++){
p = x + v[i][0];
q = y + v[i][1];
if(map[p][q] == 1)
continue;
while(p >= 0 && p < h && q >= 0 && q < w){
if(map[p][q] == 1){
map[p][q] = 0;
search(p-v[i][0], q-v[i][1], k+1);
map[p][q] = 1;
break;
}
if(map[p][q] == 3){
if(k+1 < answer)
answer = k + 1;
break;
}
p += v[i][0];
q += v[i][1];
}
}
return;
}
} | Main.java:30: error: class Game is public, should be declared in a file named Game.java
public class Game{
^
1 error
|
s985547649 | p00725 | Java | public class Game{
int answer = 11;
int w, h;
int[][] map;
int[][] v = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
Game(int iw, int ih){
w = iw;
h = ih;
map = new int[h][w];
}
void search(int x, int y, int k){
if(k >= answer)
return;
int p, q;
for(int i = 0; i < v.length; i++){
p = x + v[i][0];
q = y + v[i][1];
if(p < 0 || p >= h || q < 0 || q >= w || map[p][q] == 1)
continue;
while(p >= 0 && p < h && q >= 0 && q < w){
if(map[p][q] == 1){
map[p][q] = 0;
search(p-v[i][0], q-v[i][1], k+1);
map[p][q] = 1;
break;
}
if(map[p][q] == 3){
if(k+1 < answer)
answer = k + 1;
break;
}
p += v[i][0];
q += v[i][1];
}
}
return;
}
}
class Game{
int answer = 11;
int w, h;
int[][] map;
int[][] v = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
Game(int iw, int ih){
w = iw;
h = ih;
map = new int[h][w];
}
boolean isInRange(int x, int y){
return (x >= 0 && x < h && y >= 0 && y < w);
}
void search(int x, int y, int k){
if(k >= answer)
return;
int p, q;
for(int i = 0; i < v.length; i++){
p = x + v[i][0];
q = y + v[i][1];
if(!isInRange(p, q) || map[p][q] == 1)
continue;
while(isInRange(p, q)){
if(map[p][q] == 1){
map[p][q] = 0;
search(p-v[i][0], q-v[i][1], k+1);
map[p][q] = 1;
break;
}
if(map[p][q] == 3){
if(k+1 < answer)
answer = k + 1;
break;
}
p += v[i][0];
q += v[i][1];
}
}
return;
}
} | Main.java:1: error: class Game is public, should be declared in a file named Game.java
public class Game{
^
Main.java:39: error: duplicate class: Game
class Game{
^
2 errors
|
s147258765 | p00725 | Java | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main2 {
static int w, h;
static int[][] field;
static Queue<int[][]> q;
static Queue<Integer> x;
static Queue<Integer> y;
static Queue<Integer> floor;
static int[] v1 = {1, 0, -1, 0};
static int[] v2 = {0, 1, 0, -1};
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
label:while(true){
w = cin.nextInt();
h = cin.nextInt();
q = new LinkedList<int[][]>();
x = new LinkedList<Integer>();
y = new LinkedList<Integer>();
floor = new LinkedList<Integer>();
if(w+h==0){
break;
}
field = new int[h+2][w+2];
for(int i= 0; i < h+2;i++){
field[i][0] = -1;
field[i][w+1] = -1;
}
for(int i= 0; i < w+2;i++){
field[0][i] = -1;
field[h+1][i] = -1;
}
for(int i= 1; i <= h;i++){
for(int j = 1; j <= w; j++){
String str = cin.next();
field[i][j] = Integer.parseInt(str);
if(field[i][j] == 2){
x.add(i);
y.add(j);
}
else if(field[i][j] == 3){
}
}
}
/*
for(int i= 0; i <= h+1;i++){
for(int j = 0; j <= w+1; j++){
System.out.print(field[i][j] + " " );
}
System.out.println();
}
*/
q.add(field);
floor.add(0);
while(!q.isEmpty()){
field = q.poll();
int X = x.poll();
int Y = y.poll();
int FLOOR = floor.poll();
for(int i = 0; i < 4; i++){
int nowX = X;
int nowY = Y;
boolean first = true;
while(true){
nowX += v1[i];
nowY += v2[i];
//System.out.println(i +" " +nowX + " " +nowY + " " + field[nowX][nowY]);
if(field[nowX][nowY] == 3){
if(FLOOR+1 >= 11){
System.out.println(-1);
}
else{
System.out.println(FLOOR+1);
}
continue label;
}
else if(field[nowX][nowY] == -1){
break;
}
if(first){
if(field[nowX][nowY] == 1){
break;
}
first = false;
}
else{
if(field[nowX][nowY] == 1){
int[][] a = new int[h+2][];//field.clone();
for(int j = 0; j < h+2; j++){
a[j]= field[j].clone();
}
a[nowX][nowY] = 0;
a[nowX-v1[i]][nowY-v2[i]] = 2;
q.add(a);
x.add(nowX-v1[i]);
y.add(nowY-v2[i]);
floor.add(FLOOR+1);
break;
}
}
}
}
}
System.out.println(-1);
}
}
} | Main.java:5: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2 {
^
1 error
|
s777399288 | p00725 | Java | import java.util.*;
public class Curling {
static int startX, startY, goalX, goalY;
static int[] moveX = {0,0,-1,1};
static int[] moveY = {-1,1,0,0};
static int w, h;
static int maxMove = 10;
static int ans;
public static void finish (int move) {
if (ans == -1) {
ans = move;
} else {
ans = Math.min(move, ans);
}
}
public static boolean ok (int y, int x) {
return 0 <= y && y < h && 0 <= x && x < w;
}
public static void show (int[][] field) {
for (int i = 0; i < field.length; i++) {
for (int j = 0; j < field[i].length; j++) {
System.out.printf("%2d ", field[i][j]);
}
System.out.println();
}
System.out.println();
}
public static void dfs (int y, int x, int move, int[][] field) {
// System.out.println(y + "," + x + " : " + move);
// show(field);
if (move == maxMove) return;
for (int i = 0; i < moveX.length; i++) {
if (ok(y + moveY[i],x + moveX[i]) &&
field[y + moveY[i]][x + moveX[i]] != 1) {
int nextY = y, nextX = x;
while (ok(nextY + moveY[i],nextX + moveX[i])) {
if (field[nextY + moveY[i]][nextX + moveX[i]] == 1) break;
nextY += moveY[i];
nextX += moveX[i];
if (nextY == goalY && nextX == goalX) {
finish(move + 1);
return;
}
}
boolean flag = false;
if (ok(nextY + moveY[i],nextX + moveX[i])) {
field[nextY + moveY[i]][nextX + moveX[i]]--;
flag = true;
}
dfs(nextY,nextX,move + 1,field);
if (flag) {
field[nextY + moveY[i]][nextX + moveX[i]]++;
}
}
}
}
public static void main(String[] args) {
int[][] field;
Scanner sc = new Scanner(System.in);
while (true) {
w = sc.nextInt();
h = sc.nextInt();
if (w == 0 && h == 0) break;
ans = -1;
field = new int[h][w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
field[i][j] = sc.nextInt();
if (field[i][j] == 2) {
startX = j;
startY = i;
} else if (field[i][j] == 3) {
goalX = j;
goalY = i;
}
}
}
dfs(startY, startX, 0, field);
System.out.println("ans : " + ans);
}
}
} | Main.java:3: error: class Curling is public, should be declared in a file named Curling.java
public class Curling {
^
1 error
|
s978602716 | p00725 | Java | import java.util.*;
public class Main {
int w, h, sx, sy, ans;
int[][] map;
LinkedList<Integer> x, y;
void loop(int p, int q, int r){
if(r>=ans || r>=10) return;
for(int i=p-1;i>=0;i--){
if(map[q][i]==3){
ans = r+1;
}else if(map[q][i]==1){
if(i==p-1){
break;
}else{
map[q][i] = 0;
x.push(i);
y.push(q);
loop(i+1, q, r+1);
map[y.pop()][x.pop()] = 1;
break;
}
}
}
for(int i=p+1;i<w;i++){
if(map[q][i]==3){
ans = r+1;
}else if(map[q][i]==1){
if(i==p+1){
break;
}else{
map[q][i] = 0;
x.push(i);
y.push(q);
loop(i-1, q, r+1);
map[y.pop()][x.pop()] = 1;
break;
}
}
}
for(int i=q-1;i>=0;i--){
if(map[i][p]==3){
ans = r+1;
}else if(map[i][p]==1){
if(i==q-1){
break;
}else{
map[i][p] = 0;
x.push(p);
y.push(i);
loop(p, i+1, r+1);
map[y.pop()][x.pop()] = 1;
break;
}
}
}
for(int i=q+1;i<h;i++){
if(map[i][p]==3){
ans = r+1;
}else if(map[i][p]==1){
if(i==q+1){
break;
}else{
map[i][p] = 0;
x.push(p);
y.push(i);
loop(p, i-1, r+1);
map[y.pop()][x.pop()] = 1;
break;
}
}
}
}
void solve(){
Scanner sc = new Scanner(System.in);
while(true){
w = sc.nextInt();
h = sc.nextInt();
if(w==0 && h==0) break;
map = new int[h][w];
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
map[i][j] = sc.nextInt();
if(map[i][j]==2){
sx = j;
sy = i;
}
}
}
x = new LinkedList<Integer>();
y = new LinkedList<Integer>();
ans = Integer.MAX_VALUE;
loop(sx, sy, 0);
if(ans==Integer.MAX_VALUE) ans = -1;
System.out.println(ans);
}
}
public static void main(String[] args) {
new Main.solve();
}
} | Main.java:109: error: cannot find symbol
new Main.solve();
^
symbol: class solve
location: class Main
1 error
|
s436012612 | p00725 | Java | import java.util.Arrays;
import java.util.Scanner;
public class Curling2 {
Scanner in = new Scanner(System.in);
int W, H;
int[][] map;
int vx[] = {0, -1, 1, 0};
int vy[] = {-1, 0, 0, 1};
int ans = -1;
void search(int x, int y, int dir, int cnt) {
for (int i = 0; i < vx.length; i++) {
int nextDir = (i + 2) % 4;
int nx = x, ny = y;
if (dir == nextDir) break;
while (true) {
nx += vx[i]; ny += vy[i];
if (map[ny][nx] == 0) continue;
else if (map[ny][nx] == 1) search(nx - vx[i], ny - vy[i], i, cnt + 1);
else if (map[ny][nx] == 3) ans = Math.max(ans, cnt);
break;
}
}
}
public void run() {
while (true) {
int startX = -1, startY = -1;
W = in.nextInt(); H = in.nextInt();
if ((W|H) == 0) break;
map = new int[H+2][W+2];
for (int i = 0; i < map.length; i++) {
Arrays.fill(map[i], -1);
}
for (int i = 1; i < map.length - 1; i++) {
for (int j = 1; j < map[i].length - 1; j++) {
map[i][j] = in.nextInt();
if (map[i][j] == 2) {
startX = j; startY = i;
}
}
}
ans = -1;
search(startX, startY, -1, 0);
System.out.println(ans);
}
}
public static void main(String args[]) {
new Curling2().run();
}
} | Main.java:4: error: class Curling2 is public, should be declared in a file named Curling2.java
public class Curling2 {
^
1 error
|
s884482632 | p00725 | C | #include<stdio.h>
int map[20][20];
int W, H;
int mx(int a, int b) {
if (a == -1 && b == -1) return -1;
if (a == -1) return b;
if (b == -1) return a;
if (a < b) {
if (a == 10) return -1;
return a;
if (b == 10) return -1;
return b;
}
int solve(int x, int y) {
int righ, lef, up, dow;
int i, n;
if (x == H - 1) dow = -1;
else if (map[x + 1][y] == 1) dow = -1;
else if (map[x + 1][y] == 3) return 1;
else {
for (i = 1; 1; i ++) {
if (x + i >= H) {
dow = -1; break;
}
if (map[x + i][y] == 1) {
map[x + i][y] = 0;
dow = solve(x + i - 1, y);
map[x + i][y] = 1;
break;
} else if (map[x + i][y] == 3) return 1;
}
}
if (x == 0) up = -1;
else if (map[x - 1][y] == 1) up = -1;
else if (map[x - 1][y] == 3) return 1;
else {
for (i = 1; 1; i ++) {
if (x - i <= -1) {
up = -1; break;
}
if (map[x - i][y] == 1) {
map[x - i][y] = '0';
up = solve(x - i + 1, y);
map[x - i][y] = 1;
break;
} else if (map[x - i][y] == 3) return 1;
}
}
if (y == W - 1) righ = -1;
else if (map[x][y + 1] == 1) righ = -1;
else if (map[x][y + 1] == 3) return 1;
else {
for (i = 1; 1; i ++) {
if (y + i >= W) {
righ = -1; break;
}
if (map[x][y + i] == 1) {
map[x][y + i] = 0;
righ = solve(x, y + i - 1);
map[x][y + i] = 1;
break;
} else if (map[x][y + i] == 3) return 1;
}
}
if (y == 0) lef = -1;
else if (map[x][y - 1] == 1) lef = -1;
else if (map[x][y - 1] == 3) return 1;
else {
for (i = 1; 1; i ++) {
if (y - i <= -1) {
lef = -1; break;
}
if (map[x][y - i] == 1) {
map[x][y - i] = 0;
righ = solve(x, y - i + 1);
map[x][y - i] = 1;
break;
} else if (map[x][y - i] == 3) return 1;
}
}
n = mx(dow, mx(up, mx(righ, lef)));
if (n == -1) return -1;
return n + 1;
}
int main() {
int i, j, x, y, n;
while (1) {
scanf("%d %d", &W, &H);
if (!(W||H)) break;
for (i = 0; i < H; i ++) {
for (j = 0; j < W; j ++) {
scanf("%d", &map[i][j]);
if (map[i][j] == 2) {
x = i; y = j;
}
}
}
n = solve(x, y);
printf("%d\n", n);
}
return 0;
} | main.c: In function 'mx':
main.c:102:1: error: expected declaration or statement at end of input
102 | }
| ^
|
s942440294 | p00725 | C | #include<algorithm>
#include<cstring>
#include<cstdio>
#include<string>
#include<queue>
#include<stack>
#include<iostream>
#include<cmath>
using namespace std;
#define inf 0x3f3f3f3f
const int maxn = 20 + 8;
int n,m,sx,sy,x,y;
int g[maxn][maxn];
int ans;
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
bool is_in(int x,int y)
{
return x >= 0 && x < n && y >= 0 && y < m;
}
void dfs(int r,int c,int num)
{
if(num == 10 || num >= ans) return;
for(int i = 0; i < 4; ++i){
int x = r + dx[i];
int y = c + dy[i];
if(!is_in(x,y) || g[x][y] == 1) continue;
while(is_in(x,y) && g[x][y] == 0)
{
x += dx[i];
y += dy[i];
}
if(!is_in(x,y)) continue;
// cout << " a2: " << x-dx[i] <<" "<< y-dy[i] <<"\n";
if(g[x][y] == 3)
{
ans = min(ans, num);
return;
}
g[x][y] = 0;
dfs(x - dx[i], y - dy[i],num + 1);
g[x][y] = 1;
}
}
int main()
{
//freopen("in.txt","r",stdin);
while(scanf("%d%d", &m, &n) && n + m )
{
sx = 0,sy = 0;
memset(g,0,sizeof g);
for(int i = 0; i < n; ++i)
{
for(int j = 0; j < m; ++j)
{
scanf("%d",&g[i][j]);
if(g[i][j] == 2)
{
sx = i; sy = j;
}
}
}
g[sx][sy] = 0;
ans = inf;
dfs(sx,sy,0);
printf("%d\n", ans == inf ? -1 : ans + 1);
}
return 0;
}
/*
6 6
1 0 0 2 1 0
1 1 0 0 0 0
0 0 0 0 0 3
0 0 0 0 0 0
1 0 0 0 0 1
0 1 1 1 1 1
0 0
*/
/*
0 1 2 3 4 5
0 1 0 0 2 1 0
1 1 1 0 0 0 0
2 0 0 0 0 0 3
3 0 0 0 0 0 0
4 1 0 0 0 0 1
5 0 1 1 1 1 1
*/ | main.c:1:9: fatal error: algorithm: No such file or directory
1 | #include<algorithm>
| ^~~~~~~~~~~
compilation terminated.
|
s858237086 | p00725 | C | #include<cstdio>
#include<iostream>
#include<algorithm>
#define INF 0x3f3f3f3f
using namespace std;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int map[111][111];
int ans;
int w,h;
int judge(int x,int y)
{
if(x>=0&&x<h&&y>=0&&y<w)
return 1;
return 0;
}
void dfs(int x,int y,int step)
{
if(step>10)
return;
for(int i=0;i<4;i++)
{
int nowx=x+dx[i];
int nowy=y+dy[i];
if(map[nowx][nowy]!=1&&judge(nowx,nowy))
{
nowx=x;
nowy=y;
while(1)
{
nowx+=dx[i];
nowy+=dy[i];
if(!judge(nowx,nowy))
break;
if(map[nowx][nowy]==3)
{
ans=min(ans,step);
return;
}
if(map[nowx][nowy]==1)
{
map[nowx][nowy]=0;
dfs(nowx-dx[i],nowy-dy[i],step+1);
map[nowx][nowy]=1;//回溯
break;//??跳出
}
}
}
}
}
int main()
{
int sx,sy;
while(~scanf("%d",&w,&h)&&w&&h)
{
for(int i=0;i<h;i++)
for(int j=0;j<w;j++)
{
scanf("%d",&map[i][j]);
if(map[i][j]==2)
{
sx=i;
sy=j;
}
}
ans=INF;
dfs(sx,sy,1);
if(ans==INF)
printf("-1\n");
else
printf("%d\n",ans);
}
return 0;
} | main.c:1:9: fatal error: cstdio: No such file or directory
1 | #include<cstdio>
| ^~~~~~~~
compilation terminated.
|
s425611503 | p00725 | C | #include <iostream>
#include <algorithm>
using namespace std;
int w,h;
int area[21][21];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int ans;
void rec( int x, int y, int n ){
// cout << "rec : " << x << " " << y << " " << n << endl;
int nn=n+1;
bool f;
if( n>10 ) return;
for( int i,j, k=0;k<4;k++ ){
// cout << "k="<<k<<endl;
i=x; j=y; f=true;
while( f ){
i+=dx[k]; j+=dy[k];
if(j<0) break; if(i<0) break;
if(i>=h) break; if(j>=w) break;
// cout << " i="<<i<< " j="<<j<< " "<<area[i][j] << endl;
switch( area[i][j] ){
case 3: ans=min(ans,nn);return;
case 1:{
if( i-dx[k]!=x || j-dy[k]!=y ){
area[i][j]=0;
rec(i-dx[k],j-dy[k],nn);
area[i][j]=1;
}
f=false;
break;
}
}
}
}
// cout << "ret="<<ret<<endl;
}
void pr(){
for( int i=0;i<h;i++ ){
for( int j=0;j<w;j++ )
cout << area[i][j] << " " ;
cout << endl;
}
}
int main(){
int sx,sy;
while( cin>>w>>h && (w|h) ){
// cout << " h="<<h << " w="<<w << endl;
for( int i=0;i<h;i++ )
for( int j=0;j<w;j++ ){
cin >> area[i][j];
if( area[i][j]==2 ){ sx=i;sy=j;area[i][j]=0; }
}
/*
cout << "area"<<endl;
pr();
cout<< "answer"<<endl;
*/
ans=100;
rec( sx,sy,0 );
// cout << "ans="<<ans<<endl;
if( ans>10 ) ans=-1;
cout << ans << endl;
}
return 0;
} | main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s844472184 | p00725 | C++ | #include <iostream>
#include <vector>
using namespace std;
int w, h, ans;
void curling(int x, int y, vector< vector<int> > m, int sum)
{
if (x < 0 || y < 0 || x >= m[y].size() || y >= m.size() || sum > 10) {
return;
}
if (m[y][x] == 3) {
if (sum < ans) {
ans = sum;
}
return;
}
int minx = -10, miny = -10, maxx = -10, maxy = -10;
for (int i = y + 1; i < m.size(); ++i) {
if (m[i][x] == 1) {
if (i == y + 1) {
break;
}
maxy = i;
break;
}
if (m[i][x] == 3) {
maxy = i + 1;
break;
}
}
for (int i = y - 1; i >= 0; --i) {
if (m[i][x] == 1) {
if (i == y - 1) {
break;
}
miny = i;
break;
}
if (m[i][x] == 3) {
miny = i - 1;
break;
}
}
for (int i = x + 1; i < m[y].size(); ++i) {
if (m[y][i] == 1) {
if (i == x + 1) {
break;
}
maxx = i;
break;
}
if (m[y][i] == 3) {
maxx = i + 1;
break;
}
}
for (int i = x - 1; i >= 0; --i) {
if (m[y][i] == 1) {
if (i == x - 1) {
break;
}
minx = i;
break;
}
if (m[y][i] == 3) {
minx = i - 1;
}
}
if (minx != -10) {
m[y][minx] = 0;
curling(minx + 1, y, m, sum + 1);
}
if (maxx != -10) {
m[y][maxx] = 0;
curling(maxx - 1, y, m, sum + 1);
}
if (miny != -10) {
m[miny][x] = 0;
curling(x, miny + 1, m, sum + 1);
}
if (maxy != -10) {
m[maxy][x] = 0;
curling(x, maxy - 1, m, sum + 1);
}
}
int main(void)
{
while (cin >> w >> h && w != 0) {
vector< vector<int> > m(h, vector<int>(w));
ans = 1000000;
int sx, sy;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
cin >> m[i][j];
if (m[i][j] == 2) {
sx = j;
sy = i;
}
}
}
curling(sx, sy, m, 0);
if (ans == 1000000) {
ans = -1;
}
cout << ans << endl;
}
return 0;
| a.cc: In function 'int main()':
a.cc:115:18: error: expected '}' at end of input
115 | return 0;
| ^
a.cc:94:1: note: to match this '{'
94 | {
| ^
|
s055981110 | p00725 | C++ | 3 0 0 1
1 0 0 1
1 1 1 1
3 3
2 0 0
0 0 3
1 0 0
3 3
0 0 2
3 0 0
0 0 1
3 3
0 3 0
0 0 0
2 0 1
3 3
0 3 0
0 0 0
1 0 2
3 3
1 0 0
0 0 3
2 0 0
5 5
1 1 2 0 0
0 0 0 0 3
0 0 0 0 0
1 0 0 0 1
1 1 1 1 1
| a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 3 0 0 1
| ^
|
s756391102 | p00725 | C++ | #include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#pragma warning(disable:4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;
using namespace std;
int dx[4] = { 0, -1, 0, 1 };
int dy[4] = { 1, 0, -1, 0 };
const Int M_H(20);
const Int M_W(20);
int tile[M_H][M_W];
int H, W;
struct point{
Int x, y, step;
int tile[M_H][M_W];
point(Int x_, Int y_, Int s,int tile_[M_H][M_W]) :x(x_), y(y_), step(s)
{
memcpy(tile, tile_, sizeof(tile));
}
};
queue<point> que;
int solve()
{
while (!que.empty()){
auto now = que.front();
que.pop();
int i(4);
while (i--){
int x = now.x + dx[i];
int y = now.y + dy[i];
if (now.tile[y][x] == 1)
continue;
if (now.tile[y][x] == 4)
continue;
while(now.tile[y][x] == 0){
x += dx[i];
y += dy[i];
if (x >= M_W || x < 0 || y >= M_H || y < 0)
break;
}
if (x >= M_W || x < 0 || y >= M_H || y < 0 || now.step >= 10)
continue;
if (now.tile[y][x] == 1){
int temp[M_H][M_W];
memcpy(temp, now.tile, sizeof(temp));
temp[y][x] = 0;
que.emplace(x - dx[i], y - dy[i], now.step + 1, temp);
}
if (now.tile[y][x] == 3)
return now.step + 1;
if (now.tile[y][x] == 4)
continue;
}
}
return -1;
}
int main()
{
cin.tie(0); ios::sync_with_stdio(false);
//fstream fs("input.txt");
////////////ここから開始///////////
//fs >> W >> H;
while (cin >> W >> H,H){
REP(i, M_H)REP(j, M_W){ tile[i][j] = 4;}
REP(i, H)REP(j, W)cin >> tile[i][j];
que = {};
REP(i, H)REP(j, W){
if (tile[i][j] == 2){
tile[i][j] = 0;
que.emplace(j, i, 0, tile);
}
}
cout << solve() << endl;
}
return 0;
} | a.cc: In constructor 'point::point(Int, Int, Int, int (*)[20])':
a.cc:34:17: error: 'memcpy' was not declared in this scope
34 | memcpy(tile, tile_, sizeof(tile));
| ^~~~~~
a.cc:12:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
11 | #include <numeric>
+++ |+#include <cstring>
12 |
a.cc: In function 'int solve()':
a.cc:64:33: error: 'memcpy' was not declared in this scope
64 | memcpy(temp, now.tile, sizeof(temp));
| ^~~~~~
a.cc:64:33: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s718373689 | p00725 | C++ | #include<iostream>
using namespace std;
int grid[40][40];
int dy[4] = {1, 0, -1, 0};
int dx[4] = {0,-1, 0, 1};
int w, h;
int dfs(int x, int y, int depth){
if(depth >= 10)return 1e9;
int res = 1e9;
bool flag = false;
for (int i = 0; i < 4; i++) {
int nx = x, ny = y;
if(grid[ny + dy[i]][nx + dx[i]] == 1)continue;
while(0 <= nx + dx[i] && nx + dx[i] < w &&
0 <= ny + dy[i] && ny + dy[i] < h &&
grid[ny + dy[i]][nx + dx[i]] == 0)
nx += dx[i], ny += dy[i];
if(nx + dx[i] < 0 || w <= nx + dx[i] ||
ny + dy[i] < 0 || h <= ny + dy[i]){
continue;
}else if(grid[ny + dy[i]][nx + dx[i]] == 3){
return depth + 1;
}else{
flag = true;
grid[ny + dy[i]][nx + dx[i]] = 0;
}
res = min(res, dfs(nx, ny, depth + 1));
if(flag)grid[ny + dy[i]][nx + dx[i]] = 1;
}
return res;
}
int main(int argc, char *argv[]){
while(cin >> w >> h, w){
memset(grid, 0, sizeof(grid));
int sx, sy, tx, ty;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> grid[i][j];
if(grid[i][j] == 2){
sx = j;sy = i;
grid[i][j] = 0;
}else if(grid[i][j] == 3){
tx = j;ty = i;
}
}
}
int ans = dfs(sx, sy, 0);
if(ans == 1e9){
std::cout << -1 << std::endl;
}else{
std::cout << ans << std::endl;
}
}
return 0;
} | a.cc: In function 'int main(int, char**)':
a.cc:38:5: error: 'memset' was not declared in this scope
38 | memset(grid, 0, sizeof(grid));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include<iostream>
+++ |+#include <cstring>
2 | using namespace std;
|
s891853034 | p00725 | C++ | #include <iostream>
#define MAX_W 20
#define MAX_H 20
int w, h;
int sx, sy;
int ans;
char field[MAX_W][MAX_H];
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
bool dfs(int x, int y, int count);
int main(){
while(true){
std::cin >> w >>h;
for(int i = 0; i < h; ++i){
for(int j = 0; j < w; ++j){
std::cin >> field[j][i];
if(field[j][i] == '2')
sx = j, sy = i;
}
}
if(dfs(sx, sy, 0))
std::cout << ans << std::endl;
else
std::cout << "-1" << std::endl;
}
return 0;
}
bool dfs(int x, int y, int count){
if(count > 10)
return false;
for(int i = 0; i < 4; ++i){
int nx = x, ny = y;
while(true){
if(nx + dx[i] >= 0 && nx + dx[i] < MAX_W && ny + dy[i] >= 0 && ny + dy[i] < MAX_H){
if(dfs(nx, ny, count + 1))
return true;
if(field[nx + dx[i]][ny + dy[i]] == '1'){
field[nx + dx[i]][ny + dy[i]] == '0';
if(dfs(nx, ny, count + 1))
return true;
else
field[nx + dx[i]][ny + dy[i]] == '1';
}
if(field[nx + dx[i]][ny + dy[i]] == '3'){
ans = count + 1;
return true;
}
}
return false;
}
} | a.cc: In function 'bool dfs(int, int, int)':
a.cc:59:2: error: expected '}' at end of input
59 | }
| ^
a.cc:34:34: note: to match this '{'
34 | bool dfs(int x, int y, int count){
| ^
a.cc:59:2: warning: control reaches end of non-void function [-Wreturn-type]
59 | }
| ^
|
s738614587 | p00725 | C++ | #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define MAX 20
#define FLOOR 0
#define BLOCK 1
#define START 2
#define GOAL 3
#define OUT 4
#define UP 0
#define DOWN 1
#define RIGHT 2
#define LEFT 3
#define VARIATION 4
#define INFTY 100//>MAX
using namespace std;
int H,W;
//grid[0][i],grid[MAX+1][i],grid[i][0],grid[i][MAX+1]は番兵
int grid[MAX+3][MAX+3];
int dfs(int row,int column,int direction,int phase){
if(grid[row][column] == FLOOR){
if(direction == UP)return dfs(row,column+1,UP,phase);
if(direction == DOWN)return dfs(row,column-1,DOWN,phase);
if(direction == RIGHT)return dfs(row+1,column,RIGHT,phase);
if(direction == LEFT)return dfs(row-1,column,LEFT,phase);
}
else if(grid[row][column] == BLOCK){
phase++;
if(phase > 10)return INFTY;
grid[row][column] = FLOOR;
if(direction == UP)column--;
else if(direction == DOWN)column++;
else if(direction == RIGHT)row--;
else if(direction == LEFT)row++;
else exit(1);
if(grid[row][column] == GOAL)return phase;
if(grid[row][column+1]!=BLOCK)cnt = min(cnt,dfs(i,j,UP,0));
if(grid[row][column-1]!=BLOCK)cnt = min(cnt,dfs(i,j,DOWN,0));
if(grid[row+1][column]!=BLOCK)cnt = min(cnt,dfs(i,j,RIGHT,0));
if(grid[row-1][column]!=BLOCK)cnt = min(cnt,dfs(i,j,LEFT,0));
}
else if(grid[row][column] == GOAL)return phase+1;
else if(grid[row][column] == OUT)return INFTY;
}
//スタート地点を見つける
void solve(){
int cnt = INFTY;
for(int i = 1;i <= H;i++){
for(int j = 1;j <= W;j++){
if(grid[i][j] == START){
grid[i][j] = FLOOR;
if(grid[i][j+1]!=BLOCK)cnt = min(cnt,dfs(i,j,UP,0));
if(grid[i][j-1]!=BLOCK)cnt = min(cnt,dfs(i,j,DOWN,0));
if(grid[i+1][j]!=BLOCK)cnt = min(cnt,dfs(i,j,RIGHT,0));
if(grid[i-1][j]!=BLOCK)cnt = min(cnt,dfs(i,j,LEFT,0));
}
}
}
if(cnt == INFTY)cout <<-1 <<endl;
else cout <<cnt <<endl;
}
int main() {
char mark;
scanf("%d %d",&W,&H);//幅,高さの順に入力される
while(!(H == 0 && W == 0)){
for(int i = 0; i <= H+1;i++){
for(int j = 0;j <= W+1;j++) grid[i][j] = OUT;
}
for(int h = 1;h <= H;h++){
for(int w = 1;w <= W;w++) cin >>grid[h][w];//1文字ずつ読み込み
}
solve();
scanf("%d %d",&H,&W);
}
return 0;
} | a.cc: In function 'int dfs(int, int, int, int)':
a.cc:47:47: error: 'cnt' was not declared in this scope; did you mean 'int'?
47 | if(grid[row][column+1]!=BLOCK)cnt = min(cnt,dfs(i,j,UP,0));
| ^~~
| int
a.cc:47:65: error: 'i' was not declared in this scope
47 | if(grid[row][column+1]!=BLOCK)cnt = min(cnt,dfs(i,j,UP,0));
| ^
a.cc:47:67: error: 'j' was not declared in this scope; did you mean 'jn'?
47 | if(grid[row][column+1]!=BLOCK)cnt = min(cnt,dfs(i,j,UP,0));
| ^
| jn
a.cc:48:47: error: 'cnt' was not declared in this scope; did you mean 'int'?
48 | if(grid[row][column-1]!=BLOCK)cnt = min(cnt,dfs(i,j,DOWN,0));
| ^~~
| int
a.cc:48:65: error: 'i' was not declared in this scope
48 | if(grid[row][column-1]!=BLOCK)cnt = min(cnt,dfs(i,j,DOWN,0));
| ^
a.cc:48:67: error: 'j' was not declared in this scope; did you mean 'jn'?
48 | if(grid[row][column-1]!=BLOCK)cnt = min(cnt,dfs(i,j,DOWN,0));
| ^
| jn
a.cc:49:47: error: 'cnt' was not declared in this scope; did you mean 'int'?
49 | if(grid[row+1][column]!=BLOCK)cnt = min(cnt,dfs(i,j,RIGHT,0));
| ^~~
| int
a.cc:49:65: error: 'i' was not declared in this scope
49 | if(grid[row+1][column]!=BLOCK)cnt = min(cnt,dfs(i,j,RIGHT,0));
| ^
a.cc:49:67: error: 'j' was not declared in this scope; did you mean 'jn'?
49 | if(grid[row+1][column]!=BLOCK)cnt = min(cnt,dfs(i,j,RIGHT,0));
| ^
| jn
a.cc:50:47: error: 'cnt' was not declared in this scope; did you mean 'int'?
50 | if(grid[row-1][column]!=BLOCK)cnt = min(cnt,dfs(i,j,LEFT,0));
| ^~~
| int
a.cc:50:65: error: 'i' was not declared in this scope
50 | if(grid[row-1][column]!=BLOCK)cnt = min(cnt,dfs(i,j,LEFT,0));
| ^
a.cc:50:67: error: 'j' was not declared in this scope; did you mean 'jn'?
50 | if(grid[row-1][column]!=BLOCK)cnt = min(cnt,dfs(i,j,LEFT,0));
| ^
| jn
a.cc:55:1: warning: control reaches end of non-void function [-Wreturn-type]
55 | }
| ^
|
s982939640 | p00725 | C++ | #include <iostream>
using namespace std;
int w, h;
int f[21][21];
int ans;
int dx[] = { 0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
void rec(int n, int x, int y) {
if (n >= ans) { return; }
for (int i=0; i<4; i++) {
int mx=x, my=y;
mx += dx[i]; my += dy[i];
if (mx < 0 || mx >= w) { continue; }
if (my < 0 || my >= h) { continue; }
if (f[my][mx] == 1) { continue; }
while (1) {
if (f[my][mx] == 3) {
ans = n;
return;
}
mx += dx[i]; my += dy[i];
if (mx < 0 || mx >= w) { break; }
if (my < 0 || my >= h) { break; }
if (f[my][mx] == 1) {
f[my][mx] = 0;
rec(n+1, mx-dx[i], my-dy[i]);
f[my][mx] = 1;
break;
}
}
}
}
int main() {
while (cin >> w >> h, (w || h)) {
int sx, sy;
for (int y=0; y<h; y++) {
for (int x=0; x<w; x++) {
cin >> f[y][x];
if (f[y][x] == 2) {
sx = x; sy = y;
}
}
}
ans = 11;
rec(1, sx, sy);
if (ans > 10) { ans = -1; }
cout << ans << endl;
}
return 0; | a.cc: In function 'int main()':
a.cc:60:12: error: expected '}' at end of input
60 | return 0;
| ^
a.cc:42:12: note: to match this '{'
42 | int main() {
| ^
|
s874978763 | p00725 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int map[30][30];
int sx, sy, gx, gy, h, w;
int dfs(int x, int y, int n) {
if (n > 11)return 11;
int ret = 11, p;
p = x - 1;
if (p > 0 && map[p][y] != 1) {
while (p > 0) {
if (map[p - 1][y] == 1) {
map[p - 1][y] = 0;
ret = min(ret, dfs(p, y, n + 1));
break;
}
else if (p == gx&&y == gy)return n + 1;
p--;
}
}
p = x + 1;
if (p <= w&& map[p][y] != 1) {
while (p <= w) {
if (map[p + 1][y] == 1) {
map[p + 1][y] = 0;
ret = min(ret, dfs(p, y, n + 1));
break;
}
else if (p == gx&&y == gy)return n + 1;
p++;
}
}
p = y - 1;
if (p > 0 && map[x][p] != 1) {
while (p > 0) {
if (map[x][p - 1] == 1) {
map[x][p - 1] = 0;
ret = min(ret, dfs(x, p, n + 1));
break;
}
else if (p == gy&&x == gx)return n + 1;
p--;
}
}
p = y + 1;
if (p <= h&& map[x][p] != 1) {
while (p <= h) {
if (map[x][p + 1] == 1) {
map[x][p + 1] = 0;
ret = min(ret, dfs(x, p, n + 1));
break;
}
else if (p == gy&&x == gx)return n + 1;
p++;
}
}
return ret;
}
int main() {
while (cin >> h >> w, h, w) {
memset(map, 0, sizeof(map));
for (int i = 1; i <= w; i++) for (int j = 1; j <= h; j++) {
cin >> map[i][j];
if (map[i][j] == 2) { sx = i; sy = j; map[i][j] = 0; }
if (map[i][j] == 3) { gx = i; gy = j; }
}
int key = dfs(sx, sy, 0);
if (key == 11)cout << "-1\n"; else cout << key << endl;
}
} | a.cc: In function 'int main()':
a.cc:61:17: error: 'memset' was not declared in this scope
61 | memset(map, 0, sizeof(map));
| ^~~~~~
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;
|
s013948606 | p00725 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int map[30][30];
int sx, sy, gx, gy, h, w;
int dfs(int x, int y, int n) {
if (n > 11)return 11;
int ret = 11, p;
p = x - 1;
if (p > 0 && map[p][y] != 1) {
while (p > 0) {
if (map[p - 1][y] == 1) {
map[p - 1][y] = 0;
ret = min(ret, dfs(p, y, n + 1));
break;
}
else if (p == gx&&y == gy)return n + 1;
p--;
}
}
p = x + 1;
if (p <= w&& map[p][y] != 1) {
while (p <= w) {
if (map[p + 1][y] == 1) {
map[p + 1][y] = 0;
ret = min(ret, dfs(p, y, n + 1));
break;
}
else if (p == gx&&y == gy)return n + 1;
p++;
}
}
p = y - 1;
if (p > 0 && map[x][p] != 1) {
while (p > 0) {
if (map[x][p - 1] == 1) {
map[x][p - 1] = 0;
ret = min(ret, dfs(x, p, n + 1));
break;
}
else if (p == gy&&x == gx)return n + 1;
p--;
}
}
p = y + 1;
if (p <= h&& map[x][p] != 1) {
while (p <= h) {
if (map[x][p + 1] == 1) {
map[x][p + 1] = 0;
ret = min(ret, dfs(x, p, n + 1));
break;
}
else if (p == gy&&x == gx)return n + 1;
p++;
}
}
return ret;
}
int main() {
while (cin >> h >> w, h, w) {
memset(map, 0, sizeof(map));
for (int i = 1; i <= w; i++) for (int j = 1; j <= h; j++) {
cin >> map[i][j];
if (map[i][j] == 2) { sx = i; sy = j; map[i][j] = 0; }
if (map[i][j] == 3) { gx = i; gy = j; }
}
int key = dfs(sx, sy, 0);
if (key == 11)cout << "-1\n"; else cout << key << endl;
}
} | a.cc: In function 'int main()':
a.cc:61:17: error: 'memset' was not declared in this scope
61 | memset(map, 0, sizeof(map));
| ^~~~~~
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;
|
s587006079 | p00725 | 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
| |
s838415094 | p00725 | C++ | #include <string.h>
int gx, gy, h, w;
int cost[20][20];
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
void solve(int x,int y, int field[20][20]){
static int count = 0;
int i, j, flag;
if(cost[y][x] > count || cost[y][x] == -1){
cost[y][x] = count;
if(field[y][x] == 3)
return;
}
if(count < 10){
for(i = 0;i < 4;i++){
flag = 0;
for(j = 1;x + dx[i] * j >= 0 && x + dx[i] * j < w && y + dy[i] * j >= 0 && y + dy[i] * j < h;j++){
if(field[y + dy[i] * j][x + dx[i] * j]){
flag = 1;
break;
}
}
if(field[y + dy[i] * j][x + dx[i] * j] == 3){
count++;
solve(x + dx[i] * j,y + dy[i] * j,field);
count--;
}
else if(j != 1 && flag){
field[y + dy[i] * j][x + dx[i] * j] = 0;
count++;
solve(x + dx[i] * (j - 1),y + dy[i] * (j - 1),field);
field[y + dy[i] * j][x + dx[i] * j] = 1;
count--;
}
}
}
}
int main(void){
int i, j, field[20][20], sx, sy;
while(1){
scanf("%d%d",&w,&h);
if(w == 0 && h == 0)
break;
for(i = 0;i < h;i++){
for(j = 0;j < w;j++)
scanf("%d",&field[i][j]);
}
for(i = 0;i < h;i++){
for(j = 0;j < w;j++){
if(field[i][j] == 2){
sy = i, sx = j;
field[i][j] = 0;
}
else if(field[i][j] == 3)
gy = i, gx = j;
}
}
memset(cost,-1,sizeof(cost));
solve(sx,sy,field);
printf("%d\n",cost[gy][gx]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:44:17: error: 'scanf' was not declared in this scope
44 | scanf("%d%d",&w,&h);
| ^~~~~
a.cc:63:17: error: 'printf' was not declared in this scope
63 | printf("%d\n",cost[gy][gx]);
| ^~~~~~
a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
1 | #include <string.h>
+++ |+#include <cstdio>
2 |
|
s640445884 | p00725 | C++ | // cleartime: 4時間くらい?
#include <iostream>
#include <string>
#include <vector>
#define REP(i, n) for ( int i = 0; i < n; i++ )
using namespace std;
typedef vector< vector<int> > field;
int w, h;
field f, closed;
int mx[] = {0, 0, 1, -1},
my[] = {1, -1, 0, 0};
int in_range(int x, int y, int w, int h) {
return (int)(0 <= x && x < w && 0 <= y && y < h);
}
int bt(int x, int y, int step) {
int res = INT_MAX, tmp;
// 終了条件
if ( step == 10 ) {
return res;
}
// 上下左右に進めるなら進む
REP(i, 4) {
int nx = x, ny = y;
while(1) {
nx += mx[i];
ny += my[i];
if ( !in_range(nx, ny, w, h) ) {
break;
}
if ( f[ny][nx] == 1 ) {
break;
} else if ( f[ny][nx] == 3 ) {
return step + 1;
}
}
if ( !in_range(nx, ny, w, h) || abs(x-nx) == 1 || abs(y-ny) == 1 ) continue;
// 障害物を破壊
f[ny][nx] = 0;
tmp = bt(nx-mx[i], ny-my[i], step+1);
f[ny][nx] = 1;
// 最小手の更新
if ( tmp < res )
res = tmp;
}
return res;
}
int main() {
int fx, fy, res;
while( cin >> w >> h, w || h ) {
f = field(h, vector<int>(w));
// 入力
REP(i, h) {
REP(j, w) {
cin >> f[i][j];
if ( f[i][j] == 2 ) {
fx = j;
fy = i;
}
}
}
res = bt(fx, fy, 0);
if ( res != INT_MAX )
cout << res;
else
cout << -1;
cout << endl;
}
return 0;
} | a.cc: In function 'int bt(int, int, int)':
a.cc:22:15: error: 'INT_MAX' was not declared in this scope
22 | int res = INT_MAX, tmp;
| ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
4 | #include <vector>
+++ |+#include <climits>
5 |
a.cc:52:9: error: 'tmp' was not declared in this scope; did you mean 'tm'?
52 | tmp = bt(nx-mx[i], ny-my[i], step+1);
| ^~~
| tm
a.cc: In function 'int main()':
a.cc:82:21: error: 'INT_MAX' was not declared in this scope
82 | if ( res != INT_MAX )
| ^~~~~~~
a.cc:82:21: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
|
s750574444 | p00725 | C++ | // BT法
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#define N 20
using namespace std;
int h, w, num;
void print(vector<vector <char> > map) {
for (int i = 0; i < map.size(); i++) {
for (int j = 0; j < map[i].size(); j++) {
cout << map[i][j] << flush;
cout << " " << flush;//if (j != map[i].size()-1)
}
cout << endl;
}
}
int rec(vector<vector <char> > *map, int callnum, int y, int x, int dy, int dx)// 現在位置と、投げる方向
{
int res = 0, wy = -1, wx = -1;
// まず、引数の情報にしたがって投げてみる
while (true) {
//map[y][x] = '@'; // デバッグ用にマーク
y+=dy;
x+=dx;
// 場外に出た場合は終了
if (y < 0 || x < 0 || y >= h || x >= w || callnum > 10) {
return -1;// -1を返す:到達不可の場合
}
// ゴール発見
if (map[y][x] == '3') {
return callnum+1;
}
// 壁があったらそれを消して止まる
if (map[y][x] == '1') {
map[y][x] = '0';
wy = y; wx = x;
y-=dy;// 止まる位置は壁の前なので調整
x-=dx;
break;
}
}
if (map[y][x] == '3') {
return callnum+1; // ゴール発見:出力は「投げた回数」なので+1
}
// 投げようとする方向が場外ではなく、かつ壁が無ければ投げる
if (y-1 >= 0 && map[y-1][x] != '1')
res = rec(map, callnum+1, y, x, -1, 0);
if (res > 0) {// ゴールを発見したら戻る
return res;
}
res = 0;
if (y+1 < h && map[y+1][x] != '1')
res = rec(map, callnum+1, y, x, 1, 0);
if (res > 0) return res;
//else return -1;
res = 0;
if (x-1 >= 0 && map[y][x-1] != '1')
res = rec(map, callnum+1, y, x, 0, -1);
if (res > 0) return res;
// else return -1;
res = 0;
if (x+1 < w && map[y][x+1] != '1')
res = rec(map, callnum+1, y, x, 0, 1);
else {
if (wy != -1 && wx != -1) map[wy][wx] = '1';
return -1;
}
if (res > 0) return res;
else {
if (wy != -1 && wx != -1) map[wy][wx] = '1';
return -1;
}
}
void out(int res)
{
if (res <= 10) cout << res << endl;
else cout << -1 << endl;
}
int main()
{
int n, m, inity, initx, endy, endx;
//vector<vector <bool> > isVisit;
vector<vector <char> > map;
while (cin >> n >> m) {
if (n == 0 && m == 0) {
break;
}
// 初期化及びマップの読み込み
h = m;
w = n;
num = initx = inity = endx = endy = 0;
map.clear();
map.resize(m);
for (int i = 0; i < m; i++) map[i].resize(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> map[j][i];
if (map[j][i] == '2') {
inity = j;
initx = i;
}
}
}
int res = 0, minres = 0;
//rec(0, inity, initx, inity, initx);
if (inity-1 >= 0 && map[inity-1][initx] != '1')
res = rec(&map, 0, inity, initx, -1, 0);
else
res = -1;
if (minres == 0 && res > 0) minres = res;
if (inity+1 < h && map[inity+1][initx] != '1')
res = rec(&map, 0, inity, initx, 1, 0);
else
res = -1;
//output(res);
if (minres == 0 && res > 0) minres = res;
else if (res > 0 && res < minres) minres = res;
if (initx-1 >= 0 && map[inity][initx-1] != '1')
res = rec(&map, 0, inity, initx, 0, -1);
else
res = -1;
if (minres == 0 && res > 0) minres = res;
else if (res > 0 && res < minres) minres = res;
if (initx+1 < w && map[inity][initx+1] != '1')
res = rec(&map, 0, inity, initx, 0, 1);
else
res = -1;
if (minres == 0 && res > 0) minres = res;
else if (res > 0 && res < minres) minres = res;
// 出力する
if (minres > 0 && minres <= 10) cout << minres << endl;
else cout << -1 << endl;
/*if (num < 10) {
cout << num << endl;
} else {
cout << -1 << endl;
}*/
//print(map);// 入力はok + 書き換え確認
}
return 0;
} | a.cc: In function 'int rec(std::vector<std::vector<char> >*, int, int, int, int, int)':
a.cc:39:31: error: no match for 'operator==' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::value_type' {aka 'std::vector<char>'} and 'char')
39 | if (map[y][x] == '3') {
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:3:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::value_type' {aka 'std::vector<char>'} is not derived from 'const std::fpos<_StateT>'
39 | if (map[y][x] == '3') {
| ^~~
In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::value_type' {aka 'std::vector<char>'} is not derived from 'const std::allocator<_CharT>'
39 | if (map[y][x] == '3') {
| ^~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::value_type' {aka 'std::vector<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
39 | if (map[y][x] == '3') {
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::value_type' {aka 'std::vector<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
39 | if (map[y][x] == '3') {
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::value_type' {aka 'std::vector<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
39 | if (map[y][x] == '3') {
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::value_type' {aka 'std::vector<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
39 | if (map[y][x] == '3') {
| ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::value_type' {aka 'std::vector<char>'} is not derived from 'const std::pair<_T1, _T2>'
39 | if (map[y][x] == '3') {
| ^~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: 'std::vector<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
39 | if (map[y][x] == '3') {
| ^~~
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: 'std::vector<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
39 | if (map[y][x] == '3') {
| ^~~
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'char'
39 | if (map[y][x] == '3') {
| ^~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::value_type' {aka 'std::vector<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
39 | if (map[y][x] == '3') {
| ^~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::value_type' {aka 'std::vector<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
39 | if (map[y][x] == '3') {
| ^~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3819 | operator==(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: mismatched types 'const _CharT*' and 'std::vector<char>'
39 | if (map[y][x] == '3') {
| ^~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2558 | operator==(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<char> >, std::vector<char> >::value_type' {aka 'std::vector<char>'} is not deri |
s183888042 | p00725 | C++ | if(board[y+dy[i]][x+dx[i]] ==1){
flag[i] = 1;
}
}
if(k <=10){
//左方向
if(flag[2]==0){
for(int j = x;j >0;j--){
if(board[y][j] ==3){
step = min(step,k);
break;
}else if(board[y][j-1] ==1){
board[y][j-1] =0;
dfs(j,y,k+1);
board[y][j-1] = 1;
break;
}
}
}
//右方向
if(flag[0]==0){
for(int j = x; j <=w;j++){
if(board[y][j] ==3){
step = min(step,k);
break;
}else if(board[y][j+1] ==1){
board[y][j+1] =0;
dfs(j,y,k+1);
board[y][j+1] = 1;
break;
}
}
}
//上方向
if(flag[1] ==0){
for(int j = y; j >0;j--){
if(board[j][x] ==3){
step = min(step,k);
break;
}else if(board[j-1][x] ==1){
board[j-1][x] =0;
dfs(x,j,k+1);
board[j-1][x] = 1;
break;
}
}
}
//下方向
if(flag[3]==0){
for(int j = y; j <=h;j++){
if(board[j][x] ==3){
step = min(step,k);
break;
}else if(board[j+1][x] ==1){
board[j+1][x] =0;
dfs(x,j,k+1);
board[j+1][x] = 1;
break;
}
}
}
}
return;
}
int main()
{
while(cin>>w>>h,w||h){
step =1000;
for(int i = 1;i <=h;i++){
for(int j = 1;j <=w;j++){
cin >>board[i][j];
}
}
for(int i = 1;i <=h;i++){
for(int j = 1;j <=w;j++){
if(board[i][j] ==2){
int sx = j;
int sy = i;
dfs(sx,sy,1);
}
}
}
if(step ==1000){
cout <<"-1"<<endl;
}else
cout <<step<<endl;
}
return 0;
} | a.cc:1:5: error: expected unqualified-id before 'if'
1 | if(board[y+dy[i]][x+dx[i]] ==1){
| ^~
a.cc:4:3: error: expected declaration before '}' token
4 | }
| ^
a.cc:5:3: error: expected unqualified-id before 'if'
5 | if(k <=10){
| ^~
a.cc:63:5: error: expected unqualified-id before 'return'
63 | return;
| ^~~~~~
a.cc:64:1: error: expected declaration before '}' token
64 | }
| ^
a.cc: In function 'int main()':
a.cc:69:9: error: 'cin' was not declared in this scope
69 | while(cin>>w>>h,w||h){
| ^~~
a.cc:69:14: error: 'w' was not declared in this scope
69 | while(cin>>w>>h,w||h){
| ^
a.cc:69:17: error: 'h' was not declared in this scope
69 | while(cin>>w>>h,w||h){
| ^
a.cc:70:5: error: 'step' was not declared in this scope
70 | step =1000;
| ^~~~
a.cc:73:15: error: 'board' was not declared in this scope
73 | cin >>board[i][j];
| ^~~~~
a.cc:78:12: error: 'board' was not declared in this scope
78 | if(board[i][j] ==2){
| ^~~~~
a.cc:81:11: error: 'dfs' was not declared in this scope
81 | dfs(sx,sy,1);
| ^~~
a.cc:86:7: error: 'cout' was not declared in this scope
86 | cout <<"-1"<<endl;
| ^~~~
a.cc:86:20: error: 'endl' was not declared in this scope
86 | cout <<"-1"<<endl;
| ^~~~
a.cc:88:7: error: 'cout' was not declared in this scope
88 | cout <<step<<endl;
| ^~~~
a.cc:88:20: error: 'endl' was not declared in this scope
88 | cout <<step<<endl;
| ^~~~
|
s772479776 | p00726 | C++ | #include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
typedef string::const_iterator State;
string s;
int ref;
string expr(State& be){
string ret;
while(true){
int x=1;
if(isdigit(*be)){
x=0;
while(isdigit(*be)){
x*=10;
x+=(*be)-'0';
be++;
}
}
if(*be=='('){
be++;
string t=expr(be);
rep(i,x){
if(ret.size()>ref) break;
ret+=t;
}
be++;
}else if('A'<=*be && *be<='Z'){
rep(i,x){
if(ret.size()>ref) break;
ret+=(*be);
}
be++;
}else break;
if(ret.size()>ref) break;
}
return ret;
}
int main(){
while(true){
cin>>s>>ref;
if(s[0]=='0') break;
State be=s.begin();
string t=expr(be);
if(t.size()<=ref) cout << "0\n";
else cout << t[ref]<<endl;
}
} | a.cc: In function 'std::string expr(State&)':
a.cc:35:47: error: reference to 'ref' is ambiguous
35 | if(ret.size()>ref) break;
| ^~~
In file included from /usr/include/c++/14/string:52,
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/refwrap.h:445:5: note: candidates are: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(reference_wrapper<_Tp>)'
445 | ref(reference_wrapper<_Tp> __t) noexcept
| ^~~
/usr/include/c++/14/bits/refwrap.h:436:10: note: 'template<class _Tp> void std::ref(const _Tp&&)'
436 | void ref(const _Tp&&) = delete;
| ^~~
/usr/include/c++/14/bits/refwrap.h:425:5: note: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)'
425 | ref(_Tp& __t) noexcept
| ^~~
a.cc:18:5: note: 'int ref'
18 | int ref;
| ^~~
a.cc:41:47: error: reference to 'ref' is ambiguous
41 | if(ret.size()>ref) break;
| ^~~
/usr/include/c++/14/bits/refwrap.h:445:5: note: candidates are: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(reference_wrapper<_Tp>)'
445 | ref(reference_wrapper<_Tp> __t) noexcept
| ^~~
/usr/include/c++/14/bits/refwrap.h:436:10: note: 'template<class _Tp> void std::ref(const _Tp&&)'
436 | void ref(const _Tp&&) = delete;
| ^~~
/usr/include/c++/14/bits/refwrap.h:425:5: note: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)'
425 | ref(_Tp& __t) noexcept
| ^~~
a.cc:18:5: note: 'int ref'
18 | int ref;
| ^~~
a.cc:46:31: error: reference to 'ref' is ambiguous
46 | if(ret.size()>ref) break;
| ^~~
/usr/include/c++/14/bits/refwrap.h:445:5: note: candidates are: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(reference_wrapper<_Tp>)'
445 | ref(reference_wrapper<_Tp> __t) noexcept
| ^~~
/usr/include/c++/14/bits/refwrap.h:436:10: note: 'template<class _Tp> void std::ref(const _Tp&&)'
436 | void ref(const _Tp&&) = delete;
| ^~~
/usr/include/c++/14/bits/refwrap.h:425:5: note: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)'
425 | ref(_Tp& __t) noexcept
| ^~~
a.cc:18:5: note: 'int ref'
18 | int ref;
| ^~~
a.cc: In function 'int main()':
a.cc:52:25: error: reference to 'ref' is ambiguous
52 | cin>>s>>ref;
| ^~~
/usr/include/c++/14/bits/refwrap.h:445:5: note: candidates are: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(reference_wrapper<_Tp>)'
445 | ref(reference_wrapper<_Tp> __t) noexcept
| ^~~
/usr/include/c++/14/bits/refwrap.h:436:10: note: 'template<class _Tp> void std::ref(const _Tp&&)'
436 | void ref(const _Tp&&) = delete;
| ^~~
/usr/include/c++/14/bits/refwrap.h:425:5: note: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)'
425 | ref(_Tp& __t) noexcept
| ^~~
a.cc:18:5: note: 'int ref'
18 | int ref;
| ^~~
a.cc:56:30: error: reference to 'ref' is ambiguous
56 | if(t.size()<=ref) cout << "0\n";
| ^~~
/usr/include/c++/14/bits/refwrap.h:445:5: note: candidates are: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(reference_wrapper<_Tp>)'
445 | ref(reference_wrapper<_Tp> __t) noexcept
| ^~~
/usr/include/c++/14/bits/refwrap.h:436:10: note: 'template<class _Tp> void std::ref(const _Tp&&)'
436 | void ref(const _Tp&&) = delete;
| ^~~
/usr/include/c++/14/bits/refwrap.h:425:5: note: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)'
425 | ref(_Tp& __t) noexcept
| ^~~
a.cc:18:5: note: 'int ref'
18 | int ref;
| ^~~
a.cc:57:32: error: reference to 'ref' is ambiguous
57 | else cout << t[ref]<<endl;
| ^~~
/usr/include/c++/14/bits/refwrap.h:445:5: note: candidates are: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(reference_wrapper<_Tp>)'
445 | ref(reference_wrapper<_Tp> __t) noexcept
| ^~~
/usr/include/c++/14/bits/refwrap.h:436:10: note: 'template<class _Tp> void std::ref(const _Tp&&)'
436 | void ref(const _Tp&&) = delete;
| ^~~
/usr/include/c++/14/bits/refwrap.h:425:5: note: 'template<class _Tp> std::reference_wrapper<_Tp> std::ref(_Tp&)'
425 | ref(_Tp& __t) noexcept
| ^~~
a.cc:18:5: note: 'int ref'
18 | int ref;
| ^~~
|
s620359896 | p00726 | C++ | a | a.cc:1:1: error: 'a' does not name a type
1 | a
| ^
|
s573221300 | p00726 | C++ | #include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;
char ans;
int a;
string st;
long long int getnum() {
long long int anum=0;
while (1) {
if (isdigit(st[a])) {
anum *= 10;
anum += st[a]-'0';
a++;
}
else {
return anum;
}
}
}
string getst() {
string ast;
while (1) {
if (a == st.size())return ast;
if ('A'<=st[a]&&st[a]<='Z') {
ast += st[a];
a++;
}
else {
return ast;
}
}
}
string getans(const long long int repeatnum,const int targetnum) {
string nst;
while (1) {
if (a == st.size())return nst;
if (st[a] == '(') {
a++;
nst+=getans(repeatnum, targetnum - nst.size());
}
else if (isdigit(st[a])) {
long long int num=getnum();
string plusst;
if (st[a] == '(') {
a++;
plusst= (getans(min(1000000000000,repeatnum*num), targetnum - nst.size()*repeatnum));
}
else {
plusst = st[a];
a++;
}
for (int i = 0; i < num; ++i) {
nst += plusst;
}
if ((nst.size())*repeatnum > targetnum) {
ans = nst[targetnum % nst.size()];
throw(0);
}
}
else if (st[a] == ')') {
a++;
return nst;
}
else {
string plusst = getst();
nst += plusst;
if ((nst.size())*repeatnum > targetnum) {
ans = nst[targetnum % nst.size()];
throw(0);
}
}
}
}
int main() {
while (1) {
a = 0;
ans = '0';
int n;
cin >> st >> n;
if (st == "0")break;
try {
getans(1, n);
}
catch (...) {
}
cout << ans << endl;
}
return 0;
} | a.cc: In function 'std::string getans(long long int, int)':
a.cc:47:52: error: no matching function for call to 'min(long int, long long int)'
47 | plusst= (getans(min(1000000000000,repeatnum*num), targetnum - nst.size()*repeatnum));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:47:52: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
47 | plusst= (getans(min(1000000000000,repeatnum*num), targetnum - nst.size()*repeatnum));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:47:52: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
47 | plusst= (getans(min(1000000000000,repeatnum*num), targetnum - nst.size()*repeatnum));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s718957886 | p00726 | C++ | #include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;
char ans;
int a;
string st;
long long int getnum() {
long long int anum=0;
while (1) {
if (isdigit(st[a])) {
anum *= 10;
anum += st[a]-'0';
a++;
}
else {
return anum;
}
}
}
string getst() {
string ast;
while (1) {
if (a == st.size())return ast;
if ('A'<=st[a]&&st[a]<='Z') {
ast += st[a];
a++;
}
else {
return ast;
}
}
}
string getans(const long long int repeatnum,const int targetnum) {
string nst;
while (1) {
if (a == st.size())return nst;
if (st[a] == '(') {
a++;
nst+=getans(repeatnum, targetnum - nst.size());
}
else if (isdigit(st[a])) {
long long int num=getnum();
string plusst;
if (st[a] == '(') {
a++;
plusst= getans(min(1000000000000,repeatnum*num), targetnum - nst.size()*repeatnum);
}
else {
plusst = st[a];
a++;
}
for (int i = 0; i < num; ++i) {
nst += plusst;
}
if ((nst.size())*repeatnum > targetnum) {
ans = nst[targetnum % nst.size()];
throw(0);
}
}
else if (st[a] == ')') {
a++;
return nst;
}
else {
string plusst = getst();
nst += plusst;
if ((nst.size())*repeatnum > targetnum) {
ans = nst[targetnum % nst.size()];
throw(0);
}
}
}
}
int main() {
while (1) {
a = 0;
ans = '0';
int n;
cin >> st >> n;
if (st == "0")break;
try {
getans(1, n);
}
catch (...) {
}
cout << ans << endl;
}
return 0;
} | a.cc: In function 'std::string getans(long long int, int)':
a.cc:47:51: error: no matching function for call to 'min(long int, long long int)'
47 | plusst= getans(min(1000000000000,repeatnum*num), targetnum - nst.size()*repeatnum);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:47:51: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
47 | plusst= getans(min(1000000000000,repeatnum*num), targetnum - nst.size()*repeatnum);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:47:51: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
47 | plusst= getans(min(1000000000000,repeatnum*num), targetnum - nst.size()*repeatnum);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s689399514 | p00726 | C++ | #include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
using namespace std;
struct before_main {before_main() {cin.tie(0); ios::sync_with_stdio(false);}} before_main;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef shared_ptr<struct tree> tree_ptr;
struct tree {
string s;
vector<tree_ptr> children;
ll num = 1;
tree() noexcept = default;
tree(string s, ll num): s(s), num(num) {}
};
ll read_k(string& s) {
stringstream ss(s);
int x; string t; ss >> x >> t;
s = t;
return x;
}
string read_s(string& s) {
int n = s.size();
string t;
int last = -1;
bool br = 0;
rep(i, n) {
last = i;
if (s[i] == ')') { br = 1; break; }
t.push_back(s[i]);
}
if (br) s = s.substr(last);
else s = "";
return t;
}
void consume(string& s, char expected) {
if (s[0] != expected) {
cout << "Expected: " << expected << endl;
cout << "Remain: " << s << endl;
assert(0);
}
s = s.substr(1);
}
void dfs(string& s, tree_ptr curr) {
for (; !s.empty();) {
if (isdigit(s[0])) {
ll ck = read_k(s);
if (isalpha(s[0])) {
auto c = make_shared<tree>();
c->num = ck;
c->s = read_s(s);
curr->children.push_back(c);
return;
}
else {
consume(s, '(');
auto c = make_shared<tree>();
c->num = ck;
curr->children.push_back(c);
dfs(s, c);
consume(s, ')');
}
}
else {
curr->s = read_s(s);
return;
}
}
}
int stop;
string ans;
void visit(tree_ptr curr, ll num) {
if(stop == 2) { return; }
num *= curr->num;
if(num >= 1000000) { num = 1000000; stop = 1; }
if (curr->children.empty()) {
rep(i, num) ans += curr->s;
if(stop) { stop ++; }
}
rep(i, curr->children.size()) {
visit(curr->children[i], num);
}
}
char solve(string& s, int idx) {
auto root = make_shared<tree>();
dfs(s, root);
stop = 0; ans.clear();
visit(root, 1);
if(ans.size() <= idx) { return '0'; }
// cout << ans.size() << " / " << idx << endl;
return ans[idx];
}
int main() {
while (1) {
string s; cin >> s;
int idx; cin >> idx;
if (s == "0" && idx == 0) { break; }
cout << solve(s, idx) << endl;
}
return 0;
} | a.cc:31:9: error: 'shared_ptr' does not name a type
31 | typedef shared_ptr<struct tree> tree_ptr;
| ^~~~~~~~~~
a.cc:35:10: error: 'tree_ptr' was not declared in this scope
35 | vector<tree_ptr> children;
| ^~~~~~~~
a.cc:35:18: error: template argument 1 is invalid
35 | vector<tree_ptr> children;
| ^
a.cc:35:18: error: template argument 2 is invalid
a.cc:72:21: error: 'tree_ptr' has not been declared
72 | void dfs(string& s, tree_ptr curr) {
| ^~~~~~~~
a.cc: In function 'void dfs(std::string&, int)':
a.cc:77:18: error: 'make_shared' was not declared in this scope
77 | auto c = make_shared<tree>();
| ^~~~~~~~~~~
a.cc:21:1: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
20 | #include <bitset>
+++ |+#include <memory>
21 |
a.cc:77:34: error: expected primary-expression before '>' token
77 | auto c = make_shared<tree>();
| ^
a.cc:77:36: error: expected primary-expression before ')' token
77 | auto c = make_shared<tree>();
| ^
a.cc:80:13: error: base operand of '->' is not a pointer
80 | curr->children.push_back(c);
| ^~
a.cc:85:18: error: 'make_shared' was not declared in this scope
85 | auto c = make_shared<tree>();
| ^~~~~~~~~~~
a.cc:85:18: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
a.cc:85:34: error: expected primary-expression before '>' token
85 | auto c = make_shared<tree>();
| ^
a.cc:85:36: error: expected primary-expression before ')' token
85 | auto c = make_shared<tree>();
| ^
a.cc:87:13: error: base operand of '->' is not a pointer
87 | curr->children.push_back(c);
| ^~
a.cc:93:11: error: base operand of '->' is not a pointer
93 | curr->s = read_s(s);
| ^~
a.cc: At global scope:
a.cc:102:6: error: variable or field 'visit' declared void
102 | void visit(tree_ptr curr, ll num) {
| ^~~~~
a.cc:102:12: error: 'tree_ptr' was not declared in this scope
102 | void visit(tree_ptr curr, ll num) {
| ^~~~~~~~
a.cc:102:30: error: expected primary-expression before 'num'
102 | void visit(tree_ptr curr, ll num) {
| ^~~
a.cc: In function 'char solve(std::string&, int)':
a.cc:119:15: error: 'make_shared' was not declared in this scope
119 | auto root = make_shared<tree>();
| ^~~~~~~~~~~
a.cc:119:15: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
a.cc:119:31: error: expected primary-expression before '>' token
119 | auto root = make_shared<tree>();
| ^
a.cc:119:33: error: expected primary-expression before ')' token
119 | auto root = make_shared<tree>();
| ^
a.cc:122:3: error: 'visit' was not declared in this scope
122 | visit(root, 1);
| ^~~~~
a.cc:21:1: note: 'std::visit' is defined in header '<variant>'; this is probably fixable by adding '#include <variant>'
20 | #include <bitset>
+++ |+#include <variant>
21 |
|
s516519127 | p00726 | C++ | #include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
using namespace std;
struct before_main {before_main() {cin.tie(0); ios::sync_with_stdio(false);}} before_main;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef shared_ptr<struct tree> tree_ptr;
struct tree {
string s;
vector<tree_ptr> children;
ll num = 1;
tree() = default;
tree(string s, ll num): s(s), num(num) {}
};
ll read_k(string& s) {
stringstream ss(s);
int x; string t; ss >> x >> t;
s = t;
return x;
}
string read_s(string& s) {
int n = s.size();
string t;
int last = -1;
bool br = 0;
rep(i, n) {
last = i;
if (s[i] == ')') { br = 1; break; }
t.push_back(s[i]);
}
if (br) s = s.substr(last);
else s = "";
return t;
}
void consume(string& s, char expected) {
if (s[0] != expected) {
cout << "Expected: " << expected << endl;
cout << "Remain: " << s << endl;
assert(0);
}
s = s.substr(1);
}
void dfs(string& s, tree_ptr curr) {
for (; !s.empty();) {
if (isdigit(s[0])) {
ll ck = read_k(s);
if (isalpha(s[0])) {
auto c = make_shared<tree>();
c->num = ck;
c->s = read_s(s);
curr->children.push_back(c);
return;
}
else {
consume(s, '(');
auto c = make_shared<tree>();
c->num = ck;
curr->children.push_back(c);
dfs(s, c);
consume(s, ')');
}
}
else {
curr->s = read_s(s);
return;
}
}
}
int stop;
string ans;
void visit(tree_ptr curr, ll num) {
if(stop == 2) { return; }
num *= curr->num;
if(num >= 1000000) { num = 1000000; stop = 1; }
if (curr->children.empty()) {
rep(i, num) ans += curr->s;
if(stop) { stop ++; }
}
rep(i, curr->children.size()) {
visit(curr->children[i], num);
}
}
char solve(string& s, int idx) {
auto root = make_shared<tree>();
dfs(s, root);
stop = 0; ans.clear();
visit(root, 1);
if(ans.size() <= idx) { return '0'; }
// cout << ans.size() << " / " << idx << endl;
return ans[idx];
}
int main() {
while (1) {
string s; cin >> s;
int idx; cin >> idx;
if (s == "0" && idx == 0) { break; }
cout << solve(s, idx) << endl;
}
return 0;
} | a.cc:31:9: error: 'shared_ptr' does not name a type
31 | typedef shared_ptr<struct tree> tree_ptr;
| ^~~~~~~~~~
a.cc:35:10: error: 'tree_ptr' was not declared in this scope
35 | vector<tree_ptr> children;
| ^~~~~~~~
a.cc:35:18: error: template argument 1 is invalid
35 | vector<tree_ptr> children;
| ^
a.cc:35:18: error: template argument 2 is invalid
a.cc:72:21: error: 'tree_ptr' has not been declared
72 | void dfs(string& s, tree_ptr curr) {
| ^~~~~~~~
a.cc: In function 'void dfs(std::string&, int)':
a.cc:77:18: error: 'make_shared' was not declared in this scope
77 | auto c = make_shared<tree>();
| ^~~~~~~~~~~
a.cc:21:1: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
20 | #include <bitset>
+++ |+#include <memory>
21 |
a.cc:77:34: error: expected primary-expression before '>' token
77 | auto c = make_shared<tree>();
| ^
a.cc:77:36: error: expected primary-expression before ')' token
77 | auto c = make_shared<tree>();
| ^
a.cc:80:13: error: base operand of '->' is not a pointer
80 | curr->children.push_back(c);
| ^~
a.cc:85:18: error: 'make_shared' was not declared in this scope
85 | auto c = make_shared<tree>();
| ^~~~~~~~~~~
a.cc:85:18: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
a.cc:85:34: error: expected primary-expression before '>' token
85 | auto c = make_shared<tree>();
| ^
a.cc:85:36: error: expected primary-expression before ')' token
85 | auto c = make_shared<tree>();
| ^
a.cc:87:13: error: base operand of '->' is not a pointer
87 | curr->children.push_back(c);
| ^~
a.cc:93:11: error: base operand of '->' is not a pointer
93 | curr->s = read_s(s);
| ^~
a.cc: At global scope:
a.cc:102:6: error: variable or field 'visit' declared void
102 | void visit(tree_ptr curr, ll num) {
| ^~~~~
a.cc:102:12: error: 'tree_ptr' was not declared in this scope
102 | void visit(tree_ptr curr, ll num) {
| ^~~~~~~~
a.cc:102:30: error: expected primary-expression before 'num'
102 | void visit(tree_ptr curr, ll num) {
| ^~~
a.cc: In function 'char solve(std::string&, int)':
a.cc:119:15: error: 'make_shared' was not declared in this scope
119 | auto root = make_shared<tree>();
| ^~~~~~~~~~~
a.cc:119:15: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
a.cc:119:31: error: expected primary-expression before '>' token
119 | auto root = make_shared<tree>();
| ^
a.cc:119:33: error: expected primary-expression before ')' token
119 | auto root = make_shared<tree>();
| ^
a.cc:122:3: error: 'visit' was not declared in this scope
122 | visit(root, 1);
| ^~~~~
a.cc:21:1: note: 'std::visit' is defined in header '<variant>'; this is probably fixable by adding '#include <variant>'
20 | #include <bitset>
+++ |+#include <variant>
21 |
|
s010811031 | p00726 | C++ | #include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
using namespace std;
struct before_main {before_main() {cin.tie(0); ios::sync_with_stdio(false);}} before_main;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef shared_ptr<struct tree> tree_ptr;
struct tree {
string s;
vector<tree_ptr> children;
ll num = 1;
tree() {}
tree(string s, ll num): s(s), num(num) {}
};
ll read_k(string& s) {
stringstream ss(s);
int x; string t; ss >> x >> t;
s = t;
return x;
}
string read_s(string& s) {
int n = s.size();
string t;
int last = -1;
bool br = 0;
rep(i, n) {
last = i;
if (s[i] == ')') { br = 1; break; }
t.push_back(s[i]);
}
if (br) s = s.substr(last);
else s = "";
return t;
}
void consume(string& s, char expected) {
if (s[0] != expected) {
cout << "Expected: " << expected << endl;
cout << "Remain: " << s << endl;
assert(0);
}
s = s.substr(1);
}
void dfs(string& s, tree_ptr curr) {
for (; !s.empty();) {
if (isdigit(s[0])) {
ll ck = read_k(s);
if (isalpha(s[0])) {
auto c = make_shared<tree>();
c->num = ck;
c->s = read_s(s);
curr->children.push_back(c);
return;
}
else {
consume(s, '(');
auto c = make_shared<tree>();
c->num = ck;
curr->children.push_back(c);
dfs(s, c);
consume(s, ')');
}
}
else {
curr->s = read_s(s);
return;
}
}
}
int stop;
string ans;
void visit(tree_ptr curr, ll num) {
if(stop == 2) { return; }
num *= curr->num;
if(num >= 1000000) { num = 1000000; stop = 1; }
if (curr->children.empty()) {
rep(i, num) ans += curr->s;
if(stop) { stop ++; }
}
rep(i, curr->children.size()) {
visit(curr->children[i], num);
}
}
char solve(string& s, int idx) {
auto root = make_shared<tree>();
dfs(s, root);
stop = 0; ans.clear();
visit(root, 1);
if(ans.size() <= idx) { return '0'; }
// cout << ans.size() << " / " << idx << endl;
return ans[idx];
}
int main() {
while (1) {
string s; cin >> s;
int idx; cin >> idx;
if (s == "0" && idx == 0) { break; }
cout << solve(s, idx) << endl;
}
return 0;
} | a.cc:31:9: error: 'shared_ptr' does not name a type
31 | typedef shared_ptr<struct tree> tree_ptr;
| ^~~~~~~~~~
a.cc:35:10: error: 'tree_ptr' was not declared in this scope
35 | vector<tree_ptr> children;
| ^~~~~~~~
a.cc:35:18: error: template argument 1 is invalid
35 | vector<tree_ptr> children;
| ^
a.cc:35:18: error: template argument 2 is invalid
a.cc:72:21: error: 'tree_ptr' has not been declared
72 | void dfs(string& s, tree_ptr curr) {
| ^~~~~~~~
a.cc: In function 'void dfs(std::string&, int)':
a.cc:77:18: error: 'make_shared' was not declared in this scope
77 | auto c = make_shared<tree>();
| ^~~~~~~~~~~
a.cc:21:1: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
20 | #include <bitset>
+++ |+#include <memory>
21 |
a.cc:77:34: error: expected primary-expression before '>' token
77 | auto c = make_shared<tree>();
| ^
a.cc:77:36: error: expected primary-expression before ')' token
77 | auto c = make_shared<tree>();
| ^
a.cc:80:13: error: base operand of '->' is not a pointer
80 | curr->children.push_back(c);
| ^~
a.cc:85:18: error: 'make_shared' was not declared in this scope
85 | auto c = make_shared<tree>();
| ^~~~~~~~~~~
a.cc:85:18: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
a.cc:85:34: error: expected primary-expression before '>' token
85 | auto c = make_shared<tree>();
| ^
a.cc:85:36: error: expected primary-expression before ')' token
85 | auto c = make_shared<tree>();
| ^
a.cc:87:13: error: base operand of '->' is not a pointer
87 | curr->children.push_back(c);
| ^~
a.cc:93:11: error: base operand of '->' is not a pointer
93 | curr->s = read_s(s);
| ^~
a.cc: At global scope:
a.cc:102:6: error: variable or field 'visit' declared void
102 | void visit(tree_ptr curr, ll num) {
| ^~~~~
a.cc:102:12: error: 'tree_ptr' was not declared in this scope
102 | void visit(tree_ptr curr, ll num) {
| ^~~~~~~~
a.cc:102:30: error: expected primary-expression before 'num'
102 | void visit(tree_ptr curr, ll num) {
| ^~~
a.cc: In function 'char solve(std::string&, int)':
a.cc:119:15: error: 'make_shared' was not declared in this scope
119 | auto root = make_shared<tree>();
| ^~~~~~~~~~~
a.cc:119:15: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
a.cc:119:31: error: expected primary-expression before '>' token
119 | auto root = make_shared<tree>();
| ^
a.cc:119:33: error: expected primary-expression before ')' token
119 | auto root = make_shared<tree>();
| ^
a.cc:122:3: error: 'visit' was not declared in this scope
122 | visit(root, 1);
| ^~~~~
a.cc:21:1: note: 'std::visit' is defined in header '<variant>'; this is probably fixable by adding '#include <variant>'
20 | #include <bitset>
+++ |+#include <variant>
21 |
|
s023137594 | p00726 | C++ | #include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
using namespace std;
struct before_main {before_main() {cin.tie(0); ios::sync_with_stdio(false);}} before_main;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef shared_ptr<struct tree> tree_ptr;
struct tree {
string s;
vector<tree_ptr> children;
ll num;
tree(): num(1) {}
tree(string s, ll num): s(s), num(num) {}
};
ll read_k(string& s) {
stringstream ss(s);
int x; string t; ss >> x >> t;
s = t;
return x;
}
string read_s(string& s) {
int n = s.size();
string t;
int last = -1;
bool br = 0;
rep(i, n) {
last = i;
if (s[i] == ')') { br = 1; break; }
t.push_back(s[i]);
}
if (br) s = s.substr(last);
else s = "";
return t;
}
void consume(string& s, char expected) {
if (s[0] != expected) {
cout << "Expected: " << expected << endl;
cout << "Remain: " << s << endl;
assert(0);
}
s = s.substr(1);
}
void dfs(string& s, tree_ptr curr) {
for (; !s.empty();) {
if (isdigit(s[0])) {
ll ck = read_k(s);
if (isalpha(s[0])) {
auto c = make_shared<tree>();
c->num = ck;
c->s = read_s(s);
curr->children.push_back(c);
return;
}
else {
consume(s, '(');
auto c = make_shared<tree>();
c->num = ck;
curr->children.push_back(c);
dfs(s, c);
consume(s, ')');
}
}
else {
curr->s = read_s(s);
return;
}
}
}
int stop;
string ans;
void visit(tree_ptr curr, ll num) {
if(stop == 2) { return; }
num *= curr->num;
if(num >= 1000000) { num = 1000000; stop = 1; }
if (curr->children.empty()) {
rep(i, num) ans += curr->s;
if(stop) { stop ++; }
}
rep(i, curr->children.size()) {
visit(curr->children[i], num);
}
}
char solve(string& s, int idx) {
auto root = make_shared<tree>();
dfs(s, root);
stop = 0; ans.clear();
visit(root, 1);
if(ans.size() <= idx) { return '0'; }
// cout << ans.size() << " / " << idx << endl;
return ans[idx];
}
int main() {
while (1) {
string s; cin >> s;
int idx; cin >> idx;
if (s == "0" && idx == 0) { break; }
cout << solve(s, idx) << endl;
}
return 0;
} | a.cc:31:9: error: 'shared_ptr' does not name a type
31 | typedef shared_ptr<struct tree> tree_ptr;
| ^~~~~~~~~~
a.cc:35:10: error: 'tree_ptr' was not declared in this scope
35 | vector<tree_ptr> children;
| ^~~~~~~~
a.cc:35:18: error: template argument 1 is invalid
35 | vector<tree_ptr> children;
| ^
a.cc:35:18: error: template argument 2 is invalid
a.cc:72:21: error: 'tree_ptr' has not been declared
72 | void dfs(string& s, tree_ptr curr) {
| ^~~~~~~~
a.cc: In function 'void dfs(std::string&, int)':
a.cc:77:18: error: 'make_shared' was not declared in this scope
77 | auto c = make_shared<tree>();
| ^~~~~~~~~~~
a.cc:21:1: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
20 | #include <bitset>
+++ |+#include <memory>
21 |
a.cc:77:34: error: expected primary-expression before '>' token
77 | auto c = make_shared<tree>();
| ^
a.cc:77:36: error: expected primary-expression before ')' token
77 | auto c = make_shared<tree>();
| ^
a.cc:80:13: error: base operand of '->' is not a pointer
80 | curr->children.push_back(c);
| ^~
a.cc:85:18: error: 'make_shared' was not declared in this scope
85 | auto c = make_shared<tree>();
| ^~~~~~~~~~~
a.cc:85:18: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
a.cc:85:34: error: expected primary-expression before '>' token
85 | auto c = make_shared<tree>();
| ^
a.cc:85:36: error: expected primary-expression before ')' token
85 | auto c = make_shared<tree>();
| ^
a.cc:87:13: error: base operand of '->' is not a pointer
87 | curr->children.push_back(c);
| ^~
a.cc:93:11: error: base operand of '->' is not a pointer
93 | curr->s = read_s(s);
| ^~
a.cc: At global scope:
a.cc:102:6: error: variable or field 'visit' declared void
102 | void visit(tree_ptr curr, ll num) {
| ^~~~~
a.cc:102:12: error: 'tree_ptr' was not declared in this scope
102 | void visit(tree_ptr curr, ll num) {
| ^~~~~~~~
a.cc:102:30: error: expected primary-expression before 'num'
102 | void visit(tree_ptr curr, ll num) {
| ^~~
a.cc: In function 'char solve(std::string&, int)':
a.cc:119:15: error: 'make_shared' was not declared in this scope
119 | auto root = make_shared<tree>();
| ^~~~~~~~~~~
a.cc:119:15: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
a.cc:119:31: error: expected primary-expression before '>' token
119 | auto root = make_shared<tree>();
| ^
a.cc:119:33: error: expected primary-expression before ')' token
119 | auto root = make_shared<tree>();
| ^
a.cc:122:3: error: 'visit' was not declared in this scope
122 | visit(root, 1);
| ^~~~~
a.cc:21:1: note: 'std::visit' is defined in header '<variant>'; this is probably fixable by adding '#include <variant>'
20 | #include <bitset>
+++ |+#include <variant>
21 |
|
s092698260 | p00726 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;
string s;
int index;
int cur;
bool end;
string rec()
{
string res;
while(cur < s.size() && !end) {
while('A' <= s[cur] && s[cur] <= 'Z') {
res += s[cur];
cur++;
}
if('0' <= s[cur] && s[cur] <= '9') {
int n = s[cur++] - '0';
while('0' <= s[cur] && s[cur] <= '9') {
n = 10 * n + s[cur++] - '0';
}
string pattern;
if(s[cur] == '(') {
cur++;
pattern = rec();
} else {
pattern = s[cur++];
}
if(pattern.size() > index) {
res += pattern;
end = true;
break;
}
for(int i = 0; i < n; ++i) {
res += pattern;
}
}
if(s[cur] == ')') {
cur++;
return res;
}
}
return res;
}
int main()
{
while(true){
cin >> s >> index;
if(s == "0" && index == 0) break;
cur = 0;
end = false;
string res = rec();
//cout << res << endl;
if(res.size() <= index) {
cout << 0 << endl;
} else {
cout << res[index] << endl;
}
}
} | a.cc:9:5: warning: built-in function 'index' declared as non-function [-Wbuiltin-declaration-mismatch]
9 | int index;
| ^~~~~
a.cc: In function 'std::string rec()':
a.cc:18:30: error: reference to 'end' is ambiguous
18 | while(cur < s.size() && !end) {
| ^~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
In file included from /usr/include/c++/14/bits/range_access.h:36:
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:12:6: note: 'bool end'
12 | bool end;
| ^~~
a.cc:40:17: error: reference to 'end' is ambiguous
40 | end = true;
| ^~~
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:12:6: note: 'bool end'
12 | bool end;
| ^~~
a.cc: In function 'int main()':
a.cc:66:9: error: reference to 'end' is ambiguous
66 | end = false;
| ^~~
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:12:6: note: 'bool end'
12 | bool end;
| ^~~
|
s627026851 | p00726 | C++ | 1>------ ?????????????§?: ???????????§??????: 1145, ?§????: Debug Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(364,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
1>Source.cpp
1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
1>1145.vcxproj -> C:\Users\Owner\????????°??????\AOJ\1145\.\1145.exe
1>???????????§?????? "1145.vcxproj" ????????????????????????????????????
========== ?????????: 1 ??£????????????0 ??±??????0 ??´??°?????????0 ???????????? ========== | a.cc:1:23: error: extended character § is not valid in an identifier
1 | 1>------ ?????????????§?: ???????????§??????: 1145, ?§????: Debug Win32 ------
| ^
a.cc:1:38: error: extended character § is not valid in an identifier
1 | 1>------ ?????????????§?: ???????????§??????: 1145, ?§????: Debug Win32 ------
| ^
a.cc:1:54: error: extended character § is not valid in an identifier
1 | 1>------ ?????????????§?: ???????????§??????: 1145, ?§????: Debug Win32 ------
| ^
a.cc:2:5: error: stray '\' in program
2 | 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(364,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
| ^
a.cc:2:25: error: stray '\' in program
2 | 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(364,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
| ^
a.cc:2:33: error: stray '\' in program
2 | 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(364,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
| ^
a.cc:2:47: error: stray '\' in program
2 | 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(364,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
| ^
a.cc:2:52: error: stray '\' in program
2 | 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(364,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
| ^
a.cc:2:57: error: stray '\' in program
2 | 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(364,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
| ^
a.cc:4:5: error: stray '\' in program
4 | 1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
| ^
a.cc:4:11: error: stray '\' in program
4 | 1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
| ^
a.cc:4:17: error: stray '\' in program
4 | 1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
| ^
a.cc:4:26: error: extended character ° is not valid in an identifier
4 | 1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
| ^
a.cc:4:33: error: stray '\' in program
4 | 1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
| ^
a.cc:4:37: error: stray '\' in program
4 | 1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
| ^
a.cc:4:42: error: stray '\' in program
4 | 1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
| ^
a.cc:4:74: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes
4 | 1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
| ^~~~~~~~
a.cc:4:85: warning: multi-character character constant [-Wmultichar]
4 | 1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
| ^~~~
a.cc:4:97: warning: multi-character literal with 12 characters exceeds 'int' size of 4 bytes
4 | 1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
| ^~~~~~~~~~~~~~
a.cc:4:126: error: extended character § is not valid in an identifier
4 | 1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
| ^
a.cc:4:147: error: extended character ± is not valid in an identifier
4 | 1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
| ^
a.cc:4:165: error: extended character § is not valid in an identifier
4 | 1>c:\users\owner\????????°??????\aoj\1145\source.cpp(93): warning C4244: '?????°' : 'll' ?????? 'unsigned int' ??????????????§????????????????????±?????????????????§??????????????????
| ^
a.cc:5:21: error: stray '\' in program
5 | 1>1145.vcxproj -> C:\Users\Owner\????????°??????\AOJ\1145\.\1145.exe
| ^
a.cc:5:27: error: stray '\' in program
5 | 1>1145.vcxproj -> C:\Users\Owner\????????°??????\AOJ\1145\.\1145.exe
| ^
a.cc:5:33: error: stray '\' in program
5 | 1>1145.vcxproj -> C:\Users\Owner\????????°??????\AOJ\1145\.\1145.exe
| ^
a.cc:5:42: error: extended character ° is not valid in an identifier
5 | 1>1145.vcxproj -> C:\Users\Owner\????????°??????\AOJ\1145\.\1145.exe
| ^
a.cc:5:49: error: stray '\' in program
5 | 1>1145.vcxproj -> C:\Users\Owner\????????°??????\AOJ\1145\.\1145.exe
| ^
a.cc:5:53: error: stray '\' in program
5 | 1>1145.vcxproj -> C:\Users\Owner\????????°??????\AOJ\1145\.\1145.exe
| ^
a.cc:5:58: error: stray '\' in program
5 | 1>1145.vcxproj -> C:\Users\Owner\????????°??????\AOJ\1145\.\1145.exe
| ^
a.cc:5:60: error: stray '\' in program
5 | 1>1145.vcxproj -> C:\Users\Owner\????????°??????\AOJ\1145\.\1145.exe
| ^
a.cc:5:61: error: exponent has no digits
5 | 1>1145.vcxproj -> C:\Users\Owner\????????°??????\AOJ\1145\.\1145.exe
| ^~~~~~~~
a.cc:6:14: error: extended character § is not valid in an identifier
6 | 1>???????????§?????? "1145.vcxproj" ????????????????????????????????????
| ^
a.cc:7:27: error: extended character £ is not valid in an identifier
7 | ========== ?????????: 1 ??£????????????0 ??±??????0 ??´??°?????????0 ???????????? ==========
| ^
a.cc:7:44: error: extended character ± is not valid in an identifier
7 | ========== ?????????: 1 ??£????????????0 ??±??????0 ??´??°?????????0 ???????????? ==========
| ^
a.cc:7:58: error: extended character ° is not valid in an identifier
7 | ========== ?????????: 1 ??£????????????0 ??±??????0 ??´??°?????????0 ???????????? ==========
| ^
a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 1>------ ?????????????§?: ???????????§??????: 1145, ?§????: Debug Win32 ------
| ^
|
s464226476 | p00726 | C++ | string in;
int p;
void next(int& p){
++p;
while(p<SZ(in) && in[p]!=')'){
if(in[p]=='(')next(p);
else ++p;
}
++p;
}
ll get(int po,int re){
ll le=0;
if(in[po]!='(')return 1;
++po;
while(po<SZ(in) && in[po]!=')'){
if(isdigit(in[po])){
ll t=0;
while(isdigit(in[po]))t=t*10+in[po++]-'0';
ll cle=get(po,re);
if(cle==-1)return -1;
le+=cle*t;
if(in[po]=='(')next(po);
else ++po;
}else{
++le;
++po;
}
if(le>re)return -1;
}
return le;
}
char rec(int po,int re){
while(po<SZ(in)){
//cout<<po<<' '<<re<<endl;
if(isdigit(in[po])){
ll t=0;
while(isdigit(in[po]))t=t*10+in[po++]-'0';
ll len=get(po,re);
//cout<<len<<endl;
int de=0;
if(in[po]=='(')++de;
if(len==-1)return rec(po+de,re);
else if(re<t*len)return rec(po+de,re%len);
re-=t*len;
//cout<<re<<endl;
if(de)next(po);
else ++po;
}else{
if(re==0)return in[po];
++po;
--re;
}
}
++po;
return '0';
}
main(){
while(cin>>in>>p,in!="0")
cout<<rec(0,p)<<endl;
} | a.cc:1:1: error: 'string' does not name a type
1 | string in;
| ^~~~~~
a.cc: In function 'void next(int&)':
a.cc:6:14: error: 'in' was not declared in this scope; did you mean 'int'?
6 | while(p<SZ(in) && in[p]!=')'){
| ^~
| int
a.cc:6:11: error: 'SZ' was not declared in this scope
6 | while(p<SZ(in) && in[p]!=')'){
| ^~
a.cc: At global scope:
a.cc:13:1: error: 'll' does not name a type
13 | ll get(int po,int re){
| ^~
a.cc: In function 'char rec(int, int)':
a.cc:36:15: error: 'in' was not declared in this scope; did you mean 'int'?
36 | while(po<SZ(in)){
| ^~
| int
a.cc:36:12: error: 'SZ' was not declared in this scope
36 | while(po<SZ(in)){
| ^~
a.cc:38:8: error: 'isdigit' was not declared in this scope
38 | if(isdigit(in[po])){
| ^~~~~~~
a.cc:39:7: error: 'll' was not declared in this scope
39 | ll t=0;
| ^~
a.cc:40:29: error: 't' was not declared in this scope
40 | while(isdigit(in[po]))t=t*10+in[po++]-'0';
| ^
a.cc:41:9: error: expected ';' before 'len'
41 | ll len=get(po,re);
| ^~~~
| ;
a.cc:45:10: error: 'len' was not declared in this scope
45 | if(len==-1)return rec(po+de,re);
| ^~~
a.cc:46:18: error: 't' was not declared in this scope
46 | else if(re<t*len)return rec(po+de,re%len);
| ^
a.cc:47:11: error: 't' was not declared in this scope
47 | re-=t*len;
| ^
a.cc:47:13: error: 'len' was not declared in this scope
47 | re-=t*len;
| ^~~
a.cc: At global scope:
a.cc:63:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
63 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:64:9: error: 'cin' was not declared in this scope
64 | while(cin>>in>>p,in!="0")
| ^~~
a.cc:64:14: error: 'in' was not declared in this scope; did you mean 'int'?
64 | while(cin>>in>>p,in!="0")
| ^~
| int
a.cc:65:5: error: 'cout' was not declared in this scope
65 | cout<<rec(0,p)<<endl;
| ^~~~
a.cc:65:21: error: 'endl' was not declared in this scope
65 | cout<<rec(0,p)<<endl;
| ^~~~
|
s583415214 | p00726 | C++ | #include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int pos,n;#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int pos,n;
string s,t,p;
string f();
string expr(){
string a=f();
while(isdigit(s[pos])||isalpha(s[pos])){
if(a.size()>n)
break;
a+=f();
}
return a;
}
string f(){
t="";
if(isdigit(s[pos])){
int ret=0,i=0;
for(;isdigit(s[pos]);pos++){
ret*=10;
ret+=s[pos]-'0';
}
p=f();
for(;i<ret;i++){
t+=p;
if(t.size()>n)
break;
}
}else if(s[pos]=='('){
pos++;
t=expr();
pos++;
}else{
for(;isalpha(s[pos]);pos++){
t+=s[pos];
if(t.size()>n)
break;
}
}
return t;
}
int main(){
while(cin>>s>>n,s!="0"||n){
pos=0;
s+="#";
string t=expr();
if(t.size()-1<n)
cout<<0<<endl;
else
cout<<t[n]<<endl;
}
return 0;
}
string s;
string f();
string expr(){
string a=f();
while(isdigit(s[pos])||isalpha(s[pos])){
if(a.size()>n)
return a;
a+=f();
}
return a;
}
string f(){
string t;
if(isdigit(s[pos])){
int ret=0;
for(;isdigit(s[pos]);pos++){
ret*=10;
ret+=s[pos]-'0';
}
t="";
string p=f();
for(int i=0;i<ret;i++){
t+=p;
if(t.size()>n)
return t;
}
}else if(s[pos]=='('){
pos++;
t=expr();
pos++;
}else{
t="";
for(;isalpha(s[pos]);pos++){
t+=s[pos];
if(t.size()>n)
return t;
}
}
return t;
}
int main(){
while(cin>>s>>n,s!="0"||n){
pos=0;
s+="#";
string t=expr();
if(t.size()-1<n)
cout<<0<<endl;
else
cout<<t[n]<<endl;
}
return 0;
} | a.cc:5:11: error: stray '#' in program
5 | int pos,n;#include<iostream>
| ^
a.cc:5:12: error: 'include' does not name a type
5 | int pos,n;#include<iostream>
| ^~~~~~~
a.cc:9:5: error: redefinition of 'int pos'
9 | int pos,n;
| ^~~
a.cc:5:5: note: 'int pos' previously declared here
5 | int pos,n;#include<iostream>
| ^~~
a.cc:9:9: error: redefinition of 'int n'
9 | int pos,n;
| ^
a.cc:5:9: note: 'int n' previously declared here
5 | int pos,n;#include<iostream>
| ^
a.cc:60:8: error: redefinition of 'std::string s'
60 | string s;
| ^
a.cc:10:8: note: 'std::string s' previously declared here
10 | string s,t,p;
| ^
a.cc:62:8: error: redefinition of 'std::string expr()'
62 | string expr(){
| ^~~~
a.cc:12:8: note: 'std::string expr()' previously defined here
12 | string expr(){
| ^~~~
a.cc:71:8: error: redefinition of 'std::string f()'
71 | string f(){
| ^
a.cc:21:8: note: 'std::string f()' previously defined here
21 | string f(){
| ^
a.cc:101:5: error: redefinition of 'int main()'
101 | int main(){
| ^~~~
a.cc:48:5: note: 'int main()' previously defined here
48 | int main(){
| ^~~~
|
s887588833 | p00726 | C++ | #include<iostream>
#include<sstream>
#include<cmath>
using namespace std;
class Parsing
{
private:
string parse;
int pos;
int size;
int x;
public:
Parsing(string parse,int x):parse(parse),pos(0),x(x),size(0){}
int StringToInt(string v)
{
int ret = 0;
for(int i=0;i<v.size();i++)
ret += (v[i]-'0')*(int)pow(10.0,v.size()-i-1);
return ret;
}
string getCnt()
{
string v;
while('0' <= parse[pos] && parse[pos] <= '9')
v += parse[pos++];
return v;
}
int getCntInt(){return StringToInt(getCnt());}
string decode()
{
int power = getCntInt();
if(parse[pos] == '(')
pos++;
else
{
string mes,ret;
while('A' <= parse[pos] && parse[pos] <= 'Z')
mes += parse[pos++];
for(int i=0;i<power;i++)
{
ret += mes;
if(ret.size() >= x)
break;
}
return ret;
}
string message;
while(('0' <= parse[pos] && parse[pos] <= '9') || ('A' <= parse[pos] && parse[pos] <= 'Z') )
{
if('0' <= parse[pos] && parse[pos] <= '9')
message += decode();
else if('A' <= parse[pos] && parse[pos] <= 'Z')
message += parse[pos++];
}
if(parse[pos] == ')')
pos++;
string ret;
for(int i=0;i<power;i++)
{
ret += message,size += message.size();
if(ret.size() >= x)
break;
}
return ret;
}
string exp()
{
string ret;
for(;pos<parse.size();)
{
if('0' <= parse[pos] && parse[pos] <= '9')
ret += decode();
else
ret += parse[pos++],size++;
if(ret.size() >= x)
break;
}
return ret;
}
int getSize()
{
return size;
}
};
int main()
{
string Genome;
int pos;
while(cin >> Genome >> pos, Genome != "0" || pos != 0)
{
Parsing par = Parsing(Genome,pos+1);
string message = par.exp();
if(message.size() <= pos)
cout << 0 << endl
else
cout << message[pos] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:107:26: error: expected ';' before 'else'
107 | cout << 0 << endl
| ^
| ;
108 | else
| ~~~~
|
s455883306 | p00726 | C++ | #include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define rep(i,a) for(int i = 0;i < a; i++)
using namespace std;
struct expr;
struct term
{
bool flg;
string str;
int n;
expr *inner;
term(bool flg, string str, int n, expr *inner);
int length();
char charAt(int pos);
};
ostream& operator <<(ostream& out, expr e);
ostream& operator <<(ostream& out, term t)
{
if (t.flg)
out << *t.inner << ' ' << t.n << " times" << endl;
else
out << t.str << endl;
return out;
}
struct expr
{
vector<term> inner;
expr(vector<term> inner) : inner(inner) {}
int length() {
int ret = 0;
for (int i = 0; i < inner.size(); ++i)
ret += inner[i].length();
return ret;
}
char charAt(int pos) {
int cur = 0;
for (int i = 0; i < inner.size(); ++i) {
int next = cur + inner[i].length();
if (pos < next)
return inner[i].charAt(pos - cur);
cur = next;
}
return '0';
}
};
ostream& operator <<(ostream& out, expr e)
{
out << "expr {";
for (int i = 0; i < e.inner.size(); ++i)
out << e.inner[i] << endl;
return out << '}';
}
term::term(bool flg, string str, int n, expr *inner)
: flg(flg), str(str), n(n), inner(inner) {}
int term::length() {
return flg ? min((long long) n * inner->length(), 100000000LL) : str.length();
}
char term::charAt(int pos) {
return flg ? inner->charAt(pos % inner->length()) : str[pos];
}
int parsenum(string s, int pos, int& next)
{
int ret = 0;
while ('0' <= s[pos] && s[pos] <= '9') {
ret *= 10;
ret += s[pos] & 15;
++pos;
}
next = pos;
return ret;
}
expr *parseexpr(string s, int pos, int& next);
term parseterm(string s, int pos, int& next)
{
if ('0' <= s[pos] && s[pos] <= '9') {
int n = parsenum(s, pos, next);
if (s[next] == '(') {
expr *inner = parseexpr(s, next + 1, next);
++next;
return term(true, "", n, inner);
} else {
string str;
str.push_back(s[next]);
vector<term> inner;
inner.push_back(term(false, str, 0, NULL));
++next;
return term(true, "", n, new expr(inner));
}
} else {
string ret;
while ('A' <= s[pos] && s[pos] <= 'Z') {
ret.push_back(s[pos]);
++pos;
}
next = pos;
return term(false, ret, 0, NULL);
}
}
expr *parseexpr(string s, int pos, int& next)
{
vector<term> ret;
while (pos < s.length() && s[pos] != ')') {
term inner = parseterm(s, pos, next);
ret.push_back(inner);
pos = next;
}
return new expr(ret);
}
void solve(string s, int i)
{
int dummy;
expr *e = parseexpr(s, 0, dummy);
cout << e->charAt(i) << endl;
}
int main()
{
string s;
int i;
while (cin >> s >> i && s[0] != '0')
solve(s, i);
return 0;
} | a.cc: In function 'std::ostream& operator<<(std::ostream&, term)':
a.cc:30:12: error: invalid use of incomplete type 'struct expr'
30 | out << *t.inner << ' ' << t.n << " times" << endl;
| ^~~~~~~~
a.cc:11:8: note: forward declaration of 'struct expr'
11 | struct expr;
| ^~~~
a.cc:25:41: note: initializing argument 2 of 'std::ostream& operator<<(std::ostream&, expr)'
25 | ostream& operator <<(ostream& out, expr e);
| ~~~~~^
|
s797578505 | p00727 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
extern "C" {
#include "quadmath.h"
}
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
typedef __float128 D;
const D PI = acosq(-1);
int n;
D x[100], y[100];
D solve(D theta) {
vector<D> xx;
rep (i, n) xx.push_back(x[i] * sinq(theta) + y[i] * cosq(theta));
sort(xx.begin(), xx.end());
D res = 2;
rep (i, xx.size() - 1) res += min((D)2, xx[i + 1] - xx[i]);
return res;
}
int main() {
while (true) {
cin >> n;
if (n == 0) break;
rep (i, n) {
//char xs[80], ys[80];
string xs, ys;
cin >> xs >> ys;
x[i] = strtoflt128(xs.c_str(), NULL);
y[i] = strtoflt128(ys.c_str(), NULL);
}
vector<D> t;
t.push_back(PI);
t.push_back(0);
rep (i, n) rep (j, i) {
D t1 = -atan2q(y[i] - y[j], x[i] - y[j]);
D dt = asinq((D)2 / sqrtq(powq(x[i] - x[j], 2) + powq(y[i] - y[j], 2)));
t.push_back(t1);
t.push_back(t1 + dt);
t.push_back(t1 - dt);
}
rep (i, t.size()) while (t[i] < 0) t[i] += PI;
rep (i, t.size()) while (t[i] > PI) t[i] -= PI;
sort(t.begin(), t.end());
//rep (i, t.size()) cerr << t[i] << endl;
D ans = 0, r = 1e9;
rep (i, t.size() - 1) {
D lower = t[i];
D upper = t[i + 1];
rep (_, 100) {
D mid1 = lower * 2 / 3 + upper / 3;
D mid2 = lower / 3 + upper * 2 / 3;
D s1 = solve(mid1);
D s2 = solve(mid2);
if (s1 > s2) lower = mid1;
else upper = mid2;
if (r > s1) {
ans = mid1;
r = s1;
}
if (r > s2) {
ans = mid2;
r = s2;
}
}
}
char c[256];
quadmath_snprintf(c, 256, "%.15Qf", ans);
puts(c);
ans = 0, r = 0;
rep (i, t.size() - 1) {
D lower = t[i];
D upper = t[i + 1];
rep (_, 100) {
D mid1 = lower * 2 / 3 + upper / 3;
D mid2 = lower / 3 + upper * 2 / 3;
D s1 = solve(mid1);
D s2 = solve(mid2);
if (s1 > s2) upper = mid2;
else lower = mid1;
if (r < s1) {
ans = mid1;
r = s1;
}
if (r < s2) {
ans = mid2;
r = s2;
}
}
}
quadmath_snprintf(c, 256, "%.15Qf", ans);
puts(c);
}
} | /usr/bin/ld: /tmp/cc5tPzzA.o: in function `solve(__float128)':
a.cc:(.text+0x56): undefined reference to `sinq'
/usr/bin/ld: a.cc:(.text+0x9a): undefined reference to `cosq'
/usr/bin/ld: /tmp/cc5tPzzA.o: in function `main':
a.cc:(.text+0x2d2): undefined reference to `strtoflt128'
/usr/bin/ld: a.cc:(.text+0x305): undefined reference to `strtoflt128'
/usr/bin/ld: a.cc:(.text+0x42f): undefined reference to `atan2q'
/usr/bin/ld: a.cc:(.text+0x490): undefined reference to `powq'
/usr/bin/ld: a.cc:(.text+0x4e5): undefined reference to `powq'
/usr/bin/ld: a.cc:(.text+0x4fb): undefined reference to `sqrtq'
/usr/bin/ld: a.cc:(.text+0x511): undefined reference to `asinq'
/usr/bin/ld: a.cc:(.text+0x929): undefined reference to `quadmath_snprintf'
/usr/bin/ld: a.cc:(.text+0xb7c): undefined reference to `quadmath_snprintf'
/usr/bin/ld: /tmp/cc5tPzzA.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0xbff): undefined reference to `acosq'
collect2: error: ld returned 1 exit status
|
s976445091 | p00727 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
extern "C" {
#include "quadmath.h"
}
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
typedef __float128 D;
const D PI = acosq(-1);
int n;
D x[100], y[100];
D solve(D theta) {
vector<D> xx;
rep (i, n) xx.push_back(x[i] * sinq(theta) + y[i] * cosq(theta));
sort(xx.begin(), xx.end());
D res = 2;
rep (i, xx.size() - 1) res += min((D)2, xx[i + 1] - xx[i]);
return res;
}
int main() {
while (true) {
cin >> n;
if (n == 0) break;
rep (i, n) {
//char xs[80], ys[80];
string xs, ys;
cin >> xs >> ys;
x[i] = strtoflt128(xs.c_str(), NULL);
y[i] = strtoflt128(ys.c_str(), NULL);
}
vector<D> t;
t.push_back(PI);
t.push_back(0);
rep (i, n) rep (j, i) {
D t1 = -atan2q(y[i] - y[j], x[i] - y[j]);
D dt = asinq((D)2 / sqrtq(powq(x[i] - x[j], 2) + powq(y[i] - y[j], 2)));
t.push_back(t1);
t.push_back(t1 + dt);
t.push_back(t1 - dt);
}
rep (i, t.size()) while (t[i] < 0) t[i] += PI;
rep (i, t.size()) while (t[i] > PI) t[i] -= PI;
sort(t.begin(), t.end());
//rep (i, t.size()) cerr << t[i] << endl;
D ans = 0, r = 1e9;
rep (i, t.size() - 1) {
D lower = t[i];
D upper = t[i + 1];
rep (_, 100) {
D mid1 = lower * 2 / 3 + upper / 3;
D mid2 = lower / 3 + upper * 2 / 3;
D s1 = solve(mid1);
D s2 = solve(mid2);
if (s1 > s2) lower = mid1;
else upper = mid2;
if (r > s1) {
ans = mid1;
r = s1;
}
if (r > s2) {
ans = mid2;
r = s2;
}
}
}
char c[256];
quadmath_snprintf(c, 256, "%.15Qf", ans);
puts(c);
ans = 0, r = 0;
rep (i, t.size() - 1) {
D lower = t[i];
D upper = t[i + 1];
rep (_, 100) {
D mid1 = lower * 2 / 3 + upper / 3;
D mid2 = lower / 3 + upper * 2 / 3;
D s1 = solve(mid1);
D s2 = solve(mid2);
if (s1 > s2) upper = mid2;
else lower = mid1;
if (r < s1) {
ans = mid1;
r = s1;
}
if (r < s2) {
ans = mid2;
r = s2;
}
}
}
quadmath_snprintf(c, 256, "%.15Qf", ans);
puts(c);
}
} | /usr/bin/ld: /tmp/ccJSjzox.o: in function `solve(__float128)':
a.cc:(.text+0x56): undefined reference to `sinq'
/usr/bin/ld: a.cc:(.text+0x9a): undefined reference to `cosq'
/usr/bin/ld: /tmp/ccJSjzox.o: in function `main':
a.cc:(.text+0x2d2): undefined reference to `strtoflt128'
/usr/bin/ld: a.cc:(.text+0x305): undefined reference to `strtoflt128'
/usr/bin/ld: a.cc:(.text+0x42f): undefined reference to `atan2q'
/usr/bin/ld: a.cc:(.text+0x490): undefined reference to `powq'
/usr/bin/ld: a.cc:(.text+0x4e5): undefined reference to `powq'
/usr/bin/ld: a.cc:(.text+0x4fb): undefined reference to `sqrtq'
/usr/bin/ld: a.cc:(.text+0x511): undefined reference to `asinq'
/usr/bin/ld: a.cc:(.text+0x929): undefined reference to `quadmath_snprintf'
/usr/bin/ld: a.cc:(.text+0xb7c): undefined reference to `quadmath_snprintf'
/usr/bin/ld: /tmp/ccJSjzox.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0xbff): undefined reference to `acosq'
collect2: error: ld returned 1 exit status
|
s665478211 | p00728 | Java | import java.util.*;
class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
while(true){
int a = sc.nextInt();
if(a == 0){break;}
int total = 0;
int syo = 1000;
int dai = 0;
for(int n = 0; n < a; n++){
int tmp = sc.nextInt();
total = total + tmp;
if(tmp < syo){
syo = tmp;
}else if(tmp > dai){
dai = tmp;
}
}
System.out.println(heikin);
}
}
}
| Main.java:21: error: cannot find symbol
System.out.println(heikin);
^
symbol: variable heikin
location: class Main
1 error
|
s919035455 | p00728 | Java | import java.util.*;
/**
* ICPCScoreTotalizerSoftware
*/
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int n = sc.nextInt();
if (n == 0)
break;
List<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < n; i++) {
int num = sc.nextInt();
list.add(num);
}
Collections.sort(list);
list.remove(0);
list.remove(list.size() - 1);
// 最初と最後をカットして平均切り捨てしゅつりょく
int ans = 0;
for (int i : list) {
ans += i;
}
System.out.println(ans / list.size());
}
}
}
| Main.java:6: error: illegal character: '\u3000'
public class?Main {
^
1 error
|
s692797959 | p00728 | Java | import java;
public class Main{
public static void main(String[] args){
int n;
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
if(n==0){
exit(1);
}
int[] s;
int i=0;
int max=0;
int min=1000;
while(i<n){
s[i]=sc.nextInt();
if(s[i]>max){
max=s[i];
}
if(s[i]<min){
min=s[i];
}
i++;
}
int sum=0;
i=0;
int c=0;
int c2=0;
while(i<n){
if(s[i]!=min && s[i]!=max){
sum+=s[i];
}else if(s[i]==max){
c++;
}else if(s[i]==min){
c2++;
}
i++;
}
sum+=max*(c-1);
sum+=min*(c2-1);
int average=0;
average=sum/(n-2);
SyStem.out.println(agerage);
}
}
| Main.java:1: error: '.' expected
import java;
^
1 error
|
s179917035 | p00728 | Java | import java.util;
public class Main{
public static void main(String[] args){
int n;
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
if(n==0){
exit(1);
}
int[] s;
int i=0;
int max=0;
int min=1000;
while(i<n){
s[i]=sc.nextInt();
if(s[i]>max){
max=s[i];
}
if(s[i]<min){
min=s[i];
}
i++;
}
int sum=0;
i=0;
int c=0;
int c2=0;
while(i<n){
if(s[i]!=min && s[i]!=max){
sum+=s[i];
}else if(s[i]==max){
c++;
}else if(s[i]==min){
c2++;
}
i++;
}
sum+=max*(c-1);
sum+=min*(c2-1);
int average=0;
average=sum/(n-2);
SyStem.out.println(agerage);
}
}
| Main.java:1: error: cannot find symbol
import java.util;
^
symbol: class util
location: package java
Main.java:5: error: cannot find symbol
Scanner sc =new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:5: error: cannot find symbol
Scanner sc =new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:8: error: cannot find symbol
exit(1);
^
symbol: method exit(int)
location: class Main
Main.java:42: error: cannot find symbol
SyStem.out.println(agerage);
^
symbol: variable agerage
location: class Main
Main.java:42: error: package SyStem does not exist
SyStem.out.println(agerage);
^
6 errors
|
s352593968 | p00728 | Java | import java.util;
public class Main{
public static void main(String[] args){
int n;
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
if(n==0){
exit(1);
}
int[] s;
int i=0;
int max=0;
int min=1000;
while(i<n){
s[i]=sc.nextInt();
if(s[i]>max){
max=s[i];
}
else if(s[i]<min){
min=s[i];
}
i++;
}
int sum=0;
i=0;
int c=0;
int c2=0;
while(i<n){
if(s[i]!=min && s[i]!=max){
sum+=s[i];
}else if(s[i]==max){
c++;
}else if(s[i]==min){
c2++;
}
i++;
}
sum+=max*(c-1);
sum+=min*(c2-1);
int average=0;
average=sum/(n-2);
SyStem.out.println(agerage);
}
}
| Main.java:1: error: cannot find symbol
import java.util;
^
symbol: class util
location: package java
Main.java:5: error: cannot find symbol
Scanner sc =new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:5: error: cannot find symbol
Scanner sc =new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:8: error: cannot find symbol
exit(1);
^
symbol: method exit(int)
location: class Main
Main.java:42: error: cannot find symbol
SyStem.out.println(agerage);
^
symbol: variable agerage
location: class Main
Main.java:42: error: package SyStem does not exist
SyStem.out.println(agerage);
^
6 errors
|
s261503351 | p00728 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
int n;
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
if(n==0){
exit(1);
}
int[] s;
int i=0;
int max=0;
int min=1000;
while(i<n){
s[i]=sc.nextInt();
if(s[i]>max){
max=s[i];
}
else if(s[i]<min){
min=s[i];
}
i++;
}
int sum=0;
i=0;
int c=0;
int c2=0;
while(i<n){
if(s[i]!=min && s[i]!=max){
sum+=s[i];
}else if(s[i]==max){
c++;
}else if(s[i]==min){
c2++;
}
i++;
}
sum+=max*(c-1);
sum+=min*(c2-1);
int average=0;
average=sum/(n-2);
SyStem.out.println(agerage);
}
}
| Main.java:8: error: cannot find symbol
exit(1);
^
symbol: method exit(int)
location: class Main
Main.java:42: error: cannot find symbol
SyStem.out.println(agerage);
^
symbol: variable agerage
location: class Main
Main.java:42: error: package SyStem does not exist
SyStem.out.println(agerage);
^
3 errors
|
s964394253 | p00728 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
int n;
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
if(n==0){
System.exit(0);
}
int[] s;
int i=0;
int max=0;
int min=1000;
while(i<n){
s[i]=sc.nextInt();
if(s[i]>max){
max=s[i];
}
else if(s[i]<min){
min=s[i];
}
i++;
}
int sum=0;
i=0;
int c=0;
int c2=0;
while(i<n){
if(s[i]!=min && s[i]!=max){
sum+=s[i];
}else if(s[i]==max){
c++;
}else if(s[i]==min){
c2++;
}
i++;
}
sum+=max*(c-1);
sum+=min*(c2-1);
int average=0;
average=sum/(n-2);
SyStem.out.println(agerage);
}
}
| Main.java:42: error: cannot find symbol
SyStem.out.println(agerage);
^
symbol: variable agerage
location: class Main
Main.java:42: error: package SyStem does not exist
SyStem.out.println(agerage);
^
2 errors
|
s382849756 | p00728 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
while(ture){
int n;
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
if(n==0){
System.exit(0);
}
int[] s;
int i=0;
int max=0;
int min=1000;
while(i<n){
s[i]=sc.nextInt();
if(s[i]>max){
max=s[i];
}
else if(s[i]<min){
min=s[i];
}
i++;
}
int sum=0;
i=0;
int c=0;
int c2=0;
while(i<n){
if(s[i]!=min && s[i]!=max){
sum+=s[i];
}else if(s[i]==max){
c++;
}else if(s[i]==min){
c2++;
}
i++;
}
sum+=max*(c-1);
sum+=min*(c2-1);
int average=0;
average=sum/(n-2);
SyStem.out.println(average);
}
}
}
| Main.java:4: error: cannot find symbol
while(ture){
^
symbol: variable ture
location: class Main
Main.java:43: error: package SyStem does not exist
SyStem.out.println(average);
^
2 errors
|
s351112581 | p00728 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
while(true){
int n;
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
if(n==0){
System.exit(0);
}
int[] s;
int i=0;
int max=0;
int min=1000;
while(i<n){
s[i]=sc.nextInt();
if(s[i]>max){
max=s[i];
}
else if(s[i]<min){
min=s[i];
}
i++;
}
int sum=0;
i=0;
int c=0;
int c2=0;
while(i<n){
if(s[i]!=min && s[i]!=max){
sum+=s[i];
}else if(s[i]==max){
c++;
}else if(s[i]==min){
c2++;
}
i++;
}
sum+=max*(c-1);
sum+=min*(c2-1);
int average=0;
average=sum/(n-2);
SyStem.out.println(average);
}
}
}
| Main.java:43: error: package SyStem does not exist
SyStem.out.println(average);
^
1 error
|
s688300477 | p00728 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
while(true){
int n;
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
System.out.println(n);
if(n==0){
System.exit(0);
}
int[] s;
int i=0;
int max=0;
int min=1000;
while(i<n){
s[i]=sc.nextInt();
if(s[i]>max){
max=s[i];
}
else if(s[i]<min){
min=s[i];
}
i++;
}
int sum=0;
i=0;
int c=0;
int c2=0;
while(i<n){
if(s[i]!=min && s[i]!=max){
sum+=s[i];
}else if(s[i]==max){
c++;
}else if(s[i]==min){
c2++;
}
i++;
}
sum+=max*(c-1);
sum+=min*(c2-1);
int average=0;
average=sum/(n-2);
SyStem.out.println(average);
}
}
}
| Main.java:44: error: package SyStem does not exist
SyStem.out.println(average);
^
1 error
|
s962277809 | p00728 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
while(true){
int n;
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
System.out.println(n);
if(n==0){
System.exit(0);
}
int[] s;
int i=0;
int max=0;
int min=1000;
while(i<n){
s[i]=sc.nextInt();
if(s[i]>max){
max=s[i];
}
else if(s[i]<min){
min=s[i];
}
i++;
}
int sum=0;
i=0;
int c=0;
int c2=0;
while(i<n){
if(s[i]!=min && s[i]!=max){
sum+=s[i];
}else if(s[i]==max){
c++;
}else if(s[i]==min){
c2++;
}
i++;
}
sum+=max*(c-1);
sum+=min*(c2-1);
int average=0;
average=sum/(n-2);
System.out.println(average);
}
}
}
| Main.java:17: error: variable s might not have been initialized
s[i]=sc.nextInt();
^
Main.java:31: error: variable s might not have been initialized
if(s[i]!=min && s[i]!=max){
^
2 errors
|
s705307968 | p00728 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
while(true){
int n;
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
if(n==0){
System.exit(0);
}
int[] s;
int i=0;
s=new int[n];
int max=0;
int min=999;
while(i<n){
s[i]=sc.nextInt();
}
Arrays.sort(s);
i=1;
while(i<n-1){
sum+=s[i];
}
SyStem.out.println(sum/(n-2));
}
}
}
| Main.java:22: error: cannot find symbol
sum+=s[i];
^
symbol: variable sum
location: class Main
Main.java:24: error: cannot find symbol
SyStem.out.println(sum/(n-2));
^
symbol: variable sum
location: class Main
Main.java:24: error: package SyStem does not exist
SyStem.out.println(sum/(n-2));
^
3 errors
|
s444081490 | p00728 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
while(true){
int n;
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
if(n==0){
System.exit(0);
}
int[] s;
int i=0;
s=new int[n];
int max=0;
int min=999;
while(i<n){
s[i]=sc.nextInt();
i++;
}
Arrays.sort(s);
i=1;
while(i<n-1){
sum+=s[i];
i++;
}
SyStem.out.println(sum/(n-2));
}
}
}
| Main.java:23: error: cannot find symbol
sum+=s[i];
^
symbol: variable sum
location: class Main
Main.java:26: error: cannot find symbol
SyStem.out.println(sum/(n-2));
^
symbol: variable sum
location: class Main
Main.java:26: error: package SyStem does not exist
SyStem.out.println(sum/(n-2));
^
3 errors
|
s007549279 | p00728 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
while(true){
int n;
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
if(n==0){
System.exit(0);
}
int[] s;
int i=0;
s=new int[n];
int max=0;
int min=999;
while(i<n){
s[i]=sc.nextInt();
i++;
}
Arrays.sort(s);
i=1;
int sum=0;
while(i<n-1){
sum+=s[i];
i++;
}
SyStem.out.println(sum/(n-2));
}
}
}
| Main.java:27: error: package SyStem does not exist
SyStem.out.println(sum/(n-2));
^
1 error
|
s105358687 | p00728 | Java | import java.util.Scanner;
public class Main{
public static void main(String[] args){
while(true){
int n;
Scanner sc =new Scanner(System.in);
n = sc.nextInt();
if(n==0){
System.exit(0);
}
int[] s;
int i=0;
s=new int[n];
while(i<n){
s[i]=sc.nextInt();
i++;
}
Arrays.sort(s);
i=1;
int sum=0;
while(i<n-1){
sum+=s[i];
i++;
}
System.out.println(sum/(n-2));
}
}
}
| Main.java:18: error: cannot find symbol
Arrays.sort(s);
^
symbol: variable Arrays
location: class Main
1 error
|
s427927493 | p00728 | Java | import java.util.Arrays;
import java.util.Scanner;
public class Main {
/**
* @param args
*/
Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
// TODO Auto-generated method stub
new Main().run();
}
void run() {
while (true) {
int n = sc.nextInt();
if (n == 0)
break;
int ss[] = new int[n];
for (int i = 0; i < n; i++) {
ss[i] = sc.nextInt();
}
Arrays.sort(ss);
int sum = 0;
for (int i = 1; i <= n - 2; i++) {
sum += ss[i];
}
System.out.println(sum / (n - 2));
}
}
}
import java.util.Arrays;
import java.util.Scanner;
public class Main {
/**
* @param args
*/
Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
// TODO Auto-generated method stub
new Main().run();
}
void run() {
while (true) {
int n = sc.nextInt();
if (n == 0)
break;
int ss[] = new int[n];
for (int i = 0; i < n; i++) {
ss[i] = sc.nextInt();
}
Arrays.sort(ss);
int sum = 0;
for (int i = 1; i <= n - 2; i++) {
sum += ss[i];
}
System.out.println(sum / (n - 2));
}
}
} | Main.java:37: error: class, interface, enum, or record expected
import java.util.Arrays;
^
Main.java:38: error: class, interface, enum, or record expected
import java.util.Scanner;
^
2 errors
|
s631837096 | p00728 | Java |
import java.util.Scanner;
public class Sample {
public static void main(String[] args) {
int[] x = new int [256];
int[] y = new int [256];
Scanner stdIn = new Scanner(System.in);
int min,max,k=0,h=0;
while(true)
{
int a = stdIn.nextInt();
if(a==0)
{
break;
}
else
{
for(int i=0;i<a;i++)
{
int b = stdIn.nextInt();
x[i] = b;
}
min = x[0];
max = x[0];
h = x[0];
for(int i=1;i<a;i++)
{
h = h + x[i];
if(min>x[i])
min = x[i];
if(max<x[i])
max = x[i];
}
y[k]=(h-min-max)/(a-2);
k++;
}
}
for(int i=0;i<k;i++)
{
System.out.println(y[i]);
}
}
} | Main.java:4: error: class Sample is public, should be declared in a file named Sample.java
public class Sample {
^
1 error
|
s348247303 | p00728 | Java | import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner stdIn = new Scanner(System.in);
int n=0;
int count = 0;
while(count<20){
n=stdIn.nextInt();
if(n>=3&&n<=100) break;
count++;
}
int[] s=new int[n];
for(int i=0;i<s.length;i++){
while(count<20){
s[i]=stdIn.nextInt();
if(s[i]>=0&&s[i]<=1000) break;
count++;
}
}
int max = s[0];
int min = s[0];
int a=0;
int b=0;
for(int i=1;i<s.length;i++){
if(s[i]>max){
max = s[i];
a=i;
}
if(s[i]<min){
min = s[i];
b=i;
}
}
s[a]=0;
s[b]=0;
int all = 0;
for(int i=0;i<s.length;i++){
all += s[i];
}
int ave = all/(n-2);
System.out.println(0);
System.out.println(ave);
} | Main.java:47: error: reached end of file while parsing
}
^
1 error
|
s957930592 | p00728 | Java | import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner stdIn = new Scanner(System.in);
int n=0;
int count = 0;
while(count<20){
n=stdIn.nextInt();
if(n>=3&&n<=100) break;
count++;
}
int[] s=new int[n];
for(int i=0;i<s.length;i++){
while(count<20){
s[i]=stdIn.nextInt();
if(s[i]>=0&&s[i]<=1000) break;
count++;
}
}
int max = s[0];
int min = s[0];
int a=0;
int b=0;
for(int i=1;i<s.length;i++){
if(s[i]>max){
max = s[i];
a=i;
}
if(s[i]<min){
min = s[i];
b=i;
}
}
s[a]=0;
s[b]=0;
int all = 0;
for(int i=0;i<s.length;i++){
all += s[i];
}
int ave = all/(n-2);
System.out.println(0);
System.out.println(ave);
} | Main.java:47: error: reached end of file while parsing
}
^
1 error
|
s022236444 | p00728 | Java | import java.util.Scanner;
public class HelloWorld{
public static void main(String[] args){
Scanner stdIn = new Scanner(System.in);
int n=0;
int count = 0;
while(count<20){
n=stdIn.nextInt();
if(n>=3&&n<=100) break;
count++;
}
int[] s=new int[n];
for(int i=0;i<s.length;i++){
while(count<20){
s[i]=stdIn.nextInt();
if(s[i]>=0&&s[i]<=1000) break;
count++;
}
}
int max = s[0];
int min = s[0];
int a=0;
int b=0;
for(int i=1;i<s.length;i++){
if(s[i]>max){
max = s[i];
a=i;
}
if(s[i]<min){
min = s[i];
b=i;
}
}
s[a]=0;
s[b]=0;
int all = 0;
for(int i=0;i<s.length;i++){
all += s[i];
}
int ave = all/(n-2);
System.out.println(0);
System.out.println(ave);
}
} | Main.java:3: error: class HelloWorld is public, should be declared in a file named HelloWorld.java
public class HelloWorld{
^
1 error
|
s664048424 | p00728 | Java | public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N;
int max, min;
int score;
int x;
while(true){
score=0;
max=0;
min=1000;
x=sc.nextInt();
if(x==0){
break;
}else{
N=x;
}
for(int i=0;i<N;i++){
x=sc.nextInt();
score+=x;
if(x>=max){max=x;}
if(x<=min){min=x;}
}
score=(score-min-max)/(N-2);
System.out.println(score);
}
}
} | Main.java:4: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:4: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s159023308 | p00728 | Java | import java.io.*;
public class Main{
public static void main(String[] args){
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line;
int i;
int n;
//int[] scores;
int max;
int min;
int ave;
int score;
try{
while(null != (line=reader.readLine())){
n = Integer.parseInt(line);
if(n==0)return;
ave = 0;
min = 0;
max = 0;
scores = new int[n];
for(i=0; i<n; i++){
line = reader.readLine();
score = Integer.parseInt(line);
//scores[i] = score;
// ave += score;
/*if(max < 0){
max = score;
}else */
if(max < score){
ave += max;
max = score;
min = 0;
}else{
if(min <= 0){
min = score;
}else if(min > score){
ave += min;
min = score;
}else{
ave += score;
}
}
}
ave = ave/(n-2);
System.out.println(">"+ave);
}
}catch(IOException e){
System.out.println(e);
}
}
} | Main.java:20: error: cannot find symbol
scores = new int[n];
^
symbol: variable scores
location: class Main
1 error
|
s982960945 | p00728 | Java |
import java.util.Scanner;
public class Main2 {
public static void main(String[] args) {
int n, w, sum = 0;
int min = 10000;
int max = -100;
Scanner sc = new Scanner(System.in);
w = sc.nextInt();
for (int i = 0; i < w; i++) {
n = sc.nextInt();
sum += n;
if (n > max)
max = n;
else if (n < min)
min = n;
}
System.out.println((sum-(max+min))/(w-2));
}
} | Main.java:4: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2 {
^
1 error
|
s780597679 | p00728 | Java |
import java.util.Scanner;
public class Main2 {
public static void main(String[] args) {
int n, w, sum = 0;
int min = 10000;
int max = -100;
Scanner sc = new Scanner(System.in);
w = sc.nextInt();
for (int i = 0; i < w; i++) {
n = sc.nextInt();
sum += n;
if (n > max)
max = n;
else if (n < min)
min = n;
}
System.out.println((sum-(max+min))/(w-2));
}
} | Main.java:4: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2 {
^
1 error
|
s431100264 | p00728 | Java | import java.util.Scanner;
public class ICPCScoreTotalizerSoftware {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int max;
int min;
int sum = 0;
int ave = 0;
int n = 0;
int score;
while(true) {
n = sc.nextInt();
if(n == 0){ break; }
score = sc.nextInt();
max = score;
min = score;
sum += score;
for(int i = 0 ; i < n-1; i++){
score = sc.nextInt();
if(score > max) {
max = score;
}
if(score < min) {
min = score;
}
sum += score;
}
sum = sum - max - min;
ave = sum / (n-2);
System.out.println(ave);
}
}
} | Main.java:2: error: class ICPCScoreTotalizerSoftware is public, should be declared in a file named ICPCScoreTotalizerSoftware.java
public class ICPCScoreTotalizerSoftware {
^
1 error
|
s984231896 | p00728 | Java | import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] sum = new int[10000];
int small=0;
int max=0;
int wa= 0;
for(int i=0;i<=n-1;i++){
int k = sc.nextInt();
sum[i] = k;
wa = wa + sum[i];
if(i == 1){
if(sum[0]>=sum[1]){
max = sum[0];
small = sum[1];
}
else{
max = sum[1];
small = sum[0];
}
}
if(i>=2){
if(max<=sum[i]){
max = sum[i];
}
if(small>=sum[i]){
small = sum[i];
}
}
}
double ave;
ave = (wa-small-max)/(n-2);
System.out.println(Math.floor(ave);
}
} | Main.java:41: error: ')' or ',' expected
System.out.println(Math.floor(ave);
^
1 error
|
s920149931 | p00728 | Java | iimport java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] sum = new int[10000];
int small=0;
int max=0;
int wa= 0;
for(int i=0;i<=n-1;i++){
int k = sc.nextInt();
sum[i] = k;
wa = wa + sum[i];
if(i == 1){
if(sum[0]>=sum[1]){
max = sum[0];
small = sum[1];
}
else{
max = sum[1];
small = sum[0];
}
}
if(i>=2){
if(max<=sum[i]){
max = sum[i];
}
if(small>=sum[i]){
small = sum[i];
}
}
}
double ave;
ave = (wa-small-max)/(n-2);
System.out.println(Math.floor(ave));
}
} | Main.java:1: error: class, interface, enum, or record expected
iimport java.util.Scanner;
^
1 error
|
s605921244 | p00728 | Java | package ICPC_Score_Totalizer_Software;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Judge {
static int number; //?????£??????????????°
int score; //??????
public static void setNumberOfJudge() { //?????£??????????????°?????????
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
number = Integer.parseInt(in.readLine());
}
catch(Exception e){
System.out.println("???????????????????????????"+e);
}
}
public void setScore(){ //???????????????
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
score = Integer.parseInt(in.readLine());
}
catch(Exception e){
System.out.println("???????????????????????????"+e);
}
}
}
public class Exec {
public static void main(String[] args) {
while(true){
Judge.setNumberOfJudge(); //?????£??????????????°?????????
if(Judge.number == 0){System.exit(0);} //?????£?????????0????????????????????°???????????????
Judge j[] = new Judge[Judge.number]; //?????£??????????????°????????????????????????
int i;
for(i=0;i<Judge.number;i++){
j[i]= new Judge(); //??????????????????????????????????´???????
j[i].setScore(); //???????????????
}
int max = 0; //??????????????§????????????
int maxJ = 0; //?????§???????????????????????£????????????????????????
int min = 1001;
int minJ = 0;
for(i=0;i<Judge.number;i++){
if(max < j[i].score){ //?????§?????????????????£??????????±???????
max = j[i].score;
maxJ = i;
}
if(j[i].score < min){ //????°??????????????????£??????????±???????
min = j[i].score;
minJ = i;
}
}
int sum = 0; //?????§?????¨????°?????????????????????????????¨?
int k;
for(k=0;k < Judge.number;k++){
if(k != maxJ && k != minJ){ //?????§?????§???????°??????§???????????¨???
sum += j[k].score;
}
}
System.out.println(sum);
}
}
} | Main.java:6: error: class Judge is public, should be declared in a file named Judge.java
public class Judge {
^
Main.java:34: error: class Exec is public, should be declared in a file named Exec.java
public class Exec {
^
2 errors
|
s779371350 | p00728 | Java | package ICPC_Score_Totalizer_Software;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Judge {
static int number; //?????£??????????????°
int score; //??????
public static void setNumberOfJudge() { //?????£??????????????°?????????
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
number = Integer.parseInt(in.readLine());
}
catch(Exception e){
System.out.println("???????????????????????????"+e);
}
}
public void setScore(){ //???????????????
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
score = Integer.parseInt(in.readLine());
}
catch(Exception e){
System.out.println("???????????????????????????"+e);
}
}
public static void main(String[] args) {
while(true){
Judge.setNumberOfJudge(); //?????£??????????????°?????????
if(Judge.number == 0){System.exit(0);} //?????£?????????0????????????????????°???????????????
Judge j[] = new Judge[Judge.number]; //?????£??????????????°????????????????????????
int i;
for(i=0;i<Judge.number;i++){
j[i]= new Judge(); //??????????????????????????????????´???????
j[i].setScore(); //???????????????
}
int max = 0; //??????????????§????????????
int maxJ = 0; //?????§???????????????????????£????????????????????????
int min = 1001;
int minJ = 0;
for(i=0;i<Judge.number;i++){
if(max < j[i].score){ //?????§?????????????????£??????????±???????
max = j[i].score;
maxJ = i;
}
if(j[i].score < min){ //????°??????????????????£??????????±???????
min = j[i].score;
minJ = i;
}
}
int sum = 0; //?????§?????¨????°?????????????????????????????¨?
int k;
for(k=0;k < Judge.number;k++){
if(k != maxJ && k != minJ){ //?????§?????§???????°??????§???????????¨???
sum += j[k].score;
}
}
System.out.println(sum);
}
}
} | Main.java:6: error: class Judge is public, should be declared in a file named Judge.java
public class Judge {
^
1 error
|
s128736511 | p00728 | Java | package ICPC_Score_Totalizer_Software;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Judge {
static int number; //?????£??????????????°
int score; //??????
public static void setNumberOfJudge() { //?????£??????????????°?????????
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
number = Integer.parseInt(in.readLine());
}
catch(Exception e){
System.out.println("???????????????????????????"+e);
}
}
public void setScore(){ //???????????????
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
score = Integer.parseInt(in.readLine());
}
catch(Exception e){
System.out.println("???????????????????????????"+e);
}
}
public static void main(String[] args) {
while(true){
Judge.setNumberOfJudge(); //?????£??????????????°?????????
if(Judge.number == 0){System.exit(0);} //?????£?????????0????????????????????°???????????????
Judge j[] = new Judge[Judge.number]; //?????£??????????????°????????????????????????
int i;
for(i=0;i<Judge.number;i++){
j[i]= new Judge(); //??????????????????????????????????´???????
j[i].setScore(); //???????????????
}
int max = 0; //??????????????§????????????
int maxJ = 0; //?????§???????????????????????£????????????????????????
int min = 1001;
int minJ = 0;
for(i=0;i<Judge.number;i++){
if(max < j[i].score){ //?????§?????????????????£??????????±???????
max = j[i].score;
maxJ = i;
}
if(j[i].score < min){ //????°??????????????????£??????????±???????
min = j[i].score;
minJ = i;
}
}
int sum = 0; //?????§?????¨????°?????????????????????????????¨?
int k;
for(k=0;k < Judge.number;k++){
if(k != maxJ && k != minJ){ //?????§?????§???????°??????§???????????¨???
sum += j[k].score;
}
}
System.out.println(sum);
}
}
} | Main.java:6: error: class Judge is public, should be declared in a file named Judge.java
public class Judge {
^
1 error
|
s301754748 | p00728 | Java | import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Judge {
static int number; //?????£??????????????°
int score; //??????
public static void setNumberOfJudge() { //?????£??????????????°?????????
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
number = Integer.parseInt(in.readLine());
}
catch(Exception e){
System.out.println("???????????????????????????"+e);
}
}
public void setScore(){ //???????????????
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
score = Integer.parseInt(in.readLine());
}
catch(Exception e){
System.out.println("???????????????????????????"+e);
}
}
public static void main(String[] args) {
while(true){
Judge.setNumberOfJudge(); //?????£??????????????°?????????
if(Judge.number == 0){System.exit(0);} //?????£?????????0????????????????????°???????????????
Judge j[] = new Judge[Judge.number]; //?????£??????????????°????????????????????????
int i;
for(i=0;i<Judge.number;i++){
j[i]= new Judge(); //??????????????????????????????????´???????
j[i].setScore(); //???????????????
}
int max = 0; //??????????????§????????????
int maxJ = 0; //?????§???????????????????????£????????????????????????
int min = 1001;
int minJ = 0;
for(i=0;i<Judge.number;i++){
if(max < j[i].score){ //?????§?????????????????£??????????±???????
max = j[i].score;
maxJ = i;
}
if(j[i].score < min){ //????°??????????????????£??????????±???????
min = j[i].score;
minJ = i;
}
}
int sum = 0; //?????§?????¨????°?????????????????????????????¨?
int k;
for(k=0;k < Judge.number;k++){
if(k != maxJ && k != minJ){ //?????§?????§???????°??????§???????????¨???
sum += j[k].score;javascript:void(0)
}
}
System.out.println(sum);
}
}
} | Main.java:63: error: illegal start of expression
sum += j[k].score;javascript:void(0)
^
Main.java:63: error: ';' expected
sum += j[k].score;javascript:void(0)
^
2 errors
|
s046099228 | p00728 | Java | import java.io.*;
public class Exec {
public static void main(String[] args) {
while(true){
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int number = Integer.parseInt(reader.readLine());
if(number == 0){System.exit(0);}
int score[];
score = new int[number];
int i;
for(i=0;i<number;i++){
score[i] = Integer.parseInt(reader.readLine());
}
int max = 0;
int maxJ = 0;
int min = 1001;
int minJ = 0;
for(i=0;i<number;i++){
if(max <= score[i]){
max = score[i];
maxJ = i;
}
if(score[i] <= min && i != maxJ){
min = score[i];
minJ = i;
}
}
int sum = 0;
for(i=0;i<number;i++){
if(i != minJ && i != maxJ){
sum += score[i];
}
}
System.out.println(sum/(number-2));
}
catch(IOException e){
System.out.println(e);
}
}
}
} | Main.java:3: error: class Exec is public, should be declared in a file named Exec.java
public class Exec {
^
1 error
|
s886084563 | p00728 | Java | public class Main {
public static void main(String[] args) {
while(true){
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int number = Integer.parseInt(reader.readLine());
if(number < 3){return;}
int score[];
score = new int[number];
int i;
for(i=0;i<number;i++){
score[i] = Integer.parseInt(reader.readLine());
}
int max = 0;
int maxJ = 0;
int min = 1001;
int minJ = 0;
for(i=0;i<number;i++){
if(max <= score[i]){
max = score[i];
maxJ = i;
}
if(score[i] <= min && i != maxJ){
min = score[i];
minJ = i;
}
}
int sum = 0;
for(i=0;i<number;i++){
if(i != minJ && i != maxJ){
sum += score[i];
}
}
System.out.println(sum/(number-2));
}
catch(IOException e){
System.out.println(e);
}
}
}
} | Main.java:6: error: cannot find symbol
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
^
symbol: class BufferedReader
location: class Main
Main.java:6: error: cannot find symbol
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
^
symbol: class BufferedReader
location: class Main
Main.java:6: error: cannot find symbol
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
^
symbol: class InputStreamReader
location: class Main
Main.java:40: error: cannot find symbol
catch(IOException e){
^
symbol: class IOException
location: class Main
4 errors
|
s092434766 | p00728 | Java | package AOJ1147;
import java.io.*;
public class Main {
public static void main(String[] args) {
while(true){
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int number = Integer.parseInt(reader.readLine());
if(number < 3){break;}
int score[];
score = new int[number];
int i;
for(i=0;i<number;i++){
score[i] = Integer.parseInt(reader.readLine());
}
int max = 0;
int maxJ = 0;
int min = 1001;
int minJ = 0;
for(i=0;i<number;i++){
if(max <= score[i]){
max = score[i];
maxJ = i;
}
if(score[i] <= min && i != maxJ){
min = score[i];
minJ = i;
}
}
int sum = 0;
for(i=0;i<number;i++){
if(i != minJ && i != maxJ){
sum += score[i];
}
}
System.out.println(sum/(number-2));
}
catch(IOException e){
System.out.println(e);
}
}
return 0;
}
} | Main.java:47: error: incompatible types: unexpected return value
return 0;
^
1 error
|
s234169967 | p00728 | Java | package AOJ1147;
import java.io.*;
public class Main {
public static void main(String[] args) {
while(true){
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int number = Integer.parseInt(reader.readLine());
if(number < 3){break;}
int score[];
score = new int[number];
int i;
for(i=0;i<number;i++){
score[i] = Integer.parseInt(reader.readLine());
}
int max = 0;
int maxJ = 0;
int min = 1001;
int minJ = 0;
for(i=0;i<number;i++){
if(max <= score[i]){
max = score[i];
maxJ = i;
}
if(score[i] <= min && i != maxJ){
min = score[i];
minJ = i;
}
}
int sum = 0;
for(i=0;i<number;i++){
if(i != minJ && i != maxJ){
sum += score[i];
}
}
System.out.println(sum/(number-2));
}
catch(IOException e){
System.out.println(e);
}
}
return 0;
}
} | Main.java:47: error: incompatible types: unexpected return value
return 0;
^
1 error
|
s742256591 | p00728 | Java | package lesson1;
import java.util.Scanner;
public class Class {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int judge = sc.nextInt();
if (judge == 0)
break;
int[] score = new int[judge];
int max = 0, min = 1000, sum = 0;
for (int i = 0; i < judge; i++) {
score[i] = sc.nextInt();
sum += score[i];
if (score[i] > max)
max = score[i];
if (score[i] < min)
min = score[i];
}
System.out.println((int) Math.floor((double) (sum - max - min)
/ (double) (judge - 2)));
}
}
} | Main.java:5: error: class Class is public, should be declared in a file named Class.java
public class Class {
^
1 error
|
s033743770 | p00728 | Java | import java.util.Scanner;
public class Class {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int judge = sc.nextInt();
if (judge == 0)
break;
int[] score = new int[judge];
int max = 0, min = 1000, sum = 0;
for (int i = 0; i < judge; i++) {
score[i] = sc.nextInt();
sum += score[i];
if (score[i] > max)
max = score[i];
if (score[i] < min)
min = score[i];
}
System.out.println((int) Math.floor((double) (sum - max - min)
/ (double) (judge - 2)));
}
}
} | Main.java:3: error: class Class is public, should be declared in a file named Class.java
public class Class {
^
1 error
|
s614891192 | p00728 | Java | import java.util.Scanner;
public class Class {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int judge = sc.nextInt();
if (judge == 0)
break;
int[] score = new int[judge];
int max = 0, min = 1000, sum = 0;
for (int i = 0; i < judge; i++) {
score[i] = sc.nextInt();
sum += score[i];
if (score[i] > max)
max = score[i];
if (score[i] < min)
min = score[i];
}
System.out.println((sum - max - min) / (judge - 2));
}
}
} | Main.java:3: error: class Class is public, should be declared in a file named Class.java
public class Class {
^
1 error
|
s309130101 | p00728 | Java | import java.util.Scanner;
public class MAIN {
public static void main(String[] args) {
// !!initialize!!
Scanner sc = new Scanner(System.in);
// !!initialize!!
for (int count = 0; -1 < count; count++) {
// ??????????????°?????\??????
// val:??\??????????????°?????????
int val = sc.nextInt();
// ????????????0????????´???break??????
if (val == 0) {
break;
}
// ????????????????????´??????????????????
fig_ave(val);
}
}
// ?????§?????\????????????????????§/????°??????????????????????????±???????
public static void fig_ave(int val) {
// !!initialize!!
int[] score = new int[val];
int sum = 0;
int max = 0; // ?????§???
int min = 1001; // ????°????
Scanner sc = new Scanner(System.in);
// !!initialize!!
for (int i = 0; i < val; i++) {
score[i] = sc.nextInt();
// ??\???????????????????????§???????±??????????
if (max < score[i]) {
max = score[i];
}
// ??\??????????????????????°????????±??????????
if (min > score[i]) {
min = score[i];
}
}
// ??????????±???????
for (int j = 0; j < val; j++) {
// ??????????±??????????
sum = sum + score[j];
}
// max,min??????????????????????±??????????
sum = (sum - max - min) / (val - 2);
System.out.println(sum);
}
} | Main.java:3: error: class MAIN is public, should be declared in a file named MAIN.java
public class MAIN {
^
1 error
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.