submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s403659246
p00710
C++
#include <iostream> #include <deque> #include <vector> using namespace std; int main( void ){ vector< int > result; deque< int > card; while( true ){ int n, r; cin >> n >> r; if( n == 0 && r == 0 ) break; for( int i = 1; i < n + 1; i++ ){ card.push_front( i ); } for( int i = 0; i < r; i++ ){ int p, c; cin >> p >> c; for( auto itr = card.begin(); itr != card.end(); ++itr ){ if( ( *itr ) =< p ){ int temp = ( *itr ); card.erase( itr ); card.push_front( temp ); } } } result.push_back( card.front() ); } for( auto itr = result.begin(); itr != result.end(); ++itr ){ cout << ( *itr ) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:22:47: error: expected primary-expression before '<' token 22 | if( ( *itr ) =< p ){ | ^
s145830751
p00710
C++
#include<cstdio> #include<vector> using namespace std; int solve(int n,int r){ vector<int> m; for(int i=0;i<n;i++){ m.push_back(i); } for(int i=0;i<r;i++){ int p,c; scanf("%d %d",&p,&c); rotate(m.begin(),m.begin()+p-1,m.begin()+p+c-1); } return n-m[0]; } int main(){ while(1){ int n,r; scanf("%d %d",&n,&r); if(n==0&&r==0) return 0; printf("%d\n",solve(n,r)); } }
a.cc: In function 'int solve(int, int)': a.cc:13:9: error: 'rotate' was not declared in this scope 13 | rotate(m.begin(),m.begin()+p-1,m.begin()+p+c-1); | ^~~~~~
s554404032
p00710
C++
#include<iostream> #include<list> using namespace std; const void ShowList(list<int>); int main() { //ifstream fin("input.txt"); if (!fin)return -1; list<int> stock; while (true) { int number = 0; int shuffleCount = 0; int top = 0; cin >> number >> shuffleCount; if (number == 0 && shuffleCount == 0)break; //????????????????´??????????(?±±?????????) for (int i = 1; i <= number; i++) { stock.push_front(i); } // ShowList(stock); list<int>::iterator begin; list<int>::iterator end; for (int i = 0; i < shuffleCount; i++) { int p, c; cin >> p >> c; if (number == c)continue; begin = stock.begin(); advance(begin, p - 1); // cout << "\t" << *begin << endl; end = begin; advance(end, c); // cout << "\t" << *end << endl; stock.splice(stock.begin(), stock, begin, end); } // ShowList(stock); cout << stock.front() << endl; stock.clear(); } return 0; } const void ShowList(list<int> lst){ list<int>::iterator a = lst.begin(); for (int i = 0; i < lst.size(); i++) { cout << *a << " "; a++; } cout << endl; }
a.cc: In function 'int main()': a.cc:11:14: error: 'fin' was not declared in this scope 11 | if (!fin)return -1; | ^~~
s178881667
p00710
C++
#include<iostream> using namespace std; #include<vector> int main() { int N, R, p, c; vector<int>v, buf1, buf2; while (cin >> N >> R&&N) { v.clear(); for (int i = 1; i <= N; i++) v.push_back(i); for (int i = 0; i < R; ++i) { cin >> p >> c; buf1.clear(); buf2.clear(); for (int j = 0; j < v.size(); j++) { if (j < N - p - (c - 1) || N - p < j) { buf1.push_back(v[j]); } else { buf2.push_back(v[j]); } }v.clear(); for (int j = 0; j < buf1.size(); j++) { v.push_back(buf1[j]); } for (int j = 0; j < buf2.size; j++) { v.push_back(buf2[j]); } } cout << v[v.size() - 1] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:31:38: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?) 31 | for (int j = 0; j < buf2.size; j++) { | ~~~~~^~~~ | ()
s677800040
p00710
C++
#include <iostream> #include <vector> using namespace std; int main(int argc, char const* argv[]) { int n, r, p, c; while(true) { cin >> n >> r; if(n == 0 && r == 0) break; std::vector<int> cards(n); for(int i = 0; i < n; ++i) { cards.at(n - i - 1) = i + 1; } for(int i = 0; i < r; ++i) { cin >> p >> c; std::vector<int> temp_p; std::vector<int> temp_c; std::copy_n(cards.begin(), p - 1, std::back_inserter(temp_p)); std::copy_n(cards.begin() + p - 1, c, std::back_inserter(temp_c)); std::copy(temp_c.begin(), temp_c.end(), cards.begin()); std::copy(temp_p.begin(), temp_p.end(), cards.begin() + c); } std::cout << cards.at(0) << std::endl; } return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:26:30: error: 'copy_n' is not a member of 'std'; did you mean 'copy'? 26 | std::copy_n(cards.begin(), p - 1, std::back_inserter(temp_p)); | ^~~~~~ | copy a.cc:27:30: error: 'copy_n' is not a member of 'std'; did you mean 'copy'? 27 | std::copy_n(cards.begin() + p - 1, c, std::back_inserter(temp_c)); | ^~~~~~ | copy
s489864405
p00710
C++
#include <iostream> #include <vector> using namespace std; int main(int argc, char const* argv[]) { int n, r, p, c; while(true) { cin >> n >> r; if(n == 0 && r == 0) break; std::vector<int> cards(n); for(int i = 0; i < n; ++i) { cards.at(n - i - 1) = i + 1; } for(int i = 0; i < r; ++i) { cin >> p >> c; std::vector<int> temp_p; std::vector<int> temp_c; std::copy_n(cards.begin(), p - 1, std::back_inserter(temp_p)); std::copy_n(cards.begin() + p - 1, c, std::back_inserter(temp_c)); std::copy(temp_c.begin(), temp_c.end(), cards.begin()); std::copy(temp_p.begin(), temp_p.end(), cards.begin() + c); } std::cout << cards.at(0) << std::endl; } return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:26:30: error: 'copy_n' is not a member of 'std'; did you mean 'copy'? 26 | std::copy_n(cards.begin(), p - 1, std::back_inserter(temp_p)); | ^~~~~~ | copy a.cc:27:30: error: 'copy_n' is not a member of 'std'; did you mean 'copy'? 27 | std::copy_n(cards.begin() + p - 1, c, std::back_inserter(temp_c)); | ^~~~~~ | copy
s592032628
p00710
C++
#include <iostream> using namespace std; void shuffle(int a, int b, int *ans) { int t[a]; a--; for (int i = 0; i < a; i++) { t[i] = ans[i]; } for (int i = a; i < a + b; i++) { ans[i - b] = t[i - e]; } for (int i = b; i < a + b; i++) { ans[i] = t[i - b]; } } int main() { int n,r; while (cin >> n >> r, n) { int ans[n]; for (int i = 0; i < n; i++) { ans[i] = n - i; } for (int i = 0; i < r; i++) { int b, e; cin >> b >> e; shuffle(b, e, ans); } cout << ans[0] << endl; } return 0; }
a.cc: In function 'void shuffle(int, int, int*)': a.cc:13:28: error: 'e' was not declared in this scope 13 | ans[i - b] = t[i - e]; | ^
s436398458
p00710
C++
#include <stdio.h> ?? int main() { ?? ????int r,d,n,i,j,k,l; ????int p,c; ????int a[60] = {0}; ????int b[60] = {0}; ?? ?? ????while(1) { ?? ????????scanf("%d %d", &n, &r); ?? ????????if(n == 0 && r == 0) { ????????????break; ????????} ?? ?? ????????for(i =0 ; i<=n ; i++) { ????????????a[n-1-i] = i+1; ????????????b[n-1-i] = i+1; ????????} ?? ?? ?? ????????for(i = 0; i < r; i++) { ????????????scanf("%d %d",&p,&c); ?? ????????????for(j = 0; j<c;j++) { ????????a[j] = b[p+j-1]; ????????//printf("a[%d] = %d\n",j,a[j]); ????????????} ????????????for(j = 0;j<p-1;j++) { ????????a[c+j] = b[j]; ????????//printf("a[%d] = %d\n" ,c+j ,a[c+j]); ????????????} ?? ????????????for(j = 0;j<p+c-1;j++) { ????????b[j] = a[j]; ????????????} ????????} ?? ?? ????????printf("%d\n",a[0]); ?? ????} ?? ????return 0; }
a.cc:32:7: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs] 32 | ????????//printf("a[%d] = %d\n",j,a[j]); a.cc:36:7: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs] 36 | ????????//printf("a[%d] = %d\n" ,c+j ,a[c+j]); a.cc:2:1: error: expected unqualified-id before '?' token 2 | ?? | ^
s658552191
p00710
C++
#include <iostream> #include <vector> using namespace std; //?±±?????????????????¢??°???????±±???????±±????????°n???p?????????????????????c??? void shuffle(vector<int> &yama, int n, int p, int c); int main(){ int n, r; int p, c; vector<int> yama, v; cin >> n; cin >> r; while(n != 0 && r != 0){ //?±±?????????????????? for(int i = 0, j = n; i < n; i++, j--){ yama.push_back(j); } //?????£????????? for (int i = 0; i < r; i++){ cin >> p; cin >> c; shuffle(yama, n, p, c); } //???????????????????¨???? v.push_back(yama.front()); cin >> n; cin >> r; } for(int i = 0; i < v.size(); i++){ cout << v[i]; } cout << endl; }
/usr/bin/ld: /tmp/ccfkjfu9.o: in function `main': a.cc:(.text+0xcf): undefined reference to `shuffle(std::vector<int, std::allocator<int> >&, int, int, int)' collect2: error: ld returned 1 exit status
s439630939
p00710
C++
#include <iostream> #include <vector> using namespace std; //?±±?????????????????¢??°???????±±???????±±????????°n???p?????????????????????c??? void shuffle(vector<int> &yama, int n, int p, int c); int main(){ int n, r; int p, c; vector<int> yama, v; cin >> n; cin >> r; while(n != 0 && r != 0){ //?±±?????????????????? for(int i = 0, j = n; i < n; i++, j--){ yama.push_back(j); } //?????£????????? for (int i = 0; i < r; i++){ cin >> p; cin >> c; shuffle(yama, n, p, c); } //???????????????????¨???? v.push_back(yama.front()); cin >> n; cin >> r; } for(int i = 0; i < v.size(); i++){ cout << v[i]; } cout << endl; }
/usr/bin/ld: /tmp/cchNkAVh.o: in function `main': a.cc:(.text+0xcf): undefined reference to `shuffle(std::vector<int, std::allocator<int> >&, int, int, int)' collect2: error: ld returned 1 exit status
s143127237
p00710
C++
#include <iostream> #include <vector> using namespace std; //?±±?????????????????¢??°???????±±???????±±????????°n???p?????????????????????c??? void shuffle(vector<int> &yama, int n, int p, int c); int main(){ int n, r; int p, c; vector<int> yama, v; cin >> n; cin >> r; while(n != 0 && r != 0){ //?±±?????????????????? for(int i = 0, j = n; i < n; i++, j--){ yama.push_back(j); } //?????£????????? for (int i = 0; i < r; i++){ cin >> p; cin >> c; shuffle(&yama, n, p, c); } //???????????????????¨???? v.push_back(yama.front()); cin >> n; cin >> r; } for(int i = 0; i < v.size(); i++){ cout << v[i]; } cout << endl; }
a.cc: In function 'int main()': a.cc:26:15: error: invalid initialization of non-const reference of type 'std::vector<int>&' from an rvalue of type 'std::vector<int>*' 26 | shuffle(&yama, n, p, c); | ^~~~~ a.cc:6:27: note: in passing argument 1 of 'void shuffle(std::vector<int>&, int, int, int)' 6 | void shuffle(vector<int> &yama, int n, int p, int c); | ~~~~~~~~~~~~~^~~~
s703380375
p00710
C++
Last login: Mon Apr 24 16:33:46 on ttys000 install-no-MacBook-Pro-4:~ g-2019$ cd zemi/ install-no-MacBook-Pro-4:zemi g-2019$ ls #test.rb# 0417 0424 install-no-MacBook-Pro-4:zemi g-2019$ cd 0424 install-no-MacBook-Pro-4:0424 g-2019$ ls #test.cpp# atCoser-iroha.cpp prac1_.cpp~ a.out hanafuda.cpp str.cpp atCoder-B.cpp hanafuda.cpp~ test.cpp atCoder-B.cpp~ prac1_.cpp test.cpp~ install-no-MacBook-Pro-4:0424 g-2019$ ./a.out 5 2 0 1 2 3 4 3 1 3 1 5 5 4 3 2 1 0 0 install-no-MacBook-Pro-4:0424 g-2019$ emacs hanafuda.cpp [1]+ Stopped emacs hanafuda.cpp install-no-MacBook-Pro-4:0424 g-2019$ celar -bash: celar: command not found install-no-MacBook-Pro-4:0424 g-2019$ clear install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp install-no-MacBook-Pro-4:0424 g-2019$ ./a.out 5 2 0 1 2 3 4 3 1 3 1 4 4 3 5 2 1 0 0 install-no-MacBook-Pro-4:0424 g-2019$ fg emacs hanafuda.cpp [1]+ Stopped emacs hanafuda.cpp install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp hanafuda.cpp:22:5: error: no matching function for call to 'init' init(&yama, n); ^~~~ hanafuda.cpp:7:6: note: candidate function not viable: no known conversion from 'vector<int> *' to 'vector<int> &' for 1st argument; remove & void init(vector<int> &yama, int n); ^ 1 error generated. install-no-MacBook-Pro-4:0424 g-2019$ fg emacs hanafuda.cpp [1]+ Stopped emacs hanafuda.cpp install-no-MacBook-Pro-4:0424 g-2019$ fg emacs hanafuda.cpp [1]+ Stopped emacs hanafuda.cpp install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp hanafuda.cpp:22:5: error: no matching function for call to 'init_yama' init_yama(&yama, n); ^~~~~~~~~ hanafuda.cpp:7:6: note: candidate function not viable: no known conversion from 'vector<int> *' to 'vector<int> &' for 1st argument; remove & void init_yama(vector<int> &yama, int n); ^ 1 error generated. install-no-MacBook-Pro-4:0424 g-2019$ fg emacs hanafuda.cpp [1]+ Stopped emacs hanafuda.cpp install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp install-no-MacBook-Pro-4:0424 g-2019$ ./a.out 5 2 3 1 3 1 0 0 4 install-no-MacBook-Pro-4:0424 g-2019$ fg emacs hanafuda.cpp [1]+ Stopped emacs hanafuda.cpp install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp install-no-MacBook-Pro-4:0424 g-2019$ fg emacs hanafuda.cpp [1]+ Stopped emacs hanafuda.cpp install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp hanafuda.cpp:27:7: error: no matching function for call to 'shuffle' shuffle(&yama, n, p, c); ^~~~~~~ hanafuda.cpp:7:6: note: candidate function not viable: no known conversion from 'vector<int> *' to 'vector<int> &' for 1st argument; remove & void shuffle(vector<int> &yama, int n, int p, int c); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3122:10: note: candidate function template not viable: requires 3 arguments, but 4 were provided void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, ^ 1 error generated. install-no-MacBook-Pro-4:0424 g-2019$ fg emacs hanafuda.cpp [1]+ Stopped emacs hanafuda.cpp install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp hanafuda.cpp:45:9: error: assigning to 'int' from incompatible type 'vector<int>' tmp = yama[p-1+c-1]; ^ ~~~~~~~~~~~~~ hanafuda.cpp:46:9: error: member reference type 'vector<int> *' is a pointer; did you mean to use '->'? yama.erase(yama.begin()+p-1+c-1); ~~~~^ -> hanafuda.cpp:46:20: error: member reference type 'vector<int> *' is a pointer; did you mean to use '->'? yama.erase(yama.begin()+p-1+c-1); ~~~~^ -> hanafuda.cpp:47:9: error: member reference type 'vector<int> *' is a pointer; did you mean to use '->'? yama.insert(yama.begin(), tmp); ~~~~^ -> hanafuda.cpp:47:21: error: member reference type 'vector<int> *' is a pointer; did you mean to use '->'? yama.insert(yama.begin(), tmp); ~~~~^ -> 5 errors generated. install-no-MacBook-Pro-4:0424 g-2019$ fg emacs hanafuda.cpp [1]+ Stopped emacs hanafuda.cpp install-no-MacBook-Pro-4:0424 g-2019$ g++ -Wall hanafuda.cpp install-no-MacBook-Pro-4:0424 g-2019$ fg emacs hanafuda.cpp #include <iostream> #include <vector> using namespace std; //?±±?????????????????¢??°???????±±???????±±????????°n???p?????????????????????c??? void shuffle(vector<int> &yama, int n, int p, int c); int main(){ int n, r; int p, c; vector<int> yama, v; cin >> n; cin >> r; while(n != 0 && r != 0){ //?±±?????????????????? for(int i = 0, j = n; i < n; i++, j--){ yama.push_back(j); } //?????£????????? for (int i = 0; i < r; i++){ cin >> p; cin >> c; shuffle(yama, n, p, c); } //???????????????????¨???? v.push_back(yama.front()); cin >> n; cin >> r; } for(int i = 0; i < v.size(); i++){ cout << v[i]; } cout << endl; } void shuffle(vector<int> &yama, int n, int p, int c){ int tmp; for(int i = 0;i < c; i++){ -uuu:---F1 hanafuda.cpp Top L41 (C++/l Abbrev)----------------------------
a.cc:4:2: error: invalid preprocessing directive #test 4 | #test.rb# 0417 0424 | ^~~~ a.cc:7:2: error: invalid preprocessing directive #test 7 | #test.cpp# atCoser-iroha.cpp prac1_.cpp~ | ^~~~ a.cc:70:60: warning: multi-character character constant [-Wmultichar] 70 | hanafuda.cpp:22:5: error: no matching function for call to 'init' | ^~~~~~ a.cc:74:7: warning: multi-character literal with 13 characters exceeds 'int' size of 4 bytes 74 | 'vector<int> *' to 'vector<int> &' for 1st argument; remove & | ^~~~~~~~~~~~~~~ a.cc:74:26: warning: multi-character literal with 13 characters exceeds 'int' size of 4 bytes 74 | 'vector<int> *' to 'vector<int> &' for 1st argument; remove & | ^~~~~~~~~~~~~~~ a.cc:87:60: warning: multi-character literal with 9 characters exceeds 'int' size of 4 bytes 87 | hanafuda.cpp:22:5: error: no matching function for call to 'init_yama' | ^~~~~~~~~~~ a.cc:91:7: warning: multi-character literal with 13 characters exceeds 'int' size of 4 bytes 91 | 'vector<int> *' to 'vector<int> &' for 1st argument; remove & | ^~~~~~~~~~~~~~~ a.cc:91:26: warning: multi-character literal with 13 characters exceeds 'int' size of 4 bytes 91 | 'vector<int> *' to 'vector<int> &' for 1st argument; remove & | ^~~~~~~~~~~~~~~ a.cc:116:60: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes 116 | hanafuda.cpp:27:7: error: no matching function for call to 'shuffle' | ^~~~~~~~~ a.cc:120:7: warning: multi-character literal with 13 characters exceeds 'int' size of 4 bytes 120 | 'vector<int> *' to 'vector<int> &' for 1st argument; remove & | ^~~~~~~~~~~~~~~ a.cc:120:26: warning: multi-character literal with 13 characters exceeds 'int' size of 4 bytes 120 | 'vector<int> *' to 'vector<int> &' for 1st argument; remove & | ^~~~~~~~~~~~~~~ a.cc:134:40: warning: multi-character character constant [-Wmultichar] 134 | hanafuda.cpp:45:9: error: assigning to 'int' from incompatible type | ^~~~~ a.cc:135:7: warning: multi-character literal with 11 characters exceeds 'int' size of 4 bytes 135 | 'vector<int>' | ^~~~~~~~~~~~~ a.cc:138:49: warning: multi-character literal with 13 characters exceeds 'int' size of 4 bytes 138 | hanafuda.cpp:46:9: error: member reference type 'vector<int> *' is a pointer; | ^~~~~~~~~~~~~~~ a.cc:139:27: warning: multi-character character constant [-Wmultichar] 139 | did you mean to use '->'? | ^~~~ a.cc:143:50: warning: multi-character literal with 13 characters exceeds 'int' size of 4 bytes 143 | hanafuda.cpp:46:20: error: member reference type 'vector<int> *' is a pointer; | ^~~~~~~~~~~~~~~ a.cc:144:27: warning: multi-character character constant [-Wmultichar] 144 | did you mean to use '->'? | ^~~~ a.cc:148:49: warning: multi-character literal with 13 characters exceeds 'int' size of 4 bytes 148 | hanafuda.cpp:47:9: error: member reference type 'vector<int> *' is a pointer; | ^~~~~~~~~~~~~~~ a.cc:149:27: warning: multi-character character constant [-Wmultichar] 149 | did you mean to use '->'? | ^~~~ a.cc:153:50: warning: multi-character literal with 13 characters exceeds 'int' size of 4 bytes 153 | hanafuda.cpp:47:21: error: member reference type 'vector<int> *' is a pointer; | ^~~~~~~~~~~~~~~ a.cc:154:27: warning: multi-character character constant [-Wmultichar] 154 | did you mean to use '->'? | ^~~~ a.cc:1:1: error: 'Last' does not name a type 1 | Last login: Mon Apr 24 16:33:46 on ttys000 | ^~~~ a.cc:72:5: error: expected unqualified-id before '^' token 72 | ^~~~ | ^ a.cc:74:60: error: 'remove' does not name a type 74 | 'vector<int> *' to 'vector<int> &' for 1st argument; remove & | ^~~~~~ a.cc:76:6: error: expected unqualified-id before '^' token 76 | ^ | ^ a.cc:89:5: error: expected unqualified-id before '^' token 89 | ^~~~~~~~~ | ^ a.cc:91:60: error: 'remove' does not name a type 91 | 'vector<int> *' to 'vector<int> &' for 1st argument; remove & | ^~~~~~ a.cc:93:6: error: expected unqualified-id before '^' token 93 | ^ | ^ a.cc:118:7: error: expected unqualified-id before '^' token 118 | ^~~~~~~ | ^ a.cc:120:60: error: 'remove' does not name a type 120 | 'vector<int> *' to 'vector<int> &' for 1st argument; remove & | ^~~~~~ a.cc:122:6: error: expected unqualified-id before '^' token 122 | ^ | ^ a.cc:137:9: error: expected unqualified-id before '^' token 137 | ^ ~~~~~~~~~~~~~ | ^ a.cc:139:7: error: 'did' does not name a type 139 | did you mean to use '->'? | ^~~ a.cc:141:6: error: expected class-name before '~' token 141 | ~~~~^ | ^ a.cc:144:7: error: 'did' does not name a type 144 | did you mean to use '->'? | ^~~ a.cc:146:17: error: expected class-name before '~' token 146 | ~~~~^ | ^ a.cc:149:7: error: 'did' does not name a type 149 | did you mean to use '->'? | ^~~ a.cc:151:6: error: expected class-name before '~' token 151 | ~~~~^ | ^ a.cc:154:7: error: 'did' does not name a type 154 | did you mean to use '->'? | ^~~ a.cc:156:18: error: expected class-name before '~' token 156 | ~~~~^ | ^ 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:168: /usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type 68 | typedef ptrdiff_t streamsize; // Signed integral type | ^~~~~~~~~ /usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 40 | #include <cwchar> // For mbstate_t +++ |+#include <cstddef> 41 | In file included from /usr/include/c++/14/bits/exception_ptr.h:38, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ In file included from /usr/include/wchar.h:35, from /usr/include/c++/14/cwchar:44, from /usr/include/c++/14/bits/postypes.h:40: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive] 134 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared 140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared 142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:145:52: error: expected primary-expression before 'const' 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_U
s051645681
p00710
C++
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 5 2 | ^
s844208272
p00710
C++
#include<bits/stdc++.h> using namespace std; int index[51]; int main(){ int n,r; while(cin>>n>>r,n+r){ for(int i=0;i<n;++i) index[i]=n-i; int p,c; for(int k=0;k<r;++k){ cin>>p>>c; int cnt=0; while(cnt!=c){ int tmp=index[p-1+cnt]; for(int j=0;j<p-1;++j) index[p-j+cnt]=index[p-j-1+cnt]; index[0]=tmp; ++cnt; } } cout<<index[0]<<endl; } return 0; }
a.cc:3:13: error: 'int index [51]' redeclared as different kind of entity 3 | int index[51]; | ^ In file included from /usr/include/string.h:462, from /usr/include/c++/14/cstring:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121, from a.cc:1: /usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)' 50 | extern const char *index (const char *__s, int __c) | ^~~~~ a.cc: In function 'int main()': a.cc:7:31: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 7 | for(int i=0;i<n;++i) index[i]=n-i; | ^ a.cc:13:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 13 | int tmp=index[p-1+cnt]; | ^ a.cc:15:16: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 15 | index[p-j+cnt]=index[p-j-1+cnt]; | ^ a.cc:15:31: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 15 | index[p-j+cnt]=index[p-j-1+cnt]; | ^ a.cc:16:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 16 | index[0]=tmp; | ^ a.cc:20:16: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 20 | cout<<index[0]<<endl; | ^
s531497168
p00710
C++
#include<bits/stdc++.h> using namespace std; int x[100]; int y[100]; int card [100]; int ans[100]; int n,r,counter; int main (){ counter=0; while(input()){ solve(); } for(int i=0;i<counter;i++){ cout<<ans[i]<<endl; } return 0; } bool input(){ for(int i=0;i<100;i++){ x[i]=0; y[i]=0; } cin >>n>>r; for(int i=0;i<r;i++){ cin>>x[i]>>y[i]; } if(n==0){ return false; } else{ return true; } } void solve(){ for(int i=0;i<100;i++){ card[i]=i+1; } for(int i=0;i<r;i++){ for(int k=0;k<y[i];k++){ int a=card[x[i]+y[i]-2]; for(int j=x[i]+y[i]-1;j>0;j--){ card[j]=card[j-1]; } card[0]=a; } } ans[counter]=n-card[0]+1; counter++; }
a.cc: In function 'int main()': a.cc:10:11: error: 'input' was not declared in this scope; did you mean 'int'? 10 | while(input()){ | ^~~~~ | int a.cc:11:5: error: 'solve' was not declared in this scope 11 | solve(); | ^~~~~
s938642914
p00710
C++
#include<bits/stdc++.h> using namespace std; int x[100]; int y[100]; int card [100]; int n,r; int ans[1000]; int counter; bool input(){ for(int i=0;i<100;i++){ x[i]=0; y[i]=0; } cin >>n>>r; for(int i=0;i<r;i++){ cin>>x[i]>>y[i]; } if(n==0){ return false; } else{ return true; } } void solve(){ for(int i=0;i<100;i++){ card[i]=i+1; } for(int i=0;i<r;i++){ for(int k=0;k<y[i];k++){ int a=card[x[i]+y[i]-2]; for(int j=x[i]+y[i]-1;j>0;j--){ card[j]=card[j-1]; } card[0]=a; } for(int j=1;j<=y[i]/2;j++){ int remainder=card[j]; card[j]=card[y[i]-j]; card[y[i]-j]=remainder; } } ans[counter]=card[0]; counter+=1; } int main (){ counter=0 while(input()){ solve(); } for(int j=0;j<=counter;j++){ cout<<ans[counter]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:53:10: error: expected ';' before 'while' 53 | counter=0 | ^ | ; 54 | while(input()){ | ~~~~~
s099914362
p00710
C++
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<climits> #include<iostream> #include<algorithm> #include<stack> #include<queue> #include<vector> #include<list> #include<map> #include<set> using namespace std; int x[100]; int y[100]; int card [100]; int n,r; int ans[1000]; int counter; bool input(){ for(int i=0;i<100;i++){ x[i]=0; y[i]=0; } cin >>n>>r; for(int i=0;i<r;i++){ cin>>x[i]>>y[i]; } if(n==0){ return false; } else{ return true; } } void solve(){ for(int i=0;i<100;i++){ card[i]=i+1; } for(int i=0;i<r;i++){ for(int k=0;k<y[i];k++){ int a=card[x[i]+y[i]-2]; for(int j=x[i]+y[i]-1;j>0;j--){ card[j]=card[j-1]; } card[0]=a; } } cout<<n-card[0]+1<<endl; // ans[counter]=n-card[0]; counter+=1; } int main (){ counter=0; while(input()){ solve(); } return 0; } #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<climits> #include<iostream> #include<algorithm> #include<stack> #include<queue> #include<vector> #include<list> #include<map> #include<set> using namespace std; int x[100]; int y[100]; int card [100]; int n,r; int ans[1000]; int counter; bool input(){ for(int i=0;i<100;i++){ x[i]=0; y[i]=0; } cin >>n>>r; for(int i=0;i<r;i++){ cin>>x[i]>>y[i]; } if(n==0){ return false; } else{ return true; } } void solve(){ for(int i=0;i<100;i++){ card[i]=i+1; } for(int i=0;i<r;i++){ for(int k=0;k<y[i];k++){ int a=card[x[i]+y[i]-2]; for(int j=x[i]+y[i]-1;j>0;j--){ card[j]=card[j-1]; } card[0]=a; } } cout<<n-card[0]+1<<endl; // ans[counter]=n-card[0]; counter+=1; } int main (){ counter=0; while(input()){ solve(); } return 0; }
a.cc:79:5: error: redefinition of 'int x [100]' 79 | int x[100]; | ^ a.cc:15:5: note: 'int x [100]' previously declared here 15 | int x[100]; | ^ a.cc:80:5: error: redefinition of 'int y [100]' 80 | int y[100]; | ^ a.cc:16:5: note: 'int y [100]' previously declared here 16 | int y[100]; | ^ a.cc:81:5: error: redefinition of 'int card [100]' 81 | int card [100]; | ^~~~ a.cc:17:5: note: 'int card [100]' previously declared here 17 | int card [100]; | ^~~~ a.cc:82:5: error: redefinition of 'int n' 82 | int n,r; | ^ a.cc:18:5: note: 'int n' previously declared here 18 | int n,r; | ^ a.cc:82:7: error: redefinition of 'int r' 82 | int n,r; | ^ a.cc:18:7: note: 'int r' previously declared here 18 | int n,r; | ^ a.cc:83:5: error: redefinition of 'int ans [1000]' 83 | int ans[1000]; | ^~~ a.cc:19:5: note: 'int ans [1000]' previously declared here 19 | int ans[1000]; | ^~~ a.cc:84:5: error: redefinition of 'int counter' 84 | int counter; | ^~~~~~~ a.cc:20:5: note: 'int counter' previously declared here 20 | int counter; | ^~~~~~~ a.cc:85:6: error: redefinition of 'bool input()' 85 | bool input(){ | ^~~~~ a.cc:21:6: note: 'bool input()' previously defined here 21 | bool input(){ | ^~~~~ a.cc:101:6: error: redefinition of 'void solve()' 101 | void solve(){ | ^~~~~ a.cc:37:6: note: 'void solve()' previously defined here 37 | void solve(){ | ^~~~~ a.cc:122:5: error: redefinition of 'int main()' 122 | int main (){ | ^~~~ a.cc:58:5: note: 'int main()' previously defined here 58 | int main (){ | ^~~~
s818955272
p00710
C++
#include <iostream> #include <numeric> #include <vector> using namespace std; int main() { while (true) { int n; int r; cin >> n >> r; if (n == 0 && r == 0) { break; } vector<int> v(static_cast<size_t>(n)); iota(begin(v), end(v), 1); reverse(begin(v), end(v)); for (int i = 0; i < r; ++i) { int p; int c; cin >> p >> c; vector<int> t; copy_n(begin(v) + (p - 1), c, back_inserter(t)); copy_n(begin(v), p, back_inserter(t)); copy(begin(v) + (p - 1) + c, end(v), back_inserter(t)); v = t; } cout << v[0] << endl; } }
a.cc: In function 'int main()': a.cc:20:9: error: 'reverse' was not declared in this scope 20 | reverse(begin(v), end(v)); | ^~~~~~~ a.cc:26:13: error: 'copy_n' was not declared in this scope 26 | copy_n(begin(v) + (p - 1), c, back_inserter(t)); | ^~~~~~
s714785106
p00710
C++
#include <stdio.h> int main(void){ int n, r, p, c; while(1){ scanf("%d%d", &n, &r); if (n==0 && r==0){ break; } int card[n], temp[n]; for(int i=0;i<n;i++){ card[i] = n-i; } for(i=0;i<r;i++){ scanf("%d%d", &p, &c); //カットの処理 for(i=p-1;i<p+c-1;i++){ temp[i-p+1] = card[i]; } for(i=0;i<p-1;i++){ card[p+c-2-i] = card[p-2-i]; } for(i=0;i<c;i++){ card[i] = temp[i]; } } printf("%d", card[0]); } return 0; }
a.cc: In function 'int main()': a.cc:14:9: error: 'i' was not declared in this scope 14 | for(i=0;i<r;i++){ | ^
s598336282
p00710
C++
arr=[] ta=[] while true do n, r = gets.split.map(&:to_i) if n == 0 && r == 0 break end arr = (1..n).to_a.reverse r.times do p, c = gets.split.map(&:to_i) p -= 1 ta = arr[p...p+c] + arr[0...p] + arr[p+c..n] arr = ta end puts arr[0] end
a.cc:8:10: error: too many decimal points in number 8 | arr = (1..n).to_a.reverse | ^~~~ a.cc:12:33: error: too many decimal points in number 12 | ta = arr[p...p+c] + arr[0...p] + arr[p+c..n] | ^~~~~ a.cc:1:1: error: 'arr' does not name a type 1 | arr=[] | ^~~
s939840810
p00710
C++
using namespace std; int main(){ int n,r,p,c,a[50]; while(cin >> n >> r,n||r){ for(int i=0;i<n;i++){ a[i] = n-i; } for(int i=0;i<r;i++){ cin >> p >> c; rotate(a,a+p-1,a+p+c-1); } cout << a[0] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:6:11: error: 'cin' was not declared in this scope 6 | while(cin >> n >> r,n||r){ | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | using namespace std; a.cc:13:13: error: 'rotate' was not declared in this scope 13 | rotate(a,a+p-1,a+p+c-1); | ^~~~~~ a.cc:15:5: error: 'cout' was not declared in this scope 15 | cout << a[0] << endl; | ^~~~ a.cc:15:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:15:21: error: 'endl' was not declared in this scope 15 | cout << a[0] << endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | using namespace std;
s870857187
p00710
C++
using namespace std; int main(){ int n,r,p,c,a[50]; while(cin >> n >> r,n||r){ for(int i=0;i<n;i++){ a[i] = n-i; } for(int i=0;i<r;i++){ cin >> p >> c; rotate(a,a+p-1,a+p+c-1); } cout << a[0] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:6:11: error: 'cin' was not declared in this scope 6 | while(cin >> n >> r,n||r){ | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | using namespace std; a.cc:13:13: error: 'rotate' was not declared in this scope 13 | rotate(a,a+p-1,a+p+c-1); | ^~~~~~ a.cc:15:5: error: 'cout' was not declared in this scope 15 | cout << a[0] << endl; | ^~~~ a.cc:15:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:15:21: error: 'endl' was not declared in this scope 15 | cout << a[0] << endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | using namespace std;
s296572774
p00710
C++
using namespace std; int main(){ int n,r,p,c,a[50]; while(cin >> n >> r,n||r){ for(int i=0;i<n;i++){ a[i] = n-i; } for(int i=0;i<r;i++){ cin >> p >> c; rotate(a,a+p-1,a+p+c-1); } cout << a[0] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:6:11: error: 'cin' was not declared in this scope 6 | while(cin >> n >> r,n||r){ | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | using namespace std; a.cc:13:13: error: 'rotate' was not declared in this scope 13 | rotate(a,a+p-1,a+p+c-1); | ^~~~~~ a.cc:15:5: error: 'cout' was not declared in this scope 15 | cout << a[0] << endl; | ^~~~ a.cc:15:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:15:21: error: 'endl' was not declared in this scope 15 | cout << a[0] << endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | using namespace std;
s911641054
p00710
C++
#include <iostream> #include <algorithm> #include <vector> using namespace std; int card[50]; struct CUT{ int p; int c; }; CUT cut[51]; int swap_p[50]; int swap_c[50]; int n,r; void solve(){ for(int i = 0; i < n; i++){ card[i] = n - i; } /* for(int i = 0; i < r ; i++){ for(int x = 0; x < n; x++){ cout << card[x] << " "; } cout << endl; */ for(int j = 0; j < cut[i].p; j++) swap_p[j] = card[j]; for(int k = 0; k < cut[i].c; k++) swap_c[k] = card[cut[i].p + k - 1]; for(int l = 0; l < cut[i].p + cut[i].c - 1;l++){ if(cut[i].c > l) card[l] = swap_c[l] ; else card[l] = swap_p[ l - cut[i].c ]; } } cout << card[0] << endl; return ; } int main(){ while(true){ cin >> n >> r; if(n == 0 && r == 0) break; for(int input = 0; input < r; input++){ cin >> cut[input].p >> cut[input].c ; } solve(); } return 0; }
a.cc: In function 'void solve()': a.cc:28:28: error: 'i' was not declared in this scope 28 | for(int j = 0; j < cut[i].p; j++) swap_p[j] = card[j]; | ^ a.cc:29:28: error: 'i' was not declared in this scope 29 | for(int k = 0; k < cut[i].c; k++) swap_c[k] = card[cut[i].p + k - 1]; | ^ a.cc:30:28: error: 'i' was not declared in this scope 30 | for(int l = 0; l < cut[i].p + cut[i].c - 1;l++){ | ^ a.cc: At global scope: a.cc:35:3: error: 'cout' does not name a type 35 | cout << card[0] << endl; | ^~~~ a.cc:36:3: error: expected unqualified-id before 'return' 36 | return ; | ^~~~~~ a.cc:37:1: error: expected declaration before '}' token 37 | } | ^
s816427463
p00710
C++
#include <iostream> #include <algorithm> #include <vector> #define rep(i,n) for(int i = 0; i < n; i++) #define rrep(i,n) for(int i = n - 1; i >= 0; i--) #define REP(i,k,n) for(int i = k; i < n; i++) #define vi vector<int> #define pb push_back using namespace std; int main(){ int n,r; while(cin >> n >> r,n) { vi card(n); rep(i,n) card[i] = n - i; rep(i,r){ cin >> p >> c; vi tmp(c); rep(j,c) tmp[c] = card[p - 1 + j]; rrep(j,p - 1) card[j + c - 1] = card[j]; rep(j,c) card[j] = tmp[c]; } cout << card[0] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:20: error: 'p' was not declared in this scope 20 | cin >> p >> c; | ^ a.cc:20:25: error: 'c' was not declared in this scope 20 | cin >> p >> c; | ^
s853575211
p00710
C++
#include <iostream> using namespace std; int main(){ int n, r; int card[50], shuf[50]; while(cin >> n >> r){ if(!n) break; for(int i=0;i<n;i++) card[i] = n-i; for(int i=0;i<r;i++){ int p, c; cin >> p >> c; int j=0; for(j=0;j<c;j++) shuf[j] = card[p-1+j]; for(j=c;j<c+p-1;j++) shuf[j] = card[j-c]; for(j=c+p-1;j<n;j++) shuf[j] = card[j]; memcpy(card,shuf,sizeof(card)); } cout << shuf[0] << endl; } }
a.cc: In function 'int main()': a.cc:17:25: error: 'memcpy' was not declared in this scope 17 | memcpy(card,shuf,sizeof(card)); | ^~~~~~ a.cc:2:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 |
s961391286
p00710
C++
#include <iostream> using namespace std; int main(){ int n, r; int card[50]; while(cin >> n >> r, n){ for(int i=0;i<n;i++) card[i] = n-i; for(int i=0;i<r;i++){ int p, c; cin >> p >> c; rotate(card, card+p-1, card+p+c-1); } cout << card[0] << endl; } }
a.cc: In function 'int main()': a.cc:12:25: error: 'rotate' was not declared in this scope 12 | rotate(card, card+p-1, card+p+c-1); | ^~~~~~
s656921773
p00710
C++
#include<algorithm> #include<iostream> #include<string> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> using namespace std; struct ml{ int dt; struct ml *nx; }; typedef struct ml Ml; void f(Ml *a,int p,int q){ int i; Ml *b,*c,*d; b=a; for(i=0;i<p-1;i++) b=b->nx; c=b; for(i=0;i<q;i++) c=c->nx; d=a->nx; a->nx=b->nx; b->nx=c->nx; c->nx=d; return; } int main(){ int i; int n,r,p,q; Ml *a; while(cin>>n>>r&&n+r){ a=(Ml*)malloc((n+2)*sizeof(Ml)); for(i=0;i<n+1;i++){ (a+i)->dt=n-i+1; (a+i)->nx=a+i+1; } (a+i)->dt=n-i+1; for(i=0;i<r;i++){ cin>>p>>q; if(p!=1) f(a,p,q); } cout<<a->nx->dt<<endl; free(a);x } return 0; }
a.cc: In function 'int main()': a.cc:46:13: error: 'x' was not declared in this scope 46 | free(a);x | ^
s751194043
p00710
C++
#include <iostream> using namespace std; int n, r, p, c; int cards[50]; int temp[50]; int main() { while( 1 ) { cin >> n >> r; if(n==0 && r==0) break; for(int i=0; i<n; i++) cards[i] = n-i-1; for(int i=0; i<r; i++) { cin >> p >> c; memcpy(&temp[0], &cards[p-1], sizeof(int) * c); memcpy(&temp[c], &cards[0], sizeof(int) * (p-1)); for(int j=0; j<p+c-1; j++) cards[j] = temp[j]; } printf("%d\n", cards[0]+1); } }
a.cc: In function 'int main()': a.cc:20:25: error: 'memcpy' was not declared in this scope 20 | memcpy(&temp[0], &cards[p-1], sizeof(int) * c); | ^~~~~~ a.cc:2:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 |
s029765309
p00710
C++
#include <iostream> #include <vector> using namespace std; int main(void) { int n,r; int p,c; int i1,i2; cin << n << r; vector<int> fuda(n),temp(n); /* syokika */ for(i1=0;i1<n;i1++){ fuda[i1] = i1+1; // cout << fuda[i1] << " "; } /* copy */ for(i1=0;i1<p-1;i1++){ temp[i1] = fuda[i1]; } /* shuffle */ for(i1=0;i1<c;i1++){ fuda[i1] = fuda[p-1+i1]; } for(i1=c;i1<p-1+c;i1++){ fuda[i1] = temp[i1-c]; } for(i1=0;i1<n;i1++){ cout << fuda[i1] << " "; } return 0; }
a.cc: In function 'int main()': a.cc:13:13: error: no match for 'operator<<' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int') 13 | cin << n << r; | ~~~ ^~ ~ | | | | | int | std::istream {aka std::basic_istream<char>} a.cc:13:13: note: candidate: 'operator<<(int, int)' (built-in) 13 | cin << n << r; | ~~~~^~~~ a.cc:13:13: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int' In file included 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:1: /usr/include/c++/14/string_view:763:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>)' 763 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/string_view:763:5: note: template argument deduction/substitution failed: a.cc:13:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 13 | cin << n << r; | ^ /usr/include/c++/14/bits/basic_string.h:4077:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4077 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:4077:5: note: template argument deduction/substitution failed: a.cc:13:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 13 | cin << n << r; | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:38, from /usr/include/c++/14/string:68: /usr/include/c++/14/cstddef:125:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(byte, _IntegerType)' 125 | operator<<(byte __b, _IntegerType __shift) noexcept | ^~~~~~~~ /usr/include/c++/14/cstddef:125:5: note: template argument deduction/substitution failed: a.cc:13:9: note: cannot convert 'std::cin' (type 'std::istream' {aka 'std::basic_istream<char>'}) to type 'std::byte' 13 | cin << n << r; | ^~~ In file included from /usr/include/c++/14/bits/ios_base.h:46: /usr/include/c++/14/system_error:339:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)' 339 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) | ^~~~~~~~ /usr/include/c++/14/system_error:339:5: note: template argument deduction/substitution failed: a.cc:13:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 13 | cin << n << r; | ^ /usr/include/c++/14/ostream:563:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)' 563 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) | ^~~~~~~~ /usr/include/c++/14/ostream:563:5: note: template argument deduction/substitution failed: a.cc:13:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 13 | cin << n << r; | ^ /usr/include/c++/14/ostream:573:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)' 573 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:573:5: note: template argument deduction/substitution failed: a.cc:13:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 13 | cin << n << r; | ^ /usr/include/c++/14/ostream:579:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)' 579 | operator<<(basic_ostream<char, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:579:5: note: template argument deduction/substitution failed: a.cc:13:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 13 | cin << n << r; | ^ /usr/include/c++/14/ostream:590:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)' 590 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:590:5: note: template argument deduction/substitution failed: a.cc:13:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 13 | cin << n << r; | ^ /usr/include/c++/14/ostream:595:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)' 595 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:595:5: note: template argument deduction/substitution failed: a.cc:13:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 13 | cin << n << r; | ^ /usr/include/c++/14/ostream:654:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const _CharT*)' 654 | operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:654:5: note: template argument deduction/substitution failed: a.cc:13:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 13 | cin << n << r; | ^ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:307:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const char*)' 307 | operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:307:5: note: template argument deduction/substitution failed: a.cc:13:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 13 | cin << n << r; | ^ /usr/include/c++/14/ostream:671:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char*)' 671 | operator<<(basic_ostream<char, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:671:5: note: template argument deduction/substitution failed: a.cc:13:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 13 | cin << n << r; | ^ /usr/include/c++/14/ostream:684:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const signed char*)' 684 | operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:684:5: note: template argument deduction/substitution failed: a.cc:13:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 13 | cin << n << r; | ^ /usr/include/c++/14/ostream:689:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const unsigned char*)' 689 | operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:689:5: note: template argument deduction/substitution failed: a.cc:13:16: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 13 | cin << n << r; | ^ /usr/include/c++/14/ostream:810:5: note: candidate: 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&)' 810 | operator<<(_Ostream&& __os, const _Tp& __x) | ^~~~~~~~ /usr/include/c++/14/ostream:810:5: note: template argument deduction/substitution failed: /usr/include/c++/14/ostream: In substitution of 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&) [with _Ostream = std::basic_istream<char>&; _Tp = int]': a.cc:13:9: required from here 13 | cin << n << r; | ^ /usr/include/c++/14/ostream:810:5: error: no type named 'type' in 'struct std::enable_if<false, void>' 810 | operator<<(_Ostream&& __os, const _Tp& __x) | ^~~~~~~~
s090545906
p00710
C++
// ・AOJ1142(setの練習問題) // ・AOJ1129(vectorの練習問題) // ・AOJ10032(stackの練習問題) // ・AOJ10027(stringの練習問題) // ・AOJ10021(sort || priority_queueの練習問題) // ・AOJ1064(オーバーロードの練習問題) // ・AOJ0138(mapの練習問題) // ・AOJ0105(mapの練習問題) #include <iostream> #include <cstdio> #include <vector> using namespace std; int main() { int n, r, p, c; vector<int> v; vector<int>::iterator ite; while(1){ scanf("%d%d", &n, &r); if(n ==0 && r == 0) break; for (int i=1; i<=n; i++) { v.push_back(i); } for (int i=0; i<r; i++) { scanf("%d%d", &p, &c); ite = v.end()-p-c+1; for(int j=0; j<c; j++) { v.push_back(*ite); v.erase(ite); } // vector<int>::iterator test; // test = v.begin(); // while(test != v.end()){printf("%d", *test); test++;} // printf("\n"); // } ite = v.end()-1; printf("%d\n", *ite); } }
a.cc: In function 'int main()': a.cc:38:2: error: expected '}' at end of input 38 | } | ^ a.cc:15:12: note: to match this '{' 15 | int main() { | ^
s868438884
p00710
C++
#include<iostream> #include<string> #include<vector> #include<algorithm> #include<cstdio> using namespace std; int main(){ int maisu[50]; int katto; int swap[50]; int p,c; int i,j=0; int test; for(i=0; i<50; i++){ maisu[i] = i; } cout << maisu[0] << endl; cin >> katto; // while(j <= katto){ while(true){ scanf("%d%d",&p,&c); if(p == 0 && c == 0){break;} for(i=0; i<c; i++){ swap[i] = maisu[i + p-1]; } for(i = 0; i<p-1; i++){ swap[i+c] = maisu[i]; } for(i=0;i<p+c-1; i++){ maisu[i] = swap[i]; } } // if(p == 0 && c == 0){ // break; } // } cout << maisu[0] << endl; return 0; }
a.cc:37:5: error: 'cout' does not name a type 37 | cout << maisu[0] << endl; | ^~~~ a.cc:38:5: error: expected unqualified-id before 'return' 38 | return 0; | ^~~~~~ a.cc:39:1: error: expected declaration before '}' token 39 | } | ^
s559214768
p00710
C++
#include <iostream> using namespace std; int card[50]; int buffer[50]; void main() { int n,r; while(cin>>n>>r,n!=0){ for(int i=0;i<n;i++)card[i]=i+1; for(int i=0;i<r;i++){ int p,c; cin>>p>>c; for(j=0;j<p-1;j++) buffer[j]=card[j]; for(j=0;j<c;j++) card[j]=card[j+p-1]; for(j=0;j<p-1;j++) card[j+c-1]=buffer[j]; } cout<<card[0]<<endl; } }
a.cc:5:1: error: '::main' must return 'int' 5 | void main() | ^~~~ a.cc: In function 'int main()': a.cc:13:29: error: 'j' was not declared in this scope 13 | for(j=0;j<p-1;j++) | ^ a.cc:15:29: error: 'j' was not declared in this scope 15 | for(j=0;j<c;j++) | ^ a.cc:17:29: error: 'j' was not declared in this scope 17 | for(j=0;j<p-1;j++) | ^
s534355986
p00710
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; #define rep(i, j) for(int i = 0; i < j; i++) #define for(i, j, k) for(int i = j; i < k; i++) int main(){ int n, r; while(cin >>n >>r && n){ vector<int> v; for(int i = n; i > 0; i--) v.push_back(i); rep(i, r){ int p, c; cin >>p >>c; vector<int> next; for(int i = 0; i < c; i++) next.push_back(v[p - 1 + i]); for(int i = 0; i < p - 1; i++) next.push_back(v[i]); for(int i = p + c - 1; i < v.size(); i++) next.push_back(v[i]); v = next; } cout <<v[0] <<endl; } return 0; }
a.cc:12:30: error: macro "for" requires 3 arguments, but only 1 given 12 | for(int i = n; i > 0; i--) v.push_back(i); | ^ a.cc:6:9: note: macro "for" defined here 6 | #define for(i, j, k) for(int i = j; i < k; i++) | ^~~ a.cc:14:13: error: macro "for" requires 3 arguments, but only 1 given 14 | rep(i, r){ | ^ a.cc:6:9: note: macro "for" defined here 6 | #define for(i, j, k) for(int i = j; i < k; i++) | ^~~ a.cc:18:32: error: macro "for" requires 3 arguments, but only 1 given 18 | for(int i = 0; i < c; i++) next.push_back(v[p - 1 + i]); | ^ a.cc:6:9: note: macro "for" defined here 6 | #define for(i, j, k) for(int i = j; i < k; i++) | ^~~ a.cc:19:36: error: macro "for" requires 3 arguments, but only 1 given 19 | for(int i = 0; i < p - 1; i++) next.push_back(v[i]); | ^ a.cc:6:9: note: macro "for" defined here 6 | #define for(i, j, k) for(int i = j; i < k; i++) | ^~~ a.cc:20:47: error: macro "for" requires 3 arguments, but only 1 given 20 | for(int i = p + c - 1; i < v.size(); i++) next.push_back(v[i]); | ^ a.cc:6:9: note: macro "for" defined here 6 | #define for(i, j, k) for(int i = j; i < k; i++) | ^~~ a.cc: In function 'int main()': a.cc:12:32: error: expected '(' before 'v' 12 | for(int i = n; i > 0; i--) v.push_back(i); | ^ | ( a.cc:12:44: error: 'i' was not declared in this scope 12 | for(int i = n; i > 0; i--) v.push_back(i); | ^ a.cc:5:19: error: expected primary-expression before 'for' 5 | #define rep(i, j) for(int i = 0; i < j; i++) | ^~~ a.cc:14:5: note: in expansion of macro 'rep' 14 | rep(i, r){ | ^~~ a.cc:12:47: error: expected ';' before 'for' 12 | for(int i = n; i > 0; i--) v.push_back(i); | ^ | ; a.cc:5:19: error: expected primary-expression before 'for' 5 | #define rep(i, j) for(int i = 0; i < j; i++) | ^~~ a.cc:14:5: note: in expansion of macro 'rep' 14 | rep(i, r){ | ^~~ a.cc:12:47: error: expected ')' before 'for' 12 | for(int i = n; i > 0; i--) v.push_back(i); | ~ ^ | ) a.cc:14:14: error: expected '(' before '{' token 14 | rep(i, r){ | ^ | ( a.cc:14:14: error: expected primary-expression before '{' token a.cc:24:3: error: expected primary-expression before '}' token 24 | } | ^ a.cc:23:24: error: expected ')' before '}' token 23 | cout <<v[0] <<endl; | ^ | ) 24 | } | ~ a.cc:14:14: note: to match this '(' 14 | rep(i, r){ | ^ a.cc:24:3: error: expected primary-expression before '}' token 24 | } | ^
s433027485
p00710
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; #define REP(i, j) for(int i = 0; i < j; i++) #define FOR(i, j, k) for(int i = j; i < k; i++) int main(){ int n, r; while(cin >>n >>r && n){ vector<int> v; for(int i = n; i > 0; i--) v.push_back(i); rep(i, r){ int p, c; cin >>p >>c; vector<int> next; for(int i = 0; i < c; i++) next.push_back(v[p - 1 + i]); for(int i = 0; i < p - 1; i++) next.push_back(v[i]); for(int i = p + c - 1; i < v.size(); i++) next.push_back(v[i]); v = next; } cout <<v[0] <<endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:9: error: 'i' was not declared in this scope 14 | rep(i, r){ | ^ a.cc:14:5: error: 'rep' was not declared in this scope 14 | rep(i, r){ | ^~~
s281836032
p00710
C++
#include <iostream> #include <vector> using namespace std; typedef pair<int, int> PII; int main() { int n, r; while (cin >> n >> r, n || r) { vector<PII> shuffles; for (int i = 0; i < r; ++i) { int p, c; cin >> p >> c; shuffles.push_back(make_pair(p, c)); } reverse(shuffles.begin(), shuffles.end()); int index = 0; for (int i = 0; i < shuffles.size(); ++i) { int p = shuffles[i].first, c = shuffles[i].second; if (index < c) { index += p - 1; } else if (index < c + p - 1) { index -= c; } } cout << n - index << endl; } }
a.cc: In function 'int main()': a.cc:16:17: error: 'reverse' was not declared in this scope 16 | reverse(shuffles.begin(), shuffles.end()); | ^~~~~~~
s616691551
p00710
C++
#include <iostream> #include <algorithm> using namespace std; int main() { int N,R,p,c; while (cin>>N>>R&&N) { int A[100]={}; for(int i=0;i<N;i++){ A[i]=i+1; } reverse(A,A+N) for (int i=0; i<R; ++i) { cin >> p >> c ; rotate(A,A+p,A+p+c); } cout << A[0] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:12:23: error: expected ';' before 'for' 12 | reverse(A,A+N) | ^ | ; 13 | for (int i=0; i<R; ++i) { | ~~~ a.cc:13:23: error: 'i' was not declared in this scope 13 | for (int i=0; i<R; ++i) { | ^
s618246130
p00710
C++
#include <cstdio> #include <vector> using namespace std; int main(){ int n,r; for(;;){ scanf("%d%d",&n,&r); if(n==0 && r==0) break; int p,c; vector<int> ca(n); for(int i=0;i<n;i++){ ca[i]=n-i; } for(int i=0;i<r;i++){ scanf("%d%d",&p,&c); rotate(begin(ca),begin(ca)+p-1,begin(ca)+p-1+c); } printf("%d\n",ca[0]); } }
a.cc: In function 'int main()': a.cc:17:13: error: 'rotate' was not declared in this scope 17 | rotate(begin(ca),begin(ca)+p-1,begin(ca)+p-1+c); | ^~~~~~
s138003354
p00710
C++
#include<iostream> #include<algorithm> #include <vector> #include<array> using namespace std; int N, R, p, c, i, j; int main() { while ( cin >> N >> R && N >0 ) { int A[N] = {}; for ( i = 0; i < N; i++) { A[i] = N - i; } for ( j = 0; j<R; j++) { cin >> p >> c; rotate(A,A+(p-1),A+(p+c-1)) } cout << A[0] <<endl; } }
a.cc: In function 'int main()': a.cc:22:40: error: expected ';' before '}' token 22 | rotate(A,A+(p-1),A+(p+c-1)) | ^ | ; 23 | } | ~
s579495385
p00710
C++
#include<iostream> #include<algorithm> #include <vector> using namespace std; int N, R, p, c, i, j; int A[N] = {}; int main() { while ( cin >> N >> R && N >0 ) { for ( i = 0; i < N; i++) { A[i] = N - i; } for ( j = 0; j<R; j++) { cin >> p >> c; rotate(A,A+(p-1),A+(p+c-1)) } cout << A[0] <<endl; } }
a.cc:8:7: error: size of array 'A' is not an integral constant-expression 8 | int A[N] = {}; | ^ a.cc: In function 'int main()': a.cc:21:40: error: expected ';' before '}' token 21 | rotate(A,A+(p-1),A+(p+c-1)) | ^ | ; 22 | } | ~
s063022071
p00710
C++
#include<iostream> #include<algorithm> #include <vector> using namespace std; int N, R, p, c, i, j; int A[N] = {}; int main() { while ( cin >> N >> R && N >0 ) { int A[N] = {}; for ( i = 0; i < N; i++) { A[i] = N - i; } for ( j = 0; j<R; j++) { cin >> p >> c; rotate(A,A+(p-1),A+(p+c-1)) } cout << A[0] <<endl; } }
a.cc:8:7: error: size of array 'A' is not an integral constant-expression 8 | int A[N] = {}; | ^ a.cc: In function 'int main()': a.cc:22:40: error: expected ';' before '}' token 22 | rotate(A,A+(p-1),A+(p+c-1)) | ^ | ; 23 | } | ~
s323640150
p00710
C++
#include<iostream> #include<algorithm> #include <vector> using namespace std; int N, R, p, c, i, j; int main() { while ( cin >> N >> R && N >0 ) { int A[N]; for ( i = 0; i < N; i++) { A[i] = N - i; } for ( j = 0; j<R; j++) { cin >> p >> c; rotate(A,A+(p-1),A+(p+c-1)) } cout << A[0] <<endl; } }
a.cc: In function 'int main()': a.cc:21:40: error: expected ';' before '}' token 21 | rotate(A,A+(p-1),A+(p+c-1)) | ^ | ; 22 | } | ~
s634747065
p00710
C++
#include <algorithm> #include <iostream> #include <vector> using namespace std; int n, r, p, c; vector<int> cards(50); void shuffle(int p, int c) { reverse(cards.begin(), cards.begin() + p); reverse(cards.begin() + p, cards.begin() + p + c); reverse(cards.begin(), cards.begin() + p + c); } int main() { while (1) { cin >> n >> r; if ( ! n && ! r) break; iota(cards.rend() - n, cards.rend(), 1); for (int i=0; i<r; ++i) { cin >> p >> c; shuffle(p - 1, c); } cout << cards[0] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:9: error: 'iota' was not declared in this scope 20 | iota(cards.rend() - n, cards.rend(), 1); | ^~~~
s643938814
p00710
C++
#include <iostream> #define VARIABLE(x) cerr << #x << "=" << x << endl #define rep(i,n) for(int i=0;i<(int)(n);i++) #define REP(i,m,n) for (int i=m;i<(int)(n);i++) const int INF = 10000000; using namespace std; typedef long long ll; /** Problem1129 : Hanafuda Shuffle **/ int main() { vector<int> card; int n, r, p, c; while (cin >> n >> r, n||r) { card.clear(); rep(i, n) card.push_back(n-i); rep(k, r) { cin >> p >> c; vector<int> tmp; rep(i, c) tmp.push_back(card[i+p-1]); rep(i, p-1) tmp.push_back(card[i]); REP(i, p+c-1, n) { tmp.push_back(card[i]); } card = tmp; } cout << card[0] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:14:9: error: 'vector' was not declared in this scope 14 | vector<int> card; | ^~~~~~ a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 1 | #include <iostream> +++ |+#include <vector> 2 | a.cc:14:16: error: expected primary-expression before 'int' 14 | vector<int> card; | ^~~ a.cc:18:17: error: 'card' was not declared in this scope 18 | card.clear(); | ^~~~ a.cc:24:32: error: expected primary-expression before 'int' 24 | vector<int> tmp; | ^~~ a.cc:26:33: error: 'tmp' was not declared in this scope; did you mean 'tm'? 26 | tmp.push_back(card[i+p-1]); | ^~~ | tm a.cc:28:33: error: 'tmp' was not declared in this scope; did you mean 'tm'? 28 | tmp.push_back(card[i]); | ^~~ | tm a.cc:30:33: error: 'tmp' was not declared in this scope; did you mean 'tm'? 30 | tmp.push_back(card[i]); | ^~~ | tm a.cc:32:32: error: 'tmp' was not declared in this scope; did you mean 'tm'? 32 | card = tmp; | ^~~ | tm
s456145804
p00710
C++
#include <iostream> #include <stack> using namespace std; int main() { int n,r; while(cin>>n>r){ if(n==0&&r==0)break; stack<int> st1; for(int i=0; i<n; i++){ st1.push(i+1); } for(int rop=0; rop<r; rop++){ int p,c; cin>>p>>c; stack<int> st2,st3; for(int i=0; i<p-1; i++){ st2.push(st1.top()); st1.pop(); } for(int i=0; i<c; i++){ st3.push(st1.top()); st1.pop(); } while (!st2.empty()) { st1.push(st2.top()); st2.pop(); } while (!st3.empty()) { st1.push(st3.top()); st3.pop(); } } cout<<st1.top()<<endl; } }
a.cc: In function 'int main()': a.cc:9:17: error: no match for 'operator>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'int') 9 | while(cin>>n>r){ | ~~~~~~^~ | | | | | int | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} a.cc:9:17: note: candidate: 'operator>(int, int)' (built-in) 9 | while(cin>>n>r){ | ~~~~~~^~ a.cc:9:17: note: no known conversion for argument 1 from 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/string:48, 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.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 462 | operator>(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed: a.cc:9:18: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 9 | while(cin>>n>r){ | ^ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 507 | operator>(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed: a.cc:9:18: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 9 | while(cin>>n>r){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1714 | operator>(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed: a.cc:9:18: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 9 | while(cin>>n>r){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1774 | operator>(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed: a.cc:9:18: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 9 | while(cin>>n>r){ | ^ 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:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed: a.cc:9:18: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>' 9 | while(cin>>n>r){ | ^ 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:695:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 695 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:695:5: note: template argument deduction/substitution failed: a.cc:9:18: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 9 | while(cin>>n>r){ | ^ /usr/include/c++/14/string_view:702: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> >)' 702 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:702:5: note: template argument deduction/substitution failed: a.cc:9:18: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 9 | while(cin>>n>r){ | ^ /usr/include/c++/14/string_view:710: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>)' 710 | operator> (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:710:5: note: template argument deduction/substitution failed: a.cc:9:18: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 9 | while(cin>>n>r){ | ^ /usr/include/c++/14/bits/basic_string.h:3915: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>&)' 3915 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3915:5: note: template argument deduction/substitution failed: a.cc:9:18: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 9 | while(cin>>n>r){ | ^ /usr/include/c++/14/bits/basic_string.h:3929:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3929 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3929:5: note: template argument deduction/substitution failed: a.cc:9:18: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 9 | while(cin>>n>r){ | ^ /usr/include/c++/14/bits/basic_string.h:3942:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3942 | operator>(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3942:5: note: template argument deduction/substitution failed: a.cc:9:18: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>' 9 | while(cin>>n>r){ | ^ 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:2619:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator>(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2619 | operator>(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2619:5: note: template argument deduction/substitution failed: a.cc:9:18: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>' 9 | while(cin>>n>r){ | ^ In file included from /usr/include/c++/14/deque:66, from /usr/include/c++/14/stack:62, from a.cc:2: /usr/include/c++/14/bits/stl_deque.h:2349:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator>(const deque<_Tp, _Alloc>&, const deque<_Tp, _Alloc>&)' 2349 | operator>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_deque.h:2349:5: note: template argument deduction/substitution failed: a.cc:9:18: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::deque<_Tp, _Alloc>' 9 | while(cin>>n>r){ | ^ In file included from /usr/include/c++/14/stack:63: /usr/include/c++/14/bits/stl_stack.h:387:5: note: candidate: 'template<class _Tp, class _Seq> bool std::operator>(const stack<_Tp, _Seq>&, const stack<_Tp, _Seq>&)' 387 | operator>(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_stack.h:387:5: note: template argument deduction/substitution failed: a.cc:9:18: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::stack<_Tp, _Seq>' 9 | while(cin>>n>r){ | ^
s382580072
p00711
Java
import java.util.Scanner; public class Main { static int w,h; static int[][] tile; public static void main (String[]args) { Scanner in = new Scanner(System.in); while(true) { w = in.nextInt(); h = in.nextInt(); if(w==0) break; tile = new int[w][h]; String s; int x=0,y=0; for(int i=0; i<w; i++) { s = in.next(); for (int j=0; j<h; j++) { if(s.charAt(j)=='#') { tile[i][j]=0; }else if(s.charAt(j)=='.') { tile[i][j]=1; }else { tile[i][j]=0; x = i; y = j; } } } System.out.println(canMove(x,y)); } } public int canMove (int a, int b) { int m = 0; tile[a][b] = 0; if(a>0)if(tile[a-1][b]==1)m+=canMove(a-1,b); if(a<w-1)if(tile[a+1][b]==1)m+=canMove(a+1,b); if(b>0)if(tile[a][b-1]==1)m+=canMove(a,b-1); if(b<h-1)if(tile[a][b+1]==1)m+=canMove(a,b+1); return m++; } }
Main.java:37: error: non-static method canMove(int,int) cannot be referenced from a static context System.out.println(canMove(x,y)); ^ 1 error
s406692779
p00711
Java
package aoj; import java.util.Scanner; /** * AOJ id=1130 * Red and Black * @author scache * */ public class Main1130 { public static void main(String[] args) { Main1130 p = new Main1130(); } public Main1130() { Scanner sc = new Scanner(System.in); while(true){ w = sc.nextInt(); if(w==0) break; h = sc.nextInt(); map = new char[h][w]; for(int i=0;i<h;i++) map[i] = sc.next().toCharArray(); solve(map); } } int w; int h; char[][] map; public void solve(char[][] map) { int sx = -1; int sy = -1; for(int i=0;i<map.length;i++){ for(int j=0;j<map[i].length;j++){ if(map[i][j]=='@'){ sx = j; sy = i; break; } } if(sx>=0) break; } System.out.println(rec(sx, sy)); } int[] dx = { -1, 0, 1, 0 }; int[] dy = { 0, -1, 0, 1 }; private int rec(int curx, int cury) { if(map[cury][curx]=='#') return 0; map[cury][curx] = '#'; int res = 1; for(int i=0;i<4;i++){ int nx = curx + dx[i]; int ny = cury + dy[i]; if(nx<0 || w<=nx || ny<0 || h<=ny) continue; res += rec(nx, ny); } return res; } }
Main.java:11: error: class Main1130 is public, should be declared in a file named Main1130.java public class Main1130 { ^ 1 error
s369434253
p00711
Java
package com.company; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; /** * Created by YuyaKita on 2015/05/18. */ public class RedAndBlack { static final int MAX_W = 20, MAX_H = 20; static int W, H; static char[][] tiles = new char[MAX_H + 1][MAX_W + 1]; static int count = 0; static int[] dx = {-1, 0, 1, 0}; static int[] dy = {0, -1, 0, 1}; public static void main(String args[]) throws FileNotFoundException { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { W = sc.nextInt(); H = sc.nextInt(); if (W == 0 && H == 0) return; sc.nextLine(); for (int i = 0; i < H; i++) { tiles[i] = sc.nextLine().toCharArray(); } System.out.println(solve(tiles)); } } static int solve(char[][] input) { count = 0; for (int i = 0; i < W; i++) { for (int j = 0; j < H; j++) { if (tiles[j][i] == '@') dfs(i, j); } } return count; } static void dfs(int x, int y) { count++; tiles[y][x] = '#'; for (int i = 0; i < dx.length; i++) { int nx = x + dx[i]; int ny = y + dy[i]; if (nx >= 0 && nx < W && ny >= 0 && ny < H && tiles[ny][nx] == '.') { dfs(nx, ny); } } } }
Main.java:10: error: class RedAndBlack is public, should be declared in a file named RedAndBlack.java public class RedAndBlack { ^ 1 error
s121667378
p00711
Java
package com.company; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; /** * Created by YuyaKita on 2015/05/18. */ public class RedAndBlack { static final int MAX_W = 20, MAX_H = 20; static int W, H; static char[][] tiles = new char[MAX_H + 1][MAX_W + 1]; static int count = 0; static int[] dx = {-1, 0, 1, 0}; static int[] dy = {0, -1, 0, 1}; public static void main(String args[]) throws FileNotFoundException { Scanner sc = new Scanner(new File("aojIn.txt")); while (true) { W = sc.nextInt(); H = sc.nextInt(); if (W == 0 && H == 0){ sc.close(); break; } sc.nextLine(); for (int i = 0; i < H; i++) { tiles[i] = sc.nextLine().toCharArray(); } System.out.println(solve(tiles)); } } static int solve(char[][] input) { count = 0; for (int i = 0; i < W; i++) { for (int j = 0; j < H; j++) { if (tiles[j][i] == '@') dfs(i, j); } } return count; } static void dfs(int x, int y) { count++; tiles[y][x] = '#'; for (int i = 0; i < dx.length; i++) { int nx = x + dx[i]; int ny = y + dy[i]; if (nx >= 0 && nx < W && ny >= 0 && ny < H && tiles[ny][nx] == '.') { dfs(nx, ny); } } } }
Main.java:10: error: class RedAndBlack is public, should be declared in a file named RedAndBlack.java public class RedAndBlack { ^ 1 error
s357171577
p00711
Java
package com.company; import java.io.File; import java.util.Scanner; /** * Created by YuyaKita on 2015/05/18. */ public class Main { static final int MAX_W = 20, MAX_H = 20; static int W, H; static char[][] tiles = new char[MAX_H + 1][MAX_W + 1]; static int count = 0; static int[] dx = {-1, 0, 1, 0}; static int[] dy = {0, -1, 0, 1}; public static void main(String args[]){ Scanner sc = new Scanner(System.in); while (true) { W = sc.nextInt(); H = sc.nextInt(); if (W == 0 && H == 0){ break; } sc.nextLine(); for (int i = 0; i < H; i++) { tiles[i] = sc.nextLine().toCharArray(); } System.out.println(solve(tiles)); } sc.close(); } static int solve(char[][] input) {javascript:void(0) count = 0; for (int i = 0; i < W; i++) { for (int j = 0; j < H; j++) { if (tiles[j][i] == '@') dfs(i, j); } } return count; } static void dfs(int x, int y) { count++; tiles[y][x] = '#'; for (int i = 0; i < dx.length; i++) { int nx = x + dx[i]; int ny = y + dy[i]; if (nx >= 0 && nx < W && ny >= 0 && ny < H && tiles[ny][nx] == '.') { dfs(nx, ny); } } } }
Main.java:37: error: illegal start of expression static int solve(char[][] input) {javascript:void(0) ^ Main.java:37: error: ';' expected static int solve(char[][] input) {javascript:void(0) ^ 2 errors
s792300389
p00711
Java
import java.util.Scanner; public class DFSKurihara { int H, W; int[] dx = {1, 0, -1, 0}; int[] dy = {0, 1, 0, -1}; void run(){ Scanner sc = new Scanner(System.in); while(true){ W = sc.nextInt(); H = sc.nextInt(); if((H | W) == 0){ break; } sc.nextLine(); char[][] field = new char[H][W]; for(int i = 0; i < H; ++i){ field[i] = sc.nextLine().toCharArray(); } for(int i = 0; i < H; ++i){ for(int j = 0; j < W; ++j){ if(field[i][j] == '@'){ System.out.println(dfs(field, i, j)); } } } } } int dfs(char[][] field, int y, int x){ if(y < 0 || H <= y || x < 0 || W <= x){ return 0; } if(field[y][x] == '#'){ return 0; } field[y][x] = '#'; int ret = 0; for(int i = 0; i < 4; ++i){ ret += dfs(field, y+dy[i], x+dx[i]); } return ret+1; } public static void main(String[] args) { new DFSKurihara().run(); } }
Main.java:3: error: class DFSKurihara is public, should be declared in a file named DFSKurihara.java public class DFSKurihara { ^ 1 error
s465007071
p00711
Java
#include <iostream> int H, W; int map[20][20]; int c; using namespace std; void printArray(); void check(int, int); int main() { cin >> W >> H; int sy, sx; for (int i = 0; i < H; i++) { string line; cin >> line; for (int j = 0; j < W; j++) { if (line[j] == '@') { sy = i; sx = j; map[i][j] = 0; } else if (line[j] == '.') { map[i][j] = 0; } else if (line[j] == '#') { map[i][j] = 1; } } } // printArray(); c = 0; check(sy, sx); // printArray(); cout << c << endl; return 0; } void check(int y, int x) { if (y < 0 || x < 0 || y >= H || x >= W || map[y][x] == 1) { return; } map[y][x] = 1; c++; check(y + 1, x); check(y - 1, x); check(y, x + 1); check(y, x - 1); } void printArray() { for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cout << map[i][j]; } cout << endl; } }
Main.java:1: error: illegal character: '#' #include <iostream> ^ Main.java:1: error: class, interface, enum, or record expected #include <iostream> ^ Main.java:4: error: class, interface, enum, or record expected int map[20][20]; ^ Main.java:5: error: unnamed classes are a preview feature and are disabled by default. int c; ^ (use --enable-preview to enable unnamed classes) Main.java:6: error: class, interface, enum, or record expected using namespace std; ^ Main.java:9: error: <identifier> expected void check(int, int); ^ Main.java:9: error: <identifier> expected void check(int, int); ^ Main.java:12: error: not a statement cin >> W >> H; ^ Main.java:16: error: not a statement cin >> line; ^ Main.java:33: error: not a statement cout << c << endl; ^ Main.java:52: error: not a statement cout << map[i][j]; ^ Main.java:54: error: not a statement cout << endl; ^ 12 errors
s159242704
p00711
Java
import java.util.NoSuchElementException; import java.util.Scanner; public class RedandBlack { static int c = 0; static int[][] directions = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}}; static int[][] m; public static void spreadFrom(int x, int y) { if (m[y][x] == 0) { m[y][x] = 1; c++; } for (int k =0; k < 4; k++) { int nx = x + directions[k][0]; int ny = y + directions[k][1]; if (nx >= 0 && nx < m[y].length && ny >= 0 && ny < m.length) { spreadFrom(nx, ny); } } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { c = 0; int W = sc.nextInt(); int H = sc.nextInt(); if (W == 0 && H == 0) break; m = new int[H][W]; int[] start = new int[2]; for (int i = 0; i < H; i++) { String rowStr = sc.next(); for (int j = 0; j < W; j++) { int point; switch (Character.toString(rowStr.charAt(j))) { case ".": point = 1; break; case "#": point = 0; break; case "@": point = 2; start[0] = i; start[1] = j; break; default: throw new NoSuchElementException(); } m[i][j] = point; } } spreadFrom(start[0], start[1]); System.out.println(c); } } }
Main.java:4: error: class RedandBlack is public, should be declared in a file named RedandBlack.java public class RedandBlack { ^ 1 error
s111824022
p00711
Java
import java.util.*; public class Main { static int w, h, count, before; static int[][] dir = {{-1,0}, {0,-1}, {1,0}, {0, 1}}; public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(true){ w = sc.nextInt(); h = sc.nextInt(); sc.nextLine(); if(w == 0){ break; } int[] pos = new int[2]; int [][] c = new int[h][w]; char abc; String str = new String(); for(int i = 0; i < h; i++){/* ????????? */ str = sc.nextLine();/* ?????§???????????? */ for(int j = 0; j < w; j++){ abc = str.charAt(j); if(abc == '#'){ c[i][j] = 0; }else if(abc == '.'){ c[i][j] = 1; }else if(abc == '@'){ c[i][j] = 1; pos[0] = i; pos[1] = j; } } } count = 0; before = 1; int y; y = search(c , pos[0], pos[1]); System.out.println(count); } } public static int search(int[][] c, int i, int j){ if(c[i][j] == 0){ return 0; } c[i][j] = 0; count++; int d = before + 2/* ????????°????????????????????´???????§???? */; if(d > 3){ d -= 4; } for(int k = 0; k < 4; k++){ d++; if(d > 3){ d -= 4; } before = d; int x = i + dir[d][0], y = j + dir[d][1]; if((x >= 0) && (x < h) && (y >= 0) && (y < w)){ int z = search(c, x, y); } } return 1; }
Main.java:72: error: reached end of file while parsing } ^ 1 error
s813875739
p00711
Java
import java.util.*; public class RedAndBlack { static Scanner sc = new Scanner(System.in); static int W, H, res; static char [][]field; static int[]dx = {-1, 0, 1, 0}, dy = {0, 1, 0, -1}; public static void main(String[] args) { while(read()){ search_Start(); System.out.println(res); } } static boolean read(){ W = sc.nextInt(); H = sc.nextInt(); if(W == 0 && H == 0) return false; field = new char[H][W]; res = 0; String line; for(int i = 0; i < H; i++){ line = sc.next(); for(int j = 0; j < W; j++) field[i][j] = line.charAt(j); } return true; } static void search_Start(){ /** * ツづ慊つクツづ債スツタツーツトツ地ツ点ツづーツ探ツつキツ。 */ for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ /** * ツ個ゥツづつつッツつスツづァツ探ツ催オツ開ツ始 */ if(field[i][j] == '@') dfs(j, i); } } } static void dfs(int x, int y){ field[y][x] = '#'; res++; int mx = 0, my = 0; for(int i = 0; i < 4; i++){ mx = x + dx[i]; my = y + dy[i]; if( 0 <= mx && mx < W && 0 <= my && my < H && field[my][mx] == '.') dfs(mx, my); } } }
Main.java:2: error: class RedAndBlack is public, should be declared in a file named RedAndBlack.java public class RedAndBlack { ^ 1 error
s612017262
p00711
Java
import java.util.*; public class Main { private static Scanner sc = new Scanner(System.in); public static void main(String...args) { while(sc.hasNext()) { final int W = sc.nextInt(); final int H = sc.nextInt(); if (W == 0 && H == 0) break; solve(W, H); } } private static void solve(final int W, final int H) { final char[][] map = new char[H][]; for(int i = 0; i < H; i+;) map[i] = sc.next().toCharArray(); final Deque<Integer> deq = new ArrayDeque<Integer>(); for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) if(map[i][j] == '@') deq.offer(i * W + j); int ans = 0; while(!deq.isEmpty()) { final int p = deq.poll(); final int i = p / W; final int j = p % W; for(int d = 0; d < 4; d++) { final int ni = i + di[d]; final int nj = j + dj[d]; if(0 <= ni && ni < H && 0 <= nj && nj < W && map[ni][nj] == '.') { map[ni][nj] = '#'; deq.offer(ni * W + nj); ans++; } } } System.out.println(ans); } private static final int[] di = { 1, 0, -1, 0}; private static final int[] dj = { 0, 1, 0, -1 }; }
Main.java:16: error: illegal start of expression for(int i = 0; i < H; i+;) ^ Main.java:16: error: not a statement for(int i = 0; i < H; i+;) ^ Main.java:16: error: illegal start of expression for(int i = 0; i < H; i+;) ^ 3 errors
s363104426
p00711
Java
import java.util.*; class Main{ public static void main(String a[]) throws java.io.IOException{ Scanner scan =new Scanner (System.in); Pair pair= new Pair(); Queue<Pair> fifo = new LinkedList<Pair>(); while(true){ int W =scan.nextInt(); int H =scan.nextInt(); if((W|H)==0)break; char [][] map = new char [H][W]; for(int i=0;i<H;i++){ String tmp =scan.next(); for(int j=0;j<W;j++){ map[i][j] = tmp.charAt(j); if(tmp.charAt(j)=='@'){ pair.x=j; pair.y=i; fifo.add(pair); } } } int count =0; while(fifo.peek()!=null){ pair = fifo.poll(); int x=pair.x; int y=pair.y; int[] dx ={0,1,0,-1}; int[] dy ={1,0,-1,0}; for(int i=0;i<4;i++){ int nx =x+dx[i]; int ny =y+dy[i]; if(0<=nx&&nx<W&&0<=ny&&ny<H&&map[ny][nx]!='#'){ Pair npair =new Pair(); npair.x=nx; npair.y=ny; fifo.add(npair); map[ny][nx] = '#'; count++; } } System.out.println(count); } } } class Pair{ public int x; public int y; }
Main.java:56: error: reached end of file while parsing } ^ 1 error
s898075879
p00711
Java
import java.util.*; class Main { int dx[]={-1,0,1,0}; int dy[]={0,1,0,-1}; char[][] map; void run() { Scanner sc=new Scanner(System.in); while(true){ int W=sc.nextInt(); int H=sc.nextInt();sc.nextLine(); if(W==0&&H==0)break; int startX=0,startY=0; map=new char[H+2][W+2]; for(int i=0;i<H+2;i++){ Arrays.fill(map[i],'#'); } for(int i=1;i<H+1;i++){ char[] s=sc.next().toCharArray(); for(int j=0;j<W;j++){ if(s[j]=='@'){ startY=i; startX=j+1; } map[i][j+1]=s[j]; } } System.out.println(DFS(startY,startX)); } } int DFS(int y,int x) { if(map[y][x]=='#')return 0; map[y][x]='#'; int sum=1; for(int i=0;i<4;i++){ sum+=DFS(y+dy[i],x+dx[i]); } return sum; } public static void main(String[] args) { new AOJ1130().run(); } }
Main.java:46: error: cannot find symbol new AOJ1130().run(); ^ symbol: class AOJ1130 location: class Main 1 error
s228288041
p00711
Java
import java.util.Scanner; import java.util.Stack; public class Main2 { static int[] v1 = { 0, 1, 0, -1 }; static int[] v2 = { 1, 0, -1, 0 }; static int[][] field; static int count = 0; public static void main(String[] args) { Scanner cin = new Scanner(System.in); while (true) { int w = cin.nextInt(); int h = cin.nextInt(); if(w+h==0){break;} int startx = 0, starty = 0; count=0; field = new int[h + 2][w + 2]; for (int i = 1; i <= h; i++) { String str = cin.next(); for (int j = 1; j <= w; j++) { if (str.charAt(j-1) == '.') { field[i][j] = 1; } else if (str.charAt(j-1) == '#') { field[i][j] = 2; } else if (str.charAt(j-1) == '@') { field[i][j] = 1; startx = i; starty = j; } } } Integer[] start = {startx,starty}; Stack<Integer[]> s = new Stack<Integer[]>(); s.add(start); while(!s.isEmpty()){ Integer[] a = s.pop(); count++; field[a[0]][a[1]]=2; for(int i = 0;i<4;i++){ int xx = a[0]+v1[i]; int yy = a[1]+v2[i]; if(field[xx][yy]==1){ Integer[] next={xx,yy}; s.add(next); } } } System.out.println(count); } } }
Main.java:4: error: class Main2 is public, should be declared in a file named Main2.java public class Main2 { ^ 1 error
s792823585
p00711
Java
public class Main { public static void main(String[] args) { search(); } public static void search(){ Queue<Integer> xqueue = new LinkedList<Integer>(); Queue<Integer> yqueue = new LinkedList<Integer>(); int X; int Y; Scanner input = new Scanner(System.in); String[][] grid; int[][] visit; int currentX = 0;; int currentY = 0; X = input.nextInt(); Y = input.nextInt(); if(X == 0 && Y ==0){ input.close(); System.exit(0); } grid = new String[Y][X]; visit = new int[Y][X]; for(int i = 0; i < Y; i++){ String[] tmp = input.next().split(""); for(int z = 1; z < tmp.length; z++){ grid[i][z-1] = tmp[z]; } for(int j = 0; j < X; j++){ if(grid[i][j].equals("@")){ currentX = j; currentY = i; } } } yqueue.offer(currentY); xqueue.offer(currentX); while(yqueue.peek() != null && xqueue.peek() != null){ if(yqueue.peek() != null && xqueue.peek() != null){ currentY = yqueue.poll(); currentX = xqueue.poll(); } if(visit[currentY][currentX] == 0 && !(grid[currentY][currentX].equals("#"))){ visit[currentY][currentX] = 1; if(currentY > 0 && currentY < Y-1 && currentX > 0 && currentX < X-1){ if(grid[currentY-1][currentX].equals(".")){ yqueue.offer(currentY-1); xqueue.offer(currentX); } if(grid[currentY+1][currentX].equals(".")){ yqueue.offer(currentY+1); xqueue.offer(currentX); } if(grid[currentY][currentX-1].equals(".")){ yqueue.offer(currentY); xqueue.offer(currentX-1); } if(grid[currentY][currentX+1].equals(".")){ yqueue.offer(currentY); xqueue.offer(currentX+1); } } else if(currentY == 0 && currentX > 0 && currentX < X-1){ if(grid[currentY][currentX-1].equals(".")){ yqueue.offer(currentY); xqueue.offer(currentX-1); } if(grid[currentY][currentX+1].equals(".")){ yqueue.offer(currentY); xqueue.offer(currentX+1); } if(grid[currentY+1][currentX].equals(".")){ yqueue.offer(currentY+1); xqueue.offer(currentX); } } else if(currentY == 0 && currentX == X-1){ if(grid[currentY][currentX-1].equals(".")){ yqueue.offer(currentY); xqueue.offer(currentX-1); } if(grid[currentY+1][currentX].equals(".")){ yqueue.offer(currentY+1); xqueue.offer(currentX); } } else if(currentY == 0 && currentX == 0){ if(grid[currentY][currentX+1].equals(".")){ yqueue.offer(currentY); xqueue.offer(currentX+1); } if(grid[currentY+1][currentX].equals(".")){ yqueue.offer(currentY+1); xqueue.offer(currentX); } } else if(currentY > 0 && currentY < Y-1 && currentX == 0){ if(grid[currentY-1][currentX].equals(".")){ yqueue.offer(currentY-1); xqueue.offer(currentX); } if(grid[currentY+1][currentX].equals(".")){ yqueue.offer(currentY+1); xqueue.offer(currentX); } if(grid[currentY][currentX+1].equals(".")){ yqueue.offer(currentY); xqueue.offer(currentX+1); } } else if(currentY == Y-1 && currentX == 0){ if(grid[currentY][currentX+1].equals(".")){ yqueue.offer(currentY); xqueue.offer(currentX+1); } if(grid[currentY-1][currentX].equals(".")){ yqueue.offer(currentY-1); xqueue.offer(currentX); } } else if(currentY > 0 && currentY < Y-1 && currentX == X-1){ if(grid[currentY][currentX-1].equals(".")){ yqueue.offer(currentY); xqueue.offer(currentX-1); } if(grid[currentY+1][currentX].equals(".")){ yqueue.offer(currentY+1); xqueue.offer(currentX); } if(grid[currentY-1][currentX].equals(".")){ yqueue.offer(currentY-1); xqueue.offer(currentX); } }else if(currentY == Y-1 && currentX == X-1){ if(grid[currentY-1][currentX].equals(".")){ yqueue.offer(currentY-1); xqueue.offer(currentX); } if(grid[currentY][currentX-1].equals(".")){ yqueue.offer(currentY); xqueue.offer(currentX-1); } }else if(currentY == Y-1 && currentX > 0 && currentX < X-1){ if(grid[currentY][currentX+1].equals(".")){ yqueue.offer(currentY); xqueue.offer(currentX+1); } if(grid[currentY][currentX-1].equals(".")){ yqueue.offer(currentY); xqueue.offer(currentX-1); } } } } int count = 0; for(int i = 0; i < visit.length; i++){ for(int j = 0; j < visit[i].length; j++){ if(visit[i][j] == 1){ count++; } } } System.out.println(count); search(); } }
Main.java:8: error: cannot find symbol Queue<Integer> xqueue = new LinkedList<Integer>(); ^ symbol: class Queue location: class Main Main.java:8: error: cannot find symbol Queue<Integer> xqueue = new LinkedList<Integer>(); ^ symbol: class LinkedList location: class Main Main.java:9: error: cannot find symbol Queue<Integer> yqueue = new LinkedList<Integer>(); ^ symbol: class Queue location: class Main Main.java:9: error: cannot find symbol Queue<Integer> yqueue = new LinkedList<Integer>(); ^ symbol: class LinkedList location: class Main Main.java:13: error: cannot find symbol Scanner input = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:13: error: cannot find symbol Scanner input = new Scanner(System.in); ^ symbol: class Scanner location: class Main 6 errors
s229367083
p00711
Java
import java.io.*; import java.util.*; public class p1130 { public static void main(String[] args) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { String line; while(true){ /* input */ line = br.readLine(); int w = Integer.parseInt(line.split(" ")[0]); int h = Integer.parseInt(line.split(" ")[1]); if(w == 0 && h == 0){ return; } int[][] field = new int[h][w]; int[] pos = new int[2]; for(int i=0;i<h;i++){ String str = br.readLine(); for(int j=0;j<w;j++){ if(str.charAt(j)=='.'){ field[i][j] = 1; } else if(str.charAt(j)=='#'){ field[i][j] = 0; } else { field[i][j] = 2; pos[0] = i; pos[1] = j; } } } /* processing */ int res = search(pos[0],pos[1],field,h,w); /* output */ System.out.println(res); } } catch (IOException e) { e.printStackTrace(); } } public static int search(int posi, int posj, int[][] field,int h,int w){ int sum = 1; field[posi][posj] = 2; //up if(posi>0&&field[posi-1][posj]==1){ sum += search(posi-1,posj,field,h,w); } //right if(posj<w-1&&field[posi][posj+1]==1){ sum += search(posi,posj+1,field,h,w); } //down if(posi<h-1&&field[posi+1][posj]==1){ sum += search(posi+1,posj,field,h,w); } //left if(posj>0&&field[posi][posj-1]==1){ sum += search(posi,posj-1,field,h,w); } return sum; } }
Main.java:5: error: class p1130 is public, should be declared in a file named p1130.java public class p1130 { ^ 1 error
s751891108
p00711
Java
import java.util.Scanner; /** * Created by Reopard on 2014/05/29. */ public class RedandBlack { static Scanner sc = new Scanner(System.in); static char[][] tile = new char[22][22]; static char black_tile = '.', red_tile = '#', player_tile = '@'; static int W = 0, H = 0; public static void main(String args[]) { int x = 0, y = 0; while ((W = sc.nextInt()) != 0 && (H = sc.nextInt()) != 0) { for (int i = 0; i <= W + 1; i++) tile[0][i] = red_tile; for (int i = 1; i <= H; i++) tile[i] = (red_tile + sc.next() + red_tile).toCharArray(); for (int i = 0; i <= W + 1; i++) tile[H + 1][i] = red_tile; outer: for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { if (tile[i][j] == player_tile) { x = j; y = i; break outer; } } } System.out.println(countBlackTile(x, y)/4); } } static int countBlackTile(int x, int y) { int[] dx = {0, 1, 0, -1}; int[] dy = {-1, 0, 1, 0}; int count = 0; if (tile[y][x] == red_tile) return 0; else { tile[y][x] = red_tile; for(int i = 0; i < 4; i++) { count += countBlackTile(x + dx[i], y + dy[i]) + 1; } } return count; } }
Main.java:6: error: class RedandBlack is public, should be declared in a file named RedandBlack.java public class RedandBlack { ^ 1 error
s437855714
p00711
Java
import java.util.Scanner; /** * Created by Reopard on 2014/05/29. */ public class RedandBlack { static Scanner sc = new Scanner(System.in); static char[][] tile; static char black_tile = '.', red_tile = '#', player_tile = '@'; static int W = 0, H = 0; public static void main(String args[]) { int x = 0, y = 0; while ((W = sc.nextInt()) != 0 && (H = sc.nextInt()) != 0) { tile = new char[H+2][W+2]; for (int i = 0; i <= W + 1; i++) tile[0][i] = red_tile; for (int i = 1; i <= H; i++) tile[i] = (red_tile + sc.next() + red_tile).toCharArray(); for (int i = 0; i <= W + 1; i++) tile[H + 1][i] = red_tile; outer: for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { if (tile[i][j] == player_tile) { x = j; y = i; break outer; } } } /*for (int i = 0; i <= H+1; i++){ for(int j = 0; j <= W+1; j++){ System.out.print(tile[i][j]); } System.out.println(); } System.out.println(tile[y][x]);*/ System.out.println(countBlackTile(x, y)); } } static int countBlackTile(int x, int y) { int[] dx = {0, 1, 0, -1}; int[] dy = {-1, 0, 1, 0}; int count = 1; if (tile[y][x] == red_tile) return 0; else { tile[y][x] = red_tile; for(int i = 0; i < 4; i++) { count += countBlackTile(x + dx[i], y + dy[i]); } } return count; } }
Main.java:6: error: class RedandBlack is public, should be declared in a file named RedandBlack.java public class RedandBlack { ^ 1 error
s325422954
p00711
C
#include <stdio.h> int que[400][2], top, end; int dir[4][2]={{1,0}{0,1}{0,-1}{-1,0}}; char tile1[22][22], tile2[22][22]; int main(void) { int w, h, i, a1, a2, b1, b2, ans; while(scanf("%d %d ", &w, &h)&&w){ memset(tile1, 0, sizeof(tile1)); for(i=0, a1=0; a1<h; a1++){ scanf("%s", tile1[a1]); for(b1=0; b1<w; b1++){ if(map[a1][b1])=='@'){ que[0][0]=a1, que[0][1]=b1; tile1[a1][b1]=1, top=0, end=1, i=1: } } } while(top<end){ a1=que[top][0], b1=que[top++][1]; for(i=0; i<4; i++){ a2=a1+dir[i][0], b2=b1+dir[i][1]; if(a2<0||a2>=h||b2<0||b2>=w||tile2[a2][b2]=='#') continue; tile1[a2][b2]=1; que[end][0]=a2, que[end][1]=b2; } } for(ans=0, a1=0;, a1<h; a1++) for(b1=0; b1<w; b1++) ans+=tile1[a1][b1]; printf("%d\n", ans); } }
main.c:4:21: error: expected '}' before '{' token 4 | int dir[4][2]={{1,0}{0,1}{0,-1}{-1,0}}; | ~ ^ main.c: In function 'main': main.c:12:9: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 12 | memset(tile1, 0, sizeof(tile1)); | ^~~~~~ main.c:2:1: note: include '<string.h>' or provide a declaration of 'memset' 1 | #include <stdio.h> +++ |+#include <string.h> 2 | main.c:12:9: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] 12 | memset(tile1, 0, sizeof(tile1)); | ^~~~~~ main.c:12:9: note: include '<string.h>' or provide a declaration of 'memset' main.c:16:20: error: 'map' undeclared (first use in this function) 16 | if(map[a1][b1])=='@'){ | ^~~ main.c:16:20: note: each undeclared identifier is reported only once for each function it appears in main.c:16:32: error: expected expression before '==' token 16 | if(map[a1][b1])=='@'){ | ^~ main.c:16:37: error: expected statement before ')' token 16 | if(map[a1][b1])=='@'){ | ^ main.c:18:55: error: expected ';' before ':' token 18 | tile1[a1][b1]=1, top=0, end=1, i=1: | ^ | ; main.c:32:25: error: expected expression before ',' token 32 | for(ans=0, a1=0;, a1<h; a1++) | ^
s806324309
p00711
C
#include <stdio.h> int que[400][2], top, end; int dir[4][2]={{1,0}{0,1}{0,-1}{-1,0}}; char tile1[22][22], tile2[22][22]; int main(void) { int w, h, i, a1, a2, b1, b2, ans; while(scanf("%d %d ", &w, &h)&&w){ memset(tile1, 0, sizeof(tile1)); for(i=0, a1=0; a1<h; a1++){ scanf("%s", tile1[a1]); for(b1=0; b1<w; b1++){ if(tile2[a1][b1])=='@'){ que[0][0]=a1, que[0][1]=b1; tile1[a1][b1]=1, top=0, end=1, i=1: } } } while(top<end){ a1=que[top][0], b1=que[top++][1]; for(i=0; i<4; i++){ a2=a1+dir[i][0], b2=b1+dir[i][1]; if(a2<0||a2>=h||b2<0||b2>=w||tile2[a2][b2]=='#') continue; tile1[a2][b2]=1; que[end][0]=a2, que[end][1]=b2; } } for(ans=0, a1=0;, a1<h; a1++) for(b1=0; b1<w; b1++) ans+=tile1[a1][b1]; printf("%d\n", ans); } }
main.c:4:21: error: expected '}' before '{' token 4 | int dir[4][2]={{1,0}{0,1}{0,-1}{-1,0}}; | ~ ^ main.c: In function 'main': main.c:12:9: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 12 | memset(tile1, 0, sizeof(tile1)); | ^~~~~~ main.c:2:1: note: include '<string.h>' or provide a declaration of 'memset' 1 | #include <stdio.h> +++ |+#include <string.h> 2 | main.c:12:9: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] 12 | memset(tile1, 0, sizeof(tile1)); | ^~~~~~ main.c:12:9: note: include '<string.h>' or provide a declaration of 'memset' main.c:16:34: error: expected expression before '==' token 16 | if(tile2[a1][b1])=='@'){ | ^~ main.c:16:39: error: expected statement before ')' token 16 | if(tile2[a1][b1])=='@'){ | ^ main.c:18:55: error: expected ';' before ':' token 18 | tile1[a1][b1]=1, top=0, end=1, i=1: | ^ | ; main.c:32:25: error: expected expression before ',' token 32 | for(ans=0, a1=0;, a1<h; a1++) | ^
s315361164
p00711
C
#include <stdio.h> int que[400][2], top, end; int dir[4][2]={{1,0}{0,1}{0,-1}{-1,0}}; char tile1[22][22], tile2[22][22]; int main(void) { int w, h, i, a1, a2, b1, b2, ans; while(scanf("%d %d ", &w, &h)&&w){ memset(tile1, 0, sizeof(tile1)); for(i=0, a1=0; a1<h; a1++){ scanf("%s", tile1[a1]); for(b1=0; b1<w; b1++){ if(tile2[a1][b1])=='@'){ que[0][0]=a1, que[0][1]=b1; tile1[a1][b1]=1, top=0, end=1, i=1: } } } while(top<end){ a1=que[top][0], b1=que[top++][1]; for(i=0; i<4; i++){ a2=a1+dir[i][0], b2=b1+dir[i][1]; if(a2<0||a2>=h||b2<0||b2>=w||tile2[a2][b2]=='#') continue; tile1[a2][b2]=1; que[end][0]=a2, que[end][1]=b2; } } for(ans=0, a1=0; a1<h; a1++) for(b1=0; b1<w; b1++) ans+=tile1[a1][b1]; printf("%d\n", ans); } }
main.c:4:21: error: expected '}' before '{' token 4 | int dir[4][2]={{1,0}{0,1}{0,-1}{-1,0}}; | ~ ^ main.c: In function 'main': main.c:12:9: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 12 | memset(tile1, 0, sizeof(tile1)); | ^~~~~~ main.c:2:1: note: include '<string.h>' or provide a declaration of 'memset' 1 | #include <stdio.h> +++ |+#include <string.h> 2 | main.c:12:9: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] 12 | memset(tile1, 0, sizeof(tile1)); | ^~~~~~ main.c:12:9: note: include '<string.h>' or provide a declaration of 'memset' main.c:16:34: error: expected expression before '==' token 16 | if(tile2[a1][b1])=='@'){ | ^~ main.c:16:39: error: expected statement before ')' token 16 | if(tile2[a1][b1])=='@'){ | ^ main.c:18:55: error: expected ';' before ':' token 18 | tile1[a1][b1]=1, top=0, end=1, i=1: | ^ | ;
s998012730
p00711
C
#include <stdio.h> int que[400][2], top, end; int dir[4][2]={{1,0}{0,1}{0,-1}{-1,0}}; char tile1[22][22], tile2[22][22]; int main(void) { int w, h, i, a1, a2, b1, b2, ans; while(scanf("%d %d ", &w, &h)&&w){ memset(tile1, 0, sizeof(tile1)); for(i=0, a1=0; a1<h; a1++){ scanf("%s", tile1[a1]); for(b1=0; b1<w; b1++){ if(tile2[a1][b1]=='@'){ que[0][0]=a1, que[0][1]=b1; tile1[a1][b1]=1, top=0, end=1, i=1: } } } while(top<end){ a1=que[top][0], b1=que[top++][1]; for(i=0; i<4; i++){ a2=a1+dir[i][0], b2=b1+dir[i][1]; if(a2<0||a2>=h||b2<0||b2>=w||tile2[a2][b2]=='#') continue; tile1[a2][b2]=1; que[end][0]=a2, que[end][1]=b2; } } for(ans=0, a1=0; a1<h; a1++) for(b1=0; b1<w; b1++) ans+=tile1[a1][b1]; printf("%d\n", ans); } }
main.c:4:21: error: expected '}' before '{' token 4 | int dir[4][2]={{1,0}{0,1}{0,-1}{-1,0}}; | ~ ^ main.c: In function 'main': main.c:12:9: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 12 | memset(tile1, 0, sizeof(tile1)); | ^~~~~~ main.c:2:1: note: include '<string.h>' or provide a declaration of 'memset' 1 | #include <stdio.h> +++ |+#include <string.h> 2 | main.c:12:9: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] 12 | memset(tile1, 0, sizeof(tile1)); | ^~~~~~ main.c:12:9: note: include '<string.h>' or provide a declaration of 'memset' main.c:18:55: error: expected ';' before ':' token 18 | tile1[a1][b1]=1, top=0, end=1, i=1: | ^ | ;
s552958308
p00711
C
#include <stdio.h> int que[400][2], top, end; int dir[4][2]={{1,0}, {0,1}, {0,-1}, {-1,0}}; char tile1[22][22], tile2[22][22]; int main(void) { int w, h, i, a1, a2, b1, b2, ans; while(scanf("%d %d ", &w, &h)&&w){ memset(tile1, 0, sizeof(tile1)); for(i=0, a1=0; a1<h; a1++){ scanf("%s", tile1[a1]); for(b1=0; b1<w; b1++){ if(tile2[a1][b1]=='@'){ que[0][0]=a1, que[0][1]=b1; tile1[a1][b1]=1, top=0, end=1, i=1: } } } while(top<end){ a1=que[top][0], b1=que[top++][1]; for(i=0; i<4; i++){ a2=a1+dir[i][0], b2=b1+dir[i][1]; if(a2<0||a2>=h||b2<0||b2>=w||tile2[a2][b2]=='#') continue; tile1[a2][b2]=1; que[end][0]=a2, que[end][1]=b2; } } for(ans=0, a1=0; a1<h; a1++) for(b1=0; b1<w; b1++) ans+=tile1[a1][b1]; printf("%d\n", ans); } }
main.c: In function 'main': main.c:12:9: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 12 | memset(tile1, 0, sizeof(tile1)); | ^~~~~~ main.c:2:1: note: include '<string.h>' or provide a declaration of 'memset' 1 | #include <stdio.h> +++ |+#include <string.h> 2 | main.c:12:9: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] 12 | memset(tile1, 0, sizeof(tile1)); | ^~~~~~ main.c:12:9: note: include '<string.h>' or provide a declaration of 'memset' main.c:18:55: error: expected ';' before ':' token 18 | tile1[a1][b1]=1, top=0, end=1, i=1: | ^ | ;
s697639635
p00711
C
#include <stdio.h> char s[21][21]; int count, h, w; int dx[] = { 0,0,1,-1 }; int dy[] = { 1,-1,0,0 }; void dfs(int x, int y){ count++; s[y][x] = '#'; int i; for(i = 0; i<4; i++){ int nx = x + dx[i]; int ny = y + dy[i]; if (nx >= 0 && nx < w && ny >= 0 && ny < h && s[ny][nx] == '.') { dfs(nx, ny); } } } int main(void){ while(0){ scanf("%d %d", &w, &h); scanf("%s", &a); if(!w && !h){ break; } count = 0; int i, j, x, y; char a; for(i = 0; i<h; i++){ for(j = 0; j<w; j++){ scanf("%s", s[i][j]); if(s[i][j] == '@'){ x = j; y = i; } } scanf("%s", &a); } dfs(x, y); printf("%d\n",count); } return 0; }
main.c: In function 'main': main.c:25:30: error: 'a' undeclared (first use in this function) 25 | scanf("%s", &a); | ^ main.c:25:30: note: each undeclared identifier is reported only once for each function it appears in
s968125015
p00711
C
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <vector> #include <string> #include <algorithm> #include <stack> #include <queue> #include <set> #include <map> #include <functional> #include <utility> using namespace std; #define MOD 1000000007 #define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD) typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi; int dd[] = { 0, 1, 0, -1 }; int main() { while (true) { int W, H; cin >> W >> H; if (W == 0 && H == 0) break; char C[30][30]; int B[30][30]; int sx = -1; int sy = -1; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> C[i][j]; B[i][j] = 0; if (C[i][j] == '@') { sy = i; sx = j; } } } queue<pi> Q; Q.push(pi(sy, sx)); B[sy][sx] = 1; int ans = 1; while (!Q.empty()) { int ty = Q.front().first; int tx = Q.front().second; Q.pop(); for (int r = 0; r < 4; r++) { int y = ty + dd[r]; int x = tx + dd[r + 1]; if (y < 0 || y >= H || x < 0 || x >= W)continue; if (C[y][x] == '#')continue; if (B[y][x])continue; ans++; B[y][x] = 1; Q.push(pi(y, x)); } } cout << ans << endl; } return 0; }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s209321901
p00711
C
#include<stdio.h> #include<stdlib.h> #define MAX 20 // ????????¨?????¨ ?§??????? typedef struct { int row; // ????????? int col; // ????????? } Coord; // ??????????????¨ ?§??????? typedef struct _stack { struct _stack *next; Coord point; } *stack, stackelem; char M[MAX+2][MAX+2]; // ?????¢?????°??????????????§??? // ????????????????????£?¨? int solve (int W, int H); int search_df (int W, int H, Coord start); // ??????????????¨ stack new_stack (void); int is_empty (stack); int push (stack, Coord); Coord top (stack); Coord pop (stack); // main ??¢??° int main () { while (1) { int W, H; scanf("%d%d", &W, &H); if (W==0 && H==0) break; printf("%d\n", solve(W,H)); } return 0; } // ?????£?????¢?´¢ int solve (int W, int H) { Coord start; // ??????????????°??? int i, j; // ?£?????????????????¨???? for (i=0; i<=W+1; i++) { M[0][i] = '#'; M[H+1][i] = '#'; } for (i=1; i<=H; i++) { M[i][0] = '#'; M[i][W+1] = '#'; } // ??????????????\??? for (i=1; i<=H; i++) { for (j=1; j<=W; j++) { scanf(" %c", &M[i][j]); if (M[i][j]=='@') { start.row = i; start.col = j; } } } return search_df(W, H, start); } int search_df (int W, int H, Coord start) { stack S = new_stack (); // ?¨????????????????????????????????????? int c = 1; // ????????????????????????????????°???????????? 1 ??§????????? // ??????????????°???????¨???? push(S,start); // ??????????????°?????? push // ??¢?´¢ while (!is_empty(S)) { Coord current = pop(S); // pop ??????????????? int d; // ?????? int D1[]={1,0,-1,0}; int D2[]={0,-1,0,1}; // ????????¢?????¶?????¨ for (d=0; d<4; d++) { Coord nc = current; // Next Cell nc.row += D1[d]; nc.col += D2[d]; if (M[nc.row][nc.col] == '.') { M[nc.row][nc.col] = '*'; // ?????°???????????°????????? c++; // ??????????????????????????????????????? push(S,nc); } // nc ????????¢?´¢?????? (*) ????£? (#) ?????´????????????????????? } } return c; // ??°??????????????????????????°????????? } /* ??°??????????????????????¢?????????????????????? */ stack new_stack (void) { stack s; s = (stack) malloc (sizeof (stackelem)); if (s == NULL) return NULL; s->next = NULL; return s; } /* ???????????????????????????????????? */ int is_empty (stack s) { return (s && s->next == NULL); } /* ??°??????????´???????????????\ */ int push (stack s, Coord v) { stack p; if (s == NULL) return 0; p = (stack) malloc (sizeof (stackelem)); if (p == NULL) return 0; p->point = v; p->next = s->next; s->next = p; return 1; } /* ?????????????´?????????? */ Coord top (stack s) { if (s && s->next) return s->next->point; exit (1); } /* ????????? */ Coord pop (stack s) { stack p; Coord v = top (s); p = s->next; s->next = p->next; free (p); return v;
main.c: In function 'pop': main.c:128:3: error: expected declaration or statement at end of input 128 | return v; | ^~~~~~
s374504931
p00711
C
#include<stdio.h> #include<stdlib.h> #define MAX 20 // ????????¨?????¨ ?§??????? typedef struct { int row; // ????????? int col; // ????????? } Coord; // ??????????????¨ ?§??????? typedef struct _stack { struct _stack *next; Coord point; } *stack, stackelem; char M[MAX+2][MAX+2]; // ?????¢?????°??????????????§??? // ????????????????????£?¨? int solve (int W, int H); int search_df (int W, int H, Coord start); void display_map (int W, int H); // ??????????????¨ stack new_stack (void); int is_empty (stack); int push (stack, Coord); Coord top (stack); Coord pop (stack); // main ??¢??° int main () { int W, H; while(1){ scanf("%d%d", &W, &H); if(W==0 && H==0)break; printf("%d\n", solve(W,H)); } return 0; } // ?????£?????¢?´¢ int solve (int W, int H) { Coord start; // ??????????????°??? int i, j; // ?£?????????????????¨???? for (i=0; i<=W+1; i++) { M[0][i] = '#'; M[H+1][i] = '#'; } for (i=1; i<=H; i++) { M[i][0] = '#'; M[i][W+1] = '#'; } // ??????????????\??? for (i=1; i<=H; i++) { for (j=1; j<=W; j++) { scanf(" %c", &M[i][j]); if (M[i][j]=='@') { start.row = i; start.col = j; } } } // ??????????????°?????¨??? (??¬??\???????????????) printf("??????????????°??? [%d, %d]\n\n", start.row, start.col); // ?????£?????°??????????????? 1, ????????§???????????? 0 return search_df(W, H, start); } int search_df (int W, int H, Coord start) { stack S = new_stack (); // ?¨????????????????????????????????????? // ??????????????°???????¨???? push(S,start); // ??????????????°?????? push // ??¢?´¢ while (!is_empty(S)) { Coord current = pop(S); // pop ??????????????? int d; // ?????? int D1[]={1,0,-1,0}; int D2[]={0,-1,0,1}; // ????????¢?????¶?????¨ // printf("?????¨??°??? [%d, %d]\n", current.row, current.col); // ??¬??\??????????????? display_map(W, H); // ?????¨??????????????¨??? (??¬??\???????????????) for (d=0; d<4; d++) { Coord nc = current; // Next Cell // ????????§??????????????? nc.row += D1[d]; nc.col += D2[d]; if(M[nc.row][nc.col] == 'G') ; if(M[nc.row][nc.col] == '.'){ M[nc.row][nc.col] = '*'; push(S,nc); }// nc ????????¢?´¢??????(*)????£?(#)?????´????????????????????? } } return c; //??°??????????????¨????????´????????¢?´¢???????????´??????????????????????????? } void display_map (int W, int H) {; int i, j; for (i=1; i<=H; i++) { for (j=1; j<=W; j++) { printf("%c", M[i][j]); } putchar('\n'); } putchar('\n'); } /* ??°??????????????????????¢?????????????????????? */ stack new_stack (void) { stack s; s = (stack) malloc (sizeof (stackelem)); if (s == NULL) return NULL; s->next = NULL; return s; } /* ???????????????????????????????????? */ int is_empty (stack s) { return (s && s->next == NULL); } /* ??°??????????´???????????????\ */ int push (stack s, Coord v) { stack p; if (s == NULL) return 0; p = (stack) malloc (sizeof (stackelem)); if (p == NULL) return 0; p->point = v; p->next = s->next; s->next = p; return 1; } /* ?????????????´?????????? */ Coord top (stack s) { if (s && s->next) return s->next->point; exit (1); } /* ????????? */ Coord pop (stack s) { stack p; Coord v = top (s); p = s->next; s->next = p->next; free (p); return v; }
main.c: In function 'search_df': main.c:94:10: error: 'c' undeclared (first use in this function) 94 | return c; //??°??????????????¨????????´????????¢?´¢???????????´??????????????????????????? | ^ main.c:94:10: note: each undeclared identifier is reported only once for each function it appears in
s481341284
p00711
C
import java.util.*; public class Main { private static Scanner sc = new Scanner(System.in); public static void main(String...args) { while(sc.hasNext()) { final int W = sc.nextInt(); final int H = sc.nextInt(); if (W == 0 && H == 0) break; solve(W, H); } } private static void solve(final int W, final int H) { final char[][] map = new char[H][]; for(int i = 0; i < H; i++) map[i] = sc.next().toCharArray(); final Deque<Integer> deq = new ArrayDeque<Integer>(); for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) if(map[i][j] == '@') deq.offer(i * W + j); int ans = 0; while(!deq.isEmpty()) { final int p = deq.poll(); final int i = p / W; final int j = p % W; for(int d = 0; d < 4; d++) { final int ni = i + di[d]; final int nj = j + dj[d]; if(0 <= ni && ni < H && 0 <= nj && nj < W && map[ni][nj] == '.') { map[ni][nj] = '#'; deq.offer(ni * W + nj); ans++; } } } System.out.println(ans); } private static final int[] di = { 1, 0, -1, 0}; private static final int[] dj = { 0, 1, 0, -1 }; }
main.c:1:1: error: unknown type name 'import' 1 | import java.util.*; | ^~~~~~ main.c:1:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token 1 | import java.util.*; | ^ main.c:3:1: error: unknown type name 'public' 3 | public class Main { | ^~~~~~ main.c:3:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Main' 3 | public class Main { | ^~~~
s483224938
p00711
C++
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0;i < (n);i++) #define FOR(i, a, b) for(int i = (a);i < (b);i++) #define all(v) v.begin(),v.end() using int64 = long long; int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1}; int main(void){ int32 H, W; while(cin >> H >> W && H && W){ vector<string> f(H+2, string(W+2, '#')); int sy, sx; REP(i, H){ cin >> f[i+1]; REP(j, W+2) if(f[i+1][j] == '@'){ sy = i+1; sx = j; } f[i+1][0] = f[i+1][W+1] = '#'; } bool visited[30][30] = {}; int cnt = 0; auto dfs = [&](int y, int x){ visited[y][x] = 1; cnt++; REP(i, 4){ int yy = y+dy[i], xx = x+dx[i]; if(f[yy][xx] != '#' && !visited[yy][xx]){ dfs(yy, xx); } } }; dfs(sy, sx); cout << cnt << endl; } }
a.cc: In function 'int main()': a.cc:14:9: error: 'int32' was not declared in this scope 14 | int32 H, W; | ^~~~~ a.cc:15:22: error: 'H' was not declared in this scope 15 | while(cin >> H >> W && H && W){ | ^ a.cc:15:27: error: 'W' was not declared in this scope 15 | while(cin >> H >> W && H && W){ | ^ a.cc: In lambda function: a.cc:36:41: error: use of 'dfs' before deduction of 'auto' 36 | dfs(yy, xx); | ^~~
s722714574
p00711
C++
'#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0;i < (n);i++) #define FOR(i, a, b) for(int i = (a);i < (b);i++) #define all(v) v.begin(),v.end() using int64 = long long; int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1}; int main(void){ int H, W; while(cin >> H >> W && H && W){ vector<string> f(H+2, string(W+2, '#')); int sy, sx; REP(i, H){ cin >> f[i+1]; REP(j, W+2) if(f[i+1][j] == '@'){ sy = i+1; sx = j; } f[i+1][0] = f[i+1][W+1] = '#'; } bool visited[30][30] = {}; int cnt = 0; auto dfs = [&](int y, int x){ visited[y][x] = 1; cnt++; REP(i, 4){ int yy = y+dy[i], xx = x+dx[i]; if(f[yy][xx] != '#' && !visited[yy][xx]){ dfs(yy, xx); } } }; dfs(sy, sx); cout << cnt << endl; } }'
a.cc:1:1: warning: missing terminating ' character 1 | '#include <bits/stdc++.h> | ^ a.cc:1:1: error: missing terminating ' character 1 | '#include <bits/stdc++.h> | ^~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:43:2: warning: missing terminating ' character 43 | }' | ^ a.cc:43:2: error: missing terminating ' character a.cc: In function 'int main()': a.cc:15:15: error: 'cin' was not declared in this scope 15 | while(cin >> H >> W && H && W){ | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | '#include <bits/stdc++.h> a.cc:16:17: error: 'vector' was not declared in this scope 16 | vector<string> f(H+2, string(W+2, '#')); | ^~~~~~ a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' +++ |+#include <vector> 1 | '#include <bits/stdc++.h> a.cc:16:24: error: 'string' was not declared in this scope 16 | vector<string> f(H+2, string(W+2, '#')); | ^~~~~~ a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' +++ |+#include <string> 1 | '#include <bits/stdc++.h> a.cc:16:32: error: 'f' was not declared in this scope 16 | vector<string> f(H+2, string(W+2, '#')); | ^ a.cc: In lambda function: a.cc:36:41: error: use of 'dfs' before deduction of 'auto' 36 | dfs(yy, xx); | ^~~ a.cc: In function 'int main()': a.cc:41:17: error: 'cout' was not declared in this scope 41 | cout << cnt << endl; | ^~~~ a.cc:41:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:41:32: error: 'endl' was not declared in this scope 41 | cout << cnt << endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | '#include <bits/stdc++.h>
s423053942
p00711
C++
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0;i < (n);i++) #define FOR(i, a, b) for(int i = (a);i < (b);i++) #define all(v) v.begin(),v.end() using int64 = long long; int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1}; int main(void){ int H, W; while(cin >> H >> W && H && W){ vector<string> f(H+2, string(W+2, '#')); int sy, sx; REP(i, H){ cin >> f[i+1]; REP(j, W+2) if(f[i+1][j] == '@'){ sy = i+1; sx = j; } f[i+1][0] = f[i+1][W+1] = '#'; } bool visited[30][30] = {}; int cnt = 0; auto dfs = [&](int y, int x){ visited[y][x] = 1; cnt++; REP(i, 4){ int yy = y+dy[i], xx = x+dx[i]; if(f[yy][xx] != '#' && !visited[yy][xx]){ dfs(yy, xx); } } }; dfs(sy, sx); cout << cnt << endl; } }'
a.cc:43:2: warning: missing terminating ' character 43 | }' | ^ a.cc:43:2: error: missing terminating ' character a.cc: In lambda function: a.cc:36:41: error: use of 'dfs' before deduction of 'auto' 36 | dfs(yy, xx); | ^~~
s241507504
p00711
C++
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0;i < (n);i++) #define FOR(i, a, b) for(int i = (a);i < (b);i++) #define all(v) v.begin(),v.end() using int64 = long long; int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1}; int main(void){ int H, W; while(cin >> H >> W && H && W){ vector<string> f(H+2, string(W+2, '#')); int sy, sx; REP(i, H){ cin >> f[i+1]; REP(j, W+2){ if(f[i+1][j] == '@'){ sy = i+1; sx = j; } } f[i+1][0] = f[i+1][W+1] = '#'; } bool visited[30][30] = {}; int cnt = 0; auto dfs = [&](int y, int x){ visited[y][x] = 1; cnt++; REP(i, 4){ int yy = y+dy[i], xx = x+dx[i]; if(f[yy][xx] != '#' && !visited[yy][xx]){ dfs(yy, xx); } } }; dfs(sy, sx); cout << cnt << endl; } }'
a.cc:44:2: warning: missing terminating ' character 44 | }' | ^ a.cc:44:2: error: missing terminating ' character a.cc: In lambda function: a.cc:37:41: error: use of 'dfs' before deduction of 'auto' 37 | dfs(yy, xx); | ^~~
s767892390
p00711
C++
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0;i < (n);i++) #define FOR(i, a, b) for(int i = (a);i < (b);i++) #define all(v) v.begin(),v.end() using int64 = long long; int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1}; int main(void){ int H, W; while(cin >> H >> W && H && W){ vector<string> f(H+2, string(W+2, '#')); int sy, sx; REP(i, H){ cin >> f[i+1]; REP(j, W+2) if(f[i+1][j] == '@'){ sy = i+1; sx = j; } f[i+1][0] = f[i+1][W+1] = '#'; } bool visited[30][30] = {}; int cnt = 0; function<void(int, int)> dfs = [&](int y, int x){ visited[y][x] = 1; cnt++; REP(i, 4){ int yy = y+dy[i], xx = x+dx[i]; if(f[yy][xx] != '#' && !visited[yy][xx]){ dfs(yy, xx); } } }; dfs(sy, sx); cout << cnt << endl; } }'
a.cc:43:2: warning: missing terminating ' character 43 | }' | ^ a.cc:43:2: error: missing terminating ' character
s333900659
p00711
C++
#pragma GCC optimize("O3") #include <cstdio> #include <iostream> #include <cstring> #include <cstdlib> #include <algorithm> using namespace std; const int N=25; int a[N*N]; char c[N][N]; int root(int x){ int i=x; while(1){ if(a[x]==x) break; x=a[x]; } int j=x; while(1){ if(a[i]==i) break; x=a[i],a[i]=j,i=x; } return j; } int main(){ int m,n; while(scanf("%d%d",&n,&m)){ if(m==0&&n==0) break; getchar(); int i,j; for(i=1;i<=m*n;i++) a[i]=i; for(i=0;i<m;i++) gets(c[i]); for(i=0;i<m;i++){ for(j=0;j<n;j++){ if(c[i][j]=='#') continue; int r=root(i*n+j+1),rr; if(i&&c[i-1][j]!='#'){ rr=root((i-1)*n+j+1); if(r!=rr) a[rr]=r; } if(i+1<m&&c[i+1][j]!='#'){ rr=root((i+1)*n+j+1); if(r!=rr) a[rr]=r; } if(j&&c[i][j-1]!='#'){ rr=root(i*n+j-1+1); if(r!=rr) a[rr]=r; } if(j+1<n&&c[i][j+1]!='#'){ rr=root(i*n+j+1+1); if(r!=rr) a[rr]=r; } } } int s,ans=0; for(i=0;i<m;i++){ for(j=0;j<n;j++){ if(c[i][j]=='@'){ s=root(i*n+j+1); for(int k=1;k<=m*n;k++){ if(s==root(k)) ans++; } printf("%d\n",ans); break; } } if(j<n) break; } } return 0; }
a.cc: In function 'int main()': a.cc:32:34: error: 'gets' was not declared in this scope; did you mean 'getw'? 32 | for(i=0;i<m;i++) gets(c[i]); | ^~~~ | getw
s521354125
p00711
C++
#include <bits/stdc++.h> using namespace std; #define FOR( i, m, n ) for( int (i) = (m); (i) < (n); (i)++ ) #define REP( i, n ) FOR( i, 0, n ) #define ALL( a ) (a).begin(), (a).end() #define F first #define S second int w, h, cnt = 0; int solve( vector<vector<char>>& f, pair<int, int>& mp ) { if( mp.F - 1 >= 0 && f[mp.S][mp.F - 1] == '.' ) { cnt++; f[mp.S][mp.F - 1] = '#'; solve( f, make_pair( mp.F - 1, mp.S ) ); } if( mp.F + 1 < w && f[mp.S][mp.F + 1] == '.' ) { f[mp.S][mp.F + 1] = '#'; cnt++; solve( f, make_pair( mp.F + 1, mp.S ) ); } if( mp.S - 1 >= 0 && f[mp.S - 1][mp.F] == '.' ) { f[mp.S - 1][mp.F] = '#'; cnt++; solve( f, make_pair( mp.F, mp.S - 1 ) ); } if( mp.S + 1 < h && f[mp.S + 1][mp.F] == '.' ) { f[mp.S + 1][mp.F] = '#'; cnt++; solve( f, make_pair( mp.F, mp.S + 1 ) ); } return cnt; } int main() { while( 1 ) { cin >> w >> h; if( w == 0 && h == 0 ) break; pair<int, int> mp; vector<vector<char>> f; vector<char> tmp( w ); REP( i, h ) { REP( j, w ) { cin >> tmp[j]; if( tmp[j] == '@' ) { mp.first = j; mp.second = i; tmp[j] = '#'; cnt++; } } f.push_back( tmp ); } cout << solve( f, mp ) << endl; cnt = 0; } }
a.cc: In function 'int solve(std::vector<std::vector<char> >&, std::pair<int, int>&)': a.cc:18:36: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>' 18 | solve( f, make_pair( mp.F - 1, mp.S ) ); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:13:53: note: initializing argument 2 of 'int solve(std::vector<std::vector<char> >&, std::pair<int, int>&)' 13 | int solve( vector<vector<char>>& f, pair<int, int>& mp ) { | ~~~~~~~~~~~~~~~~^~ a.cc:23:36: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>' 23 | solve( f, make_pair( mp.F + 1, mp.S ) ); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:13:53: note: initializing argument 2 of 'int solve(std::vector<std::vector<char> >&, std::pair<int, int>&)' 13 | int solve( vector<vector<char>>& f, pair<int, int>& mp ) { | ~~~~~~~~~~~~~~~~^~ a.cc:28:36: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>' 28 | solve( f, make_pair( mp.F, mp.S - 1 ) ); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:13:53: note: initializing argument 2 of 'int solve(std::vector<std::vector<char> >&, std::pair<int, int>&)' 13 | int solve( vector<vector<char>>& f, pair<int, int>& mp ) { | ~~~~~~~~~~~~~~~~^~ a.cc:33:36: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>' 33 | solve( f, make_pair( mp.F, mp.S + 1 ) ); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:13:53: note: initializing argument 2 of 'int solve(std::vector<std::vector<char> >&, std::pair<int, int>&)' 13 | int solve( vector<vector<char>>& f, pair<int, int>& mp ) { | ~~~~~~~~~~~~~~~~^~
s870342738
p00711
C++
#include <bits/stdc++.h> using namespace std; #define FOR( i, m, n ) for( int (i) = (m); (i) < (n); (i)++ ) #define REP( i, n ) FOR( i, 0, n ) #define ALL( a ) (a).begin(), (a).end() #define F first #define S second int w, h, cnt = 0; void solve( vector<vector<char>>& f, pair<int, int>& mp ) { if( mp.F - 1 >= 0 && f[mp.S][mp.F - 1] == '.' ) { cnt++; f[mp.S][mp.F - 1] = '#'; solve( f, make_pair( mp.F - 1, mp.S ) ); } if( mp.F + 1 < w && f[mp.S][mp.F + 1] == '.' ) { f[mp.S][mp.F + 1] = '#'; cnt++; solve( f, make_pair( mp.F + 1, mp.S ) ); } if( mp.S - 1 >= 0 && f[mp.S - 1][mp.F] == '.' ) { f[mp.S - 1][mp.F] = '#'; cnt++; solve( f, make_pair( mp.F, mp.S - 1 ) ); } if( mp.S + 1 < h && f[mp.S + 1][mp.F] == '.' ) { f[mp.S + 1][mp.F] = '#'; cnt++; solve( f, make_pair( mp.F, mp.S + 1 ) ); } } int main() { while( 1 ) { cin >> w >> h; if( w == 0 && h == 0 ) break; pair<int, int> mp; vector<vector<char>> f; vector<char> tmp( w ); REP( i, h ) { REP( j, w ) { cin >> tmp[j]; if( tmp[j] == '@' ) { mp.first = j; mp.second = i; tmp[j] = '#'; cnt++; } } f.push_back( tmp ); } solve( f, mp ); cout << cnt << endl; cnt = 0; } }
a.cc: In function 'void solve(std::vector<std::vector<char> >&, std::pair<int, int>&)': a.cc:18:36: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>' 18 | solve( f, make_pair( mp.F - 1, mp.S ) ); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:13:54: note: initializing argument 2 of 'void solve(std::vector<std::vector<char> >&, std::pair<int, int>&)' 13 | void solve( vector<vector<char>>& f, pair<int, int>& mp ) { | ~~~~~~~~~~~~~~~~^~ a.cc:23:36: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>' 23 | solve( f, make_pair( mp.F + 1, mp.S ) ); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:13:54: note: initializing argument 2 of 'void solve(std::vector<std::vector<char> >&, std::pair<int, int>&)' 13 | void solve( vector<vector<char>>& f, pair<int, int>& mp ) { | ~~~~~~~~~~~~~~~~^~ a.cc:28:36: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>' 28 | solve( f, make_pair( mp.F, mp.S - 1 ) ); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:13:54: note: initializing argument 2 of 'void solve(std::vector<std::vector<char> >&, std::pair<int, int>&)' 13 | void solve( vector<vector<char>>& f, pair<int, int>& mp ) { | ~~~~~~~~~~~~~~~~^~ a.cc:33:36: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>' 33 | solve( f, make_pair( mp.F, mp.S + 1 ) ); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:13:54: note: initializing argument 2 of 'void solve(std::vector<std::vector<char> >&, std::pair<int, int>&)' 13 | void solve( vector<vector<char>>& f, pair<int, int>& mp ) { | ~~~~~~~~~~~~~~~~^~
s803776702
p00711
C++
#include<iostream> #include<string> #include<queue> #include <utility> #include <functional> //#include<> using namespace std; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; //#define int long long; signed main(){ int w, h; while(cin >> w >> h, w){ int cnt{}; vector<string> v(h); for(int i = 0; i < h; ++i){ cin >> v[i]; } //initialize pair<int, int> p; queue<pair<int, int>> q; for(int i = 0; i < h; ++i){ for(int j = 0; j < w; ++j){ if(v[i][j] == '@'){ p = make_pair(i,j); q.push(p); } } } while(!q.empty()){ pair<int, int> p; p = q.front(); q.pop(); for(int k = 0; k < 4; ++k){ int x = p.first + dx[k]; int y = p.second + dy[k]; if(0 > x || h <= x || 0 > y || w <= y)continue; if('.' == v[x][y]){ v[x][y] = '@'; ++cn q.push(make_pair(x, y)); } } } cout << cnt+1 << endl; } return 0; }
a.cc: In function 'int main()': a.cc:40:13: error: 'cn' was not declared in this scope; did you mean 'cnt'? 40 | ++cn | ^~ | cnt
s154880945
p00711
C++
#include<iostream> #include<string> #include<queue> #include <utility> #include <functional> //#include<> using namespace std; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; //#define int long long; signed main(){ int w, h; while(cin >> w >> h, w){ int cnt{}; vector<string> v(h); for(int i = 0; i < h; ++i){ cin >> v[i]; } //initialize pair<int, int> p; queue<pair<int, int>> q; for(int i = 0; i < h; ++i){ for(int j = 0; j < w; ++j){ if(v[i][j] == '@'){ p = make_pair(i,j); q.push(p); } } } while(!q.empty()){ pair<int, int> p; p = q.front(); q.pop(); for(int k = 0; k < 4; ++k){ int x = p.first + dx[k]; int y = p.second + dy[k]; if(0 > x || h <= x || 0 > y || w <= y)continue; if('.' == v[x][y]){ v[x][y] = '@'; ++cn q.push(make_pair(x, y)); } } } cout << cnt+1 << endl; } return 0; }
a.cc: In function 'int main()': a.cc:40:13: error: 'cn' was not declared in this scope; did you mean 'cnt'? 40 | ++cn | ^~ | cnt
s947460985
p00711
C++
#include <iostream> #include <string> using namespace std; int W, H; string s[20]; int num; int dx[4] = {0, 1, 0, -1}; int dy[4] = {-1, 0, 1, 0}; void dfs(int x, int y){ num++; s[y][x] = '#'; for(int i=0; i<4; i++){ if(0<=x+dx[i] && x+dx[i]<W && 0<=y+dy[i] && y+dy<H && s[y+dy[i]][x+dx[i]]=='.'){ dfs(x+dx[i], y+dy[i]); } } } int main(){ while(cin >> W >> H, W || H){ for(int i=0; i<H; i++){ cin >> s[i]; } int x, y; for(int i=0; i<H; i++){ for(int j=0; j<W; j++){ if(s[i][j] == '@'){ x = j; y = i; } } } num = 0; dfs(x, y); cout << num << endl; } return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:15:53: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 15 | if(0<=x+dx[i] && x+dx[i]<W && 0<=y+dy[i] && y+dy<H && s[y+dy[i]][x+dx[i]]=='.'){ | ~~~~^~
s246114306
p00711
C++
#include<iostream> #include<queue> #include<string> #include<map> #define F first #define S second using namespace std; char c[33][33]; int w,h; int solve(int x, int y){ typedef pair < int, int > P; queue < P > que; int count = 0; que.push( P(x, y) ); while(!que.empty()){ P q = que.front(); que.pop(); int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; for(int i=0;i<4;i++){ int xx = dx[i] + q.F; int yy = dy[i] + q.S; if(xx < 0 || yy < 0 || xx == w || yy == h) continue; if(c[yy][xx] == '#') continue; c[yy][xx] = '#'; que.push( P(xx, yy) ); count++; } } return count; } int main(){ int sx, sy; while(true){ cin >> w >> h; if(!w && !h) break; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin >> c[i][j]; if(c[i][j] == '@') sx = j, sy = i; } } while(!que.empty()) que.pop(); cout << solve(sx, sy) << endl; } }
a.cc: In function 'int main()': a.cc:56:12: error: 'que' was not declared in this scope 56 | while(!que.empty()) que.pop(); | ^~~
s283386918
p00711
C++
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); while (true) { int w = 1; int h = 1; int moveCan = 0; w = scan.nextInt(); h = scan.nextInt(); if (w == 0 && h == 0) break; char[][] table = new char[h][w]; // int[][] num = new int[h][w]; for (int i = 0; i < h; i++) { // for (int j = 0; j < w; j++) { table[i]/* [j] */= scan.next().toCharArray(); // } } moveCan = AtCheck(table, w, h); System.out.println(moveCan); } scan.close(); } public static int AtCheck(char table[][], int w, int h) { int befAtNum = 0; int aftAtNum = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (table[i][j] == '@') befAtNum++; } } int[][] atPlace = new int[h][w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (table[i][j] == '@') { atPlace[i][j] = 1; // if (i != (h - 1) && j != (w - 1) && i != 0 && j != 0 // && table[i - 1][j - 1]=='.') // atPlace[i - 1][j - 1] = 1; if (j != 0 && table[i][j - 1] == '.') atPlace[i][j - 1] = 1; // if (i != (h - 1) && j != (w - 1) && i != 0 && j != 0 // && table[i + 1][j - 1]=='.') // atPlace[i + 1][j - 1] = 1; if (i != 0 && table[i - 1][j] == '.') atPlace[i - 1][j] = 1; if (i != (h - 1) && table[i + 1][j] == '.') atPlace[i + 1][j] = 1; // if (i != (h - 1) && j != (w - 1) && i != 0 && j != 0 // && table[i - 1][j + 1]=='.') // atPlace[i - 1][j + 1] = 1; if (j != (w - 1) && table[i][j + 1] == '.') atPlace[i][j + 1] = 1; // if (i != (h - 1) && j != (w - 1) && i != 0 && j != 0 // && table[i + 1][j + 1]=='.') // atPlace[i + 1][j + 1] = 1; } } } for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (atPlace[i][j] == 1) table[i][j] = '@'; } } for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (table[i][j] == '@') aftAtNum++; } } if (befAtNum != aftAtNum) { return AtCheck(table, w, h); } else { return aftAtNum; } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Scanner; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main { | ^~~~~~
s293062558
p00711
C++
#include <cstdio> #include <string> #include <iostream> using namespace std; const dx[] = {-1, 0, 1, 0}; const dy[] = {0, -1, 0, 1}; char tile[40][40]; int h, w; int search(int nx, int ny) { int sum = 0; if (ny == 0 || nx == 0 || ny == h + 1 || nx == w + 1)return (sum); if (tile[nx][ny] == '.' || tile[nx][ny] == '@'){ sum++; } tile[nx][ny] = '#'; for (int i = 0; i < 4; i++){ if (tile[nx + dx[i]][ny + dy[i]] != '#'){ sum += search(nx + dx[i], ny + dy[i]); } } return (sum); } int main() { while (1){ scanf("%d %d", &w, &h); if (h == 0 && w == 0)return (0); int mx, my; for (int i = 1; i <= h; i++){ for (int j = 1; j <= w; j++){ scanf(" %c", &tile[j][i]); if (tile[j][i] == '@'){ mx = j; my = i; } } } printf("%d\n", search(mx, my)); } }
a.cc:6:7: error: 'dx' does not name a type 6 | const dx[] = {-1, 0, 1, 0}; | ^~ a.cc:7:7: error: 'dy' does not name a type 7 | const dy[] = {0, -1, 0, 1}; | ^~ a.cc: In function 'int search(int, int)': a.cc:22:31: error: 'dx' was not declared in this scope; did you mean 'nx'? 22 | if (tile[nx + dx[i]][ny + dy[i]] != '#'){ | ^~ | nx a.cc:22:43: error: 'dy' was not declared in this scope; did you mean 'ny'? 22 | if (tile[nx + dx[i]][ny + dy[i]] != '#'){ | ^~ | ny
s493033436
p00711
C++
#include<iostream> using namespace std; int w,h; char tail[21][21]; int a[]={-1,0,1,0}; int b[]={0,1,0,-1}; int cnt=0; void func(int x,int y); main(){ int sx,sy; while(1){ cin>> w>> h if(w==0&&h==0) break; cnt=0; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>> tail[i][j]; if(tail[i][j]=='@'){ sx=j; sy=i; } } } func(sx,sy); cout<< cnt<< endl; } } void func(int x,int y){ tail[y][x]='#'; cnt++; for(int i=0;i<4;i++){ int nx=x+a[i]; int ny=y+b[i]; if(nx>=0 && nx<w && ny>=0 && ny<h && tail[ny][nx]!='#'){ func(nx,ny); } } }
a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 9 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:12:16: error: expected ';' before 'if' 12 | cin>> w>> h | ^ | ; 13 | if(w==0&&h==0) break; | ~~
s139940406
p00711
C++
#include<iostream> using namespace std; int dfs(int x,int y); int h,w; char ta[22][22]; //int cheak[22][22]={0}; int dx[4]={-1,0,1,0}; int dy[4]={0,-1,0,1}; int cou=0; int main(){ int a,b; while(1){ cin >> w >> h; if(w==0 && h==0) break; cou=0; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin >> ta[i][j]; cheak[i][j]=0; if(ta[i][j] == '@'){ a=i,b=j; } } } //cout << a << " " << b << endl; cout << dfs(a,b) << endl; /*for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cout << cheak[i][j]; } cout << endl; }*/ } } void dfs(int x,int y){ //cheak[x][y]=1; ta[nx][ny]='#'; cou++; for(int i=0;i<4;i++){ int nx=x+dx[i]; int ny=y+dy[i]; if(nx>=0 && nx<h && ny>=0 && ny<w && ta[nx][ny]=='.'){ dfs(nx,ny); } } }
a.cc: In function 'int main()': a.cc:22:9: error: 'cheak' was not declared in this scope 22 | cheak[i][j]=0; | ^~~~~ a.cc: At global scope: a.cc:39:6: error: ambiguating new declaration of 'void dfs(int, int)' 39 | void dfs(int x,int y){ | ^~~ a.cc:4:5: note: old declaration 'int dfs(int, int)' 4 | int dfs(int x,int y); | ^~~ a.cc: In function 'void dfs(int, int)': a.cc:41:6: error: 'nx' was not declared in this scope; did you mean 'x'? 41 | ta[nx][ny]='#'; | ^~ | x a.cc:41:10: error: 'ny' was not declared in this scope; did you mean 'y'? 41 | ta[nx][ny]='#'; | ^~ | y
s092410316
p00711
C++
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; ++i) #define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i) #define each(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define all(v) v.begin(), v.end() #define mset(a, n) memset(a, n, sizeof(a)) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<string> vs; typedef vector<vector<int> > vvi; typedef vector<pair<int, int> > vpii; typedef pair<int, int> pii; typedef pair<long long, long long> pll; const int inf = 1000000000; const int mod = 1000000007; const double eps = 1e-9; const int dx[] = { -1, 0, 1, 0}; const int dy[] = { 0, -1, 0, 1}; string field[]; void dfs(int y, int x) { if (x < 0 || y < 0 || x == w || y == h) return; if (field[y][x] == '#') return; ans++; field[y][x] = '#'; rep(i, 4) dfs(y + dy[i], x + dx[i]); } int main() { int W, H; while (cin >> W >> H, W) { int ans = 0; rep(i, H) cin >> s[i]; rep(i, H) rep(i, W) { if (s[i][j] == '@') solve(i, j); } } return 0; }
a.cc:27:8: error: array size missing in 'field' 27 | string field[]; | ^~~~~ a.cc: In function 'void dfs(int, int)': a.cc:30:36: error: 'w' was not declared in this scope 30 | if (x < 0 || y < 0 || x == w || y == h) return; | ^ a.cc:30:46: error: 'h' was not declared in this scope 30 | if (x < 0 || y < 0 || x == w || y == h) return; | ^ a.cc:32:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 32 | ans++; | ^~~ | abs a.cc: In function 'int main()': a.cc:41:34: error: 's' was not declared in this scope 41 | rep(i, H) cin >> s[i]; | ^ a.cc:43:29: error: 's' was not declared in this scope 43 | if (s[i][j] == '@') solve(i, j); | ^ a.cc:43:34: error: 'j' was not declared in this scope 43 | if (s[i][j] == '@') solve(i, j); | ^ a.cc:43:45: error: 'solve' was not declared in this scope 43 | if (s[i][j] == '@') solve(i, j); | ^~~~~
s378077082
p00711
C++
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; ++i) #define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i) #define each(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define all(v) v.begin(), v.end() #define mset(a, n) memset(a, n, sizeof(a)) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<string> vs; typedef vector<vector<int> > vvi; typedef vector<pair<int, int> > vpii; typedef pair<int, int> pii; typedef pair<long long, long long> pll; const int inf = 1000000000; const int mod = 1000000007; const double eps = 1e-9; const int dx[] = { -1, 0, 1, 0}; const int dy[] = { 0, -1, 0, 1}; string field[100]; void dfs(int y, int x) { if (x < 0 || y < 0 || x == w || y == h) return; if (field[y][x] == '#') return; ans++; field[y][x] = '#'; rep(i, 4) dfs(y + dy[i], x + dx[i]); } int main() { int W, H; while (cin >> W >> H, W) { int ans = 0; rep(i, H) cin >> s[i]; rep(i, H) rep(i, W) { if (s[i][j] == '@') solve(i, j); } } return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:30:36: error: 'w' was not declared in this scope 30 | if (x < 0 || y < 0 || x == w || y == h) return; | ^ a.cc:30:46: error: 'h' was not declared in this scope 30 | if (x < 0 || y < 0 || x == w || y == h) return; | ^ a.cc:32:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 32 | ans++; | ^~~ | abs a.cc: In function 'int main()': a.cc:41:34: error: 's' was not declared in this scope 41 | rep(i, H) cin >> s[i]; | ^ a.cc:43:29: error: 's' was not declared in this scope 43 | if (s[i][j] == '@') solve(i, j); | ^ a.cc:43:34: error: 'j' was not declared in this scope 43 | if (s[i][j] == '@') solve(i, j); | ^ a.cc:43:45: error: 'solve' was not declared in this scope 43 | if (s[i][j] == '@') solve(i, j); | ^~~~~
s990265915
p00711
C++
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; ++i) #define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i) #define each(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define all(v) v.begin(), v.end() #define mset(a, n) memset(a, n, sizeof(a)) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<string> vs; typedef vector<vector<int> > vvi; typedef vector<pair<int, int> > vpii; typedef pair<int, int> pii; typedef pair<long long, long long> pll; const int inf = 1000000000; const int mod = 1000000007; const double eps = 1e-9; const int dx[] = { -1, 0, 1, 0}; const int dy[] = { 0, -1, 0, 1}; int W, H; int ans = 0; string field[100]; void dfs(int y, int x) { if (x < 0 || y < 0 || x == W || y == H) return; if (field[y][x] == '#') return; ans++; field[y][x] = '#'; rep(i, 4) dfs(y + dy[i], x + dx[i]); } int main() { while (cin >> W >> H, W) { rep(i, H) cin >> s[i]; rep(i, H) rep(j, W) { if (s[i][j] == '@') solve(i, j); } } return 0; }
a.cc: In function 'int main()': a.cc:41:34: error: 's' was not declared in this scope 41 | rep(i, H) cin >> s[i]; | ^ a.cc:43:29: error: 's' was not declared in this scope 43 | if (s[i][j] == '@') solve(i, j); | ^ a.cc:43:45: error: 'solve' was not declared in this scope 43 | if (s[i][j] == '@') solve(i, j); | ^~~~~
s406964367
p00711
C++
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; ++i) #define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i) #define each(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define all(v) v.begin(), v.end() #define mset(a, n) memset(a, n, sizeof(a)) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<string> vs; typedef vector<vector<int> > vvi; typedef vector<pair<int, int> > vpii; typedef pair<int, int> pii; typedef pair<long long, long long> pll; const int inf = 1000000000; const int mod = 1000000007; const double eps = 1e-9; const int dx[] = { -1, 0, 1, 0}; const int dy[] = { 0, -1, 0, 1}; int W, H; int ans = 0; string field[100]; void dfs(int y, int x) { if (x < 0 || y < 0 || x == W || y == H) return; if (field[y][x] == '#') return; ans++; field[y][x] = '#'; rep(i, 4) dfs(y + dy[i], x + dx[i]); } int main() { while (cin >> W >> H, W) { rep(i, H) cin >> field[i]; rep(i, H) rep(j, W) { if (s[i][j] == '@') solve(i, j); } } return 0; }
a.cc: In function 'int main()': a.cc:43:29: error: 's' was not declared in this scope 43 | if (s[i][j] == '@') solve(i, j); | ^ a.cc:43:45: error: 'solve' was not declared in this scope 43 | if (s[i][j] == '@') solve(i, j); | ^~~~~
s711956124
p00711
C++
#include<iostream> char map[20][20]={0}; int number=1; int h,w; void debug(void) { for(int i=0;i<h;i++) { for(int j=0;j<w;j++) putchar(map[i][j]); putchar('\n'); } } void trace(int x,int y) { if(x-1 >= 0 && map[y][x-1]=='.') { map[y][x-1] = '@'; trace(x-1,y); number++; } if(x+1 < w && map[y][x+1]=='.') { map[y][x+1] = '@'; trace(x+1,y); number++; } if(y-1 >= 0 && map[y-1][x]=='.') { map[y-1][x] = '@'; trace(x,y-1); number++; } if(y+1 < h && map[y+1][x]=='.') { map[y+1][x] = '@'; trace(x,y+1); number++; } } int main(void) { char buf[21]; int x,y; for(;;) { number=1; scanf("%d %d\n",&w,&h); if(w==0 || h==0) break; for(int i=0;i<h;i++) { fgets(buf,1024,stdin); memcpy(&map[i],buf,w); } for(int j=0;j<h;j++) { for(int i=0;i<w;i++) { if(map[j][i] == '@'){ x=i;y=j; } } } trace(x,y); printf("%d\n",number); } //debug(); return 0; }
a.cc: In function 'int main()': a.cc:53:25: error: 'memcpy' was not declared in this scope 53 | memcpy(&map[i],buf,w); | ^~~~~~ a.cc:2:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<iostream> +++ |+#include <cstring> 2 |
s362739660
p00711
C++
#include <iostream> #include <queue> #include <utility> #include <array> using namespace std; typedef pair<int, int> pii; int height, width; int sx, sy; int ans = 0; array<int, 4> dx = {0, 0, 1, -1}; array<int, 4> dy = {1, -1, 0, 0}; void bfs() { queue<pii> p; p.push({sx, sy}); while (!p.empty()) { pii q = p.front(); p.pop(); //?????? int cx = p.first; int cy = p.second; for (int i = 0; i < 4; ++i) { int nx = cx + dx.at(i); int ny = cy + dy.at(i); if (nx >= 0 && nx < width && ny >= 0 && ny < height && field.at(ny).at(nx) == '.') { ans++; p.push({nx, ny}); } } } std::cout << ans << std::endl; } int main() { while (cin >> height >> width) { if (height == 0 && width == 0) break; ans = 0; vector<vector<char>> field(height, vector<char>(width)); for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { cin >> field.at(y).at(x); if (field.at(y).at(x) == '@') { sx = x; sy = y; } } } bfs(); } return 0; }
a.cc: In function 'void bfs()': a.cc:26:20: error: 'class std::queue<std::pair<int, int> >' has no member named 'first' 26 | int cx = p.first; | ^~~~~ a.cc:27:20: error: 'class std::queue<std::pair<int, int> >' has no member named 'second' 27 | int cy = p.second; | ^~~~~~ a.cc:34:24: error: 'field' was not declared in this scope 34 | && field.at(ny).at(nx) == '.') { | ^~~~~
s356449364
p00711
C++
#include<iostream> #include<algorithm> #include<utility> #include<queue> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define P pair<int, int> using namespace std; char field[20][20]; int W, H,sx,sy,nx,ny; int dx[4] = { 1, 0, -1, 0 }; int dy[4] = { 0, 1, 0, -1 }; int cnt = 1; void bfs(){ queue<P> que; que.push(P(sx, sy)); while (1){ if (que.empty()){ break; } P p = que.front(); que.pop(); rep(i, 4){ nx = p.first + dx[i]; ny = p.second + dy[i]; if (nx >= 0 && nx < W && 0 <= ny && ny < H && field[ny][nx] == '.'){ field[ny][nx] = '#'; que.push(P(nx, ny)); cnt++; } } /* rep(i, H){ rep(j, W){ cout << field[i][j]; } cout << endl; } */ } }
/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
s978634870
p00711
C++
1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 int w, h, cnt; 6 int vx[] = {0, 1, 0, -1}; 7 int vy[] = {1, 0, -1, 0}; 8 char field[20][20]; 9 10 void solve(int x, int y){ 11 12 ++cnt; 13 field[y][x] = '#'; 14 15 for(int i = 0; i < 4; ++i){ 16 17 int nx = x + vx[i]; 18 int ny = y + vy[i]; 19 20 if(nx >= 0 && nx < w && ny >= 0 && ny < h && field[ny][nx] == '.') 21 solve(nx, ny); 22 23 } 24 25 } 26 27 int main(){ 28 29 int sx, sy; 30 while(cin >> w >> h){ 31 32 if(!(w || h)) break; 33 34 for(int i = 0; i < h; ++i){ 35 for(int j = 0; j < w; ++j){ 36 cin >> field[i][j]; 37 if(field[i][j] == '@'){ 38 sx = j; 39 sy = i; 40 } 41 } 42 } 43 44 cnt = 0; 45 46 solve(sx, sy); 47 48 cout << cnt << endl; 49 50 } 51 52 } ~
a.cc:1:5: error: stray '#' in program 1 | 1 #include <bits/stdc++.h> | ^ a.cc:1:3: error: expected unqualified-id before numeric constant 1 | 1 #include <bits/stdc++.h> | ^ a.cc:4:3: error: expected unqualified-id before numeric constant 4 | 4 | ^ a.cc:6:3: error: expected unqualified-id before numeric constant 6 | 6 int vx[] = {0, 1, 0, -1}; | ^ a.cc:7:3: error: expected unqualified-id before numeric constant 7 | 7 int vy[] = {1, 0, -1, 0}; | ^ a.cc:8:3: error: expected unqualified-id before numeric constant 8 | 8 char field[20][20]; | ^ a.cc:9:3: error: expected unqualified-id before numeric constant 9 | 9 | ^ a.cc:26:2: error: expected unqualified-id before numeric constant 26 | 26 | ^~ a.cc:53:2: error: expected class-name at end of input 53 | ~ | ^
s126221540
p00711
C++
#include<iostrem> #include<utility> #include<queue> using namespace std; char room[21][21]; int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1}; typedef pair<int,int> p; int main(){ int x,y; queue<p> que; int w,h; cin>>w>>h; if(w+h==0) return; for(int a=0;a<h;a++){ for(int b=0;b<w;b++){ cin>>room[a][b]; if(room[a][b]=='@'){ x=b,y=a; que.push(p(b,a)); room[a][b]='#'; } } } int cnt=1; int nx,ny; while(que.size()){ p ap=que.front(); que.pop; for(int i=-1;i<=1;i++){ nx=ap.first+dx[i]; ny=ap.second+dy[i]; if(0<=nx&&nx<=w&&0<=ny&&ny<=h&&room[ny][nx]!='#'){ room[ny][nx]='#'; que.push(p(nx,ny)); cnt++; } } } }
a.cc:1:9: fatal error: iostrem: No such file or directory 1 | #include<iostrem> | ^~~~~~~~~ compilation terminated.
s015599225
p00711
C++
#include<iostream> #include<utility> #include<queue> using namespace std; char room[21][21]; int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1}; typedef pair<int,int> p; int main(){ int x,y; queue<p> que; int w,h; cin>>w>>h; if(w+h==0) return; for(int a=0;a<h;a++){ for(int b=0;b<w;b++){ cin>>room[a][b]; if(room[a][b]=='@'){ x=b,y=a; que.push(p(b,a)); room[a][b]='#'; } } } int cnt=1; int nx,ny; while(que.size()){ p ap=que.front(); que.pop; for(int i=-1;i<=1;i++){ nx=ap.first+dx[i]; ny=ap.second+dy[i]; if(0<=nx&&nx<=w&&0<=ny&&ny<=h&&room[ny][nx]!='#'){ room[ny][nx]='#'; que.push(p(nx,ny)); cnt++; } } } cout<<cnt; }
a.cc: In function 'int main()': a.cc:15:20: error: return-statement with no value, in function returning 'int' [-fpermissive] 15 | if(w+h==0) return; | ^~~~~~ a.cc:31:21: error: invalid use of non-static member function 'void std::queue<_Tp, _Sequence>::pop() [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >]' 31 | que.pop; | ~~~~^~~ In file included from /usr/include/c++/14/queue:66, from a.cc:3: /usr/include/c++/14/bits/stl_queue.h:316:7: note: declared here 316 | pop() | ^~~
s852763388
p00711
C++
#include <iostream> #include <queue> #include <set> using namespace std; const int MAX_SIZE = 20; typedef pair<int, int> P; int calc(char f[][MAX_SIZE], queue<P> q, int W, int H) { set<P> s; while (q.size()) { P p = q.front(); q.pop(); s.insert(p); int di[] = {-1, 1, 0, 0}; int dj[] = {0, 0, -1, 1}; for (int k = 0; k < 4; ++k) { int i = p.first + di[k]; int j = p.second + dj[k]; if (i >= 0 && j >= 0 && i < H && j < W && f[i][j] == '.') { pair<set<P>::iterator, bool> r = s.insert(P(i, j)); if (r.second) q.push(*r.first); } } } return s.size(); } int main() { int W, H; char f[MAX_SIZE + 1][MAX_SIZE + 1]; while (true) { queue<P> q; cin >> W >> H; if (W == 0 && H == 0) break; for (int i = 0; i < H; ++i) { cin >> f[i]; for (int j = 0; j < W; ++j) { if (f[i][j] == '@') { q.push(P(i, j)); } } } cout << calc(f, q, W, H) << endl; } }
a.cc: In function 'int main()': a.cc:43:18: error: cannot convert 'char (*)[21]' to 'char (*)[20]' 43 | cout << calc(f, q, W, H) << endl; | ^ | | | char (*)[21] a.cc:9:15: note: initializing argument 1 of 'int calc(char (*)[20], std::queue<std::pair<int, int> >, int, int)' 9 | int calc(char f[][MAX_SIZE], queue<P> q, int W, int H) { | ~~~~~^~~~~~~~~~~~~