submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s568434604 | p00602 | C | #include<stdlib.h>
p(int*a,int*b){return*a-*b;}c,V,i,f[999];
main(d){for(;f[1]=scanf("%d%d",&V,&d)+1;printf("%d\n",c)){
for(f[0]=i=2;i<V;i++)f[i]=(f[i-1]+f[i-2])%1001;
qsort(f,V,4,p);
for(i=c=1;i<V;f[i]-f[i++-1]<d?:c++);}
div(0);} | main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int]
2 | p(int*a,int*b){return*a-*b;}c,V,i,f[999];
| ^
main.c:2:29: warning: data definition has no type or storage class
2 | p(int*a,int*b){return*a-*b;}c,V,i,f[999];
| ^
main.c:2:29: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int]
main.c:2:31: error: type defaults to 'int' in declaration of 'V' [-Wimplicit-int]
2 | p(int*a,int*b){return*a-*b;}c,V,i,f[999];
| ^
main.c:2:33: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
2 | p(int*a,int*b){return*a-*b;}c,V,i,f[999];
| ^
main.c:2:35: error: type defaults to 'int' in declaration of 'f' [-Wimplicit-int]
2 | p(int*a,int*b){return*a-*b;}c,V,i,f[999];
| ^
main.c:3:1: error: return type defaults to 'int' [-Wimplicit-int]
3 | main(d){for(;f[1]=scanf("%d%d",&V,&d)+1;printf("%d\n",c)){
| ^~~~
main.c: In function 'main':
main.c:3:1: error: type of 'd' defaults to 'int' [-Wimplicit-int]
main.c:3:19: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
3 | main(d){for(;f[1]=scanf("%d%d",&V,&d)+1;printf("%d\n",c)){
| ^~~~~
main.c:2:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
1 | #include<stdlib.h>
+++ |+#include <stdio.h>
2 | p(int*a,int*b){return*a-*b;}c,V,i,f[999];
main.c:3:19: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
3 | main(d){for(;f[1]=scanf("%d%d",&V,&d)+1;printf("%d\n",c)){
| ^~~~~
main.c:3:19: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:3:41: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
3 | main(d){for(;f[1]=scanf("%d%d",&V,&d)+1;printf("%d\n",c)){
| ^~~~~~
main.c:3:41: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:3:41: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:3:41: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:5:13: error: passing argument 4 of 'qsort' from incompatible pointer type [-Wincompatible-pointer-types]
5 | qsort(f,V,4,p);
| ^
| |
| int (*)(int *, int *)
In file included from main.c:1:
/usr/include/stdlib.h:971:34: note: expected '__compar_fn_t' {aka 'int (*)(const void *, const void *)'} but argument is of type 'int (*)(int *, int *)'
971 | __compar_fn_t __compar) __nonnull ((1, 4));
| ~~~~~~~~~~~~~~^~~~~~~~
main.c:7:1: error: too few arguments to function 'div'
7 | div(0);}
| ^~~
/usr/include/stdlib.h:992:14: note: declared here
992 | extern div_t div (int __numer, int __denom)
| ^~~
|
s552674681 | p00602 | C++ | #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
//#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
//#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
//#include <atomic>
#include <chrono>
//#include <condition_variable>
#include <forward_list>
//#include <future>
#include <initializer_list>
//#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
//#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
template<typename T>
class UF
{
public:
void UF ()
{
count = 0;
}
void push ( T a )
{
M[a] = count;
V.push_back ( count );
rank.push_back ( 0 );
count++;
}
void unite ( T a , T b )
{
long long int x = find ( M[a] );
long long int y = find ( M[b] );
if( x == y )return;
if( rank[x] < rank[y] )
{
V[x] = y;
} else
{
V[y] = x;
if( rank[x] == rank[y] )rank[x]++;
}
}
void merge ( T a , T b )
{
unite ( a , b );
}
bool same ( T a , T b )
{
return find ( M[a] ) == find ( M[b] );
}
long long int group ()
{
set < long long int >
S;
for( long long int i = 0; i < V.size (); i++ )
{
S.insert ( find ( V[i] ) );
}
return S.size ();
}
private:
vector<long long int>
V , rank;
map < T , long long int>M;
long long int count = 0;
long long int find ( long long int x )
{
if( V[x] == x )return x;
else return V[x] = find ( V[x] );
}
};
int main ()
{
int V , d;
int data[1001] = {};
data[0] = 2;
data[1] = 3;
for( size_t i = 2; i < 1001; i++ )
{
data[i] = data[i - 1] + data[i - 2];
data[i] %= 1001;
}
while( cin >> V >> d )
{
UF<int> uf;
for( size_t i = 0; i < V; i++ )
{
uf.push ( data[i] );
}
for( size_t i = 0; i < V; i++ )
{
for( size_t j = i+1; j < V; j++ )
{
if( abs ( data[i] - data[j] ) < d )
{
uf.merge ( data[i] , data[j] );
}
}
}
cout << uf.group () << endl;
}
} | a.cc:91:9: error: return type specification for constructor invalid
91 | void UF ()
| ^~~~
|
s233407441 | p00602 | C++ | #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
//#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
//#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
//#include <atomic>
#include <chrono>
//#include <condition_variable>
#include <forward_list>
//#include <future>
#include <initializer_list>
//#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
//#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
template<typename T>
class UF
{
public:
void UF ()
{
count = 0;
}
void push ( T a )
{
M[a] = count;
V.push_back ( count );
rank.push_back ( 0 );
count++;
}
void unite ( T a , T b )
{
long long int x = find ( M[a] );
long long int y = find ( M[b] );
if( x == y )return;
if( rank[x] < rank[y] )
{
V[x] = y;
} else
{
V[y] = x;
if( rank[x] == rank[y] )rank[x]++;
}
}
void merge ( T a , T b )
{
unite ( a , b );
}
bool same ( T a , T b )
{
return find ( M[a] ) == find ( M[b] );
}
long long int group ()
{
set < long long int >
S;
for( long long int i = 0; i < V.size (); i++ )
{
S.insert ( find ( V[i] ) );
}
return S.size ();
}
private:
vector<long long int>
V , rank;
map < T , long long int>M;
long long int count;
long long int find ( long long int x )
{
if( V[x] == x )return x;
else return V[x] = find ( V[x] );
}
};
int main ()
{
int V , d;
int data[1001] = {};
data[0] = 2;
data[1] = 3;
for( size_t i = 2; i < 1001; i++ )
{
data[i] = data[i - 1] + data[i - 2];
data[i] %= 1001;
}
while( cin >> V >> d )
{
UF<int> uf;
for( size_t i = 0; i < V; i++ )
{
uf.push ( data[i] );
}
for( size_t i = 0; i < V; i++ )
{
for( size_t j = i+1; j < V; j++ )
{
if( abs ( data[i] - data[j] ) < d )
{
uf.merge ( data[i] , data[j] );
}
}
}
cout << uf.group () << endl;
}
} | a.cc:91:9: error: return type specification for constructor invalid
91 | void UF ()
| ^~~~
|
s233296892 | p00602 | C++ | #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
//#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
//#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
//#include <atomic>
#include <chrono>
//#include <condition_variable>
#include <forward_list>
//#include <future>
#include <initializer_list>
//#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
//#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
template<typename T>
class UF
{
public:
void UF ()
{
count = 0;
}
void push ( T a )
{
M[a] = count;
V.push_back ( count );
rank.push_back ( 0 );
count++;
}
void unite ( T a , T b )
{
long long int x = find ( M[a] );
long long int y = find ( M[b] );
if( x == y )return;
if( rank[x] < rank[y] )
{
V[x] = y;
} else
{
V[y] = x;
if( rank[x] == rank[y] )rank[x]++;
}
}
void merge ( T a , T b )
{
unite ( a , b );
}
bool same ( T a , T b )
{
return find ( M[a] ) == find ( M[b] );
}
long long int group ()
{
set < long long int >
S;
for( long long int i = 0; i < V.size (); i++ )
{
S.insert ( find ( V[i] ) );
}
return S.size ();
}
private:
vector<long long int>
V , rank;
map < T , long long int>M;
long long int count;
long long int find ( long long int x )
{
if( V[x] == x )return x;
else return V[x] = find ( V[x] );
}
};
int main ()
{
int V , d;
int data[1001] = {};
data[0] = 2;
data[1] = 3;
for( size_t i = 2; i < 1001; i++ )
{
data[i] = data[i - 1] + data[i - 2];
data[i] %= 1001;
}
while( cin >> V >> d )
{
UF<int> uf;
for( size_t i = 0; i < V; i++ )
{
uf.push ( data[i] );
}
for( size_t i = 0; i < V; i++ )
{
for( size_t j = i+1; j < V; j++ )
{
if( abs ( data[i] - data[j] ) < d )
{
uf.merge ( data[i] , data[j] );
}
}
}
cout << uf.group () << endl;
}
} | a.cc:91:9: error: return type specification for constructor invalid
91 | void UF ()
| ^~~~
|
s102151093 | p00602 | C++ | #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
//#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
//#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
//#include <atomic>
#include <chrono>
//#include <condition_variable>
#include <forward_list>
//#include <future>
#include <initializer_list>
//#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
//#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
template<typename T>
class UF
{
public:
void UF ()
{
count = 0;
return;
}
void push ( T a )
{
M[a] = count;
V.push_back ( count );
rank.push_back ( 0 );
count++;
}
void unite ( T a , T b )
{
long long int x = find ( M[a] );
long long int y = find ( M[b] );
if( x == y )return;
if( rank[x] < rank[y] )
{
V[x] = y;
} else
{
V[y] = x;
if( rank[x] == rank[y] )rank[x]++;
}
}
void merge ( T a , T b )
{
unite ( a , b );
}
bool same ( T a , T b )
{
return find ( M[a] ) == find ( M[b] );
}
long long int group ()
{
set < long long int >
S;
for( long long int i = 0; i < V.size (); i++ )
{
S.insert ( find ( V[i] ) );
}
return S.size ();
}
private:
vector<long long int>
V , rank;
map < T , long long int>M;
long long int count;
long long int find ( long long int x )
{
if( V[x] == x )return x;
else return V[x] = find ( V[x] );
}
};
int main ()
{
int V , d;
int data[1001] = {};
data[0] = 2;
data[1] = 3;
for( size_t i = 2; i < 1001; i++ )
{
data[i] = data[i - 1] + data[i - 2];
data[i] %= 1001;
}
while( cin >> V >> d )
{
UF<int> uf;
for( size_t i = 0; i < V; i++ )
{
uf.push ( data[i] );
}
for( size_t i = 0; i < V; i++ )
{
for( size_t j = i+1; j < V; j++ )
{
if( abs ( data[i] - data[j] ) < d )
{
uf.merge ( data[i] , data[j] );
}
}
}
cout << uf.group () << endl;
}
} | a.cc:91:9: error: return type specification for constructor invalid
91 | void UF ()
| ^~~~
|
s973548576 | p00602 | C++ | #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
//#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
//#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
//#include <atomic>
#include <chrono>
//#include <condition_variable>
#include <forward_list>
//#include <future>
#include <initializer_list>
//#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
//#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
template<typename T>
class UF
{
public:
int UF ()
{
count = 0;
return 0;
}
void push ( T a )
{
M[a] = count;
V.push_back ( count );
rank.push_back ( 0 );
count++;
}
void unite ( T a , T b )
{
long long int x = find ( M[a] );
long long int y = find ( M[b] );
if( x == y )return;
if( rank[x] < rank[y] )
{
V[x] = y;
} else
{
V[y] = x;
if( rank[x] == rank[y] )rank[x]++;
}
}
void merge ( T a , T b )
{
unite ( a , b );
}
bool same ( T a , T b )
{
return find ( M[a] ) == find ( M[b] );
}
long long int group ()
{
set < long long int >
S;
for( long long int i = 0; i < V.size (); i++ )
{
S.insert ( find ( V[i] ) );
}
return S.size ();
}
private:
vector<long long int>
V , rank;
map < T , long long int>M;
long long int count;
long long int find ( long long int x )
{
if( V[x] == x )return x;
else return V[x] = find ( V[x] );
}
};
int main ()
{
int V , d;
int data[1001] = {};
data[0] = 2;
data[1] = 3;
for( size_t i = 2; i < 1001; i++ )
{
data[i] = data[i - 1] + data[i - 2];
data[i] %= 1001;
}
while( cin >> V >> d )
{
UF<int> uf;
for( size_t i = 0; i < V; i++ )
{
uf.push ( data[i] );
}
for( size_t i = 0; i < V; i++ )
{
for( size_t j = i+1; j < V; j++ )
{
if( abs ( data[i] - data[j] ) < d )
{
uf.merge ( data[i] , data[j] );
}
}
}
cout << uf.group () << endl;
}
} | a.cc:91:9: error: return type specification for constructor invalid
91 | int UF ()
| ^~~
a.cc: In constructor 'UF<T>::UF()':
a.cc:94:24: error: returning a value from a constructor
94 | return 0;
| ^
|
s465790501 | p00602 | C++ | #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
//#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
//#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
//#include <atomic>
#include <chrono>
//#include <condition_variable>
#include <forward_list>
//#include <future>
#include <initializer_list>
//#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
//#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
template<typename T>
class UF
{
public:
void push ( T a )
{
static count = 0;
M[a] = count;
V.push_back ( count );
rank.push_back ( 0 );
count++;
}
void unite ( T a , T b )
{
long long int x = find ( M[a] );
long long int y = find ( M[b] );
if( x == y )return;
if( rank[x] < rank[y] )
{
V[x] = y;
} else
{
V[y] = x;
if( rank[x] == rank[y] )rank[x]++;
}
}
void merge ( T a , T b )
{
unite ( a , b );
}
bool same ( T a , T b )
{
return find ( M[a] ) == find ( M[b] );
}
long long int group ()
{
set < long long int >
S;
for( long long int i = 0; i < V.size (); i++ )
{
S.insert ( find ( V[i] ) );
}
return S.size ();
}
private:
vector<long long int>
V , rank;
map < T , long long int>M;
long long int count;
long long int find ( long long int x )
{
if( V[x] == x )return x;
else return V[x] = find ( V[x] );
}
};
int main ()
{
int V , d;
int data[1001] = {};
data[0] = 2;
data[1] = 3;
for( size_t i = 2; i < 1001; i++ )
{
data[i] = data[i - 1] + data[i - 2];
data[i] %= 1001;
}
while( cin >> V >> d )
{
UF<int> uf;
for( size_t i = 0; i < V; i++ )
{
uf.push ( data[i] );
}
for( size_t i = 0; i < V; i++ )
{
for( size_t j = i + 1; j < V; j++ )
{
if( abs ( data[i] - data[j] ) < d )
{
uf.merge ( data[i] , data[j] );
}
}
}
cout << uf.group () << endl;
}
} | a.cc: In member function 'void UF<T>::push(T)':
a.cc:93:24: error: 'count' does not name a type
93 | static count = 0;
| ^~~~~
|
s681621179 | p00602 | C++ | #include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int F[1001];
int P[10010];
void init(int N){
for(int i=0;i<=N;i++)
P[i] = i;
}
int root(int a){
if(P[a]==a)
return a;
return(P[a] = root(P[a]));
}
bool is_same_set(int a, int b){
return root(a) == root(b);
}
void unit(int a, int b){
P[root(a)] = root(b);
}
int main(){
F[0] = 1; F[1]=2;
for(int i=2;i<=1001;i++){
F[i] = F[i-1]+F[i-2];
}
for(int i=2;i<=1001;i++){
F[i] %=1001;
}
int V,d;
while(cin >> V >> d){
int count=0;
init(V);
for(int i=1;i<=V;i++){
for(int j=i+1; j<=V;j++){
if(abs(F[j]-F[i])<d){
unit(i,j);
}
}
}
for(int i=1;i<=V;i++){
if(root(i)==i)\\
count++;
}
cout << count << endl;
}
} | a.cc:48:27: error: stray '\' in program
48 | if(root(i)==i)\\
49 | count++;
|
s128453682 | p00602 | C++ | #include <iostream>
#include <vector>
using namespace std;
int P[100000];
int fibo[1000];
void init(int n){
for (int i = 0; i < n; ++i){P[i] = i;}
}
int root(int n){
if(P[n]==n){return n;}
return root(P[n]);
}
void unite(int a, int b){
P[root(a)] = root(b);
}
bool is_in_the_same_tree(int a, int b){
return root(a) == root(b);
}
int num_of_trees(int n){
int i, roothere, sum=0;
vector<int> roots;
for (i = 0; i < n; ++i){
roothere = root(i);
if(find(roots.begin(), roots.end(), roothere) == roots.end()){
roots.push_back(roothere);
}
}
return roots.size();
}
int fibonacci(int n){
if(n == 0){
fibo[n] = 2;
return 2;
}else if(n == 1){
fibo[n] = 3;
return 3;
}else{
if(fibo[n] != 0){
return fibo[n];
}else if(fibo[n-1] != 0 && fibo[n-2] != 0){
fibo[n] = (fibo[n-1]+fibo[n-2])%1001;
return fibo[n];
}else{
int result = (fibonacci(n-1)+fibonacci(n-2)) %1001;
fibo[n] = result;
return result;
}
}
}
int main(){
int V, d, i;
for (i = 0; i < 1000; ++i){
fibo[i] = 0;
}
while(cin >> V >> d){
fibonacci(V);
init(V);
if(V == 1){
cout << 1 << endl;
}else{
for (i = 0; i < V-1; ++i){
if(abs(fibo[i+1] - fibo[i]) < d){
unite(i, i+1);
}
}
cout << num_of_trees(V)<< endl;
}
}
} | a.cc: In function 'int num_of_trees(int)':
a.cc:30:12: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
30 | if(find(roots.begin(), roots.end(), roothere) == roots.end()){
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:30:12: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
30 | if(find(roots.begin(), roots.end(), roothere) == roots.end()){
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s299932594 | p00602 | C++ | #include <iostream>
#include <vector>
using namespace std;
int P[100000];
int fibo[1000];
void init(int n){
for (int i = 0; i < n; ++i){P[i] = i;}
}
int root(int n){
if(P[n]==n){return n;}
return root(P[n]);
}
void unite(int a, int b){
P[root(a)] = root(b);
}
bool is_in_the_same_tree(int a, int b){
return root(a) == root(b);
}
int num_of_trees(int n){
int i, roothere, sum=0;
vector<int> roots;
for (i = 0; i < n; ++i){
roothere = root(i);
if(find(roots.begin(), roots.end(), roothere) == roots.end()){
roots.push_back(roothere);
}
}
return roots.size();
}
int fibonacci(int n){
if(n == 0){
fibo[n] = 2;
return 2;
}else if(n == 1){
fibo[n] = 3;
return 3;
}else{
if(fibo[n] != 0){
return fibo[n];
}else if(fibo[n-1] != 0 && fibo[n-2] != 0){
fibo[n] = (fibo[n-1]+fibo[n-2])%1001;
return fibo[n];
}else{
int result = (fibonacci(n-1)+fibonacci(n-2)) %1001;
fibo[n] = result;
return result;
}
}
}
int main(){
int V, d, i;
for (i = 0; i < 1000; ++i){
fibo[i] = 0;
}
while(cin >> V >> d){
fibonacci(V);
init(V);
if(V == 1){
cout << 1 << endl;
}else{
for (i = 0; i < V-1; ++i){
if(abs(fibo[i+1] - fibo[i]) < d){
unite(i, i+1);
}
}
cout << num_of_trees(V)<< endl;
}
}
} | a.cc: In function 'int num_of_trees(int)':
a.cc:30:12: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
30 | if(find(roots.begin(), roots.end(), roothere) == roots.end()){
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:30:12: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
30 | if(find(roots.begin(), roots.end(), roothere) == roots.end()){
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s643052706 | p00602 | C++ | import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Main {
static Scanner sc = new Scanner(System.in);
static int V, d, N;
static int[] fib = new int[1001];
public static void main(String[] args) {
N = 1001;
fib[0] = 1; fib[1] = 2;
for (int i = 2; i < 1001; i++)
fib[i] = (fib[i - 1] + fib[i - 2]) % N;
while (read()) {
solve();
}
}
static boolean read() {
if (!sc.hasNextInt()) return false;
V = sc.nextInt();
d = sc.nextInt();
return true;
}
static void solve() {
UF uf = new UF(V + 1);
for (int i = 1; i <= V; i++) {
for (int j = i + 1; j <= V; j++) {
if (abs(fib[i] - fib[j]) < d) {
uf.merge(i, j);
}
}
}
int res = 0;
for (int i = 1; i <= V; i++) {
if (i == uf.find(i))
res++;
}
System.out.println(res);
}
}
class UF {
int[] p, r;
UF(int n) {
p = new int[n];
r = new int[n];
for (int i = 0; i < n; i++) {
p[i] = i;
r[i] = 0;
}
}
int find(int x) {
if (x == p[x]) return p[x];
else return p[x] = find(p[x]);
}
void merge(int x, int y) {
x = find(x);
y = find(y);
if (x == y) return;
if (r[x] < r[y]) p[x] = y;
else {
p[y] = x;
if (r[x] == r[y]) r[x]++;
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.*;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import static java.util.Arrays.*;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import static java.lang.Math.*;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
5 | public class Main {
| ^~~~~~
a.cc:49:12: error: expected unqualified-id before '[' token
49 | int[] p, r;
| ^
a.cc:76:2: error: expected ';' after class definition
76 | }
| ^
| ;
a.cc: In constructor 'UF::UF(int)':
a.cc:52:17: error: 'p' was not declared in this scope
52 | p = new int[n];
| ^
a.cc:53:17: error: 'r' was not declared in this scope
53 | r = new int[n];
| ^
a.cc: In member function 'int UF::find(int)':
a.cc:61:26: error: 'p' was not declared in this scope
61 | if (x == p[x]) return p[x];
| ^
a.cc: In member function 'void UF::merge(int, int)':
a.cc:70:21: error: 'r' was not declared in this scope
70 | if (r[x] < r[y]) p[x] = y;
| ^
a.cc:70:34: error: 'p' was not declared in this scope
70 | if (r[x] < r[y]) p[x] = y;
| ^
a.cc:72:25: error: 'p' was not declared in this scope
72 | p[y] = x;
| ^
|
s549333876 | p00602 | C++ | import java.util.*;
import java.io.*;
class Main {
public static void main(String[] args) {
Scanner stdin = new Scanner(System.in);
while ( stdin.hasNextInt() ) {
final int V = stdin.nextInt();
final int d = stdin.nextInt();
solve( V, d );
}
}
static void solve( final int V, final int d ) {
final int[] vs = fibs( V );
final int[] parents = new int[V];
final int[] rank = new int[V];
for ( int i = 0; i < V; i++ ) {
parents[i] = i;
}
for ( int i = 0; i < V; i++ ) {
for ( int j = i + 1; j < V; j++ ) {
if ( Math.abs( vs[i] - vs[j] ) < d ) {
unite( i, j, parents, rank );
}
}
}
Set<Integer> set = new HashSet<Integer>();
for ( int i = 0; i < V; i++ ) {
final int parent = find( i, parents, rank );
if ( !set.contains( parent ) ) {
set.add( parent );
}
}
System.out.println( set.size() );
}
static int find( final int x, final int[] parents, final int[] rank ) {
if ( parents[x] == x ) {
return x;
} else {
parents[x] = find( parents[x], parents, rank );
return parents[x];
}
}
static void unite( int x, int y, final int[] parents, final int[] rank ) {
final int xp = find( x, parents, rank );
final int yp = find( y, parents, rank );
if ( xp == yp ) {
return;
}
if ( rank[xp] < rank[yp] ) {
parents[xp] = yp;
} else {
parents[yp] = xp;
if ( rank[xp] == rank[yp] ) {
rank[xp]++;
}
}
}
static boolean same( final int x, final int y, final int[] parents, final int[] rank ) {
return find( x, parents, rank ) == find( y, parents, rank );
}
static int[] fibs( final int V ) {
if ( V == 1 ) {
final int[] ar = {2};
return ar;
} else {
final int[] vs = new int[V];
vs[0] = 2;
vs[1] = 3;
for ( int i = 2; i < V; i++ ) {
vs[i] = ( vs[i - 1] + vs[i - 2] ) % 1001;
}
return vs;
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.*;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.io.*;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:11: error: expected ':' before 'static'
6 | public static void main(String[] args) {
| ^~~~~~~
| :
a.cc:6:29: error: 'String' has not been declared
6 | public static void main(String[] args) {
| ^~~~~~
a.cc:6:38: error: expected ',' or '...' before 'args'
6 | public static void main(String[] args) {
| ^~~~
a.cc:18:24: error: 'final' has not been declared
18 | static void solve( final int V, final int d ) {
| ^~~~~
a.cc:18:24: error: two or more data types in declaration of 'V'
a.cc:18:35: error: expected ')' before ',' token
18 | static void solve( final int V, final int d ) {
| ~ ^
| )
a.cc:18:37: error: variable or field 'final' declared void
18 | static void solve( final int V, final int d ) {
| ^~~~~
a.cc:18:37: error: expected ';' at end of member declaration
18 | static void solve( final int V, final int d ) {
| ^~~~~
| ;
a.cc:18:47: error: expected ';' at end of member declaration
18 | static void solve( final int V, final int d ) {
| ^
| ;
a.cc:18:49: error: expected unqualified-id before ')' token
18 | static void solve( final int V, final int d ) {
| ^
a.cc:45:22: error: 'final' has not been declared
45 | static int find( final int x, final int[] parents, final int[] rank ) {
| ^~~~~
a.cc:45:22: error: two or more data types in declaration of 'x'
a.cc:45:33: error: expected ')' before ',' token
45 | static int find( final int x, final int[] parents, final int[] rank ) {
| ~ ^
| )
a.cc:45:35: error: expected ';' at end of member declaration
45 | static int find( final int x, final int[] parents, final int[] rank ) {
| ^~~~~
| ;
a.cc:45:44: error: expected unqualified-id before '[' token
45 | static int find( final int x, final int[] parents, final int[] rank ) {
| ^
a.cc:54:38: error: 'final' is not a type
54 | static void unite( int x, int y, final int[] parents, final int[] rank ) {
| ^~~~~
a.cc:54:38: error: two or more data types in declaration of 'parameter'
a.cc:54:49: error: expected ')' before 'parents'
54 | static void unite( int x, int y, final int[] parents, final int[] rank ) {
| ~ ^~~~~~~~
| )
a.cc:54:48: error: expected ';' at end of member declaration
54 | static void unite( int x, int y, final int[] parents, final int[] rank ) {
| ^
| ;
a.cc:54:50: error: 'parents' does not name a type
54 | static void unite( int x, int y, final int[] parents, final int[] rank ) {
| ^~~~~~~
a.cc:72:12: error: 'boolean' does not name a type; did you mean 'bool'?
72 | static boolean same( final int x, final int y, final int[] parents, final int[] rank ) {
| ^~~~~~~
| bool
a.cc:76:15: error: expected unqualified-id before '[' token
76 | static int[] fibs( final int V ) {
| ^
a.cc:91:2: error: expected ';' after class definition
91 | }
| ^
| ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:8:9: error: 'Scanner' was not declared in this scope
8 | Scanner stdin = new Scanner(System.in);
| ^~~~~~~
a.cc:10:17: error: 'stdin' was not declared in this scope
10 | while ( stdin.hasNextInt() ) {
| ^~~~~
a.cc:1:1: note: 'stdin' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | import java.util.*;
a.cc:12:19: error: expected ';' before 'int'
12 | final int V = stdin.nextInt();
| ^~~
a.cc:13:19: error: expected ';' before 'int'
13 | final int d = stdin.nextInt();
| ^~~
a.cc:14:20: error: 'V' was not declared in this scope
14 | solve( V, d );
| ^
a.cc:14:23: error: invalid use of member 'Main::d' in static member function
14 | solve( V, d );
| ^
a.cc:18:47: note: declared here
18 | static void solve( final int V, final int d ) {
| ^
|
s606205464 | p00602 | C++ | #include<stdlib.h>
p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}} | a.cc:2:1: error: ISO C++ forbids declaration of 'p' with no type [-fpermissive]
2 | p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}}
| ^
a.cc:2:30: error: 'd' does not name a type
2 | p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}}
| ^
a.cc:2:46: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
2 | p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}}
| ^~~~
a.cc: In function 'int main()':
a.cc:2:73: error: 'V' was not declared in this scope
2 | p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}}
| ^
a.cc:2:76: error: 'd' was not declared in this scope
2 | p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}}
| ^
a.cc:2:59: error: 'scanf' was not declared in this scope
2 | p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}}
| ^~~~~
a.cc:2:93: error: 'c' was not declared in this scope
2 | p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}}
| ^
a.cc:2:79: error: 'printf' was not declared in this scope
2 | p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}}
| ^~~~~~
a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
1 | #include<stdlib.h>
+++ |+#include <cstdio>
2 | p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}}
a.cc:2:101: error: 'f' was not declared in this scope
2 | p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}}
| ^
a.cc:2:113: error: 'i' was not declared in this scope
2 | p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}}
| ^
a.cc:2:160: error: 'f' was not declared in this scope
2 | p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}}
| ^
a.cc:2:173: error: 'i' was not declared in this scope
2 | p(int*a,int*b){return *a-*b;}d,c,V,i,f[1001];main(){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){for(f[1]=3,f[0]=i=2;i<V;)f[i]=(f[i-1]+f[i++-2])%1001;for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);}}
| ^
|
s568567370 | p00603 | Java | import java.math.*;
public class Main{
public static void main(String[] arg) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String is;
String[] ia;
while((is = in.readLine()) != null){
ia = is.split(" ");
int n = Integer.parseInt(ia[0]);
int r = Integer.parseInt(ia[1]);
LinkedList<Integer> a,b,d;
d = new LinkedList<Integer>();
for(int i = 0;i < n; ++i){
d.addFirst(i);
}
ia = in.readLine().split(" ");
for(int j = 0;j < r; ++j){
int c = Integer.parseInt(ia[j]);
a = new LinkedList<Integer>();
int x = d.size()/2;
for(int i = 0;i <= x; ++i){
a.addLast(d.removeFirst());
}
b = d;
d = new LinkedList<Integer>();
while(a.size() > 0 || b.size() > 0){
for(int i = 0;i < c && a.size() > 0; ++i){
d.addFirst(a.removeLast());
}
for(int i = 0;i < c && b.size() > 0; ++i){
d.addFirst(b.removeLast());
}
}
}
System.out.println(d.getFirst());
}
}
} | Main.java:3: error: cannot find symbol
public static void main(String[] arg) throws IOException {
^
symbol: class IOException
location: class Main
Main.java:4: error: cannot find symbol
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
^
symbol: class BufferedReader
location: class Main
Main.java:4: error: cannot find symbol
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
^
symbol: class BufferedReader
location: class Main
Main.java:4: error: cannot find symbol
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
^
symbol: class InputStreamReader
location: class Main
Main.java:12: error: cannot find symbol
LinkedList<Integer> a,b,d;
^
symbol: class LinkedList
location: class Main
Main.java:13: error: cannot find symbol
d = new LinkedList<Integer>();
^
symbol: class LinkedList
location: class Main
Main.java:20: error: cannot find symbol
a = new LinkedList<Integer>();
^
symbol: class LinkedList
location: class Main
Main.java:26: error: cannot find symbol
d = new LinkedList<Integer>();
^
symbol: class LinkedList
location: class Main
8 errors
|
s436833765 | p00604 | C | #include<stdio.h>
#include<stdlib.h>
int a;
int cmp(const void *s,const void *b){
return (*(int *)b)-(*(int *)s);
}
int main(void){
int n,m,k;
int i,j;
while(scanf("%d",&n)!=EOF){
m=0;
for(i=n;i>0;i--){
scanf("%d",&a);
m+=a*i;
}
printf("%d\n",m);
return 0;} | main.c: In function 'main':
main.c:19:1: error: expected declaration or statement at end of input
19 | return 0;}
| ^~~~~~
|
s171251874 | p00604 | C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
int i,t,a[100],sum=0;
while(scanf("%d",&t)==1){
for(i=0;i<t;i++){
scanf("%d",&a[i]);
}
sort(a,a+t);
for(i=0;i<t;i++){
sum+=(a[i]*(t-i));
}
printf("%d\n",sum);
sum=0;
}
return 0;
} | main.c:4:10: fatal error: algorithm: No such file or directory
4 | #include <algorithm>
| ^~~~~~~~~~~
compilation terminated.
|
s886228000 | p00604 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main(){
int n;
while(cin >> n){
int result = 0;
vector<int> p;
int tmp;
for(int i=1; i<=n; i++){
cin >> tmp;
p.push_back(tmp);
}
sort(p.begin(), p.end());
tmp = 0;
for(int i=1; i<=n; i++){
result += tmp + p[i-1];
tmp += p[i-1];
}
cout << result << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'short'?
16 | sort(p.begin(), p.end());
| ^~~~
| short
|
s980654638 | p00604 | C++ | #include <iostream>
using namespace std;
int main(){
int loop_num;
long sum;
long Penalty[12800];
while(cin >> loop_num){
for(int i=0;i<loop_num;i++){
cin >> Penalty[i];
}
sort(Penalty,Penalty+loop_num);
sum = 0;
for(int i=0;i<loop_num;i++){
sum += Penalty[i]*(loop_num-i);
}
cout << sum << endl;
}
} | a.cc: In function 'int main()':
a.cc:14:5: error: 'sort' was not declared in this scope; did you mean 'short'?
14 | sort(Penalty,Penalty+loop_num);
| ^~~~
| short
|
s888555654 | p00604 | C++ | #include <iostream>
#include <algorithm>
#define MAX 20000
int main(void){
int array[MAX],n,sum,ans;
while(cin >> n){
for(int i = 0 ; i < n ; i++) cin >> array[i];
sort(array,array+n);
sum = 0;
ans = 0;
for(int i = 0 ; i < n ; i++){
sum += array[i];
ans += sum;
}
cout << ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:8:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
8 | while(cin >> n){
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:11:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
11 | sort(array,array+n);
| ^~~~
| std::sort
In file included from /usr/include/c++/14/algorithm:86,
from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
| ^~~~
a.cc:19:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
19 | cout << ans << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:19:20: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
19 | cout << ans << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s752982480 | p00604 | C++ | //使い方もわからないくせにincludeしまくる人間のクズ
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<deque>
//using namespaceは必須
using namespace std;
//defineは可読性を左右する諸刃の剣
//型宣言をいつやればいいのか分からないためグローバルに宣言
int a[10], b, i;
char str[10];
bool judge;
class InterestingNumber{
public:
char test(){
return std::Interesting;
}
}
int main(){
InterestingNumber ok;
memset(a, 0, sizeof(int));
scanf("%s", str);
b = strlen(str);
if(b % 2 != 0){
printf("Not interesting\n");
return 0;
}
judge = true;
for(i = 0; i < b / 2; i++){
if(str[i] == 'z') continue;
if(i + (str[i] - '0') >= b){
judge = false;
break;
}
if(str[i] != str[i + str[i] - '0' + 1]){
judge = false;
break;
}
str[i + str[i] - '0' + 1] = 'z';
}
if(judge) ok.
else printf("Not interesting\n");
return 0;
} | a.cc:27:2: error: expected ';' after class definition
27 | }
| ^
| ;
a.cc: In member function 'char InterestingNumber::test()':
a.cc:25:17: error: 'Interesting' is not a member of 'std'
25 | return std::Interesting;
| ^~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:53:3: error: expected unqualified-id before 'else'
53 | else printf("Not interesting\n");
| ^~~~
|
s584212723 | p00604 | C++ | #include<iostream>
using namespace std;
int main()
{
int n;
for(;cin>>n;)
{
long long int data[n];
for(int i=0;i<n;i++)
cin>>data[i];
long long int ans=0;
long long int sum=0;
sort(data,data+n);
for(int i=0;i<n;i++)
{
sum+=data[i];
ans+=sum;
}
cout<<ans<<endl;
}
} | a.cc: In function 'int main()':
a.cc:14:7: error: 'sort' was not declared in this scope; did you mean 'short'?
14 | sort(data,data+n);
| ^~~~
| short
|
s931117219 | p00604 | C++ | #include <iostream>
#include <math.h>
using namespace std;
int main(int argc, const char * argv[])
{
int n;
while(cin >> n){
int times[n];
for(int i = 0; i < n; i++){
cin >> times[i];
}
sort(times, times+n);
int part_sum = 0;
int all_sum = 0;
for(int i = 0; i < n; i++){
part_sum += times[i];
all_sum += part_sum;
}
cout << all_sum; << "\n";
}
return 0;
} | a.cc: In function 'int main(int, const char**)':
a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
14 | sort(times, times+n);
| ^~~~
| sqrt
a.cc:23:26: error: expected primary-expression before '<<' token
23 | cout << all_sum; << "\n";
| ^~
|
s602711619 | p00604 | C++ | #include <iostream>
#include <math.h>
using namespace std;
int main(int argc, const char * argv[])
{
int n;
while(cin >> n){
int times[n];
for(int i = 0; i < n; i++){
cin >> times[i];
}
sort(times, times+n);
int part_sum = 0;
int all_sum = 0;
for(int i = 0; i < n; i++){
part_sum += times[i];
all_sum += part_sum;
}
cout << all_sum << "\n";
}
return 0;
} | a.cc: In function 'int main(int, const char**)':
a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
14 | sort(times, times+n);
| ^~~~
| sqrt
|
s066099179 | p00605 | Java | import java.util.Scanner;
/**
* Vampirish Night
* URL:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1019&lang=jp
*
* @author Igari Kazuya
*/
public class P1019_Vampirish_Night {
/**
* @param args
*/
public static void main(String[] args) {
// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
Scanner sc = new Scanner(System.in);
int n,k;
while(true){
n = sc.nextInt();
k = sc.nextInt();
if(n==0 && k==0){
break;
}
int[][] array = new int[n+1][k];
for(int i=0;i<n+1;i++){
for(int j=0;j<k;j++){
array[i][j] = sc.nextInt();
}
}
for(int i=1;i<n+1;i++){
for(int j=0;j<k;j++){
array[0][j] -= array[i][j];
}
}
boolean flag = true;
for(int i=0;i<k;i++){
if(array[0][i] < 0){
flag = false;
}
}
if(flag){
System.out.println("Yes");
}else{
System.out.println("No");
}
}
}
} | Main.java:9: error: class P1019_Vampirish_Night is public, should be declared in a file named P1019_Vampirish_Night.java
public class P1019_Vampirish_Night {
^
1 error
|
s780006900 | p00605 | C | for(;scanf("%d%d",&n,&k),n;){
for(i=0;i<k;i++)scanf("%d",a+i);
for(;n--;)
for(i=0;i<k;a[i++]-=x)scanf("%d",&x),;
for(i=0;i<k&&a[i]>=0;i++);
puts(k-i?"No":"Yes");
}
return 0;
} | main.c:1:3: error: expected identifier or '(' before 'for'
1 | for(;scanf("%d%d",&n,&k),n;){
| ^~~
main.c:1:14: error: expected declaration specifiers or '...' before string constant
1 | for(;scanf("%d%d",&n,&k),n;){
| ^~~~~~
main.c:1:21: error: expected declaration specifiers or '...' before '&' token
1 | for(;scanf("%d%d",&n,&k),n;){
| ^
main.c:1:24: error: expected declaration specifiers or '...' before '&' token
1 | for(;scanf("%d%d",&n,&k),n;){
| ^
main.c:1:30: error: expected identifier or '(' before ')' token
1 | for(;scanf("%d%d",&n,&k),n;){
| ^
main.c:8:3: error: expected identifier or '(' before 'return'
8 | return 0;
| ^~~~~~
main.c:9:1: error: expected identifier or '(' before '}' token
9 | }
| ^
|
s008992319 | p00605 | C | K,B,n,*p;main(N,S){for(;scanf("%d%d",&N,&K)*N;n=!puts(n&1?"No":"Yes"))for(;~N--;n|=2)for(p=S+K*4;S-p--;n|=*p<0)scanf("%d",&B),*p=n?*p-B:B;} | main.c:1:1: warning: data definition has no type or storage class
1 | K,B,n,*p;main(N,S){for(;scanf("%d%d",&N,&K)*N;n=!puts(n&1?"No":"Yes"))for(;~N--;n|=2)for(p=S+K*4;S-p--;n|=*p<0)scanf("%d",&B),*p=n?*p-B:B;}
| ^
main.c:1:1: error: type defaults to 'int' in declaration of 'K' [-Wimplicit-int]
main.c:1:3: error: type defaults to 'int' in declaration of 'B' [-Wimplicit-int]
1 | K,B,n,*p;main(N,S){for(;scanf("%d%d",&N,&K)*N;n=!puts(n&1?"No":"Yes"))for(;~N--;n|=2)for(p=S+K*4;S-p--;n|=*p<0)scanf("%d",&B),*p=n?*p-B:B;}
| ^
main.c:1:5: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
1 | K,B,n,*p;main(N,S){for(;scanf("%d%d",&N,&K)*N;n=!puts(n&1?"No":"Yes"))for(;~N--;n|=2)for(p=S+K*4;S-p--;n|=*p<0)scanf("%d",&B),*p=n?*p-B:B;}
| ^
main.c:1:8: error: type defaults to 'int' in declaration of 'p' [-Wimplicit-int]
1 | K,B,n,*p;main(N,S){for(;scanf("%d%d",&N,&K)*N;n=!puts(n&1?"No":"Yes"))for(;~N--;n|=2)for(p=S+K*4;S-p--;n|=*p<0)scanf("%d",&B),*p=n?*p-B:B;}
| ^
main.c:1:10: error: return type defaults to 'int' [-Wimplicit-int]
1 | K,B,n,*p;main(N,S){for(;scanf("%d%d",&N,&K)*N;n=!puts(n&1?"No":"Yes"))for(;~N--;n|=2)for(p=S+K*4;S-p--;n|=*p<0)scanf("%d",&B),*p=n?*p-B:B;}
| ^~~~
main.c: In function 'main':
main.c:1:10: error: type of 'N' defaults to 'int' [-Wimplicit-int]
main.c:1:10: error: type of 'S' defaults to 'int' [-Wimplicit-int]
main.c:1:25: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
1 | K,B,n,*p;main(N,S){for(;scanf("%d%d",&N,&K)*N;n=!puts(n&1?"No":"Yes"))for(;~N--;n|=2)for(p=S+K*4;S-p--;n|=*p<0)scanf("%d",&B),*p=n?*p-B:B;}
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | K,B,n,*p;main(N,S){for(;scanf("%d%d",&N,&K)*N;n=!puts(n&1?"No":"Yes"))for(;~N--;n|=2)for(p=S+K*4;S-p--;n|=*p<0)scanf("%d",&B),*p=n?*p-B:B;}
main.c:1:25: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
1 | K,B,n,*p;main(N,S){for(;scanf("%d%d",&N,&K)*N;n=!puts(n&1?"No":"Yes"))for(;~N--;n|=2)for(p=S+K*4;S-p--;n|=*p<0)scanf("%d",&B),*p=n?*p-B:B;}
| ^~~~~
main.c:1:25: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:1:50: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
1 | K,B,n,*p;main(N,S){for(;scanf("%d%d",&N,&K)*N;n=!puts(n&1?"No":"Yes"))for(;~N--;n|=2)for(p=S+K*4;S-p--;n|=*p<0)scanf("%d",&B),*p=n?*p-B:B;}
| ^~~~
main.c:1:50: note: include '<stdio.h>' or provide a declaration of 'puts'
main.c:1:91: error: assignment to 'int *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
1 | K,B,n,*p;main(N,S){for(;scanf("%d%d",&N,&K)*N;n=!puts(n&1?"No":"Yes"))for(;~N--;n|=2)for(p=S+K*4;S-p--;n|=*p<0)scanf("%d",&B),*p=n?*p-B:B;}
| ^
main.c:1:99: error: invalid operands to binary - (have 'int' and 'int *')
1 | K,B,n,*p;main(N,S){for(;scanf("%d%d",&N,&K)*N;n=!puts(n&1?"No":"Yes"))for(;~N--;n|=2)for(p=S+K*4;S-p--;n|=*p<0)scanf("%d",&B),*p=n?*p-B:B;}
| ^~~~
| |
| int *
|
s054980052 | p00605 | C | #define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
using namespace std;
typedef long long ll;
typedef pair <int,int> P;
static const double EPS = 1e-8;
int main(){
int N,K;
int tank[100];
while(~scanf("%d %d",&N,&K)){
if(N==K && K==0) break;
for(int i=0;i<K;i++){
scanf("%d",tank+i);
}
bool isok = true;
for(int i=0;i<N;i++){
for(int j=0;j<K;j++){
int B;
scanf("%d",&B);
tank[j]-=B;
if(tank[j]<0) isok = false;
}
}
printf("%s\n",isok ? "Yes" : "No");
}
} | main.c:3:10: fatal error: iostream: No such file or directory
3 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s012613255 | p00605 | C | using System;
using System.Collections.Generic;
using System.Text;
class TEST{
static void Main(){
while(true){
String s="";
if((s=Console.ReadLine())==null)break;
long[] ss=Array.ConvertAll(s.Split(' '),elem=>long.Parse(elem));
if(ss[0]==0)break;
long N=ss[0];
long K=ss[1];
Sol mySol=new Sol(N,K);
Console.WriteLine(mySol.Ans);
}
}
}
class Sol{
String ans;
public String Ans{
get{return ans;}
}
public Sol(long N,long K){
long[] Stock=Array.ConvertAll(Console.ReadLine().Split(' '),elem=>long.Parse(elem));
bool chk=true;
for(int i=0;i<N;i++){
var S=Console.ReadLine().Split(' ');
for(int j=0;j<K;j++){
Stock[j]-=long.Parse(S[j]);
if(Stock[j]<0)chk=false;
}
}
if(chk)ans="Yes";
if(!chk)ans="No";
}
} | main.c:1:1: error: unknown type name 'using'
1 | using System;
| ^~~~~
main.c:2:1: error: unknown type name 'using'
2 | using System.Collections.Generic;
| ^~~~~
main.c:2:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
2 | using System.Collections.Generic;
| ^
main.c:3:1: error: unknown type name 'using'
3 | using System.Text;
| ^~~~~
main.c:3:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
3 | using System.Text;
| ^
main.c:5:1: error: unknown type name 'class'
5 | class TEST{
| ^~~~~
main.c:5:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
5 | class TEST{
| ^
main.c:20:1: error: unknown type name 'class'
20 | class Sol{
| ^~~~~
main.c:20:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
20 | class Sol{
| ^
|
s398647737 | p00605 | C++ | #include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
int a,b;
while(cin>>a>>b,a+b){
int S[b];
for(int i=0;i<b;i++)
cin>>S[i];
int flag=1;
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
int B;
cin>>B;
S[j]-=B;
if(S[j]<0){
flag=0;
}
}
}
if(flag)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:18:9: error: 'cin' was not declared in this scope
18 | while(cin>>a>>b,a+b){
| ^~~
a.cc:7:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
6 | #include<cmath>
+++ |+#include <iostream>
7 | #define INF 2147483647
a.cc:34:7: error: 'cout' was not declared in this scope
34 | cout<<"Yes"<<endl;
| ^~~~
a.cc:34:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:34:20: error: 'endl' was not declared in this scope
34 | cout<<"Yes"<<endl;
| ^~~~
a.cc:7:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
6 | #include<cmath>
+++ |+#include <ostream>
7 | #define INF 2147483647
a.cc:36:7: error: 'cout' was not declared in this scope
36 | cout<<"No"<<endl;
| ^~~~
a.cc:36:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:36:19: error: 'endl' was not declared in this scope
36 | cout<<"No"<<endl;
| ^~~~
a.cc:36:19: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
|
s312852200 | p00605 | C++ | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int exist[100000];
int needed[100000];
int main(){
int n,k;
while(1)
{
cin >> n >> k;
if (n==0)break;
memset(exist,0,sizeof(exist));
memset(needed,0,sizeof(needed));
for (int i=0; i<k; i++)
{
cin >> exist[i];
}
int tmp;
for (int i=0; i<n; i++)
{
for (int j=0; j<k; j++)
{
cin >> tmp;
needed[j]+=tmp;
}
}
int ok=1;
for (int i=0; i<k; i++)
{
if (exist[i]<needed[i])
{
ok=0;
break;
}
}
(ok==1)?cout << "YES" << endl:cout << "NO" << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:16:17: error: 'memset' was not declared in this scope
16 | memset(exist,0,sizeof(exist));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <algorithm>
+++ |+#include <cstring>
5 |
|
s616256477 | p00605 | C++ | #include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int N, K;
int main()
{
while (scanf("%d %d ", &N, &K) == 2) {
if (N == 0 && K == 0) {
break;
}
// printf("(N, K) = (%d, %d)\n", N, K);
vector<int> S;
for (int i = 0; i < K; i++) {
int s;
scanf("%d ", &s);
S.push_back(s);
}
bool flag = true;
for (int i = 0; i < N; i++) {
for (int j = 0; j < K; j++) {
int b;
scanf("%d ", &b);
S[j] -= b;
if (S[j] < 0) {
flag = false;
}
}
}
if (flag) {
printf("YES\n");
} else {
printf("NO\n");
}
}
}
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int N, K;
int main()
{
while (scanf("%d %d ", &N, &K) == 2) {
if (N == 0 && K == 0) {
break;
}
// printf("(N, K) = (%d, %d)\n", N, K);
vector<int> S;
for (int i = 0; i < K; i++) {
int s;
scanf("%d ", &s);
S.push_back(s);
}
bool flag = true;
for (int i = 0; i < N; i++) {
for (int j = 0; j < K; j++) {
int b;
scanf("%d ", &b);
S[j] -= b;
if (S[j] < 0) {
flag = false;
}
}
}
if (flag) {
printf("YES\n");
} else {
printf("NO\n");
}
}
} | a.cc:45:5: error: redefinition of 'int N'
45 | int N, K;
| ^
a.cc:6:5: note: 'int N' previously declared here
6 | int N, K;
| ^
a.cc:45:8: error: redefinition of 'int K'
45 | int N, K;
| ^
a.cc:6:8: note: 'int K' previously declared here
6 | int N, K;
| ^
a.cc:47:5: error: redefinition of 'int main()'
47 | int main()
| ^~~~
a.cc:8:5: note: 'int main()' previously defined here
8 | int main()
| ^~~~
|
s746346684 | p00605 | C++ | #include<stdio.h>
int main(){
int N,K;
int S[100];
int B;
int count;
int h=1;
int i,j;
scanf("%d %d",&N,&K);
while((N!=0)&&(K!=0)){
h=1;
for(i=0;i<K;i++){
scanf("%d",&S[i]);
}
for(i=0;i<N;i++){
for(j=0;j<K;j++){
scanf("%d",&B);
}
}
}
if(h==1){
printf("Yes\n");
}
scanf("%d %d",&N,&K);
}
return 0;
} | a.cc:37:9: error: expected unqualified-id before 'return'
37 | return 0;
| ^~~~~~
a.cc:39:1: error: expected declaration before '}' token
39 | }
| ^
|
s617550524 | p00605 | C++ | #include<cstdio>
#include<vector>
using namespace std;
int main(){
int N, K;
while( scanf("%d %d", &N, &K), N||K ){
vector<int> bloods;
for( int i=0; i<K; i++ ){
int b;
scanf("%d", &b);
bloods.push_back(b);
}
for( int i=0; i<N; i++ ){
for( int j=0; j<K; j++ ){
int b;
scanf("%d", &b );
bloods[j] -= b;
}
}
bool runout = false;
for( int i=0; i<K; i++ ){
if( bloods[j] < 0 ){
runout = true;
break;
}
printf(runout?"No\n":"Yes\n");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:18: error: 'j' was not declared in this scope
24 | if( bloods[j] < 0 ){
| ^
a.cc:31:2: error: expected '}' at end of input
31 | }
| ^
a.cc:5:11: note: to match this '{'
5 | int main(){
| ^
|
s636367769 | p00605 | C++ | #include<stdio.h>
main(){
int N,K,blood[101],family[101],tmp,i,j,x;
while(1){
scanf("%d %d", &N, &K)
if(N==0&&k==0)
break;
tmp=1;
for(i=0;i<K;i++)
scanf("%d",&blood[i]);
for(i=0;i<N;i++){
for(j=0;j<K;j++){
scanf("%d",&x);
blood[j]-=x;
if(blood[j]<0)
tmp=0;
}
}
if(tmp==0)
printf("no\n");
else
printf("yes\n");
}
} | a.cc:2:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
2 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:5:32: error: expected ';' before 'if'
5 | scanf("%d %d", &N, &K)
| ^
| ;
6 | if(N==0&&k==0)
| ~~
|
s524937732 | p00605 | C++ | #include<stdio.h>
main(){
int N,K,blood[101],family[101],tmp,i,j,x;
while(1){
scanf("%d %d", &N, &K);
if(N==0&&k==0)
break;
tmp=1;
for(i=0;i<K;i++)
scanf("%d",&blood[i]);
for(i=0;i<N;i++){
for(j=0;j<K;j++){
scanf("%d",&x);
blood[j]-=x;
if(blood[j]<0)
tmp=0;
}
}
if(tmp==0)
printf("no\n");
else
printf("yes\n");
}
} | a.cc:2:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
2 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:6:19: error: 'k' was not declared in this scope
6 | if(N==0&&k==0)
| ^
|
s710045835 | p00606 | C | #include "stdio.h"
#include "math.h"
int main()
{
int n;
char s, t, b;
scanf("%d", &n);
while(n>0){
scanf(" %c %c %c", &s, &t, &b);
s-='A'; t-='A'; b-='A';
int footprint1[9]={0,0,0,0,0,0,0,0,0};
int footprint2[9];
footprint1[s] = 1;
for(int i=0; i<n; i++){
for(int j=0; j<9; j++) footprint2[j]=0;
for(int j=0; j<9; j++){
if(footprint1[j]>0){
if(j>2 && j-3!=b) footprint2[j-3]+=footprint1[j];
else footprint2[j]+=footprint1[j];
if(j%3>0 && j-1!=b) footprint2[j-1]+=footprint1[j];
else footprint2[j]+=footprint1[j];
if((j+1)%3>0 && j+1!=b) footprint2[j+1]+=footprint1[j];
else footprint2[j]+=footprint1[j];
if(j<6 && j+3!=b) footprint2[j+3]+=footprint1[j];
else footprint2[j]+=footprint1[j];
}
}
for(int j=0; j<9; j++) footprint1[j]=footprint2[j];
}
printf("%f\n", footprint1[t] / pow(4.0, n));
scanf("%d", &n);
}
return 0;
} | /usr/bin/ld: /tmp/ccEm14L3.o: in function `main':
main.c:(.text+0x2fe): undefined reference to `pow'
collect2: error: ld returned 1 exit status
|
s036818790 | p00606 | C | #include "stdio.h"
#include "math.h"
int main()
{
int n;
char s, t, b;
scanf("%d", &n);
while(n>0){
scanf(" %c %c %c", &s, &t, &b);
s-='A'; t-='A'; b-='A';
int footprint1[9]={0,0,0,0,0,0,0,0,0};
int footprint2[9];
footprint1[s] = 1;
for(int i=0; i<n; i++){
for(int j=0; j<9; j++) footprint2[j]=0;
for(int j=0; j<9; j++){
if(footprint1[j]>0){
if(j>2 && j-3!=b) footprint2[j-3]+=footprint1[j];
else footprint2[j]+=footprint1[j];
if(j%3>0 && j-1!=b) footprint2[j-1]+=footprint1[j];
else footprint2[j]+=footprint1[j];
if((j+1)%3>0 && j+1!=b) footprint2[j+1]+=footprint1[j];
else footprint2[j]+=footprint1[j];
if(j<6 && j+3!=b) footprint2[j+3]+=footprint1[j];
else footprint2[j]+=footprint1[j];
}
}
for(int j=0; j<9; j++) footprint1[j]=footprint2[j];
}
printf("%f\n", footprint1[t] / pow(4.0, n));
scanf("%d", &n);
}
return 0;
} | /usr/bin/ld: /tmp/ccHTJXQ4.o: in function `main':
main.c:(.text+0x2fe): undefined reference to `pow'
collect2: error: ld returned 1 exit status
|
s718877377 | p00606 | C++ | #include <bits/stdc++.h>
using namespace std;
int dp[16][9];
const int m[]={-3,-1,1,3};
int main(){
while(true){
int n; cin>>n;
if(n==0) return 0;
char s,t,b; cin>>s>>t>>b;
int ss=s-'A',bb=b-'A',tt=t-'A';
memset(dp,0,sizeof(dp));
dp[0][tt]=1;
for(int i=0;i<n;i++){
for(int j=0;j<9;j++){
if(dp[i][j]==0) continue;
for(int k=0;k<4;k++){
if(j+m[k]<0||9<=j+m[k]) dp[i+1][j]+=dp[i][j];
else if(bb==j+m[k]) dp[i+1][j]+=dp[i][j];
else dp[i+1][j+m[k]]+=dp[i][j];
}
}
}
printf("%.15lf\n",(double)dp[n][ss]>>(2*n));
}
} | a.cc: In function 'int main()':
a.cc:23:52: error: invalid operands of types 'double' and 'int' to binary 'operator>>'
23 | printf("%.15lf\n",(double)dp[n][ss]>>(2*n));
| ~~~~~~~~~~~~~~~~~^~~~~~~
| | |
| double int
|
s480870387 | p00606 | C++ | #include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
using namespace std;
double dp[16][9];
int k, x, y, z;
int b[9][4]={
{1,3,-1,-1},
{ 0,2,4,-1 },
{ 1,5,-1,-1 },
{ 0,4,6,-1 },
{ 1,3,5,7 },
{ 2,4,8,-1 },
{ 3,7,-1,-1 },
{ 4,6,8,-1 },
{ 5,7,-1,-1 }
};
int main() {
while (cin >> k, k) {
memset(dp, 0, sizeof(dp));
char a, b, c; cin >> a >> b >> c;
dp[0][a - 'A'] = 1;
y = b - 'A'; z = c - 'A';
double S = 0;
for (int i = 0; i < k; i++) {
for (int j = 0; j < 9; j++) {
for (int l = 0; l < 4; l++) {
if (::b[j][l] == -1 || ::b[j][l] == z) {
dp[i + 1][j] += dp[i][j] * 0.25;
}
else {
dp[i + 1][::b[j][l]] += dp[i][j] * 0.25;
}
}
}
}
printf("%.10lf\n", dp[k][y]);
}
} | a.cc: In function 'int main()':
a.cc:26:17: error: 'memset' was not declared in this scope
26 | memset(dp, 0, sizeof(dp));
| ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
7 | #include<set>
+++ |+#include <cstring>
8 | #include<map>
|
s087068887 | p00606 | C++ | # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);
int n;
char s, t, b;
pair<int, int> S, T, B;
double dp[16][3][3];
int dx[] = { 0,1,0,-1 }, dy[] = { -1,0,1,0 };
int main() {
while (cin >> n&&n) {
cin >> s >> t >> b;
S = make_pair((s - 'A') / 3, (s - 'A') % 3);
T = make_pair((t - 'A') / 3, (t - 'A') % 3);
B = make_pair((b - 'A') / 3, (b - 'A') % 3);
memset(dp, 0.0, sizeof(dp));
dp[0][S.first][S.second] = 1;
for (int i = 0; i < n; i++) {
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
if (dp[i][y][x] == 0)continue;
for (int d = 0; d < 4; d++) {
int ny = y + dy[d], nx = x + dx[d];
if (0 <= nx&&nx < 3 && 0 <= ny&&ny < 3 && make_pair(ny, nx) != B)dp[i + 1][ny][nx] += dp[i][y][x] * 0.25;
else dp[i + 1][y][x] += dp[i][y][x] * 0.25;
}
}
}
}
cout << fixed << setprecision(10) << dp[n][T.first][T.second] << endl;
}
} | a.cc: In function 'int main()':
a.cc:34:17: error: 'memset' was not declared in this scope
34 | memset(dp, 0.0, sizeof(dp));
| ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
13 | # include <list>
+++ |+#include <cstring>
14 | using namespace std;
|
s035544341 | p00606 | C++ | # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);
int n;
char s, t, b;
pair<int, int> S, T, B;
double dp[16][3][3];
int dx[] = { 0,1,0,-1 }, dy[] = { -1,0,1,0 };
int main() {
while (cin >> n&&n) {
cin >> s >> t >> b;
S = make_pair((s - 'A') / 3, (s - 'A') % 3);
T = make_pair((t - 'A') / 3, (t - 'A') % 3);
B = make_pair((b - 'A') / 3, (b - 'A') % 3);
memset(dp, 0.0, sizeof(dp));
dp[0][S.first][S.second] = 1;
for (int i = 0; i < n; i++) {
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
if (dp[i][y][x] == 0)continue;
for (int d = 0; d < 4; d++) {
int ny = y + dy[d], nx = x + dx[d];
if (0 <= nx&&nx < 3 && 0 <= ny&&ny < 3 && make_pair(ny, nx) != B)dp[i + 1][ny][nx] += dp[i][y][x] * 0.25;
else dp[i + 1][y][x] += dp[i][y][x] * 0.25;
}
}
}
}
cout << fixed << setprecision(10) << dp[n][T.first][T.second] << endl;
}
} | a.cc: In function 'int main()':
a.cc:34:17: error: 'memset' was not declared in this scope
34 | memset(dp, 0.0, sizeof(dp));
| ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
13 | # include <list>
+++ |+#include <cstring>
14 | using namespace std;
|
s341498460 | p00606 | C++ | # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);
int n;
char s, t, b;
pair<int, int> S, T, B;
double dp[16][3][3];
int dx[] = { 0,1,0,-1 }, dy[] = { -1,0,1,0 };
int main() {
while (cin >> n&&n) {
cin >> s >> t >> b;
S = make_pair((s - 'A') / 3, (s - 'A') % 3);
T = make_pair((t - 'A') / 3, (t - 'A') % 3);
B = make_pair((b - 'A') / 3, (b - 'A') % 3);
std::memset(dp, 0.0, sizeof(dp));
dp[0][S.first][S.second] = 1;
for (int i = 0; i < n; i++) {
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
if (dp[i][y][x] == 0)continue;
for (int d = 0; d < 4; d++) {
int ny = y + dy[d], nx = x + dx[d];
if (0 <= nx&&nx < 3 && 0 <= ny&&ny < 3 && make_pair(ny, nx) != B)dp[i + 1][ny][nx] += dp[i][y][x] * 0.25;
else dp[i + 1][y][x] += dp[i][y][x] * 0.25;
}
}
}
}
cout << fixed << setprecision(10) << dp[n][T.first][T.second] << endl;
}
} | a.cc: In function 'int main()':
a.cc:34:22: error: 'memset' is not a member of 'std'; did you mean 'wmemset'?
34 | std::memset(dp, 0.0, sizeof(dp));
| ^~~~~~
| wmemset
|
s079822112 | p00606 | C++ | #include <stdio.h>
int dp[16][3 + 2][3 + 2];
int main(void)
{
int n;
char s[2], e[2], t[2];
int start;
int end;
int not;
int mot;
while (1){
scanf("%d", &n);
if (n == 0) break;
scanf("%s%s%s", s, e, t);
for (int i = 0; i < 5; i++){
for (int j = 0; j < 5; j++){
for (int k = 0; k < 16; k++){
if (i == 0 || i == 4 || j == 0 || j == 4){
dp[k][i][j] = -1;
}
else {
dp[k][i][j] = 0;
}
}
}
}
start = s[0] - 'A';
not = t[0] - 'A';
dp[0][(start % 3) + 1][(start / 3) + 1] = 1;
for (int i = 0; i < n + 1; i++){
dp[i][(not % 3) + 1][(not / 3) + 1] = -1;
}
for (int i = 0; i < n; i++){
for (int y = 1; y <= 3; y++){
for (int x = 1; x <= 3; x++){
if (dp[i][x][y] == -1) continue;
if (dp[i][x + 1][y] == -1){
dp[i + 1][x][y] += dp[i][x][y];
}
else {
dp[i + 1][x + 1][y] += dp[i][x][y];
}
if (dp[i][x - 1][y] == -1){
dp[i + 1][x][y] += dp[i][x][y];
}
else {
dp[i + 1][x - 1][y] += dp[i][x][y];
}
if (dp[i][x][y + 1] == -1){
dp[i + 1][x][y] += dp[i][x][y];
}
else {
dp[i + 1][x][y + 1] += dp[i][x][y];
}
if (dp[i][x][y - 1] == -1){
dp[i + 1][x][y] += dp[i][x][y];
}
else {
dp[i + 1][x][y - 1] += dp[i][x][y];
}
}
}
}
mot = 0;
for (int y = 1; y <= 3; y++){
for (int x = 1; x <= 3; x++){
if (dp[n][x][y] != -1){
mot += dp[n][x][y];
}
}
}
end = e[0] - 'A';
printf("%lf\n", double((double)(dp[n][(end % 3) + 1][(end / 3) + 1]) / (double)mot));
}
return (0);
} | a.cc: In function 'int main()':
a.cc:11:13: error: expected unqualified-id before 'not' token
11 | int not;
| ^~~
a.cc:34:21: error: expected primary-expression before '=' token
34 | not = t[0] - 'A';
| ^
a.cc:38:36: error: expected primary-expression before '%' token
38 | dp[i][(not % 3) + 1][(not / 3) + 1] = -1;
| ^
a.cc:38:51: error: expected primary-expression before '/' token
38 | dp[i][(not % 3) + 1][(not / 3) + 1] = -1;
| ^
|
s439930391 | p00606 | C++ | #include <iostream>
#include <vector>
#include <fstream>
using namespace std;
int n;
char s,t,b;
double calc(){
char floar[3][3];
floar[0][0] = 'A';
floar[0][1] = 'B';
floar[0][2] = 'C';
floar[1][0] = 'D';
floar[1][1] = 'E';
floar[1][2] = 'F';
floar[2][0] = 'G';
floar[2][1] = 'H';
floar[2][2] = 'I';
pair<int,int> startPlace;
pair<int,int> finPlace;
pair<int,int> wareHouse;
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
if(floar[i][j] == s){
startPlace.first = i;
startPlace.second = j;
}
else if(floar[i][j] == t){
finPlace.first = i;
finPlace.second = j;
}
else if(floar[i][j] == b){
wareHouse.first = i;
wareHouse.second = j;
}
}
}
vector<pair<int,int>> placeList;
vector<pair<int,int>> nextPlaceList;
placeList.push_back(startPlace);
int leaveBattery = n;
pair<int,int> newPlace;
int trueCount = 0;
int falseCount = 0;
while(placeList.size()){
// àµobe[ª0ÆÈÁ½ç
if(leaveBattery == 0){
// »ÝÊuªobeÌę̂ð¦é
for(int i = 0; i < placeList.size(); i++){
if(placeList[i].first == finPlace.first && placeList[i].second == finPlace.second){
trueCount++;
}
}
break;
}else if(leaveBattery == 1){
falseCount = placeList.size() * 4;
}
for(int i = 0; i < placeList.size(); i++){
// ãAºA¶AEÉÍÝoµÄ¢È¢êA©ÂqÉÅÈ¢ê»ÌûüÉÚ®
if(placeList[i].first - 1 >= 0){
if(wareHouse.first != placeList[i].first - 1 || wareHouse.second != placeList[i].second){
newPlace.first = placeList[i].first - 1;
newPlace.second = placeList[i].second;
nextPlaceList.push_back(newPlace);
}
else{
nextPlaceList.push_back(placeList[i]);
}
}
if(placeList[i].first + 1 < 3){
if(wareHouse.first != placeList[i].first + 1 || wareHouse.second != placeList[i].second){
newPlace.first = placeList[i].first + 1;
newPlace.second = placeList[i].second;
nextPlaceList.push_back(newPlace);
}
else{
nextPlaceList.push_back(placeList[i]);
}
}
if(placeList[i].second - 1 >= 0){
if(wareHouse.first != placeList[i].first || wareHouse.second != placeList[i].second - 1){
newPlace.first = placeList[i].first;
newPlace.second = placeList[i].second - 1;
nextPlaceList.push_back(newPlace);
}
else{
nextPlaceList.push_back(placeList[i]);
}
}
if(placeList[i].second + 1 < 3){
if(wareHouse.first != placeList[i].first || wareHouse.second != placeList[i].second + 1){
newPlace.first = placeList[i].first;
newPlace.second = placeList[i].second + 1;
nextPlaceList.push_back(newPlace);
}
else{
nextPlaceList.push_back(placeList[i]);
}
}
}
leaveBattery--;
placeList = nextPlaceList;
nextPlaceList.clear();
}
return (double)trueCount/falseCount;
}
void solve(){
//ifstream ifs("prob1020.txt");
while(1){
//ifs >> n;
cin >> n;
if(n == 0)
break;
cin >> s;
cin >> t;
cin >> b;
//ifs >> s;
//ifs >> t;
//ifs >> b;
cout << calc() << endl;
}
}
int main(){
solve():
return 0;
} | a.cc: In function 'int main()':
a.cc:135:8: error: expected ';' before ':' token
135 | solve():
| ^
| ;
|
s526867294 | p00606 | C++ | #include<iostream>
#include<cstdio>
using namespace std;
char s,t,b;
char fld[3][3]={"ABC","DEF","GHI"};
int ans,sum,dx[]={1,0,-1,0},dy[]={0,1,0,-1};
void rep(int now,int y,int x){
int X,Y;
if(now==0){
sum++;
if(fld[y][x]==t){
ans++;
}
return ;
}
for(int i=0;i<4;i++){
X=x+dx[i];
Y=y+dy[i];
if(X>=0&&X<3&&Y>=0&&Y<3&&fld[Y][X]!=b){
rep(now-1,Y,X);
}
else{
rep(now-1,y,x);
}
}
}
int main(){
int n;
while(cin>>n,n){
cin>>s>>t>>b;
sum=0;
ans=0;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++){
if(fld[i][j]==s)
rep(n,i,j);
}
cout<<ans<<' '<<sum<<endl;
printf("%.8lf\n",(double)ans/sum);
}
return 0;
} | a.cc:5:17: error: initializer-string for 'char [3]' is too long [-fpermissive]
5 | char fld[3][3]={"ABC","DEF","GHI"};
| ^~~~~
a.cc:5:23: error: initializer-string for 'char [3]' is too long [-fpermissive]
5 | char fld[3][3]={"ABC","DEF","GHI"};
| ^~~~~
a.cc:5:29: error: initializer-string for 'char [3]' is too long [-fpermissive]
5 | char fld[3][3]={"ABC","DEF","GHI"};
| ^~~~~
|
s370549348 | p00606 | C++ | int dy[4]={0,0,1,-1};
int bx,by;
int tx,ty;
long double rec(int rest,int x,int y){
//cout<<"x:"<<x<<"y:"<<y<<endl;
if(x<0||x>2||y<0||y>2)return 0;
if(dp[rest][x][y]>0)return dp[rest][x][y];
if(rest==0){
if(x==tx&&y==ty)return 1;
else return 0;
}
long double sum=0;
for(int i=0;i<4;i++){
if(((x+dx[i]==bx)&&(y+dy[i]==by))||x+dx[i]<0||x+dx[i]>2||y+dy[i]>2||y+dy[i]<0){
sum+=rec(rest-1,x,y);
}else{
sum+=rec(rest-1,x+dx[i],y+dy[i]);
}
}
sum=sum/4.0;
dp[rest][x][y]=sum;
return sum;
}
void topoint(char a,int &x,int &y){
int tmp=a-'A';
x=tmp/3;
y=tmp%3;
return;
}
int main(){
int N;
cout.precision(8);
cout.setf(ios::fixed);
while(cin>>N,N){
char s,t,b;
cin>>s>>t>>b;
int sx,sy;
topoint(s,sx,sy);
topoint(t,tx,ty);
topoint(b,bx,by);
//cout<<sx<<":"<<sy<<" "<<tx<<":"<<ty<<endl;
cout<<rec(N,sx,sy)<<endl;
for(int i=0;i<15;i++){
for(int j=0;j<3;j++){
for(int k=0;k<3;k++){
dp[i][j][k]=0;
}
}
}
}
return 0;
} | a.cc: In function 'long double rec(int, int, int)':
a.cc:8:9: error: 'dp' was not declared in this scope; did you mean 'dy'?
8 | if(dp[rest][x][y]>0)return dp[rest][x][y];
| ^~
| dy
a.cc:16:18: error: 'dx' was not declared in this scope; did you mean 'x'?
16 | if(((x+dx[i]==bx)&&(y+dy[i]==by))||x+dx[i]<0||x+dx[i]>2||y+dy[i]>2||y+dy[i]<0){
| ^~
| x
a.cc:23:6: error: 'dp' was not declared in this scope; did you mean 'dy'?
23 | dp[rest][x][y]=sum;
| ^~
| dy
a.cc: In function 'int main()':
a.cc:34:6: error: 'cout' was not declared in this scope
34 | cout.precision(8);
| ^~~~
a.cc:35:16: error: 'ios' has not been declared
35 | cout.setf(ios::fixed);
| ^~~
a.cc:36:12: error: 'cin' was not declared in this scope
36 | while(cin>>N,N){
| ^~~
a.cc:44:31: error: 'endl' was not declared in this scope
44 | cout<<rec(N,sx,sy)<<endl;
| ^~~~
a.cc:48:26: error: 'dp' was not declared in this scope; did you mean 'dy'?
48 | dp[i][j][k]=0;
| ^~
| dy
|
s279873153 | p00606 | C++ | #include <iostream>
using namespace std;
int n;
char room[10] = "ABCDEFGHI";
char s, t, b;
int off[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
int x, y;
double table[3][3];
double solve()
{
memset(&table[0][0], 0, sizeof(double) * 9);
table[x][y] = 1.0;
for(int k=0; k<n; k++)
{
double temp[3][3];
memset(&temp[0][0], 0, sizeof(double) * 9);
for(int j=0; j<3; j++)
{
for(int i=0; i<3; i++)
{
if(table[j][i] != 0.0)
{
for(int m=0; m<4; m++)
{
int xx = i + off[m][0];
int yy = j + off[m][1];
int index = xx + yy * 3;
xx = (xx>=0 && xx<3 && room[index] != b) ? xx : i;
yy = (yy>=0 && yy<3 && room[index] != b) ? yy : j;
temp[yy][xx] += table[j][i] / 4.0;
}
}
}
}
memcpy(&table[0][0], &temp[0][0], sizeof(double) * 9);
}
for(int i=0; i<9; i++)
{
if(room[i]==t) return table[i/3][i%3];
}
return 0.0;
}
int main()
{
while( 1 )
{
cin >> n;
if(n==0) break;
cin >> s >> t >> b;
for(int i=0; i<9; i++)
{
if(room[i] == s)
{
x = i%3;
y = i/3;
}
}
printf("%.8f\n", solve());
}
return 0;
} | a.cc: In function 'double solve()':
a.cc:15:9: error: 'memset' was not declared in this scope
15 | memset(&table[0][0], 0, sizeof(double) * 9);
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 |
a.cc:40:17: error: 'memcpy' was not declared in this scope
40 | memcpy(&table[0][0], &temp[0][0], sizeof(double) * 9);
| ^~~~~~
a.cc:40:17: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s254202848 | p00606 | C++ | #include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdio>
#include <iomanip>
using namespace std;
const double EPS = 1e-8;
int n;
pair<int, int> s, t, b;
double dp[16][3][3];
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};
bool equals(double a, double b){
return abs(a-b) < EPS;
}
void setp(pair<int, int>& p, char c){
int tmp = c - 'A';
p = make_pair(tmp/3, tmp-(tmp/3)*3);
}
main(){
while(cin >> n && n){
char in1, in2, in3;
cin >> in1 >> in2 >> in3;
setp(s, in1);
setp(t, in2);
setp(b, in3);
fill(dp[0][0], dp[16][0], 0.0);
dp[0][s.first][s.second] = 1.0;
for(int i=0;i<n;i++){
for(int j=0;j<3;j++){
for(int k=0;k<3;k++){
if(equals(dp[i][j][k], 0.0)) continue;
/*if(j == t.first && k == t.second){
dp[i+1][j][k] += dp[i][j][k];
continue;
}*/
for(int l=0;l<4;l++){
int ty = j + dy[l];
int tx = k + dx[l];
if(ty>=0 && ty<3){
if(tx>=0 && tx<3){
if(ty != b.first || tx != b.second){
dp[i+1][ty][tx] += dp[i][j][k] / 4.0;
continue;
}
}
}
dp[i+1][j][k] += dp[i][j][k] / 4.0;
}
}
}
/*for(int j=0;j<3;j++){
for(int k=0;k<3;k++){
cout << setw(6) << dp[i][j][k] << ' ';
}
cout << endl;
}
cout << endl;*/
}
/*for(int j=0;j<3;j++){
for(int k=0;k<3;k++){
cout << setw(6) << dp[n][j][k] << ' ';
}
cout << endl;
}*/
printf("%.8f\n", dp[n][t.first][t.second]);
} | a.cc:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
27 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:74:4: error: expected '}' at end of input
74 | }
| ^
a.cc:27:7: note: to match this '{'
27 | main(){
| ^
|
s508976105 | p00606 | C++ | #include<iostream>
#include<map>
#include<string.h>
using namespace std;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Cor{
int x,y;
Cor(int a,int b){
x=a,y=b;
}
};
int main()
{
map<char,pair<int,int>> M;
M['A']=make_pair(0,0);
M['B']=make_pair(1,0);
M['C']=make_pair(2,0);
M['D']=make_pair(0,1);
M['E']=make_pair(1,1);
M['F']=make_pair(2,1);
M['G']=make_pair(0,2);
M['H']=make_pair(1,2);
M['I']=make_pair(2,2);
int n;
while(cin>>n &&n!=0){
char s,t,b;
cin>>s>>t>>b;
pair<int,int> now=M[s];
pair<int,int> goal=M[t];
pair<int,int> not=M[b];
double ans[17][3][3];
for(int i=0;i<16;i++)
for(int x=0;x<3;x++)
for(int y=0;y<3;y++)
ans[i][y][x]=0.0;
cout<<now.first<<" "<<now.second<<endl;
ans[0][now.second][now.first]=1.0;
for(int i=0;i<n;i++){
for(int x=0;x<3;x++){
for(int y=0;y<3;y++){
for(int r=0;r<4;r++){
int nx=x+dx[r],ny=y+dy[r];
if(nx<0 || nx>=3 || ny<0 || ny>=3 || make_pair(nx,ny)==not){
ans[i+1][y][x]+=ans[i][y][x]/4.0;
}
else{
ans[i+1][ny][nx]+=ans[i][y][x]/4.0;
}
}
}
}
}
cout<<ans[n][goal.second][goal.first]<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:35:31: error: expected unqualified-id before 'not' token
35 | pair<int,int> not=M[b];
| ^~~
a.cc:52:107: error: expected primary-expression before ')' token
52 | if(nx<0 || nx>=3 || ny<0 || ny>=3 || make_pair(nx,ny)==not){
| ^
|
s781259019 | p00606 | C++ | #include<iostream>
#include<map>
#include<string.h>
using namespace std;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main()
{
map<char,pair<int,int> > M;
M['A']=make_pair(0,0);
M['B']=make_pair(1,0);
M['C']=make_pair(2,0);
M['D']=make_pair(0,1);
M['E']=make_pair(1,1);
M['F']=make_pair(2,1);
M['G']=make_pair(0,2);
M['H']=make_pair(1,2);
M['I']=make_pair(2,2);
int n;
while(cin>>n &&n!=0){
char s,t,b;
cin>>s>>t>>b;
pair<int,int> now=M[s];
pair<int,int> goal=M[t];
pair<int,int> not=M[b];
double ans[17][3][3];
for(int i=0;i<16;i++)
for(int x=0;x<3;x++)
for(int y=0;y<3;y++)
ans[i][y][x]=0.0;
cout<<now.first<<" "<<now.second<<endl;
ans[0][now.second][now.first]=1.0;
for(int i=0;i<n;i++){
for(int x=0;x<3;x++){
for(int y=0;y<3;y++){
for(int r=0;r<4;r++){
int nx=x+dx[r],ny=y+dy[r];
if(nx<0 || nx>=3 || ny<0 || ny>=3 || make_pair(nx,ny)==not){
ans[i+1][y][x]+=ans[i][y][x]/4.0;
}
else{
ans[i+1][ny][nx]+=ans[i][y][x]/4.0;
}
}
}
}
}
cout<<ans[n][goal.second][goal.first]<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:28:31: error: expected unqualified-id before 'not' token
28 | pair<int,int> not=M[b];
| ^~~
a.cc:45:107: error: expected primary-expression before ')' token
45 | if(nx<0 || nx>=3 || ny<0 || ny>=3 || make_pair(nx,ny)==not){
| ^
|
s172355264 | p00606 | C++ |
#Include <iostream>
#include <queue>
using namespace std;
static const int MV = 100;
typedef pair<int, int> T;
int main() {
while(1) {
int w, h, Gcount=0, sum=0;
cin >> w >> h;
if (w ==0 && h == 0) break;
char M[h][w];
int A[h][w];
queue<T> Q;
for (int i=0;i<h;i++) {
for (int j=0;j<w;j++) {
cin >> M[i][j];
A[i][j]=MV;
if (M[i][j] == '*')
Gcount++;
if (M[i][j] == 'o'){
Q.push(make_pair(i, j));
A[i][j]=0;
}
}
}
/*
for (int i=0;i<h;i++) {
for (int j=0;j<w;j++) {
cout << A[i][j];
}cout << endl;
}
*/
while(Gcount != 0 || Q.empty()) {
if(Q.empty()) break;//cout << -1<< endl;
int Dy[4]={1, 0, -1, 0}, Dx[4]={0, 1, 0, -1}, ny, nx;
M[Q.front().first][Q.front().second]='+';
for (int i=0;i<4;i++) {
ny = Q.front().first + Dy[i]; nx = Q.front().second + Dx[i];
// cout << endl << ny << " " << nx << endl;
if (M[ny][nx] == '.' && 0<=nx && nx<w && 0<=ny && ny<h) {
Q.push(make_pair(ny, nx));
// cout << endl << " " << ny << " " << nx << endl;
M[ny][nx]='+';
A[ny][nx]=A[Q.front().first][Q.front().second] + 1;
}
if (M[ny][nx] == '*' && 0<=nx && nx<w && 0<=ny && ny<h) {
Gcount--;
M[ny][nx]='+';
sum+=A[Q.front().first][Q.front().second] + 1;
// cout << endl << sum << endl;
for (int j=0;j<h;j++) {
for (int k=0;k<w;k++) {
A[j][k]=MV;
if (M[j][k] == '+') {
M[j][k] = '.';
}
}
}
int q=Q.size();
for (int j=1;j<q;j++) {
//while(!Q.empty()) {
Q.pop();
}
Q.push(make_pair(ny, nx));
A[ny][nx] = 0;
i=4;
}
}
/*
for (int i=0;i<h;i++) {
for (int j=0;j<w;j++) {
cout << A[i][j] << " ";
}cout << endl;
}
cout << endl;
*/
Q.pop();
}
if(sum == 0) cout << -1 << endl;
else cout << sum << endl;
}
}
/*
while(!Q.empty() || a) {
for(int i=0; i<4; i++) {
int nx = Q.front().first + dx[i], ny = Q.front().second + dy[i];
if(A[nx][ny]!='x' && 0<=nx && nx<w && 0<=ny && ny<h) {
Q.push(make_pair(nx, ny));
A[nx][ny]='+';
A[nx][ny]=AA[Q.front().first][Q.front().second]+1;
for (int aa=0;aa<h;aa++){
for (int bb=0;bb<w;bb++){
cout << AA[aa][bb];
}cout << endl;
}
}
if(A[nx][ny]=='*') {
a=false;
}
}
Q.pop();
}
*/ | a.cc:2:2: error: invalid preprocessing directive #Include; did you mean #include?
2 | #Include <iostream>
| ^~~~~~~
| include
a.cc: In function 'int main()':
a.cc:12:5: error: 'cin' was not declared in this scope
12 | cin >> w >> h;
| ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
3 | #include <queue>
+++ |+#include <iostream>
4 |
a.cc:84:18: error: 'cout' was not declared in this scope
84 | if(sum == 0) cout << -1 << endl;
| ^~~~
a.cc:84:18: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:84:32: error: 'endl' was not declared in this scope
84 | if(sum == 0) cout << -1 << endl;
| ^~~~
a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
3 | #include <queue>
+++ |+#include <ostream>
4 |
a.cc:85:10: error: 'cout' was not declared in this scope
85 | else cout << sum << endl;
| ^~~~
a.cc:85:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:85:25: error: 'endl' was not declared in this scope
85 | else cout << sum << endl;
| ^~~~
a.cc:85:25: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
|
s436320429 | p00606 | C++ | #include<stdlib.h>
#include<iostream>
using namespace std;
int s,t,b,n;
double p,nn;
int d[4]={1,3,-1,-3};
double df[10][20];
void dfs(int s,int n){
double p1;
if(n==0){
if(s==t){p+=pow(0.25,nn);}
return;
}
if(df[s][n]>=0){
p+=df[s][n];
return;
}else{
for(int i=0;i<4;i++){
if(s+d[i]==b){
p1=p;
dfs(s,n-1);
df[s][n-1]=p-p1;
}else if(s/3!=(s+d[i])/3){
if(d[i]*d[i]==9&&0<=s+d[i]&&s+d[i]<9){
p1=p;
dfs(s+d[i],n-1);
df[s+d[1]][n-1]=p-p1;
}else{
p1=p;
dfs(s,n-1);
df[s][n-1]=p-p1;
}
}else{
p1=p;
dfs(s+d[i],n-1);
df[s+d[i]][n-1]=p-p1;
}
}
}
return;
}
int main(){
while(1){
char cs,ct,cb;
p=0;
cin>>n;
nn=n;
if(n==0)break;
for(int i=0;i<10;i++){
for(int j=0;j<20;j++){
df[i][j]=-1;
}
}
cin>>cs>>ct>>cb;
s=(int)cs-'A';
t=(int)ct-'A';
b=(int)cb-'A';
dfs(s,n);
cout<<p<<endl;
}
return 0;
} | a.cc: In function 'void dfs(int, int)':
a.cc:11:29: error: 'pow' was not declared in this scope
11 | if(s==t){p+=pow(0.25,nn);}
| ^~~
|
s260369002 | p00606 | C++ | #include<iostream>
#include<algorithm>
#include<vectoer>
#include<string>
#include<map>
#include<cstdio>
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int main(void){
int n,id=0;
string s="ABCDEFGHI";
char s,t,d;
map<char,P>mp;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
mp[s[id++]]=P(i,j);
}
}
while(cin >> n,n){
cin >> s >> t >> d;
P S=mp[s],T=mp[t],D=mp[d];
int dp[16][3][3];
for(int k=0;k<16;k++)
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)dp[k][i][j]=0;
dp[0][S.s][S.f]=1;
for(int k=0;k<n;k++){
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
for(int l=0;l<4;l++){
int nx=j+dx[l],ny=i+dy[l];
if(nx<0 || ny<0 || 2<nx || 2<ny ||
(nx==D.s&&ny==D.f))nx=j,ny=i;
dp[k+1][ny][nx]+=dp[k][i][j]/4;
}
}
}
}
printf("%.8f\n",dp[n][T.s][T.f]);
}
return 0;
} | a.cc:3:9: fatal error: vectoer: No such file or directory
3 | #include<vectoer>
| ^~~~~~~~~
compilation terminated.
|
s342342166 | p00606 | C++ | #include<iostream>
#include<algorithm>
#include<vectoer>
#include<string>
#include<map>
#include<cstdio>
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int main(void){
int n,id=0;
string s="ABCDEFGHI";
char s,t,d;
map<char,P>mp;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
mp[s[id++]]=P(j,i);
}
}
while(cin >> n,n){
cin >> s >> t >> d;
P S=mp[s],T=mp[t],D=mp[d];
double dp[16][3][3];
for(int k=0;k<16;k++)
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)dp[k][i][j]=0;
dp[0][S.s][S.f]=1;
for(int k=0;k<n;k++){
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
for(int l=0;l<4;l++){
int nx=j+dx[l],ny=i+dy[l];
if(nx<0 || ny<0 || 2<nx || 2<ny ||
(nx==D.s&&ny==D.f))nx=j,ny=i;
dp[k+1][ny][nx]+=dp[k][i][j]/4;
}
}
}
}
printf("%.8f\n",dp[n][T.s][T.f]);
}
return 0;
} | a.cc:3:9: fatal error: vectoer: No such file or directory
3 | #include<vectoer>
| ^~~~~~~~~
compilation terminated.
|
s389992273 | p00606 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cstdio>
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int main(void){
int n,id=0;
string s="ABCDEFGHI";
char s,t,d;
map<char,P>mp;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
mp[s[id++]]=P(j,i);
}
}
while(cin >> n,n){
cin >> s >> t >> d;
P S=mp[s],T=mp[t],D=mp[d];
double dp[16][3][3];
for(int k=0;k<16;k++)
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)dp[k][i][j]=0;
dp[0][S.s][S.f]=1;
for(int k=0;k<n;k++){
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
for(int l=0;l<4;l++){
int nx=j+dx[l],ny=i+dy[l];
if(nx<0 || ny<0 || 2<nx || 2<ny ||
(nx==D.s&&ny==D.f))nx=j,ny=i;
dp[k+1][ny][nx]+=dp[k][i][j]/4;
}
}
}
}
printf("%.8f\n",dp[n][T.s][T.f]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:9:11: error: conflicting declaration 'char second'
9 | #define s second
| ^~~~~~
a.cc:22:6: note: in expansion of macro 's'
22 | char s,t,d;
| ^
a.cc:9:11: note: previous declaration as 'std::string second'
9 | #define s second
| ^~~~~~
a.cc:21:8: note: in expansion of macro 's'
21 | string s="ABCDEFGHI";
| ^
a.cc:33:7: error: no match for 'operator[]' (operand types are 'std::map<char, std::pair<int, int> >' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
33 | P S=mp[s],T=mp[t],D=mp[d];
| ^
In file included from /usr/include/c++/14/map:63,
from a.cc:5:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
504 | operator[](const key_type& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::map<char, std::pair<int, int> >::key_type&' {aka 'const char&'}
504 | operator[](const key_type& __k)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
524 | operator[](key_type&& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::map<char, std::pair<int, int> >::key_type&&' {aka 'char&&'}
524 | operator[](key_type&& __k)
| ~~~~~~~~~~~^~~
a.cc:49:6: error: 'D' was not declared in this scope
49 | (nx==D.s&&ny==D.f))nx=j,ny=i;
| ^
a.cc:55:23: error: 'T' was not declared in this scope
55 | printf("%.8f\n",dp[n][T.s][T.f]);
| ^
|
s190604626 | p00606 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cstdio>
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int main(void){
int n,id=0;
string s="ABCDEFGHI";
char s,t,d;
map<char,P>mp;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
mp[s[id++]]=P(j,i);
}
}
while(cin >> n,n){
cin >> s >> t >> d;
P S,T,D;
S.f=mp[s].f,S.s=mp[s].s;
T.f=mp[t].f,T.s=mp[t].s;
D.f=mp[d].f,D.s=mp[d].s;
double dp[16][3][3];
for(int k=0;k<16;k++)
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)dp[k][i][j]=0;
dp[0][S.s][S.f]=1;
for(int k=0;k<n;k++){
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
for(int l=0;l<4;l++){
int nx=j+dx[l],ny=i+dy[l];
if(nx<0 || ny<0 || 2<nx || 2<ny ||
(nx==D.s&&ny==D.f))nx=j,ny=i;
dp[k+1][ny][nx]+=dp[k][i][j]/4;
}
}
}
}
printf("%.8f\n",dp[n][T.s][T.f]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:9:11: error: conflicting declaration 'char second'
9 | #define s second
| ^~~~~~
a.cc:22:6: note: in expansion of macro 's'
22 | char s,t,d;
| ^
a.cc:9:11: note: previous declaration as 'std::string second'
9 | #define s second
| ^~~~~~
a.cc:21:8: note: in expansion of macro 's'
21 | string s="ABCDEFGHI";
| ^
a.cc:35:7: error: no match for 'operator[]' (operand types are 'std::map<char, std::pair<int, int> >' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
35 | S.f=mp[s].f,S.s=mp[s].s;
| ^
In file included from /usr/include/c++/14/map:63,
from a.cc:5:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
504 | operator[](const key_type& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::map<char, std::pair<int, int> >::key_type&' {aka 'const char&'}
504 | operator[](const key_type& __k)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
524 | operator[](key_type&& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::map<char, std::pair<int, int> >::key_type&&' {aka 'char&&'}
524 | operator[](key_type&& __k)
| ~~~~~~~~~~~^~~
a.cc:35:19: error: no match for 'operator[]' (operand types are 'std::map<char, std::pair<int, int> >' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
35 | S.f=mp[s].f,S.s=mp[s].s;
| ^
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
504 | operator[](const key_type& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::map<char, std::pair<int, int> >::key_type&' {aka 'const char&'}
504 | operator[](const key_type& __k)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
524 | operator[](key_type&& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::map<char, std::pair<int, int> >::key_type&&' {aka 'char&&'}
524 | operator[](key_type&& __k)
| ~~~~~~~~~~~^~~
|
s164716008 | p00606 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cstdio>
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int main(void){
int n,id=0;
string s="ABCDEFGHI";
char s,t,d;
map<char,P>mp;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
mp[s[id++]]=P(j,i);
}
}
while(cin >> n,n){
cin >> s >> t >> d;
P S,T,D;
S.f=mp[s].f,S.s=mp[s].s;
T.f=mp[t].f,T.s=mp[t].s;
D.f=mp[d].f,D.s=mp[d].s;
double dp[16][3][3];
for(int k=0;k<16;k++)
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)dp[k][i][j]=0;
dp[0][S.s][S.f]=1;
for(int k=0;k<n;k++){
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
for(int l=0;l<4;l++){
int nx=j+dx[l],ny=i+dy[l];
if(nx<0 || ny<0 || 2<nx || 2<ny ||
(nx==D.s&&ny==D.f))nx=j,ny=i;
dp[k+1][ny][nx]+=dp[k][i][j]/4;
}
}
}
}
printf("%.8f",dp[n][T.s][T.f]);
cout << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:9:11: error: conflicting declaration 'char second'
9 | #define s second
| ^~~~~~
a.cc:22:6: note: in expansion of macro 's'
22 | char s,t,d;
| ^
a.cc:9:11: note: previous declaration as 'std::string second'
9 | #define s second
| ^~~~~~
a.cc:21:8: note: in expansion of macro 's'
21 | string s="ABCDEFGHI";
| ^
a.cc:35:7: error: no match for 'operator[]' (operand types are 'std::map<char, std::pair<int, int> >' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
35 | S.f=mp[s].f,S.s=mp[s].s;
| ^
In file included from /usr/include/c++/14/map:63,
from a.cc:5:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
504 | operator[](const key_type& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::map<char, std::pair<int, int> >::key_type&' {aka 'const char&'}
504 | operator[](const key_type& __k)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
524 | operator[](key_type&& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::map<char, std::pair<int, int> >::key_type&&' {aka 'char&&'}
524 | operator[](key_type&& __k)
| ~~~~~~~~~~~^~~
a.cc:35:19: error: no match for 'operator[]' (operand types are 'std::map<char, std::pair<int, int> >' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
35 | S.f=mp[s].f,S.s=mp[s].s;
| ^
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
504 | operator[](const key_type& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::map<char, std::pair<int, int> >::key_type&' {aka 'const char&'}
504 | operator[](const key_type& __k)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = char; _Tp = std::pair<int, int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::pair<int, int> > >; mapped_type = std::pair<int, int>; key_type = char]'
524 | operator[](key_type&& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::map<char, std::pair<int, int> >::key_type&&' {aka 'char&&'}
524 | operator[](key_type&& __k)
| ~~~~~~~~~~~^~~
|
s956725700 | p00606 | C++ | #define rep(i,n) for(int i=0;i<n;i++)
#define ck(a) (0<=(a)&&(a)<9)
int di[]={-3,-1,1,3};
int main(){
int n,s,t,b; char cs,ct,cb;
while(scanf("%d",&n),n){
scanf(" %c %c %c",&cs,&ct,&cb); s=cs-'A', t=ct-'A', b=cb-'A';
double p[9]={0}; p[s]=1;
while(n--){
double q[9]={0};
rep(i,9)rep(d,4){
if(ck(i+di[d])&&!(i%3==0&&di[d]==-1)&&!(i%3==2&&di[d]==1)&&i+di[d]!=b)q[i+di[d]]+=p[i]/4;
else q[i]+=p[i]/4;
}
rep(i,9)p[i]=q[i];
}
printf("%.8f\n",p[t]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:6:11: error: 'scanf' was not declared in this scope
6 | while(scanf("%d",&n),n){
| ^~~~~
a.cc:19:9: error: 'printf' was not declared in this scope
19 | printf("%.8f\n",p[t]);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | #define rep(i,n) for(int i=0;i<n;i++)
|
s514345048 | p00607 | Java | import java.util.Scanner;
public class EditText {
static final int MAXINPUTLINE = 10;
static final int MAXINPUTCOMMAND = 300;
static final int MAXMODIFIEDTEXTLINE = 100;
static final int MAXMODIFIERTEXTCHAR = 1000;
static String[] modifyingText = new String[MAXMODIFIEDTEXTLINE];
static String buffer;
static int cursorLocLine = 0;
static int cursorLocRow = 0;
public static void main(String args[]) {
String inputText[];
String inputCommand[];
inputText = giveTextLine();
inputCommand = giveCommand();
modifyText(inputText, inputCommand);
for(int i = 0; i < modifyingText.length; i++){
System.out.println(modifyingText[i]);
}
}
private static String[] giveTextLine() {
String input;
String[] inputText = new String[MAXINPUTLINE];
Scanner scan = new Scanner(System.in);
for (int i = 0; i < MAXINPUTLINE; i++) {
input = scan.next();
if (input.equals("END_OF_TEXT")) break;
inputText[i] = input;
}
return inputText;
}
private static String[] giveCommand() {
String input;
String[] inputCommand = new String[MAXINPUTCOMMAND];
Scanner scan = new Scanner(System.in);
for (int i = 0; i < MAXINPUTCOMMAND; i++) {
input = scan.next();
if (input.equals("-")) break;
inputCommand[i] = input;
}
return inputCommand;
}
private static void modifyText(final String inputText[], final String inputCommand[]) {
for (int i = 0; i < inputText.length; i++) {
modifyingText[i] = inputText[i];
}
for (int i = 0; i < inputCommand.length; i++) {
if (inputCommand[i].equals("a")) editA();
else if (inputCommand[i].equals("e")) editE();
else if (inputCommand[i].equals("p")) editP();
else if (inputCommand[i].equals("n")) editN();
else if (inputCommand[i].equals("f")) editF();
else if (inputCommand[i].equals("b")) editB();
else if (inputCommand[i].equals("d")) editD();
else if (inputCommand[i].equals("k")) editK();
else if (inputCommand[i].equals("y")) editY();
}
}
private static String remove(String str, int removeIndex) {
return str.substring(0, removeIndex) + str.substring(removeIndex + 1);
}
private static String insert(String str, int insertIndex) {
return str.substring(0, insertIndex) + buffer + str.substring(insertIndex);
}
private static void editA() {
cursorLocRow = 0;
}
private static void editE() {
cursorLocRow = modifyingText[cursorLocLine].length();
}
private static void editP() {
cursorLocRow = 0;
if (cursorLocLine > 0) cursorLocLine--;
}
private static void editN() {
cursorLocRow = 0;
if (modifyingText[cursorLocLine + 1] != null) cursorLocLine++;
}
private static void editF() {
if (modifyingText[cursorLocLine].length() == cursorLocRow + 1) {
cursorLocLine++;
cursorLocRow = 0;
} else {
cursorLocRow++;
}
}
private static void editB() {
if (cursorLocRow > 0) cursorLocRow--;
else {
cursorLocRow = modifyingText[cursorLocLine - 1].length() - 1;
cursorLocLine--;
}
}
private static void editD() {
if (cursorLocRow != modifyingText[cursorLocLine].length() - 1) {
modifyingText[cursorLocLine] = remove(modifyingText[cursorLocLine], cursorLocRow);
} else if (modifyingText[cursorLocLine + 1] != null) {
for (int i = cursorLocLine; i < modifyingText.length; i++) {
if (modifyingText[i + 1] == null) break;
modifyingText[i] += modifyingText[i + 1];
}
}
}
private static void editK() {
if (cursorLocRow == modifyingText[cursorLocLine].length() - 1 && modifyingText[cursorLocLine + 1] != null) {
for (int i = cursorLocLine; i < modifyingText.length; i++) {
if (modifyingText[i + 1] == null) break;
modifyingText[i] += modifyingText[i + 1];
}
buffer = "\n";
} else {
buffer = modifyingText[cursorLocLine].substring(cursorLocRow);
modifyingText[cursorLocLine] = modifyingText[cursorLocLine].substring(0, cursorLocRow - 1);
}
}
/**
* yank
*/
private static void editY() {
if(buffer.equals("\n")) {
String movingText = modifyingText[cursorLocLine].substring(cursorLocRow);
modifyingText[cursorLocLine] = modifyingText[cursorLocLine].substring(0, cursorLocRow-1);
for( int i = modifyingText.length; i != cursorLocLine; i-- ){
if(modifyingText[cursorLocLine] != null)
modifyingText[cursorLocLine+1] = modifyingText[cursorLocLine];
}
cursorLocLine++;
cursorLocRow = 0;
}else if (buffer != null){
modifyingText[cursorLocLine] = insert(modifyingText[cursorLocLine], cursorLocRow);
}
}
}
| Main.java:3: error: class EditText is public, should be declared in a file named EditText.java
public class EditText {
^
1 error
|
s568951289 | p00607 | Java | import java.util.ArrayList;
import java.util.Scanner;
public class EditText {
static final int MAXINPUTLINE = 10;
static final int MAXINPUTCOMMAND = 300;
static final int MAXMODIFIEDTEXTLINE = 100;
static final int MAXMODIFIERTEXTCHAR = 1000;
static Scanner scan = new Scanner(System.in);
static ArrayList<String> modifyingText = new ArrayList<String>();
static String buffer;
static int cursorLocLine = 0;
static int cursorLocRow = 0;
public static void main(String args[]) {
ArrayList<String> inputText;
ArrayList<String> inputCommand;
inputText = giveTextLine();
System.out.println("==============================");
System.out.println("give Text Success");
inputCommand = giveCommand();
System.out.println("==============================");
System.out.println("give Command Success");
modifyText(inputText, inputCommand);
for (int i = 0; i < modifyingText.size(); i++) {
int outLen = modifyingText.get(i).length();
System.out.println(modifyingText.get(i).substring(0,outLen-1));
}
}
private static ArrayList<String> giveTextLine() {
String input;
ArrayList<String> inputText = new ArrayList<>();
// Scanner scan = new Scanner(System.in);
for (int i = 0; i < MAXINPUTLINE; i++) {
input = scan.nextLine();
if (input.equals("END_OF_TEXT")) break;
inputText.add(i, input);
}
return inputText;
}
private static ArrayList<String> giveCommand() {
String input;
ArrayList<String> inputCommand = new ArrayList<>();
// Scanner scan = new Scanner(System.in);
for (int i = 0; i < MAXINPUTCOMMAND; i++) {
input = scan.nextLine();
if (input.equals("-")) break;
inputCommand.add(i, input);
}
return inputCommand;
}
private static void modifyText(final ArrayList<String> inputText, final ArrayList<String> inputCommand) {
for (int i = 0; i < inputText.size(); i++) {
modifyingText.add(i, inputText.get(i) + "$");
}
for (int i = 0; i < inputCommand.size(); i++) {
System.out.println("===============================");
System.out.println(inputCommand.get(i) + " " + cursorLocRow + " " + cursorLocLine + " " + modifyingText.get(cursorLocLine).length() + " " + buffer);
System.out.println("===============================");
modifyingText.forEach(System.out::println);
if (inputCommand.get(i).equals("a")) editA();
else if (inputCommand.get(i).equals("e")) editE();
else if (inputCommand.get(i).equals("p")) editP();
else if (inputCommand.get(i).equals("n")) editN();
else if (inputCommand.get(i).equals("f")) editF();
else if (inputCommand.get(i).equals("b")) editB();
else if (inputCommand.get(i).equals("d")) editD();
else if (inputCommand.get(i).equals("k")) editK();
else if (inputCommand.get(i).equals("y")) editY();
}
}
private static String remove(String str, int removeIndex) {
StringBuilder builder = new StringBuilder(str);
return builder.deleteCharAt(removeIndex).toString();
// return str.substring(0, removeIndex) + str.substring(removeIndex + 1);
}
private static String insert(String str, int insertIndex) {
// return str.substring(0, insertIndex) + buffer + str.substring(insertIndex);
StringBuilder builder = new StringBuilder(str);
if (builder.length() <= insertIndex) {
return builder.append(buffer).toString();
} else {
return builder.insert(insertIndex, buffer).toString();
}
}
private static void editA() {
cursorLocRow = 0;
}
private static void editE() {
cursorLocRow = modifyingText.get(cursorLocLine).length() - 1;
}
private static void editP() {
cursorLocRow = 0;
if (cursorLocLine > 0) cursorLocLine--;
}
private static void editN() {
cursorLocRow = 0;
if (modifyingText.size() <= cursorLocLine + 1) return;
if (modifyingText.get(cursorLocLine + 1) != null) cursorLocLine++;
}
private static void editF() {
if (modifyingText.get(cursorLocLine).length() == cursorLocRow + 1) {
if (modifyingText.size() <= cursorLocLine + 1) return;
cursorLocLine++;
cursorLocRow = 0;
} else {
cursorLocRow++;
}
}
private static void editB() {
if (cursorLocRow > 0) cursorLocRow--;
else if (cursorLocLine > 0) {
cursorLocRow = modifyingText.get(cursorLocLine - 1).length() - 1;
cursorLocLine--;
}
}
private static void editD() {
// if (cursorLocRow != modifyingText.get(cursorLocLine).length() - 1) {
modifyingText.set(cursorLocLine, remove(modifyingText.get(cursorLocLine), cursorLocRow));
// } else if (modifyingText.get(cursorLocLine + 1) != null) {
if (modifyingText.get(cursorLocLine).length() == cursorLocRow) {
for (int i = cursorLocLine; i < modifyingText.size(); i++) {
if(modifyingText.size() >= i + 1) break;
// if (modifyingText.get(i + 1) == null) break;
modifyingText.add(i, modifyingText.get(i) + modifyingText.get(i + 1));
}
}
}
private static void editK() {
if (cursorLocRow == modifyingText.get(cursorLocLine).length() - 1 && modifyingText.size() <= cursorLocLine + 1) {
for (int i = cursorLocLine; i < modifyingText.size(); i++) {
if (modifyingText.size() <= cursorLocLine + 1) break;
modifyingText.add(i, modifyingText.get(i) + modifyingText.get(i + 1));
}
if(cursorLocLine != modifyingText.size() - 1) buffer = "\n";
} else {
if (cursorLocRow < 0) return;
buffer = modifyingText.get(cursorLocLine).substring(cursorLocRow, modifyingText.get(cursorLocLine).length() - 1);
if(cursorLocRow == 0) modifyingText.set(cursorLocLine, "$");
else modifyingText.add(cursorLocLine, modifyingText.get(cursorLocLine).substring(0, cursorLocRow - 1));
}
}
private static void editY() {
if (buffer != null) {
if (buffer.equals("\n")) {
String movingText = modifyingText.get(cursorLocLine).substring(cursorLocRow);
if (cursorLocRow != 0) {
modifyingText.add(cursorLocLine, modifyingText.get(cursorLocLine).substring(0, cursorLocRow - 1));
}
modifyingText.add("");
for (int i = modifyingText.size() - 1; i != cursorLocLine; i--) {
modifyingText.set(i, modifyingText.get(i - 1));
}
modifyingText.add(cursorLocLine + 1, movingText);
cursorLocLine++;
cursorLocRow = 0;
} else {
modifyingText.set(cursorLocLine, insert(modifyingText.get(cursorLocLine), cursorLocRow));
}
}
}
}
| Main.java:4: error: class EditText is public, should be declared in a file named EditText.java
public class EditText {
^
1 error
|
s416618457 | p00607 | Java | import java.util.ArrayList;
import java.util.Scanner;
public class EditText {
static final int MAXINPUTLINE = 10;
static final int MAXINPUTCOMMAND = 300;
static final int MAXMODIFIEDTEXTLINE = 100;
static final int MAXMODIFIERTEXTCHAR = 1000;
static final String ENDOFLINE = "$";
static Scanner scan = new Scanner(System.in);
static ArrayList<String> modifyingText = new ArrayList<String>();
static String buffer;
static int cursorLocLine = 0;
static int cursorLocRow = 0;
public static void main(String args[]) {
ArrayList<String> inputText;
ArrayList<String> inputCommand;
inputText = giveTextLine();
// System.out.println("==============================");
// System.out.println("give Text Success");
inputCommand = giveCommand();
// System.out.println("==============================");
// System.out.println("give Command Success");
modifyText(inputText, inputCommand);
for (int i = 0; i < modifyingText.size(); i++) {
int outLen = modifyingText.get(i).length();
if (outLen <= 1) {
System.out.print("\n");
} else System.out.println(modifyingText.get(i).substring(0, outLen - 1));
}
}
private static ArrayList<String> giveTextLine() {
String input;
ArrayList<String> inputText = new ArrayList<>();
// Scanner scan = new Scanner(System.in);
for (int i = 0; i < MAXINPUTLINE; i++) {
input = scan.nextLine();
if (input.equals("END_OF_TEXT")) break;
inputText.add(i, input);
}
return inputText;
}
private static ArrayList<String> giveCommand() {
String input;
ArrayList<String> inputCommand = new ArrayList<>();
// Scanner scan = new Scanner(System.in);
for (int i = 0; i < MAXINPUTCOMMAND; i++) {
input = scan.nextLine();
if (input.equals("-")) break;
inputCommand.add(i, input);
}
return inputCommand;
}
private static void modifyText(final ArrayList<String> inputText, final ArrayList<String> inputCommand) {
for (int i = 0; i < inputText.size(); i++) {
modifyingText.add(i, inputText.get(i) + ENDOFLINE);
}
for (int i = 0; i < inputCommand.size(); i++) {
// System.out.println("===============================");
// System.out.println(inputCommand.get(i) + " " + cursorLocRow + " " + cursorLocLine + " " + modifyingText.get(cursorLocLine).length() + " " + buffer);
// System.out.println("===============================");
// modifyingText.forEach(System.out::println);
if (inputCommand.get(i).equals("a")) editA();
else if (inputCommand.get(i).equals("e")) editE();
else if (inputCommand.get(i).equals("p")) editP();
else if (inputCommand.get(i).equals("n")) editN();
else if (inputCommand.get(i).equals("f")) editF();
else if (inputCommand.get(i).equals("b")) editB();
else if (inputCommand.get(i).equals("d")) editD();
else if (inputCommand.get(i).equals("k")) editK();
else if (inputCommand.get(i).equals("y")) editY();
}
}
private static String remove(String str, int removeIndex) {
StringBuilder builder = new StringBuilder(str);
return builder.deleteCharAt(removeIndex).toString();
}
private static String insert(String str, int insertIndex) {
StringBuilder builder = new StringBuilder(str);
if (builder.length() <= insertIndex) {
return builder.append(buffer).toString();
} else {
return builder.insert(insertIndex, buffer).toString();
}
}
private static void editA() {
cursorLocRow = 0;
}
private static void editE() {
cursorLocRow = currentLineString().length() - 1;
}
private static void editP() {
cursorLocRow = 0;
if (cursorLocLine > 0) cursorLocLine--;
}
private static void editN() {
cursorLocRow = 0;
if (isLastLine()) return;
cursorLocLine++;
}
private static void editF() {
if (isLastRow()) {
if (isLastLine()) return;
cursorLocLine++;
cursorLocRow = 0;
} else {
cursorLocRow++;
}
}
private static void editB() {
if (cursorLocRow > 0) cursorLocRow--;
else if (cursorLocLine > 0) {
cursorLocRow = modifyingText.get(cursorLocLine - 1).length() - 1;
cursorLocLine--;
}
}
private static void editD() {
if (!isEOL()) {
replaceCurrentLine(remove(modifyingText.get(cursorLocLine), cursorLocRow));
} else {
if (!isLastLine()) {
replaceCurrentLine(currentLineString() + modifyingText.get(cursorLocLine + 1));
replaceCurrentLine(remove(currentLineString(), cursorLocRow));
for (int i = cursorLocLine + 1; i < modifyingText.size(); i++) {
if (isLastLine(i + 1)) break;
replaceLine(i, modifyingText.get(i) + modifyingText.get(i + 1));
}
}
}
}
private static void editK() {
if (isLastRow()) {
if (!isLastLine()) {
replaceCurrentLine(currentLineString() + modifyingText.get(cursorLocLine + 1));
replaceCurrentLine(remove(currentLineString(), cursorLocRow));
for (int i = cursorLocLine + 1; i < modifyingText.size(); i++) {
if (isLastLine(i + 1))
replaceLine(i, modifyingText.get(i + 1));
}
modifyingText.remove(lastLine());
buffer = "\n";
}
} else {
buffer = currentLineString().substring(cursorLocRow, currentLineString().length() - 1);
if (cursorLocRow == 0) replaceCurrentLine(ENDOFLINE);
else replaceCurrentLine(currentLineString().substring(0, cursorLocRow) + ENDOFLINE);
}
}
private static void editY() {
if (buffer != null) {
if (buffer.equals("\n")) {
if (isLastRow()) {
String movingText = currentLineString().substring(cursorLocRow);
replaceCurrentLine(currentLineString().substring(0, cursorLocRow) + ENDOFLINE);
insertLine(cursorLocLine + 1, movingText);
} else {
String movingText = currentLineString().substring(cursorLocRow);
insertLine(cursorLocLine + 1, movingText);
if (cursorLocRow != 0) {
replaceCurrentLine(currentLineString().substring(0, cursorLocRow) + ENDOFLINE);
} else {
replaceCurrentLine(ENDOFLINE);
}
}
cursorLocRow = 0;
cursorLocLine++;
} else {
replaceCurrentLine(insert(currentLineString(), cursorLocRow));
}
}
}
private static String currentLineString() {
return modifyingText.get(cursorLocLine);
}
private static void replaceLine(int index, String str) {
modifyingText.set(index, str);
}
private static void replaceCurrentLine(String str) {
modifyingText.set(cursorLocLine, str);
}
private static void insertLine(int index, String str) {
modifyingText.add(index, str);
}
private static void insertInCurrentLine(String str) {
modifyingText.add(cursorLocLine, str);
}
private static boolean isLastLine() {
return modifyingText.size() <= cursorLocLine + 1;
}
private static boolean isLastLine(int i) {
return modifyingText.size() > i;
}
private static boolean isLastRow() {
return modifyingText.get(cursorLocLine).length() <= cursorLocRow + 1;
}
private static int lastLine() {
return modifyingText.size() - 1;
}
private static boolean isEOL() {
return String.valueOf(currentLineString().charAt(cursorLocRow)).equals(ENDOFLINE);
}
}
| Main.java:4: error: class EditText is public, should be declared in a file named EditText.java
public class EditText {
^
1 error
|
s698397090 | p00607 | Java | import java.util.ArrayList;
import java.util.Scanner;
public class EditText {
static final int MAXINPUTLINE = 10;
static final int MAXINPUTCOMMAND = 300;
static final int MAXMODIFIEDTEXTLINE = 100;
static final int MAXMODIFIERTEXTCHAR = 1000;
static final String ENDOFLINE = "$";
static Scanner scan = new Scanner(System.in);
static ArrayList<String> modifyingText = new ArrayList<String>();
static String buffer;
static int cursorLocLine = 0;
static int cursorLocRow = 0;
public static void main(String args[]) {
ArrayList<String> inputText;
ArrayList<String> inputCommand;
inputText = giveTextLine();
// System.out.println("==============================");
// System.out.println("give Text Success");
inputCommand = giveCommand();
// System.out.println("==============================");
// System.out.println("give Command Success");
modifyText(inputText, inputCommand);
for (int i = 0; i < modifyingText.size(); i++) {
int outLen = modifyingText.get(i).length();
if (outLen <= 1) {
System.out.print("\n");
} else System.out.println(modifyingText.get(i).substring(0, outLen - 1));
}
}
private static ArrayList<String> giveTextLine() {
String input;
ArrayList<String> inputText = new ArrayList<>();
// Scanner scan = new Scanner(System.in);
for (int i = 0; i < MAXINPUTLINE; i++) {
input = scan.nextLine();
if (input.equals("END_OF_TEXT")) break;
inputText.add(i, input);
}
return inputText;
}
private static ArrayList<String> giveCommand() {
String input;
ArrayList<String> inputCommand = new ArrayList<>();
// Scanner scan = new Scanner(System.in);
for (int i = 0; i < MAXINPUTCOMMAND; i++) {
input = scan.nextLine();
if (input.equals("-")) break;
inputCommand.add(i, input);
}
return inputCommand;
}
private static void modifyText(final ArrayList<String> inputText, final ArrayList<String> inputCommand) {
for (int i = 0; i < inputText.size(); i++) {
modifyingText.add(i, inputText.get(i) + ENDOFLINE);
}
for (int i = 0; i < inputCommand.size(); i++) {
// System.out.println("===============================");
// System.out.println(inputCommand.get(i) + " " + cursorLocRow + " " + cursorLocLine + " " + modifyingText.get(cursorLocLine).length() + " " + buffer);
// System.out.println("===============================");
// modifyingText.forEach(System.out::println);
if (inputCommand.get(i).equals("a")) editA();
else if (inputCommand.get(i).equals("e")) editE();
else if (inputCommand.get(i).equals("p")) editP();
else if (inputCommand.get(i).equals("n")) editN();
else if (inputCommand.get(i).equals("f")) editF();
else if (inputCommand.get(i).equals("b")) editB();
else if (inputCommand.get(i).equals("d")) editD();
else if (inputCommand.get(i).equals("k")) editK();
else if (inputCommand.get(i).equals("y")) editY();
}
}
private static String remove(String str, int removeIndex) {
StringBuilder builder = new StringBuilder(str);
return builder.deleteCharAt(removeIndex).toString();
}
private static String insert(String str, int insertIndex) {
StringBuilder builder = new StringBuilder(str);
if (builder.length() <= insertIndex) {
return builder.append(buffer).toString();
} else {
return builder.insert(insertIndex, buffer).toString();
}
}
private static void editA() {
cursorLocRow = 0;
}
private static void editE() {
cursorLocRow = currentLineString().length() - 1;
}
private static void editP() {
cursorLocRow = 0;
if (cursorLocLine > 0) cursorLocLine--;
}
private static void editN() {
cursorLocRow = 0;
if (isLastLine()) return;
cursorLocLine++;
}
private static void editF() {
if (isLastRow()) {
if (isLastLine()) return;
cursorLocLine++;
cursorLocRow = 0;
} else {
cursorLocRow++;
}
}
private static void editB() {
if (cursorLocRow > 0) cursorLocRow--;
else if (cursorLocLine > 0) {
cursorLocRow = modifyingText.get(cursorLocLine - 1).length() - 1;
cursorLocLine--;
}
}
private static void editD() {
if (!isEOL()) {
replaceCurrentLine(remove(modifyingText.get(cursorLocLine), cursorLocRow));
} else {
if (!isLastLine()) {
replaceCurrentLine(currentLineString() + modifyingText.get(cursorLocLine + 1));
replaceCurrentLine(remove(currentLineString(), cursorLocRow));
for (int i = cursorLocLine + 1; i < modifyingText.size(); i++) {
if (isLastLine(i + 1)) break;
replaceLine(i, modifyingText.get(i) + modifyingText.get(i + 1));
}
}
}
}
private static void editK() {
if (isLastRow()) {
if (!isLastLine()) {
replaceCurrentLine(currentLineString() + modifyingText.get(cursorLocLine + 1));
replaceCurrentLine(remove(currentLineString(), cursorLocRow));
for (int i = cursorLocLine + 1; i < modifyingText.size(); i++) {
if (isLastLine(i + 1))
replaceLine(i, modifyingText.get(i + 1));
}
modifyingText.remove(lastLine());
buffer = "\n";
}
} else {
buffer = currentLineString().substring(cursorLocRow, currentLineString().length() - 1);
if (cursorLocRow == 0) replaceCurrentLine(ENDOFLINE);
else replaceCurrentLine(currentLineString().substring(0, cursorLocRow) + ENDOFLINE);
cursorLocRow = currentLineString().length() - 1;
}
}
private static void editY() {
if (buffer != null) {
if (buffer.equals("\n")) {
if (isLastRow()) {
String movingText = currentLineString().substring(cursorLocRow);
replaceCurrentLine(currentLineString().substring(0, cursorLocRow) + ENDOFLINE);
insertLine(cursorLocLine + 1, movingText);
} else {
String movingText = currentLineString().substring(cursorLocRow);
insertLine(cursorLocLine + 1, movingText);
if (cursorLocRow != 0) {
replaceCurrentLine(currentLineString().substring(0, cursorLocRow) + ENDOFLINE);
} else {
replaceCurrentLine(ENDOFLINE);
}
}
cursorLocRow = 0;
cursorLocLine++;
} else {
replaceCurrentLine(insert(currentLineString(), cursorLocRow));
}
}
}
private static String currentLineString() {
return modifyingText.get(cursorLocLine);
}
private static void replaceLine(int index, String str) {
modifyingText.set(index, str);
}
private static void replaceCurrentLine(String str) {
modifyingText.set(cursorLocLine, str);
}
private static void insertLine(int index, String str) {
modifyingText.add(index, str);
}
private static void insertInCurrentLine(String str) {
modifyingText.add(cursorLocLine, str);
}
private static boolean isLastLine() {
return modifyingText.size() <= cursorLocLine + 1;
}
private static boolean isLastLine(int i) {
return modifyingText.size() > i;
}
private static boolean isLastRow() {
return modifyingText.get(cursorLocLine).length() <= cursorLocRow + 1;
}
private static int lastLine() {
return modifyingText.size() - 1;
}
private static boolean isEOL() {
return String.valueOf(currentLineString().charAt(cursorLocRow)).equals(ENDOFLINE);
}
}
| Main.java:4: error: class EditText is public, should be declared in a file named EditText.java
public class EditText {
^
1 error
|
s380891773 | p00607 | Java | import java.awt.Point;
import java.io.InputStreamReader;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Pattern;
public class AOJ1021 {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Scanner sc = new Scanner(new InputStreamReader(System.in));
ArrayList<StringBuilder> lines = new ArrayList<StringBuilder>();
while (true) {
String text = sc.next();
if (text.equals("END_OF_TEXT"))
break;
lines.add(new StringBuilder(text));
}
Point cursor = new Point();
String buffer = null;
commandLoop: while (true) {
char command = sc.next().charAt(0);
StringBuilder currentLine = lines.get(cursor.y);
switch (command) {
case 'a':
cursor.x = 0;
break;
case 'e':
cursor.x = currentLine.length();
break;
case 'p':
if (cursor.y > 0)
cursor.y--;
else
cursor.x = 0;
break;
case 'n':
if (cursor.y + 1 < lines.size())
cursor.y++;
cursor.x = 0; // ?
break;
case 'f':
if (cursor.x < currentLine.length()) {
cursor.x++;
}
else if (cursor.y + 1 < lines.size()) {
cursor.y++;
cursor.x = 0;
}
break;
case 'b':
if (cursor.x > 0) {
cursor.x--;
break;
}
else if (cursor.y > 0) {
cursor.y--;
cursor.x = 0;
}
break;
case 'd':
if (cursor.x < currentLine.length()) {
currentLine.deleteCharAt(cursor.x);
}
else if (cursor.y + 1 < lines.size()) {
currentLine.append(lines.remove(cursor.y + 1));
}
break;
case 'k':
if (cursor.x == currentLine.length()) {
if (cursor.y + 1 < lines.size()) {
currentLine.append(lines.remove(cursor.y + 1));
buffer = "\n";
}
}
else {
buffer = currentLine.substring(cursor.x);
currentLine.delete(cursor.x, currentLine.length());
}
break;
case 'y':
if (buffer != null) {
if (buffer.equals("\n")) {
StringBuilder newLine = new StringBuilder();
if(cursor.x != currentLine.length()) {
newLine.append(currentLine.substring(cursor.x));
currentLine.delete(cursor.x, currentLine.length());
}
lines.add(cursor.y, newLine);
cursor.y++;
cursor.x = 0;
}
else {
if(cursor.x == currentLine.length())
currentLine.append(buffer);
else
currentLine.insert(cursor.x, buffer);
cursor.x += buffer.length();
}
}
break;
default:
break commandLoop;
}
// System.out.println(cursor);
// System.out.println(currentLine);
}
for (StringBuilder sb : lines) {
System.out.println(sb);
}
}
} | Main.java:9: error: class AOJ1021 is public, should be declared in a file named AOJ1021.java
public class AOJ1021 {
^
1 error
|
s563428125 | p00607 | C | #include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <list>
using namespace std;
vector<string> text;
string buf;
int row, col;
void func_a(){
col = 0;
}
void func_e(){
col = text[row].size() - 1;
}
void func_p(){
if (row > 0) row--;
func_a();
}
void func_n(){
if (row < text.size() - 1) row++;
func_a();
}
void func_f(){
if (col < text[row].size() - 1) col++;
else func_n();
}
void func_b(){
if (col > 0) col--;
else if (row > 0){
func_p();
func_e();
}
}
void func_d(){
if (col < text[row].size() - 1) text[row].erase(col, col);
else if (row < text.size() - 1){
text[row] += text[row + 1];
text.erase(text.begin() + row + 1);
}
}
void func_k(){
if (col < text[row].size() - 1){
buf = text[row].substr(col, text[row].size() - col - 1);
text[row].erase(col, text[row].size() - 1);
col = text[row].size() - 1;
}
else if (row < text.size() - 1){
func_d();
buf = "\n";
}
}
void func_y(){
if (!buf.empty()){
if (buf == "\n"){
text.insert(text.begin() + row + 1, text[row].substr(col, text[row].size() - 1));
text[row].erase(col, text[row].size() - 1);
}
else {
text[row].insert(col, buf);
col += buf.size();
}
}
}
int main()
{
string in;
char cmd;
while (getline(cin, in), in != "END_OF_TEXT"){
text.push_back(in + '$');
}
col = row = 0;
buf.clear();
while (cin >> cmd, cmd != '-'){
switch (cmd){
case 'a': func_a(); break;
case 'e': func_e(); break;
case 'p': func_p(); break;
case 'n': func_n(); break;
case 'f': func_f(); break;
case 'b': func_b(); break;
case 'd': func_d(); break;
case 'k': func_k(); break;
case 'y': func_y(); break;
}
#if 0
printf("col:%d row:%d\n", col, row);
puts("status:");
for (vector<string>::iterator it = text.begin(); it != text.end(); it++){
cout << *it << endl;
}
puts("buffer:");
cout << buf << endl;
#endif
}
for (vector<string>::iterator it = text.begin(); it != text.end(); it++){
cout << it->substr(0, it->size() - 1) << endl;
}
return (0);
} | main.c:1:10: fatal error: cstdio: No such file or directory
1 | #include <cstdio>
| ^~~~~~~~
compilation terminated.
|
s796388798 | p00607 | C++ | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
vector<string> e;
string s;
while (getline(cin, s), s != "END_OF_TEXT") {
e.push_back(s);
}
int y = 0, x = 0;
string buffer = "";
char c;
while (cin >> c, c != '-') {
switch (c) {
case 'a':
x = 0;
break;
case 'e':
x = e[y].size();
break;
case 'p':
x = 0;
y = max(0, y-1);
break;
case 'n':
x = 0;
y = min(e.size()-1, y+1);
break;
case 'f':
if (x < e[y].size()) {
++x;
} else if (y+1 < e.size()) {
x = 0;
++y;
}
break;
case 'b':
if (0 < x) {
--x;
} else if (0 <= y-1) {
x = e[y-1].size();
--y;
}
break;
case 'd':
if (x < e[y].size()) {
e[y] = e[y].substr(0,x) + e[y].substr(x+1);
} else if (y+1 < e.size()) {
e[y] += e[y+1];
e.erase(e.begin()+y+1);
}
break;
case 'k':
if (x < e[y].size()) {
buffer = e[y].substr(x);
e[y] = e[y].substr(0,x);
x = e[y].size();
} else if (y+1 < e.size()) {
buffer = "\n";
e[y] += e[y+1];
e.erase(e.begin()+y+1);
}
break;
case 'y':
if (buffer != "") {
if (buffer == "\n") {
e.insert(e.begin()+y+1, e[y].substr(x));
e[y] = e[y].substr(0,x);
x = 0;
++y;
} else {
e[y] = e[y].substr(0,x) + buffer + e[y].substr(x);
x += buffer.size();
}
}
break;
}
}
for (int i=0; i<e.size(); ++i) {
cout << e[i] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:29:40: error: no matching function for call to 'min(std::vector<std::__cxx11::basic_string<char> >::size_type, int)'
29 | y = min(e.size()-1, y+1);
| ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:29:40: note: deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
29 | y = min(e.size()-1, y+1);
| ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
|
s317506166 | p00607 | C++ | #include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
using namespace std;
int main(){
char str[128][1024],c,buf[1024],input[1024];
int i,j,now_x,now_y,y_max;
memset(str,0,sizeof(str));
memset(buf,0,sizeof(buf));
for(i=0;gets(input);i++){
if(!strcmp(input,"END_OF_TEXT"))break;
strcpy(str[i],input);
}
y_max=i-1;
now_x=now_y=0;
for(;scanf(" %c ",&c),c!='-';){
if(c=='a') //J[\ð»ÝÌsÌæª
{
now_x=0;
}
else if(c=='e') //J[\ð»ÝÌsÌs
{
now_x=strlen(str[now_y]);
}
else if(c=='p') //ãÉsª êÎJ[\ðãÌsÌæªAÈÄàæª
{
if(now_y>0)now_y--;
now_x=0;
}
else if(c=='n') //ºÉsª ``
{
if(now_y<y_max)now_y++;
now_x=0;
}
else if(c=='f') //¶°¿ÙªsÅȢƫEÉÚ®AsºÉsª 鯫ºÌsÌæªAȢƫͽàµÈ¢
{
if(now_x!=strlen(str[now_y]))now_x++;
else{
if(now_y<y_max)now_y++,now_x=0;
}
}
else if(c=='b') //¶°¿Ùªæª¶ÅÈ¢Èç¶°¿Ùð¶ÉÚ®AæªãÉsª``
{
if(now_x>0)now_x--;
else{
if(now_y>0)now_y--,now_x=strlen(str[now_y]);
}
}
else if(c=='d')//¶°¿Ùª¶ðw·êíAí³ê½¶ÌE¤Í¶É¼ÌÄ``
{
if(now_x!=strlen(str[now_y])){
for(i=now_x;i<strlen(str[now_y]);i++)str[now_y][i]=str[now_y][i+1];
}
else{//¶°¿ÙªsÌÆ«
if(now_y<y_max){
strcat(str[now_y],str[now_y+1]);
y_max=now_y;
for(i=now_y+1;i<127;i++){
strcpy(str[i],str[i+1]);
if(str[i]!=0)y_max=i;
}
}
}
}
else if(c=='k') //
{
if(now_x==strlen(str[now_y])){
if(now_y<y_max){
strcat(str[now_y],str[now_y+1]);
y_max=now_y;
for(i=now_y+1;i<127;i++){
strcpy(str[i],str[i+1]);
if(str[i][0]!=0)y_max=i;
}
}
buf[0]='\n'; buf[1]=0;
}else{
strcpy(buf,str[now_y]+now_x);
str[now_y][now_x]=0;
now_x=strlen(str[now_y]);
}
}
else if(c=='y') //
{
if(buf[0]!=0){
if(buf[0]=='\n'){
for(i=126;i>now_y;i--)strcpy(str[i+1],str[i]);
strcpy(str[now_y+1],str[now_y]+now_x);
str[now_y][now_x]=0;
now_y++; now_x=0;
y_max++;
}else{
char tmp[1024];
int t=now_x+1>strlen(str[now_y])?strlen(str[now_y]):now_x+1;
strcpy(tmp,str[now_y]+now_x);
for(i=now_x,j=0;j<strlen(buf);)str[now_y][i++]=buf[j++];
str[now_y][i]=0;
strcat(str[now_y],tmp);
}
}
//memset(buf,0,sizeof(buf));
}
//printf("y_max:%d\n",y_max);
//for(i=0;i<=y_max;i++)printf("%d:%s\n",i,str[i]);
//printf("%c-----------------now_x:%d , now_y:%d , y_max:%d\n",c,now_x,now_y,y_max);
}
for(i=0;i<=y_max;i++)puts(str[i]);
return 0;
} | a.cc: In function 'int main()':
a.cc:20:11: error: 'gets' was not declared in this scope; did you mean 'getw'?
20 | for(i=0;gets(input);i++){
| ^~~~
| getw
|
s012325604 | p00607 | C++ | #include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
using namespace std;
int main(){
char str[128][1024],c,buf[1024],input[1024];
int i,j,now_x,now_y,y_max;
memset(str,0,sizeof(str));
memset(buf,0,sizeof(buf));
for(i=0;gets(input);i++){
if(!strcmp(input,"END_OF_TEXT"))break;
strcpy(str[i],input);
}
y_max=i-1;
now_x=now_y=0;
for(;scanf(" %c ",&c),c!='-';){
if(c=='a') //J[\ð»ÝÌsÌæª
{
now_x=0;
}
else if(c=='e') //J[\ð»ÝÌsÌs
{
now_x=strlen(str[now_y]);
}
else if(c=='p') //ãÉsª êÎJ[\ðãÌsÌæªAÈÄàæª
{
if(now_y>0)now_y--;
now_x=0;
}
else if(c=='n') //ºÉsª ``
{
if(now_y<y_max)now_y++;
now_x=0;
}
else if(c=='f') //¶°¿ÙªsÅȢƫEÉÚ®AsºÉsª 鯫ºÌsÌæªAȢƫͽàµÈ¢
{
if(now_x!=strlen(str[now_y]))now_x++;
else{
if(now_y<y_max)now_y++,now_x=0;
}
}
else if(c=='b') //¶°¿Ùªæª¶ÅÈ¢Èç¶°¿Ùð¶ÉÚ®AæªãÉsª``
{
if(now_x>0)now_x--;
else{
if(now_y>0)now_y--,now_x=strlen(str[now_y]);
}
}
else if(c=='d')//¶°¿Ùª¶ðw·êíAí³ê½¶ÌE¤Í¶É¼ÌÄ``
{
if(now_x!=strlen(str[now_y])){
for(i=now_x;i<strlen(str[now_y]);i++)str[now_y][i]=str[now_y][i+1];
}
else{//¶°¿ÙªsÌÆ«
if(now_y<y_max){
strcat(str[now_y],str[now_y+1]);
y_max=now_y;
for(i=now_y+1;i<127;i++){
strcpy(str[i],str[i+1]);
if(str[i]!=0)y_max=i;
}
}
}
}
else if(c=='k') //
{
if(now_x==strlen(str[now_y])){
if(now_y<y_max){
strcat(str[now_y],str[now_y+1]);
y_max=now_y;
for(i=now_y+1;i<127;i++){
strcpy(str[i],str[i+1]);
if(str[i][0]!=0)y_max=i;
}
}
buf[0]='\n'; buf[1]=0;
}else{
strcpy(buf,str[now_y]+now_x);
str[now_y][now_x]=0;
now_x=strlen(str[now_y]);
}
}
else if(c=='y') //
{
if(buf[0]!=0){
if(buf[0]=='\n'){
for(i=126;i>now_y;i--)strcpy(str[i+1],str[i]);
strcpy(str[now_y+1],str[now_y]+now_x);
str[now_y][now_x]=0;
now_y++; now_x=0;
y_max++;
}else{
char tmp[1024];
int t=now_x+1>strlen(str[now_y])?strlen(str[now_y]):now_x+1;
strcpy(tmp,str[now_y]+now_x);
for(i=now_x,j=0;j<strlen(buf);)str[now_y][i++]=buf[j++];
str[now_y][i]=0;
strcat(str[now_y],tmp);
}
}
//memset(buf,0,sizeof(buf));
}
//printf("y_max:%d\n",y_max);
//for(i=0;i<=y_max;i++)printf("%d:%s\n",i,str[i]);
//printf("%c-----------------now_x:%d , now_y:%d , y_max:%d\n",c,now_x,now_y,y_max);
}
for(i=0;i<=y_max;i++)puts(str[i]);
return 0;
} | a.cc: In function 'int main()':
a.cc:21:11: error: 'gets' was not declared in this scope; did you mean 'getw'?
21 | for(i=0;gets(input);i++){
| ^~~~
| getw
|
s960854618 | p00607 | C++ | import java.awt.Point;
import java.io.InputStreamReader;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Pattern;
public class Main {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Scanner sc = new Scanner(new InputStreamReader(System.in));
ArrayList<StringBuilder> lines = new ArrayList<StringBuilder>();
while (true) {
String text = sc.next();
if (text.equals("END_OF_TEXT"))
break;
lines.add(new StringBuilder(text));
}
Point cursor = new Point();
String buffer = null;
commandLoop: while (true) {
char command = sc.next().charAt(0);
StringBuilder currentLine = lines.get(cursor.y);
switch (command) {
case 'a':
cursor.x = 0;
break;
case 'e':
cursor.x = currentLine.length();
break;
case 'p':
if (cursor.y > 0)
cursor.y--;
else
cursor.x = 0;
break;
case 'n':
if (cursor.y + 1 < lines.size())
cursor.y++;
cursor.x = 0; // ?
break;
case 'f':
if (cursor.x < currentLine.length()) {
cursor.x++;
}
else if (cursor.y + 1 < lines.size()) {
cursor.y++;
cursor.x = 0;
}
break;
case 'b':
if (cursor.x > 0) {
cursor.x--;
break;
}
else if (cursor.y > 0) {
cursor.y--;
cursor.x = 0;
}
break;
case 'd':
if (cursor.x < currentLine.length()) {
currentLine.deleteCharAt(cursor.x);
}
else if (cursor.y + 1 < lines.size()) {
currentLine.append(lines.remove(cursor.y + 1));
}
break;
case 'k':
if (cursor.x == currentLine.length()) {
if (cursor.y + 1 < lines.size()) {
currentLine.append(lines.remove(cursor.y + 1));
buffer = "\n";
}
}
else {
buffer = currentLine.substring(cursor.x);
currentLine.delete(cursor.x, currentLine.length());
}
break;
case 'y':
if (buffer != null) {
if (buffer.equals("\n")) {
StringBuilder newLine = new StringBuilder();
if(cursor.x != currentLine.length()) {
newLine.append(currentLine.substring(cursor.x));
currentLine.delete(cursor.x, currentLine.length());
}
lines.add(cursor.y, newLine);
cursor.y++;
cursor.x = 0;
}
else {
if(cursor.x == currentLine.length())
currentLine.append(buffer);
else
currentLine.insert(cursor.x, buffer);
cursor.x += buffer.length();
}
}
break;
default:
break commandLoop;
}
// System.out.println(cursor);
// System.out.println(currentLine);
}
for (StringBuilder sb : lines) {
System.out.println(sb);
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.awt.Point;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.io.InputStreamReader;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.nio.Buffer;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.util.ArrayList;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.util.List;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
6 | import java.util.Scanner;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
7 | import java.util.regex.Pattern;
| ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: expected unqualified-id before 'public'
9 | public class Main {
| ^~~~~~
|
s396444893 | p00607 | C++ | #define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;
typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const ll INF = 1LL << 50;
const double EPS = 1E-10;
#define rep(i, n) for(int i = 0; i < n; i++)
size_t tpos;
size_t lpos;
void do_a(const vector<string> &text){
lpos = 0;
}
void do_e(const vector<string> &text){
lpos = text[tpos].size();
}
void do_p(const vector<string> &text){
lpos = 0;
tpos = max(0, (int)tpos - 1);
}
void do_n(const vector<string> &text){
lpos = 0;
tpos = min((int)tpos + 1, (int)text.size() - 1);
}
void do_f(const vector<string> &text){
if(lpos == text[tpos].size()){
if((int)tpos < (int)text.size() - 1){
lpos = 0;
tpos++;
}
}else{
lpos++;
}
}
void do_b(const vector<string> &text){
if(lpos != 0){
lpos--;
}else{
if(tpos > 0){
tpos--;
lpos = text[tpos].size();
}
}
}
void do_d(vector<string> &text){
if(lpos != text[tpos].size()){
text[tpos].erase(lpos, 1);
}else{
if((int)tpos < (int)text.size() - 1){
text[tpos]+=text[tpos+1];
text.erase(text.begin() + tpos+1);
}
}
}
void do_k(vector<string> &text, string &buffer){
if(lpos == text[tpos].size()){
if((int)tpos < (int)text.size() - 1){
buffer = "\n";
do_d(text);
}
}else{
buffer = string(text[tpos].begin() + lpos, text[tpos].end());
text[tpos].erase(text[tpos].begin() + lpos, text[tpos].end());
}else{
buffer = "\n";
}
}
void do_y(vector<string> &text, string &buffer){
if(buffer != ""){
if(buffer == "\n"){
string a(text[tpos].begin() + lpos, text[tpos].end());
text[tpos].erase(lpos);
text.insert(text.begin() + tpos + 1, a);
tpos++;
lpos = 0;
}else{
if(lpos == text[tpos].size()){
text[tpos] += buffer;
lpos = text[tpos].size();
}else{
text[tpos].insert(text[tpos].begin() + lpos, buffer.begin(), buffer.end());
lpos += buffer.size();
}
}
}
}
void output(const vector<string> &text){
rep(i, (int)text.size()) cout << text[i] << endl;
}
int main(){
string line;
vector<string> text;
string buffer;
while(cin >> line && line != "END_OF_TEXT"){
text.push_back(line);
}
tpos = lpos = 0;
char command;
while(cin >> command && command != '-'){
switch(command){
case 'a':
do_a(text);
break;
case 'e':
do_e(text);
break;
case 'p':
do_p(text);
break;
case 'n':
do_n(text);
break;
case 'f':
do_f(text);
break;
case 'b':
do_b(text);
break;
case 'd':
do_d(text);
break;
case 'k':
do_k(text, buffer);
break;
case 'y':
do_y(text, buffer);
break;
default:
assert(false);
}
//output(text);
//cout << tpos << " " << lpos << endl;
}
output(text);
return 0;
} | a.cc: In function 'void do_k(std::vector<std::__cxx11::basic_string<char> >&, std::string&)':
a.cc:101:10: error: 'else' without a previous 'if'
101 | }else{
| ^~~~
|
s500398102 | p00607 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
template <class T> void pv(T a, T b) {
for(typeof(a) it = a; it != b; ++it)
cerr << *it << " ";
cerr << endl;
}
#define all(v) (v).begin(), (v).end()
vector<string> text;
vector<char> command;
int cursol_row;
int cursol_col;
void com_a() {
cursol_col = 0;
}
void com_e() {
cursol_col = text.at(cursol_row).length() - 1;
}
void com_p() {
if(cursol_row > 0) cursol_row--;
com_a();
}
void com_n() {
if(cursol_row < (int)text.size() - 1) cursol_row++;
com_a();
}
void com_f() {
if(text[cursol_row][cursol_col] != '^') cursol_col++;
else if(text[cursol_row][cursol_col] == '^' && cursol_row < (int)text.size() - 1) {
com_f()
}
}
void com_b() {
if(cursol_col > 0) cursol_col--;
else if(cursol_col == 0 && cursol_row > 0) {
cursol_row--;
com_e();
}
}
void show_cursol() {
cerr << "ROW: " << cursol_row << " COL: " << cursol_col << endl;
}
void com_d() {
if(text[cursol_row][cursol_col] != '^') {
string line = text[cursol_row];
string left = line.substr(0, cursol_col);
string right = line.substr(cursol_col + 1);
text[cursol_row] = left + right;
} else if(text[cursol_row][cursol_col] == '^' && cursol_row < (int)text.size() - 1) {
string line = text[cursol_row];
line = line.substr(0, line.length() - 1) + text[cursol_row + 1];
text[cursol_row] = line;
vector<string>::iterator it = text.begin();
advance(it, cursol_row + 1);
text.erase(it);
}
}
string buffer;
void com_k() {
if(text[cursol_row][cursol_col] == '^' && cursol_row < (int)text.size() - 1) {
com_d(); buffer = "^";
}
else if(text[cursol_row][cursol_col] != '^') {
string line = text[cursol_row];
buffer = line.substr(cursol_col);
buffer = buffer.substr(0, buffer.length() - 1);
text[cursol_row] = line.substr(0, cursol_col) + "^";
}
}
void com_y() {
if(buffer == "^") {
string line = text[cursol_row];
string fs = line.substr(0, cursol_col) + "^";
string sc = line.substr(cursol_col);
text[cursol_row] = fs;
vector<string>::iterator it = text.begin();
advance(it, cursol_row + 1);
text.insert(it, sc);
cursol_row++;
cursol_col = 0;
}
else if(buffer != "") {
string line = text[cursol_row];
string left = line.substr(0, cursol_col);
string right = line.substr(cursol_col);
text[cursol_row] = left + buffer + right;
}
}
int main() {
buffer = "";
cursol_row = 0;
cursol_col = 0;
#if 1
for(string line; getline(cin, line) && line != "END_OF_TEXT";) {
text.push_back(line + "^");
}
for(char c; cin >> c && c != '-'; ) {
command.push_back(c);
}
#else
for(string line; getline(cin, line) && line != "-";) {
text.push_back(line + "^");
}
for(char c; cin >> c && c != '-'; ) {
switch(c) {
case 'a': com_a(); break;
case 'e': com_e(); break;
case 'p': com_p(); break;
case 'n': com_n(); break;
case 'f': com_f(); break;
case 'b': com_b(); break;
case 'd': com_d(); break;
case 'k': com_k(); break;
case 'y': com_y(); break;
default: break;
}
pv(all(text));
show_cursol();
}
#endif
#if 0
pv(all(text));
pv(all(command));
#endif
#if 1
for(int i = 0; i < (int)command.size(); i++) {
char c = command[i];
switch(c) {
case 'a': com_a(); break;
case 'e': com_e(); break;
case 'p': com_p(); break;
case 'n': com_n(); break;
case 'f': com_f(); break;
case 'b': com_b(); break;
case 'd': com_d(); break;
case 'k': com_k(); break;
case 'y': com_y(); break;
default: break;
}
}
for(int i = 0; i < (int)text.size(); i++) {
cout << text[i].substr(0, text[i].length() - 1) << endl;
// cout << text[i] << endl;
}
#endif
return 0;
} | a.cc: In function 'void com_f()':
a.cc:43:24: error: expected ';' before '}' token
43 | com_f()
| ^
| ;
44 | }
| ~
|
s850004811 | p00607 | C++ | #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>
using namespace std;
typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i)
#define repc(i,n) for(int i=0;i<=(n);++i)
#define repcn(i,m,n) for(int i=(m);i<=(n);++i)
#define repcd(i,n) for(int i=(n);i>=0;--i)
#define repcnd(i,m,n) for(int i=(n);i>=(m);--i)
#define repc0(i,n) for(i=0;i<=(n);++i)
#define repcn0(i,m,n) for(i=(m);i<=(n);++i)
#define repcd0(i,n) for(i=(n);i>=0;--i)
#define repcnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define p_queue(n) priority_queue<n,vector<n>,greater<n> >
#define PUTLINE cout<<"LINE:"<<__LINE__<<endl;
const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int dx[]={1,-1,0,0,1,1,-1,-1,0};
const int dy[]={0,0,1,-1,1,-1,1,-1,0};
string str[111];
char s[100];
int main() {
int h = 0;
IL {
gets(s);
str[h] = s;
str[h] = str[h].substr(0, sz(str[h]) - 1);
if (str[h] == "END_OF_TEXT") break;
++h;
}
int x = 0, y = 0;
string com, buf = "";
IL {
cin >> com;
if (com == "a") {
x = 0;
} else if (com == "e") {
x = sz(str[y]);
} else if (com == "p") {
x = 0;
if (y > 0) --y;
} else if (com == "n") {
x = 0;
if (y < h - 1) ++y;
} else if (com == "f") {
if (x < sz(str[y])) ++x;
else if (y < h - 1) {x = 0; ++y;}
} else if (com == "b") {
if (x > 0) --x;
else if (y > 0) {--y; x = sz(str[y]);}
} else if (com == "d") {
if (x < sz(str[y])) str[y] = str[y].substr(0, x) + str[y].substr(x + 1);
else if (y < h - 1) {
str[y] += str[y + 1];
--h;
repn (i, y + 1, h) str[i] = str[i + 1];
}
} else if (com == "k") {
if (x == sz(str[y])) {
if (y < h - 1) {
buf = "\n";
str[y] += str[y + 1];
--h;
repn (i, y + 1, h) str[i] = str[i + 1];
}
} else {
buf = str[y].substr(x);
str[y] = str[y].substr(0, x);
x = sz(str[y]);
}
} else if (com == "y") {
if (buf == "\n") {
++h;
repn (i, y + 2, h) str[i] = str[i - 1];
str[y + 1] = str[y].substr(x);
str[y] = str[y].substr(0, x);
x = 0;
++y;
} else if (sz(buf) > 0) {
str[y] = str[y].substr(0, x) + buf + str[y].substr(x);
x += sz(buf);
}
} else if (com == "-") {
break;
}
}
rep (i, h) cout << str[i] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:71:17: error: 'gets' was not declared in this scope; did you mean 'getw'?
71 | gets(s);
| ^~~~
| getw
|
s597919111 | p00607 | C++ | #include <iostream>
#include <vector>
#include <string>
using namespace std;
void doA(int *l, int *c, string &s, string &b, vector<string> &v) {
*c = 0;
}
void doE(int *l, int *c, string &s, string &b, vector<string> &v) {
*c = s.size();
}
void doP(int *l, int *c, string &s, string &b, vector<string> &v) {
if (*l > 0)
*l -= 1;
*c = 0;
}
void doN(int *l, int *c, string &s, string &b, vector<string> &v) {
if (*l < v.size()-1)
*l += 1;
*c = 0;
}
void doF(int *l, int *c, string &s, string &b, vector<string> &v) {
if (*c < s.size()) {
*c += 1;
} else if (*l < v.size()-1){
*l += 1;
*c = 0;
}
}
void doB(int *l, int *c, string &s, string &b, vector<string> &v) {
if (*c > 0) {
*c -= 1;
} else if (*l > 0) {
*l -= 1;
*c = v[*l].size();
}
}
void doD(int *l, int *c, string &s, string &b, vector<string> &v) {
if (*c < s.size()) {
s.erase(*c, 1);
} else if (*l < v.size()-1) {
s.append(v[*l+1]);
vector<string>::iterator itr = v.begin() + *l + 1;
v.erase(itr);
}
}
void doK(int *l, int *c, string &s, string &b, vector<string> &v) {
if (*c == s.size() && *l < v.size()-1) {
doD(l, c, s, b, v);
b = "\n";
} else if (*c < s.size()) {
b = s.substr(*c, s.size() - *c);
s.erase(*c, s.size() - *c);
*c = s.size();
}
}
void doY(int *l, int *c, string &s, string &b, vector<string> &v) {
if (b.empty()) {
return;
} else if (b == "\n") {
doK(l, c, s, b, v);
vector<string>::iterator itr = v.begin() + *l + 1;
v.insert(itr, );
b = "\n";
*l++;
*c = 0;
} else {
s.insert(*c, b);
*c = s.size();
}
}
int main(int argc, char *argv[]) {
string buf;
vector<string> strs;
while (true) {
string s;
getline(cin, s);
if (s == "END_OF_TEXT")
break;
strs.push_back(s);
}
int line = 0, chrc = 0;
while (true) {
char c;
cin >> c;
if (c == '-')
break;
else if (c == 'a')
doA(&line, &chrc, strs[line], buf, strs);
else if (c == 'e')
doE(&line, &chrc, strs[line], buf, strs);
else if (c == 'p')
doP(&line, &chrc, strs[line], buf, strs);
else if (c == 'n')
doN(&line, &chrc, strs[line], buf, strs);
else if (c == 'f')
doF(&line, &chrc, strs[line], buf, strs);
else if (c == 'b')
doB(&line, &chrc, strs[line], buf, strs);
else if (c == 'd')
doD(&line, &chrc, strs[line], buf, strs);
else if (c == 'k')
doK(&line, &chrc, strs[line], buf, strs);
else if (c == 'y')
doY(&line, &chrc, strs[line], buf, strs);
}
for (int i = 0; i < strs.size(); i++)
cout << strs[i] << endl;
return 0;
} | a.cc: In function 'void doY(int*, int*, std::string&, std::string&, std::vector<std::__cxx11::basic_string<char> >&)':
a.cc:73:19: error: expected primary-expression before ')' token
73 | v.insert(itr, );
| ^
|
s104312987 | p00607 | C++ | #include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <list>
using namespace std;
vector<string> text;
string buf;
int row, col;
void func_a(){
col = 0;
}
void func_e(){
col = text[row].size() - 1;
}
void func_p(){
if (row > 0) row--;
func_a();
}
void func_n(){
if (row < text.size() - 1) row++;
func_a();
}
void func_f(){
if (col < text[row].size() - 1) col++;
else func_n();
}
void func_b(){
if (col > 0) col--;
else if (row > 0){
func_p();
func_e();
}
}
void func_d(){
if (col < text[row].size() - 1) text[row].erase(col, 1);
else if (row < text.size() - 1){
text[row].erase(text[row].end() - 1);
text[row] += text[row + 1];
text.erase(text.begin() + row + 1);
}
}
void func_k(){
if (col < text[row].size() - 1){
buf = text[row].substr(col, text[row].size() - col - 1);
text[row].erase(col, text[row].size() - 1);
col = text[row].size() - 1;
}
else if (row < text.size() - 1){
func_d();
buf = "\n";
}
}
void func_y(){
if (!buf.empty()){
if (buf == "\n"){
text.insert(text.begin() + row + 1, text[row].substr(col, text[row].size() - 1));
text[row].erase(col, text[row].size() - 1);
text[row] += '$';
}
else {
text[row].insert(col, buf);
col += buf.size();
}
}
}
int main()
{
string in;
char cmd;
while (getline(cin, in), in != "END_OF_TEXT"){
text.push_back(in + '$');
}
col = row = 0;
buf.clear();
while (cin >> cmd, cmd != '-'){
switch (cmd){
case 'a': func_a(); break;
case 'e': func_e(); break;
case 'p': func_p(); break;
case 'n': func_n(); break;
case 'f': func_f(); break;
case 'b': func_b(); break;
case 'd': func_d(); break;
case 'k': func_k(); break;
case 'y': func_y(); break;
}
#if 0
printf("col:%d row:%d\n", col, row);
puts("status:");
for (vector<string>::iterator it = text.begin(); it != text.end(); it++){
cout << *it << endl;
}
puts("buffer:");
cout << buf << endl;
#endif
}
for (vector<string>::iterator it = text.begin(); it != text.end(); it++){
cout << it->substr(0, it->size() - 1) << endl;
}
return (0); | a.cc: In function 'int main()':
a.cc:120:20: error: expected '}' at end of input
120 | return (0);
| ^
a.cc:81:1: note: to match this '{'
81 | {
| ^
|
s755406368 | p00607 | C++ | #include <iostream>
#include <string>
 
using namespace std;
 
int main(){
    string str[1000];
    string s;
    int size = 0;
    while(getline(cin,s)){
        if(s == "END_OF_TEXT") break;
        str[size++] = s;
    }
    char ch;
    string buf = "";
    int line = 0, pos = 0;
    while(cin >> ch){
        if(ch == '-') break;
        if(ch == 'a') pos = 0;
        if(ch == 'e') pos = str[line].size();
        if(ch == 'p'){
            pos = 0;
            if(line!=0) line--;
        }
        if(ch == 'n'){
            pos = 0;
            if(line+1!=size) line++;
        }
        if(ch == 'f'){
            if(pos != str[line].size()) pos++;
            else if(line+1!=size) { pos = 0; line++; }
        }
        if(ch == 'b'){
            if(pos != 0) pos--;
            else if(line!=0) { line--; pos = str[line].size(); }
        }
        if(ch == 'd'){
            if(pos != str[line].size()){
                str[line] = str[line].substr(0,pos) + str[line].substr(pos+1);
            } else if(line+1!=size){
                str[line] = str[line] + str[line+1];
                for(int i=line+1;i+1<size;i++){
                    str[i] = str[i+1];
                }
                str[size-1] = "";
                size--;
            }
        }
        if(ch == 'k'){
            if(pos == str[line].size() && line+1!=size){
                str[line] = str[line] + str[line+1];
                for(int i=line+1;i+1<size;i++){
                    str[i] = str[i+1];
                }
                str[size-1] = "";
                size--;
                buf = "IS_BREAK_LINE";
            }
            else if(pos < str[line].size()){
                buf = str[line].substr(pos);
                str[line] = str[line].substr(0,pos);
            }
        }
        if(ch == 'y'){
            if(buf == "IS_BREAK_LINE"){
                for(int i=size-1;i>=line+1;i--){
                    str[i+1] = str[i];
                }
                size++;
                str[line+1] = str[line].substr(pos);
                str[line] = str[line].substr(0,pos);
                line++;
                pos = 0;
            } else if(buf != ""){
                str[line] = str[line].substr(0,pos) + buf + str[line].substr(pos);
                pos += buf.size();
            }
        }
        /*
        cout << line << " " << pos << endl;
        for(int i=0;i<size;i++){
            cout << str[i] << endl;
        }
        puts("");
        */
    }
    for(int i=0;i<size;i++){
        cout << str[i] << endl;
    }
} | a.cc:3:2: error: stray '#' in program
3 |  
| ^
a.cc:5:2: error: stray '#' in program
5 |  
| ^
a.cc:7:2: error: stray '#' in program
7 |     string str[1000];
| ^
a.cc:7:8: error: stray '#' in program
7 |     string str[1000];
| ^
a.cc:7:14: error: stray '#' in program
7 |     string str[1000];
| ^
a.cc:7:20: error: stray '#' in program
7 |     string str[1000];
| ^
a.cc:8:2: error: stray '#' in program
8 |     string s;
| ^
a.cc:8:8: error: stray '#' in program
8 |     string s;
| ^
a.cc:8:14: error: stray '#' in program
8 |     string s;
| ^
a.cc:8:20: error: stray '#' in program
8 |     string s;
| ^
a.cc:9:2: error: stray '#' in program
9 |     int size = 0;
| ^
a.cc:9:8: error: stray '#' in program
9 |     int size = 0;
| ^
a.cc:9:14: error: stray '#' in program
9 |     int size = 0;
| ^
a.cc:9:20: error: stray '#' in program
9 |     int size = 0;
| ^
a.cc:10:2: error: stray '#' in program
10 |     while(getline(cin,s)){
| ^
a.cc:10:8: error: stray '#' in program
10 |     while(getline(cin,s)){
| ^
a.cc:10:14: error: stray '#' in program
10 |     while(getline(cin,s)){
| ^
a.cc:10:20: error: stray '#' in program
10 |     while(getline(cin,s)){
| ^
a.cc:11:2: error: stray '#' in program
11 |         if(s == "END_OF_TEXT") break;
| ^
a.cc:11:8: error: stray '#' in program
11 |         if(s == "END_OF_TEXT") break;
| ^
a.cc:11:14: error: stray '#' in program
11 |         if(s == "END_OF_TEXT") break;
| ^
a.cc:11:20: error: stray '#' in program
11 |         if(s == "END_OF_TEXT") break;
| ^
a.cc:11:26: error: stray '#' in program
11 |         if(s == "END_OF_TEXT") break;
| ^
a.cc:11:32: error: stray '#' in program
11 |         if(s == "END_OF_TEXT") break;
| ^
a.cc:11:38: error: stray '#' in program
11 |         if(s == "END_OF_TEXT") break;
| ^
a.cc:11:44: error: stray '#' in program
11 |         if(s == "END_OF_TEXT") break;
| ^
a.cc:12:2: error: stray '#' in program
12 |         str[size++] = s;
| ^
a.cc:12:8: error: stray '#' in program
12 |         str[size++] = s;
| ^
a.cc:12:14: error: stray '#' in program
12 |         str[size++] = s;
| ^
a.cc:12:20: error: stray '#' in program
12 |         str[size++] = s;
| ^
a.cc:12:26: error: stray '#' in program
12 |         str[size++] = s;
| ^
a.cc:12:32: error: stray '#' in program
12 |         str[size++] = s;
| ^
a.cc:12:38: error: stray '#' in program
12 |         str[size++] = s;
| ^
a.cc:12:44: error: stray '#' in program
12 |         str[size++] = s;
| ^
a.cc:13:2: error: stray '#' in program
13 |     }
| ^
a.cc:13:8: error: stray '#' in program
13 |     }
| ^
a.cc:13:14: error: stray '#' in program
13 |     }
| ^
a.cc:13:20: error: stray '#' in program
13 |     }
| ^
a.cc:14:2: error: stray '#' in program
14 |     char ch;
| ^
a.cc:14:8: error: stray '#' in program
14 |     char ch;
| ^
a.cc:14:14: error: stray '#' in program
14 |     char ch;
| ^
a.cc:14:20: error: stray '#' in program
14 |     char ch;
| ^
a.cc:15:2: error: stray '#' in program
15 |     string buf = "";
| ^
a.cc:15:8: error: stray '#' in program
15 |     string buf = "";
| ^
a.cc:15:14: error: stray '#' in program
15 |     string buf = "";
| ^
a.cc:15:20: error: stray '#' in program
15 |     string buf = "";
| ^
a.cc:16:2: error: stray '#' in program
16 |     int line = 0, pos = 0;
| ^
a.cc:16:8: error: stray '#' in program
16 |     int line = 0, pos = 0;
| ^
a.cc:16:14: error: stray '#' in program
16 |     int line = 0, pos = 0;
| ^
a.cc:16:20: error: stray '#' in program
16 |     int line = 0, pos = 0;
| ^
a.cc:17:2: error: stray '#' in program
17 |     while(cin >> ch){
| ^
a.cc:17:8: error: stray '#' in program
17 |     while(cin >> ch){
| ^
a.cc:17:14: error: stray '#' in program
17 |     while(cin >> ch){
| ^
a.cc:17:20: error: stray '#' in program
17 |     while(cin >> ch){
| ^
a.cc:18:2: error: stray '#' in program
18 |         if(ch == '-') break;
| ^
a.cc:18:8: error: stray '#' in program
18 |         if(ch == '-') break;
| ^
a.cc:18:14: error: stray '#' in program
18 |         if(ch == '-') break;
| ^
a.cc:18:20: error: stray '#' in program
18 |         if(ch == '-') break;
| ^
a.cc:18:26: error: stray '#' in program
18 |         if(ch == '-') break;
| ^
a.cc:18:32: error: stray '#' in program
18 |         if(ch == '-') break;
| ^
a.cc:18:38: error: stray '#' in program
18 |         if(ch == '-') break;
| ^
a.cc:18:44: error: stray '#' in program
18 |         if(ch == '-') break;
| ^
a.cc:19:2: error: stray '#' in program
19 |         if(ch == 'a') pos = 0;
| ^
a.cc:19:8: error: stray '#' in program
19 |         if(ch == 'a') pos = 0;
| ^
a.cc:19:14: error: stray '#' in program
19 |         if(ch == 'a') pos = 0;
| ^
a.cc:19:20: error: stray '#' in program
19 |         if(ch == 'a') pos = 0;
| ^
a.cc:19:26: error: stray '#' in program
19 |         if(ch == 'a') pos = 0;
| ^
a.cc:19:32: error: stray '#' in program
19 |         if(ch == 'a') pos = 0;
| ^
a.cc:19:38: error: stray '#' in program
19 |         if(ch == 'a') pos = 0;
| ^
a.cc:19:44: error: stray '#' in program
19 |         if(ch == 'a') pos = 0;
| ^
a.cc:20:2: error: stray '#' in program
20 |         if(ch == 'e') pos = str[line].size();
| ^
a.cc:20:8: error: stray '#' in program
20 |         if(ch == 'e') pos = str[line].size();
| ^
a.cc:20:14: error: stray '#' in program
20 |         if(ch == 'e') pos = str[line].size();
| ^
a.cc:20:20: error: stray '#' in program
20 |         if(ch == 'e') pos = str[line].size();
| ^
a.cc:20:26: error: stray '#' in program
20 |         if(ch == 'e') pos = str[line].size();
| ^
a.cc:20:32: error: stray '#' in program
20 |         if(ch == 'e') pos = str[line].size();
| ^
a.cc:20:38: error: stray '#' in program
20 |         if(ch == 'e') pos = str[line].size();
| ^
a.cc:20:44: error: stray '#' in program
20 |         if(ch == 'e') pos = str[line].size();
| ^
a.cc:21:2: error: stray '#' in program
21 |         if(ch == 'p'){
| ^
a.cc:21:8: error: stray '#' in p |
s047613521 | p00607 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector< vector<char> > t,u;
vector<char> tmp;
vector<char> z;
char ch;
int x,y;
void input();
void funcA();
void funcE();
void funcP();
void funcN();
void funcF();
void funcB();
void funcD();
void funcK();
void funcY();
void yinsert(int,vector<char>);
void xinsert(int,int,char);
void ydelete(int);
void xdelete(int,int);
int main(){
t.clear();
tmp.clear();
input();
x=y=0;
while(1){
cin>>ch;
if(ch=='a')funcA();
else if(ch=='e')funcE();
else if(ch=='p')funcP();
else if(ch=='n')funcN();
else if(ch=='f')funcF();
else if(ch=='b')funcB();
else if(ch=='d')funcD();
else if(ch=='k')funcK();
else if(ch=='y')funcY();
else break;
//cout<<y<<' '<<x<<" ty"<<t.size()<<endl;
}
for(int i=0;i<t.size();i++){
for(int j=0;j<t[i].size();j++){
cout<<t[i][j];
}
}
return 0;
}
void funcA(){
x=0;
}
void funcE(){
x=t[y].size()-1;
}
void funcP(){
if(y>0)y--;
x=0;
}
void funcN(){
if(y+1<(int)t.size())y++;
x=0;
}
void funcF(){
if(x+1<(int)t[y].size())x++;
else if(y+1<(int)t.size()){y++;x=0;}
}
void funcB(){
if(x>0)x--;
else if(y>0){y--;x=t[y].size()-1;}
}
void funcD(){
if(t[y][x]!='\n'){
xdelete(y,x);
return;
}
if(y+1==(int)t.size())return;
xdelete(y,x);
for(int i=0;i<(int)t[y+1].size();i++)
t[y].push_back(t[y+1][i]);
ydelete(y+1);
}
void funcK(){
tmp.clear();
if(t[y][x]=='\n'){
if(y+1<(int)t.size()){
funcD();
tmp.push_back('\n');
}
return;
}
while(t[y][x]!='\n'){
tmp.push_back(t[y][x]);
xdelete(y,x);
}
reverse(tmp.begin(),tmp.end());
//funcE();
}
void funcY(){
z.clear();
if(tmp.size()==0)return;
if(tmp[0]=='\n'){
while(t[y][x]!='\n'){
z.push_back(t[y][x]);
xdelete(y,x);
}
yinsert(y+1,z);
y++;
x=0;
return;
}
for(int i=0;i<(int)tmp.size();i++){
xinsert(y,x,tmp[i]);
}
//funcE();
}
void input(){
vector<char> a;
string str;
while(1){
getline(cin,str);
if(str=="END_OF_TEXT")break;
a.clear();
for(int i=0;i<(int)str.size();i++)
a.push_back(str[i]);
a.push_back('\n');
t.push_back(a);
}
} | /usr/bin/ld: /tmp/cchXCm8x.o: in function `funcD()':
a.cc:(.text+0x3c7): undefined reference to `xdelete(int, int)'
/usr/bin/ld: a.cc:(.text+0x406): undefined reference to `xdelete(int, int)'
/usr/bin/ld: a.cc:(.text+0x4ae): undefined reference to `ydelete(int)'
/usr/bin/ld: /tmp/cchXCm8x.o: in function `funcK()':
a.cc:(.text+0x5af): undefined reference to `xdelete(int, int)'
/usr/bin/ld: /tmp/cchXCm8x.o: in function `funcY()':
a.cc:(.text+0x6d6): undefined reference to `xdelete(int, int)'
/usr/bin/ld: a.cc:(.text+0x743): undefined reference to `yinsert(int, std::vector<char, std::allocator<char> >)'
/usr/bin/ld: a.cc:(.text+0x7a5): undefined reference to `xinsert(int, int, char)'
collect2: error: ld returned 1 exit status
|
s865606188 | p00607 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector< vector<char> > t,u;
vector<char> tmp;
vector<char> z;
char ch;
int x,y;
void input();
void funcA();
void funcE();
void funcP();
void funcN();
void funcF();
void funcB();
void funcD();
void funcK();
void funcY();
void yinsert(int,vector<char>);
void xinsert(int,int,char);
void ydelete(int);
void xdelete(int,int);
int main(){
t.clear();
tmp.clear();
input();
x=y=0;
while(1){
cin>>ch;
if(ch=='a')funcA();
else if(ch=='e')funcE();
else if(ch=='p')funcP();
else if(ch=='n')funcN();
else if(ch=='f')funcF();
else if(ch=='b')funcB();
else if(ch=='d')funcD();
else if(ch=='k')funcK();
else if(ch=='y')funcY();
else break;
//cout<<y<<' '<<x<<" ty"<<t.size()<<endl;
}
for(int i=0;i<t.size();i++){
for(int j=0;j<t[i].size();j++){
cout<<t[i][j];
}
}
return 0;
}
void funcA(){
x=0;
}
void funcE(){
x=t[y].size()-1;
}
void funcP(){
if(y>0)y--;
x=0;
}
void funcN(){
if(y+1<(int)t.size())y++;
x=0;
}
void funcF(){
if(x+1<(int)t[y].size())x++;
else if(y+1<(int)t.size()){y++;x=0;}
}
void funcB(){
if(x>0)x--;
else if(y>0){y--;x=t[y].size()-1;}
}
void funcD(){
if(t[y][x]!='\n'){
xdelete(y,x);
return;
}
if(y+1==(int)t.size())return;
xdelete(y,x);
for(int i=0;i<(int)t[y+1].size();i++)
t[y].push_back(t[y+1][i]);
ydelete(y+1);
}
void funcK(){
tmp.clear();
if(t[y][x]=='\n'){
if(y+1<(int)t.size()){
funcD();
tmp.push_back('\n');
}
return;
}
while(t[y][x]!='\n'){
tmp.push_back(t[y][x]);
xdelete(y,x);
}
reverse(tmp.begin(),tmp.end());
//funcE();
}
void funcY(){
vector<char> z;
if(tmp.size()==0)return;
if(tmp[0]=='\n'){
while(t[y][x]!='\n'){
z.push_back(t[y][x]);
xdelete(y,x);
}
yinsert(y+1,z);
y++;
x=0;
return;
}
for(int i=0;i<(int)tmp.size();i++){
xinsert(y,x,tmp[i]);
}
//funcE();
}
void input(){
vector<char> a;
string str;
while(1){
getline(cin,str);
if(str=="END_OF_TEXT")break;
a.clear();
for(int i=0;i<(int)str.size();i++)
a.push_back(str[i]);
a.push_back('\n');
t.push_back(a);
}
} | /usr/bin/ld: /tmp/cclyDZR9.o: in function `funcD()':
a.cc:(.text+0x3c7): undefined reference to `xdelete(int, int)'
/usr/bin/ld: a.cc:(.text+0x406): undefined reference to `xdelete(int, int)'
/usr/bin/ld: a.cc:(.text+0x4ae): undefined reference to `ydelete(int)'
/usr/bin/ld: /tmp/cclyDZR9.o: in function `funcK()':
a.cc:(.text+0x5af): undefined reference to `xdelete(int, int)'
/usr/bin/ld: /tmp/cclyDZR9.o: in function `funcY()':
a.cc:(.text+0x6d9): undefined reference to `xdelete(int, int)'
/usr/bin/ld: a.cc:(.text+0x743): undefined reference to `yinsert(int, std::vector<char, std::allocator<char> >)'
/usr/bin/ld: a.cc:(.text+0x7aa): undefined reference to `xinsert(int, int, char)'
collect2: error: ld returned 1 exit status
|
s471370590 | p00607 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector< vector<char> > t,u;
vector<char> tmp;
char ch;
int x,y;
void input();
void funcA();
void funcE();
void funcP();
void funcN();
void funcF();
void funcB();
void funcD();
void funcK();
void funcY();
void yinsert(int,vector<char>);
void xinsert(int,int,char);
void ydelete(int);
void xdelete(int,int);
int main(){
t.clear();
tmp.clear();
input();
x=y=0;
while(1){
cin>>ch;
if(ch=='a')funcA();
else if(ch=='e')funcE();
else if(ch=='p')funcP();
else if(ch=='n')funcN();
else if(ch=='f')funcF();
else if(ch=='b')funcB();
else if(ch=='d')funcD();
else if(ch=='k')funcK();
else if(ch=='y')funcY();
else break;
//cout<<y<<' '<<x<<" ty"<<t.size()<<endl;
}
for(int i=0;i<t.size();i++){
for(int j=0;j<t[i].size();j++){
cout<<t[i][j];
}
}
return 0;
}
void funcA(){
x=0;
}
void funcE(){
x=t[y].size()-1;
}
void funcP(){
if(y>0)y--;
x=0;
}
void funcN(){
if(y+1<(int)t.size())y++;
x=0;
}
void funcF(){
if(x+1<(int)t[y].size())x++;
else if(y+1<(int)t.size()){y++;x=0;}
}
void funcB(){
if(x>0)x--;
else if(y>0){y--;x=t[y].size()-1;}
}
void funcD(){
if(t[y][x]!='\n'){
xdelete(y,x);
return;
}
if(y+1==(int)t.size())return;
xdelete(y,x);
for(int i=0;i<(int)t[y+1].size();i++)
t[y].push_back(t[y+1][i]);
ydelete(y+1);
}
void funcK(){
if(t[y][x]=='\n'){
if(y+1<(int)t.size()){
funcD();
tmp.clear();
tmp.push_back('\n');
}
return;
}
tmp.clear();
while(t[y][x]!='\n'){
tmp.push_back(t[y][x]);
xdelete(y,x);
}
reverse(tmp.begin(),tmp.end());
}
void funcY(){
vector<char> z;
if(tmp.size()==0)return;
if(tmp[0]=='\n'){
while(t[y][x]!='\n'){
z.push_back(t[y][x]);
xdelete(y,x);
}
yinsert(y+1,z);
y++;
x=0;
return;
}
for(int i=0;i<(int)tmp.size();i++){
xinsert(y,x,tmp[i]);
}
x+=tmp.size();
//funcE();
}
void input(){
vector<char> a;
string str;
while(1){
getline(cin,str);
if(str=="END_OF_TEXT")break;
a.clear();
for(int i=0;i<(int)str.size();i++)
a.push_back(str[i]);
a.push_back('\n');
t.push_back(a);
}
} | /usr/bin/ld: /tmp/cc66aCe7.o: in function `funcD()':
a.cc:(.text+0x3c7): undefined reference to `xdelete(int, int)'
/usr/bin/ld: a.cc:(.text+0x406): undefined reference to `xdelete(int, int)'
/usr/bin/ld: a.cc:(.text+0x4ae): undefined reference to `ydelete(int)'
/usr/bin/ld: /tmp/cc66aCe7.o: in function `funcK()':
a.cc:(.text+0x5bc): undefined reference to `xdelete(int, int)'
/usr/bin/ld: /tmp/cc66aCe7.o: in function `funcY()':
a.cc:(.text+0x6e6): undefined reference to `xdelete(int, int)'
/usr/bin/ld: a.cc:(.text+0x750): undefined reference to `yinsert(int, std::vector<char, std::allocator<char> >)'
/usr/bin/ld: a.cc:(.text+0x7b7): undefined reference to `xinsert(int, int, char)'
collect2: error: ld returned 1 exit status
|
s322032816 | p00608 | Java | // AOJ 1022
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#define value first
#define p second
using namespace std;
typedef pair<int,int> result;
// {{{
const int OutOfIntExc = 1, NegIntExc = 2, NotEquationExc = 3,
NotNumExc = 4, LackNumExc = 5, IterExceedExc = 6,
IncorrectExc = 7;// }}}
//{{{
result equation(const string &s, int p = 0);
result expression(const string &s, int p = 0);
result factor(const string &s, int p = 0);
result term(const string &s, int p = 0);
// }}}
result equation(const string &s, int p) { // {{{
if (s[p] == '=') { throw NotEquationExc; }
result r = expression(s, p);
if (s[r.p] != '=') { throw NotEquationExc; }
r.p++;
result t = expression(s, r.p);
t.value = (int)(r.value == t.value);
return t;
} // }}}
result expression(const string &s, int p) { // {{{
result r = factor(s, p);
while (s[r.p] == '+' or s[r.p] == '-') {
result r_ = factor(s, r.p+1);
r.value += (s[r.p] == '+' ? r_.value : - r_.value);
if (r.value < 0) { throw NegIntExc; }
r.p = r_.p;
}
return r;
} // }}}
result factor(const string &s, int p) { // {{{
result r = term(s, p);
while (s[r.p] == '*' or s[r.p] == '/') {
result r_ = term(s, r.p+1);
if (s[r.p] == '*') {
r.value *= r_.value;
} else {
if (r_.value == 0 or r.value % r_.value != 0) {
throw OutOfIntExc;
}
r.value /= r_.value;
}
r.p = r_.p;
}
return r;
} // }}}
result term(const string &s, int p) { // {{{
if (not isdigit(s[p])) { throw LackNumExc; }
int value = 0;
bool flag = false;
while (isdigit(s[p])) {
if (flag and value == 0) { throw NotNumExc; }
flag = true;
value = value * 10 + (s[p++] - '0');
}
return result(value, p);
} // }}}
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define X first
#define Y second
int H, W, n;
const int HMAX = 200, WMAX = 200, NMAX = 200;
char table[HMAX][WMAX], block[NMAX];
typedef pair<int,int> P;
bool printed[HMAX][WMAX];
P blanks[NMAX];
bool operand_not_allowed[NMAX];
vector<P> vbegins, hbegins;
P vsolvables[NMAX], hsolvables[NMAX];
void init() { // {{{
vbegins.clear();
hbegins.clear();
REP(y, H) REP(x, W) {
printed[x][y] = false;
}
REP(i, n) {
operand_not_allowed[i] = false;
}
} // }}}
string tostr(P x) {
return "(" + to_string(x.first) + "," + to_string(x.second) + ")";
}
bool is_operand(char c) {
return c == '=' or c == '+' or c == '-' or c == '*' or c == '/';
}
bool operand_connected(string str) {
bool flag = true;
for (int i = 0, len = str.size(); i < len; i++) {
if (is_operand(str[i])) {
if (flag) return true;
flag = true;
} else {
flag = false;
}
}
return false;
}
bool incorrect(string str) {
// cout << "<" << str << ">" << endl;
return !operand_connected(str) and equation(str).value != 1;
}
bool legal(int x, int y) { // {{{
return 0 <= x and x < W and 0 <= y and y < H;
} // }}}
bool legal(P p) { return legal(p.X, p.Y); }
bool is_white_block(int x, int y) {
return legal(x, y) and table[x][y] != '#';
}
bool is_white_block(P p) {
return is_white_block(p.X, p.Y);
}
string getv(int x, int y) { // {{{
string str;
while (legal(x, y) and table[x][y] != '#') {
str.push_back(table[x][y]);
y++;
}
return str;
} // }}}
string getv(P p) { return getv(p.X, p.Y) ; }
string geth(int x, int y) { // {{{
string str;
while (legal(x, y) and table[x][y] != '#') {
str.push_back(table[x][y]);
x++;
}
return str;
} // }}}
string geth(P p) { return geth(p.X, p.Y) ; }
bool taboo_operand() {
REP(i, n) {
if (operand_not_allowed[i] and is_operand(block[i]))
return true;
}
return false;
}
bool solve() { // {{{
sort(block, block + n);
do {
if (taboo_operand()) continue;
try {
REP(i, n) {
P p = blanks[i];
table[p.X][p.Y] = block[i];
P q = vsolvables[i];
// cout << '#' << i << tostr(q) << getv(q) << endl;
if (legal(q) and incorrect(getv(q))) {
// cout << "!" << getv(q.first, q.second) << endl;
throw IncorrectExc;
}
q = hsolvables[i];
// cout << '#' << i << tostr(q) << geth(q) << endl;
if (legal(q) and incorrect(geth(q))) {
// cout << "?" << geth(q.first, q.second) << endl;
throw IncorrectExc;
}
}
for (P begin : vbegins) {
if (incorrect(getv(begin))) throw IncorrectExc;
}
for (P begin : hbegins) {
if (incorrect(geth(begin))) throw IncorrectExc;
}
return true;
} catch (int exc) {
continue;
}
} while (next_permutation(block, block + n));
return false;
} // }}}
P v_solvable(P p) { // {{{
string v = getv(p.X, p.Y + 1);
// cout << v << endl;
if (v.find(".", 0) == string::npos and
is_white_block(p.X, p.Y - 1)) {
int x = p.X, y = p.Y;
while (is_white_block(x,y)) y--;
return P(x, ++y);
} else {
return P(-1, -1);
}
} // }}}
P h_solvable(P p) { // {{{
string h = geth(p.X + 1, p.Y);
if (h.find(".", 0) == string::npos and
is_white_block(p.X - 1, p.Y)) {
int x = p.X, y = p.Y;
while (is_white_block(x,y)) x--;
return P(++x, y);
} else {
return P(-1, -1);
}
} // }}}
bool nearby_operand(P p) {
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
REP(i, 4) {
int nx = p.X + dx[i], ny = p.Y + dy[i];
if (is_operand(table[nx][ny])) return true;
}
return false;
}
bool is_vbeginner(P p) {
return is_white_block(p) and is_white_block(p.X, p.Y + 1)
and !is_white_block(p.X, p.Y - 1);
}
bool is_hbeginner(P p) {
return is_white_block(p) and is_white_block(p.X + 1, p.Y)
and !is_white_block(p.X-1, p.Y);
}
int main() {
while (cin >> H >> W and H + W) {
REP(y, H) { // {{{
string row;
cin >> row;
REP(x, W) {
table[x][y] = row[x];
printed[x][y] = row[x] != '.';
}
} // }}}
for (int i = 0, x = 0; x < W; x++) for (int y = 0; y < H; y++) {
if (table[x][y] == '.') {
blanks[i] = P(x, y);
i++;
}
}
cin >> n;
REP(i, n) { cin >> block[i]; }
init();
for (int i = 0; i < n; i++) {
vsolvables[i] = v_solvable(blanks[i]);
hsolvables[i] = h_solvable(blanks[i]);
// cout << tostr(vsolvables[i]) << getv(vsolvables[i]) << endl;
// cout << tostr(hsolvables[i]) << geth(hsolvables[i]) << endl;
operand_not_allowed[i] = nearby_operand(blanks[i]);
}
REP(y,H) REP(x,W) {
if (is_vbeginner(P(x,y))) { vbegins.push_back(P(x,y)); }
if (is_hbeginner(P(x,y))) { hbegins.push_back(P(x,y)); }
}
cout << (solve() ? "Yes" : "No") << endl;
}
}
// vim: set foldmethod=marker : | Main.java:2: error: illegal character: '#'
#include<iostream>
^
Main.java:3: error: illegal character: '#'
#include<string>
^
Main.java:4: error: illegal character: '#'
#include<map>
^
Main.java:5: error: illegal character: '#'
#include<algorithm>
^
Main.java:6: error: illegal character: '#'
#include<vector>
^
Main.java:7: error: illegal character: '#'
#define value first
^
Main.java:8: error: illegal character: '#'
#define p second
^
Main.java:10: error: class, interface, enum, or record expected
typedef pair<int,int> result;
^
Main.java:13: error: class, interface, enum, or record expected
const int OutOfIntExc = 1, NegIntExc = 2, NotEquationExc = 3,
^
Main.java:18: error: unnamed classes are a preview feature and are disabled by default.
result equation(const string &s, int p = 0);
^
(use --enable-preview to enable unnamed classes)
Main.java:18: error: illegal start of type
result equation(const string &s, int p = 0);
^
Main.java:18: error: ';' expected
result equation(const string &s, int p = 0);
^
Main.java:19: error: illegal start of type
result expression(const string &s, int p = 0);
^
Main.java:19: error: ';' expected
result expression(const string &s, int p = 0);
^
Main.java:20: error: illegal start of type
result factor(const string &s, int p = 0);
^
Main.java:20: error: ';' expected
result factor(const string &s, int p = 0);
^
Main.java:21: error: illegal start of type
result term(const string &s, int p = 0);
^
Main.java:21: error: ';' expected
result term(const string &s, int p = 0);
^
Main.java:24: error: illegal start of type
result equation(const string &s, int p) { // {{{
^
Main.java:24: error: class, interface, enum, or record expected
result equation(const string &s, int p) { // {{{
^
Main.java:25: error: class, interface, enum, or record expected
if (s[p] == '=') { throw NotEquationExc; }
^
Main.java:27: error: class, interface, enum, or record expected
if (s[r.p] != '=') { throw NotEquationExc; }
^
Main.java:27: error: class, interface, enum, or record expected
if (s[r.p] != '=') { throw NotEquationExc; }
^
Main.java:31: error: class, interface, enum, or record expected
t.value = (int)(r.value == t.value);
^
Main.java:33: error: class, interface, enum, or record expected
return t;
^
Main.java:34: error: class, interface, enum, or record expected
} // }}}
^
Main.java:38: error: class, interface, enum, or record expected
while (s[r.p] == '+' or s[r.p] == '-') {
^
Main.java:40: error: class, interface, enum, or record expected
r.value += (s[r.p] == '+' ? r_.value : - r_.value);
^
Main.java:41: error: class, interface, enum, or record expected
if (r.value < 0) { throw NegIntExc; }
^
Main.java:41: error: class, interface, enum, or record expected
if (r.value < 0) { throw NegIntExc; }
^
Main.java:43: error: class, interface, enum, or record expected
}
^
Main.java:45: error: class, interface, enum, or record expected
} // }}}
^
Main.java:49: error: class, interface, enum, or record expected
while (s[r.p] == '*' or s[r.p] == '/') {
^
Main.java:51: error: class, interface, enum, or record expected
if (s[r.p] == '*') {
^
Main.java:53: error: class, interface, enum, or record expected
} else {
^
Main.java:56: error: class, interface, enum, or record expected
}
^
Main.java:58: error: class, interface, enum, or record expected
}
^
Main.java:60: error: class, interface, enum, or record expected
}
^
Main.java:62: error: class, interface, enum, or record expected
} // }}}
^
Main.java:65: error: class, interface, enum, or record expected
if (not isdigit(s[p])) { throw LackNumExc; }
^
Main.java:69: error: class, interface, enum, or record expected
while (isdigit(s[p])) {
^
Main.java:70: error: class, interface, enum, or record expected
if (flag and value == 0) { throw NotNumExc; }
^
Main.java:72: error: class, interface, enum, or record expected
value = value * 10 + (s[p++] - '0');
^
Main.java:73: error: class, interface, enum, or record expected
}
^
Main.java:75: error: class, interface, enum, or record expected
} // }}}
^
Main.java:77: error: illegal character: '#'
#define REP(i,n) for(int i=0;i<(int)(n);i++)
^
Main.java:77: error: class, interface, enum, or record expected
#define REP(i,n) for(int i=0;i<(int)(n);i++)
^
Main.java:77: error: class, interface, enum, or record expected
#define REP(i,n) for(int i=0;i<(int)(n);i++)
^
Main.java:78: error: illegal character: '#'
#define X first
^
Main.java:79: error: illegal character: '#'
#define Y second
^
Main.java:81: error: class, interface, enum, or record expected
const int HMAX = 200, WMAX = 200, NMAX = 200;
^
Main.java:82: error: class, interface, enum, or record expected
char table[HMAX][WMAX], block[NMAX];
^
Main.java:84: error: class, interface, enum, or record expected
typedef pair<int,int> P;
^
Main.java:85: error: class, interface, enum, or record expected
bool printed[HMAX][WMAX];
^
Main.java:86: error: class, interface, enum, or record expected
P blanks[NMAX];
^
Main.java:87: error: class, interface, enum, or record expected
bool operand_not_allowed[NMAX];
^
Main.java:88: error: class, interface, enum, or record expected
vector<P> vbegins, hbegins;
^
Main.java:89: error: class, interface, enum, or record expected
P vsolvables[NMAX], hsolvables[NMAX];
^
Main.java:95: error: ';' expected
REP(y, H) REP(x, W) {
^
Main.java:95: error: ';' expected
REP(y, H) REP(x, W) {
^
Main.java:99: error: ';' expected
REP(i, n) {
^
Main.java:109: error: ';' expected
return c == '=' or c == '+' or c == '-' or c == '*' or c == '/';
^
Main.java:109: error: ';' expected
return c == '=' or c == '+' or c == '-' or c == '*' or c == '/';
^
Main.java:109: error: ';' expected
return c == '=' or c == '+' or c == '-' or c == '*' or c == '/';
^
Main.java:109: error: ';' expected
return c == '=' or c == '+' or c == '-' or c == '*' or c == '/';
^
Main.java:109: error: ';' expected
return c == '=' or c == '+' or c == '-' or c == '*' or c == '/';
^
Main.java:127: error: not a statement
return !operand_connected(str) and equation(str).value != 1;
^
Main.java:127: error: not a statement
return !operand_connected(str) and equation(str).value != 1;
^
Main.java:127: error: ';' expected
return !operand_connected(str) and equation(str).value != 1;
^
Main.java:127: error: ';' expected
return !operand_connected(str) and equation(str).value != 1;
^
Main.java:127: error: ';' expected
return !operand_connected(str) and equation(str).value != 1;
^
Main.java:131: error: not a statement
return 0 <= x and x < W and 0 <= y and y < H;
^
Main.java:131: error: not a statement
return 0 <= x and x < W and 0 <= y and y < H;
^
Main.java:131: error: ';' expected
return 0 <= x and x < W and 0 <= y and y < H;
^
Main.java:131: error: ';' expected
return 0 <= x and x < W and 0 <= y and y < H;
^
Main.java:131: error: ';' expected
return 0 <= x and x < W and 0 <= y and y < H;
^
Main.java:131: error: ';' expected
return 0 <= x and x < W and 0 <= y and y < H;
^
Main.java:131: error: > or ',' expected
return 0 <= x and x < W and 0 <= y and y < H;
^
Main.java:137: error: not a statement
return legal(x, y) and table[x][y] != '#';
^
Main.java:137: error: not a statement
return legal(x, y) and table[x][y] != '#';
^
Main.java:137: error: ';' expected
return legal(x, y) and table[x][y] != '#';
^
Main.java:137: error: ';' expected
return legal(x, y) and table[x][y] != '#';
^
Main.java:137: error: ';' expected
return legal(x, y) and table[x][y] != '#';
^
Main.java:146: error: variable declaration not allowed here
while (legal(x, y) and table[x][y] != '#') {
^
Main.java:146: error: not a statement
while (legal(x, y) and table[x][y] != '#') {
^
Main.java:146: error: not a statement
while (legal(x, y) and table[x][y] != '#') {
^
Main.java:146: error: ')' expected
while (legal(x, y) and table[x][y] != '#') {
^
Main.java:146: error: ';' expected
while (legal(x, y) and table[x][y] != '#') {
^
Main.java:146: error: ';' expected
while (legal(x, y) and table[x][y] != '#') {
^
Main.java:157: error: variable declaration not allowed here
while (legal(x, y) and table[x][y] != '#') {
^
Main.java:157: error: not a statement
while (legal(x, y) and table[x][y] != '#') {
^
Main.java:157: error: not a statement
while (legal(x, y) and table[x][y] != '#') {
^
Main.java:157: error: ')' expected
while (legal(x, y) and table[x][y] != '#') {
^
Main.java:157: error: ';' expected
while (legal(x, y) and table[x][y] != '#') {
|
s325836820 | p00608 | Java | aimport java.io.*;
import java.util.*;
import java.math.*;
public class Main{
public static void main(String[] arg) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String[] ia;
while(true){
ia = in.readLine().split(" ");
H = Integer.parseInt(ia[0]);
W = Integer.parseInt(ia[1]);
if(H == 0 && W == 0){
break;
}
prob1 = new char[H][W];
prob2 = new char[W][H];
for(int i = 0;i < H; ++i){
prob1[i] = in.readLine().toCharArray();
}
n = Integer.parseInt(in.readLine());
cont = new char[n];
ia = in.readLine().split(" ");
on = 0;
for(int i = 0;i < n; ++i){
cont[i] = ia[i].charAt(0);
if(cont[i] == '-' || cont[i] == '+' || cont[i] == '*' || cont[i] == '/'){
++on;
}
}
Arrays.sort(cont);
con = new int[n][2];
co = new boolean[n];
os = new boolean[n];
boolean cs = true;
int c = 0;
for(int i = 0;i < H; ++i){
for(int j = 0;j < W; ++j){
if((prob2[j][i] = prob1[i][j]) == '.'){
con[c][0] = i;
con[c][1] = j;
++c;
}
}
}
if(c != n){
cs = false;
}
osc = 0;
for(int i = 0;i < n; ++i){
os[i] = sfos(con[i][0],con[i][1]);
}
if(cs && solv(0)){
System.out.println("Yes");
} else {
System.out.println("No");
}
}
}
static int H;
static int W;
static char[][] prob1;
static char[][] prob2;
static int n;
static char[] cont;
static int[][] con;
static boolean[] co;
static boolean[] os;
static int osc;
static int ss;
static int on;
static boolean sfos(int a, int b){
if(0 < a && a < H){
if(!(prob1[a-1][b] == '.' || prob1[a-1][b] == '#' ||
(0 <= (prob1[a-1][b] - '0') && (prob1[a-1][b] - '0') < 10))){
return false;
}
}
if(0 <= a && a < H-1){
if(!(prob1[a+1][b] == '.' || prob1[a+1][b] == '#' ||
(0 <= (prob1[a+1][b] - '0') && (prob1[a+1][b] - '0') < 10))){
return false;
}
}
if(0 < b && b < W){
if(!(prob1[a][b-1] == '.' || prob1[a][b-1] == '#' ||
(0 <= (prob1[a][b-1] - '0') && (prob1[a][b-1] - '0') < 10))){
return false;
}
}
if(0 <= b && b < W-1){
if(!(prob1[a][b+1] == '.' || prob1[a][b+1] == '#' ||
(0 <= (prob1[a][b+1] - '0') && (prob1[a][b+1] - '0') < 10))){
return false;
}
}
++osc;
return true;
}
static boolean solv(int c){
if(c == on){
return solve(c);
}
for(int i = 0;i < n; ++i){
if(os[i] && !co[i]){
co[i] = true;
prob1[con[i][0]][con[i][1]] = cont[c];
prob2[con[i][1]][con[i][0]] = cont[c];
if(solv(c+1)){
return true;
}
co[i] = false;
}
}
return false;
}
static boolean solve(int c){
char b = 'n';
if(c == n){
return ca();
}
for(int i = 0;i < n; ++i){
if(!co[i] && cont[i] != b){
b = cont[i];
co[i] = true;
prob1[con[i][0]][con[i][1]] = cont[c];
prob2[con[i][1]][con[i][0]] = cont[c];
if(solve(c+1)){
return true;
}
co[i] = false;
}
}
return false;
}
static boolean ca(){
for(int i = 0;i < H; ++i){
if(!cal(prob1[i])){
return false;
}
}
for(int i = 0;i < W; ++i){
if(!cal(prob2[i])){
return false;
}
}
return true;
}
static boolean cal(char[] s){
int b=0,i,j;
boolean flag = true;
while(b < s.length){
for(i = b;i < s.length; ++i){
if(s[i] == '='){
break;
}
}
for(j = b;j < s.length; ++j){
if(s[j] == '#'){
break;
}
}
if(j-b > 2){
if(i != s.length){
flag = flag && (calc(s,b,i) == calc(s,i+1,j));
} else {
return false;
}
}
b = j+1;
}
return flag;
}
static int calc(char[] s, Integer t, Integer e){
int x = 0;
int t1 = 0;
if(e-t==0){
return -100000;
}
for(int i = t;t < e; ++t){
if(0 < s[t]-'0' && s[t]-'0'<10){
t1 = t1*10+s[t]-'0';
} else if(s[t] == '+'){
return calc(s,i,new Integer(t)) + calc(s,++t,e);
} else if(s[t] == '-'){
return calc(s,i,new Integer(t)) - calc(s,++t,e);
} else if(s[t] == '*'){
t1 *= calc(s,++t,e);
} else if(s[t] == '/'){
try{
t1 /= calc(s,++t,e);
} catch(ArithmeticException f){
return -100000;
}
break;
}
}
return t1;
}
} | Main.java:1: error: class, interface, enum, or record expected
aimport java.io.*;
^
Main.java:2: error: class, interface, enum, or record expected
import java.util.*;
^
Main.java:3: error: class, interface, enum, or record expected
import java.math.*;
^
3 errors
|
s199459531 | p00608 | C++ | // AOJ 1022
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#define value first
#define p second
using namespace std;
typedef pair<int,int> result;
const int OutOfIntExc = 1,
NegIntExc = 2,
NotEquationExc = 3,
NotNumExc = 4,
NotMultExc = 5;
result equation(const string &s, int p = 0);
result expression(const string &s, int p = 0);
result factor(const string &s, int p = 0);
result term(const string &s, int p = 0);
result equation(const string &s, int p) {
cout << "? " << s << " ";
if (s[p] == '=') { throw NotEquationExc; }
result r = expression(s, p);
if (s[r.p] != '=') { throw NotEquationExc; }
r.p++; // skip '=';
result t = expression(s, r.p);
t.value = (int)(r.value == t.value);
cout << (t.value ? "T" : "F") << endl;
return t;
}
result expression(const string &s, int p) {
result r = factor(s, p);
while (s[r.p] == '+' or s[r.p] == '-') {
result r_ = factor(s, r.p+1);
cout << "r_:" << r.value << "," << r_
r.value += (s[r.p] == '+' ? r_.value : - r_.value);
if (r.value < 0) { throw NegIntExc; }
r.p = r_.p;
}
return r;
}
result factor(const string &s, int p) {
result r = term(s, p);
while (s[r.p] == '*' or s[r.p] == '/') {
result r_ = term(s, r.p+1);
if (s[r.p] == '*') {
r.value *= r_.value;
} else {
if (r_.value == 0 or r.value % r_.value != 0) {
throw OutOfIntExc;
}
r.value /= r_.value;
}
r.p = r_.p;
}
return r;
}
result term(const string &s, int p) {
int value = 0;
bool flag = false;
while (isdigit(s[p])) {
if (flag and value == 0) {
throw NotNumExc;
}
flag = true;
value = value * 10 + (s[p++] - '0');
}
return result(value, p);
}
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int H, W, n;
const int HMAX = 14, WMAX = 14, NMAX = 15;
char TABLE[HMAX][WMAX];
bool PRINTED[HMAX][WMAX], HBEGIN[HMAX][WMAX], VBEGIN[HMAX][WMAX];
char BLOCK[NMAX];
void init() {
REP(y, H) REP(x, W) {
PRINTED[x][y] = false;
HBEGIN[x][y] = false;
VBEGIN[x][y] = false;
}
}
bool legal(int x, int y) {
return 0 <= x and x < W and 0 <= y and y < H;
}
void fill_blank() {
int i = 0;
REP(y, H) REP(x, W) {
if (i == n) return;
if (not PRINTED[x][y]) {
TABLE[x][y] = BLOCK[i++];
}
}
}
string getv(int x, int y) {
string str;
while (legal(x, y) and TABLE[x][y] != '#') {
str.push_back(TABLE[x][y]);
y++;
}
return str;
}
string geth(int x, int y) {
string str;
while (legal(x, y) and TABLE[x][y] != '#') {
str.push_back(TABLE[x][y]);
x++;
}
return str;
}
bool solved() {
REP(y, H) REP(x, W) {
if (not HBEGIN[x][y]) continue;
string eq = geth(x, y);
try {
result e = equation(eq);
if (e.value == 0) { return false; }
} catch (int ex) {
return false;
}
}
REP(y, H) REP(x, W) {
if (not VBEGIN[x][y]) continue;
string eq = getv(x, y);
result e = equation(eq);
if (e.value == 0) { return false; }
}
return true;
}
bool solve() {
sort(BLOCK, BLOCK + n);
do {
fill_blank();
REP(y, H) {
REP(x, W) {
cout << TABLE[x][y];
}
cout << endl;
}
if (solved()) { return true; }
} while (next_permutation(BLOCK, BLOCK + n));
}
int main() {
while (cin >> H >> W and H + W) {
init();
REP(y, H) {
string row;
cin >> row;
REP(x, W) {
TABLE[x][y] = row[x];
PRINTED[x][y] = row[x] != '.';
}
}
REP(y, H) REP(x, W) {
if (TABLE[x][y]!='#' and legal(x+1,y) and TABLE[x+1][y]!='#'
and (!legal(x-1,y) or TABLE[x-1][y] == '#')) {
HBEGIN[x][y] = true;
}
if (TABLE[x][y]!='#' and legal(x,y+1) and TABLE[x][y+1]!='#'
and (!legal(x,y-1) or TABLE[x][y-1] == '#')) {
VBEGIN[x][y] = true;
}
}
cin >> n;
REP(i, n) { cin >> BLOCK[i]; }
cout << (solve() ? "Yes" : "No") << endl;
}
} | a.cc: In function 'result expression(const std::string&, int)':
a.cc:42:37: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and 'result' {aka 'std::pair<int, int>'})
42 | cout << "r_:" << r.value << "," << r_
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~
| | |
| | result {aka std::pair<int, int>}
| std::basic_ostream<char>
In file included from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from 'result' {aka 'std::pair<int, int>'} to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]'
306 | operator<<(nullptr_t)
| |
s342179824 | p00608 | C++ | // AOJ 1022
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#define value first
#define p second
using namespace std;
typedef pair<int,int> result;
const int OutOfIntExc = 1,
NegIntExc = 2,
NotEquationExc = 3,
NotNumExc = 4,
LackNumExc = 5,
IterExceedExc = 6;
result equation(const string &s, int p = 0);
result expression(const string &s, int p = 0);
result factor(const string &s, int p = 0);
result term(const string &s, int p = 0);
result equation(const string &s, int p) {
// cout << "? " << s << " ";
if (s[p] == '=') { throw NotEquationExc; }
result r = expression(s, p);
if (s[r.p] != '=') { throw NotEquationExc; }
r.p++; // skip '=';
result t = expression(s, r.p);
t.value = (int)(r.value == t.value);
// cout << (t.value ? "T" : "F") << endl;
return t;
}
result expression(const char* &s, int p) {
result r = factor(s, p);
while (s[r.p] == '+' or s[r.p] == '-') {
result r_ = factor(s, r.p+1);
r.value += (s[r.p] == '+' ? r_.value : - r_.value);
if (r.value < 0) { throw NegIntExc; }
r.p = r_.p;
}
return r;
}
result factor(const char* &s, int p) {
result r = term(s, p);
while (s[r.p] == '*' or s[r.p] == '/') {
result r_ = term(s, r.p+1);
if (s[r.p] == '*') {
r.value *= r_.value;
} else {
if (r_.value == 0 or r.value % r_.value != 0) {
throw OutOfIntExc;
}
r.value /= r_.value;
}
r.p = r_.p;
}
return r;
}
result term(const char* &s, int p) {
if (not isdigit(s[p])) { throw LackNumExc; }
int value = 0;
bool flag = false;
while (isdigit(s[p])) {
if (flag and value == 0) { throw NotNumExc; }
flag = true;
value = value * 10 + (s[p++] - '0');
}
return result(value, p);
}
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int H, W, n;
const int HMAX = 200, WMAX = 200, NMAX = 200;
char TABLE[HMAX][WMAX];
bool PRINTED[HMAX][WMAX], HBEGIN[HMAX][WMAX], VBEGIN[HMAX][WMAX];
char BLOCK[NMAX];
void init() {
REP(y, H) REP(x, W) {
PRINTED[x][y] = false;
HBEGIN[x][y] = false;
VBEGIN[x][y] = false;
}
}
bool legal(int x, int y) {
return 0 <= x and x < W and 0 <= y and y < H;
}
void fill_blank() {
int i = 0;
REP(y, H) REP(x, W) {
if (i == n) return;
if (not PRINTED[x][y]) {
TABLE[x][y] = BLOCK[i++];
}
}
}
string getv(int x, int y) {
string str;
while (legal(x, y) and TABLE[x][y] != '#') {
str.push_back(TABLE[x][y]);
y++;
}
return str;
}
string geth(int x, int y) {
string str;
while (legal(x, y) and TABLE[x][y] != '#') {
str.push_back(TABLE[x][y]);
x++;
}
return str;
}
bool is_operand(char c) {
return c == '=' or c == '+' or c == '-' or c == '*' or c == '/';
}
bool is_illegal_operand() {
REP(y, H) REP(x, W) {
if (PRINTED[x][y]) continue;
if (not is_operand(TABLE[x][y])) continue;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
REP(i, 4) {
int nx = x + dx[i], ny = y + dy[i];
if (legal(nx, ny) and is_operand(TABLE[nx][ny])) {
return true;
}
}
}
REP(y, H) REP(x,W) {
if ((VBEGIN[x][y] or HBEGIN[x][y]) and is_operand(TABLE[x][y])) {
return true;
}
}
return false;
}
bool solved() {
REP(y, H) REP(x, W) {
if (not HBEGIN[x][y]) continue;
string eq = geth(x, y);
try {
result e = equation(eq);
if (e.value == 0) { return false; }
} catch (int ex) {
return false;
}
}
REP(y, H) REP(x, W) {
if (not VBEGIN[x][y]) continue;
string eq = getv(x, y);
try {
result e = equation(eq);
if (e.value == 0) { return false; }
} catch(int ex) {
return false;
}
}
return true;
}
bool solve() {
sort(BLOCK, BLOCK + n);
do {
fill_blank();
/* REP(y, H) {
REP(x, W) {
cout << TABLE[x][y];
}
cout << endl;
}*/
if (is_illegal_operand()) continue;
if (solved()) { return true; }
} while (next_permutation(BLOCK, BLOCK + n));
}
int main() {
while (cin >> H >> W and H + W) {
init();
REP(y, H) {
string row;
cin >> row;
REP(x, W) {
TABLE[x][y] = row[x];
PRINTED[x][y] = row[x] != '.';
}
}
REP(y, H) REP(x, W) {
if (TABLE[x][y]!='#' and legal(x+1,y) and TABLE[x+1][y]!='#'
and (!legal(x-1,y) or TABLE[x-1][y] == '#')) {
HBEGIN[x][y] = true;
}
if (TABLE[x][y]!='#' and legal(x,y+1) and TABLE[x][y+1]!='#'
and (!legal(x,y-1) or TABLE[x][y-1] == '#')) {
VBEGIN[x][y] = true;
}
}
cin >> n;
REP(i, n) { cin >> BLOCK[i]; }
cout << (solve() ? "Yes" : "No") << endl;
}
} | a.cc: In function 'bool solve()':
a.cc:190:1: warning: control reaches end of non-void function [-Wreturn-type]
190 | }
| ^
/usr/bin/ld: /tmp/ccmbA8kc.o: in function `equation(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
a.cc:(.text+0x64): undefined reference to `expression(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/usr/bin/ld: a.cc:(.text+0xca): undefined reference to `expression(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/usr/bin/ld: /tmp/ccmbA8kc.o: in function `expression(char const*&, int)':
a.cc:(.text+0x139): undefined reference to `factor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/usr/bin/ld: a.cc:(.text+0x19c): undefined reference to `factor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/usr/bin/ld: /tmp/ccmbA8kc.o: in function `factor(char const*&, int)':
a.cc:(.text+0x32e): undefined reference to `term(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/usr/bin/ld: a.cc:(.text+0x391): undefined reference to `term(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
collect2: error: ld returned 1 exit status
|
s568912463 | p00608 | C++ | // AOJ 1022
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#define value first
#define p second
using namespace std;
typedef pair<int,int> result;
const int OutOfIntExc = 1,
NegIntExc = 2,
NotEquationExc = 3,
NotNumExc = 4,
LackNumExc = 5,
IterExceedExc = 6;
result equation(const string &s, int p = 0);
result expression(const string &s, int p = 0);
result factor(const string &s, int p = 0);
result term(const string &s, int p = 0);
result equation(const string &s, int p) { // {{{
if (s[p] == '=') { throw NotEquationExc; }
result r = expression(s, p);
if (s[r.p] != '=') { throw NotEquationExc; }
r.p++;
result t = expression(s, r.p);
t.value = (int)(r.value == t.value);
return t;
} // }}}
result expression(const string &s, int p) { // {{{
result r = factor(s, p);
while (s[r.p] == '+' or s[r.p] == '-') {
result r_ = factor(s, r.p+1);
r.value += (s[r.p] == '+' ? r_.value : - r_.value);
if (r.value < 0) { throw NegIntExc; }
r.p = r_.p;
}
return r;
} // }}}
result factor(const string &s, int p) { // {{{
result r = term(s, p);
while (s[r.p] == '*' or s[r.p] == '/') {
result r_ = term(s, r.p+1);
if (s[r.p] == '*') {
r.value *= r_.value;
} else {
if (r_.value == 0 or r.value % r_.value != 0) {
throw OutOfIntExc;
}
r.value /= r_.value;
}
r.p = r_.p;
}
return r;
} // }}}
result term(const string &s, int p) { // {{{
if (not isdigit(s[p])) { throw LackNumExc; }
int value = 0;
bool flag = false;
while (isdigit(s[p])) {
if (flag and value == 0) { throw NotNumExc; }
flag = true;
value = value * 10 + (s[p++] - '0');
}
return result(value, p);
} // }}}
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int H, W, n;
const int HMAX = 200, WMAX = 200, NMAX = 200;
char TABLE[HMAX][WMAX];
bool PRINTED[HMAX][WMAX], HBEGIN[HMAX][WMAX], VBEGIN[HMAX][WMAX];
char BLOCK[NMAX];
pair<int,int> BLANKS[NMAX];
bool legal(int x, int y) {
return 0 <= x and x < W and 0 <= y and y < H;
}
string getv(int x, int y) { // {{{
string str;
while (legal(x, y) and TABLE[x][y] != '#') {
str.push_back(TABLE[x][y]);
y++;
}
return str;
} // }}}
string geth(int x, int y) { // {{{
string str;
while (legal(x, y) and TABLE[x][y] != '#') {
str.push_back(TABLE[x][y]);
x++;
}
return str;
} // }}}
bool is_operand(char c) {
return c == '=' or c == '+' or c == '-' or c == '*' or c == '/';
}
bool is_illegal_operand() {
REP(y, H) REP(x, W) {
if (PRINTED[x][y]) continue;
if (not is_operand(TABLE[x][y])) continue;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
REP(i, 4) {
int nx = x + dx[i], ny = y + dy[i];
if (legal(nx, ny) and is_operand(TABLE[nx][ny])) {
return true;
}
}
}
REP(y, H) REP(x,W) {
if ((VBEGIN[x][y] or HBEGIN[x][y]) and is_operand(TABLE[x][y])) {
return true;
}
}
return false;
}
int hbadx, hbady, vbadx, vbady;
bool hbadflag, vbadflag;
string hbadeq, vbadeq;
bool solved() {
if (hbadflag and geth(hbadx, hbady) == hbadeq) return false;
if (vbadflag and geth(vbadx, vbady) == vbadeq) return false;
REP(y, H) REP(x, W) {
if (not HBEGIN[x][y]) continue;
string eq = geth(x, y);
try {
result e = equation(eq);
if (e.value == 0) {
hbadflag = true;
hbadx = x, hbady = y;
hbadeq = eq;
return false;
}
} catch (int ex) {
hbadflag = true;
hbadx = x, hbady = y;
hbadeq = eq;
return false;
}
}
REP(y, H) REP(x, W) {
if (not VBEGIN[x][y]) continue;
string eq = getv(x, y);
try {
result e = equation(eq);
if (e.value == 0) {
vbadflag = true;
vbadx = x, vbady = y;
vbadeq = eq;
return false;
}
} catch(int ex) {
vbadflag = true;
vbadx = x, vbady = y;
vbadeq = eq;
return false;
}
}
return true;
}
bool solve() {
sort(BLOCK, BLOCK + n);
do {
try {
for (int i = 0; i < n; i++) {
TABLE[BLANKS[i].first][BLANKS[i].second] = BLOCK[i];
if (VSOLVABLE[i] and incorrect
}
}
} catch (int ex) {
continue;
}
} while (next_permutation(BLOCK, BLOCK + n));
return false;
}
void init() {
REP(y, H) REP(x, W) {
hbadflag = vbadflag = false;
PRINTED[x][y] = false;
HBEGIN[x][y] = false;
VBEGIN[x][y] = false;
}
}
int main() {
while (cin >> H >> W and H + W) {
init();
REP(y, H) {
string row;
cin >> row;
REP(x, W) {
TABLE[x][y] = row[x];
PRINTED[x][y] = row[x] != '.';
}
}
int idx = 0;
REP(y, H) REP(x, W) {
if (TABLE[x][y]!='#' and legal(x+1,y) and TABLE[x+1][y]!='#'
and (!legal(x-1,y) or TABLE[x-1][y] == '#')) {
HBEGIN[x][y] = true;
}
if (TABLE[x][y]!='#' and legal(x,y+1) and TABLE[x][y+1]!='#'
and (!legal(x,y-1) or TABLE[x][y-1] == '#')) {
VBEGIN[x][y] = true;
}
if (not PRINTED[x][y]) {
BLANKS[idx] = make_pair(x, y);
idx++;
}
}
cin >> n;
REP(i, n) { cin >> BLOCK[i]; }
cout << (solve() ? "Yes" : "No") << endl;
}
}
// vim: set foldmethod=marker : | a.cc: In function 'bool solve()':
a.cc:185:13: error: 'VSOLVABLE' was not declared in this scope
185 | if (VSOLVABLE[i] and incorrect
| ^~~~~~~~~
a.cc:185:30: error: 'incorrect' was not declared in this scope
185 | if (VSOLVABLE[i] and incorrect
| ^~~~~~~~~
a.cc:185:39: error: expected ')' before '}' token
185 | if (VSOLVABLE[i] and incorrect
| ~ ^
| )
186 | }
| ~
a.cc:186:9: error: expected primary-expression before '}' token
186 | }
| ^
a.cc:188:5: error: expected 'catch' before '}' token
188 | } catch (int ex) {
| ^
a.cc:188:5: error: expected '(' before '}' token
188 | } catch (int ex) {
| ^
| (
a.cc:188:5: error: expected type-specifier before '}' token
a.cc:187:8: error: expected ')' before '}' token
187 | }
| ^
| )
188 | } catch (int ex) {
| ~
a.cc:188:5: error: expected '{' before '}' token
188 | } catch (int ex) {
| ^
a.cc:188:13: error: expected 'while' before '(' token
188 | } catch (int ex) {
| ^
a.cc:188:14: error: expected primary-expression before 'int'
188 | } catch (int ex) {
| ^~~
a.cc:188:14: error: expected ')' before 'int'
188 | } catch (int ex) {
| ~^~~
| )
a.cc:188:14: error: expected ';' before 'int'
188 | } catch (int ex) {
| ^~~
| ;
a.cc:188:20: error: expected initializer before ')' token
188 | } catch (int ex) {
| ^
a.cc:191:3: warning: no return statement in function returning non-void [-Wreturn-type]
191 | } while (next_permutation(BLOCK, BLOCK + n));
| ^
a.cc: At global scope:
a.cc:191:5: error: expected unqualified-id before 'while'
191 | } while (next_permutation(BLOCK, BLOCK + n));
| ^~~~~
a.cc:192:3: error: expected unqualified-id before 'return'
192 | return false;
| ^~~~~~
a.cc:193:1: error: expected declaration before '}' token
193 | }
| ^
|
s490999545 | p00608 | C++ | // AOJ 1022
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#define value first
#define p second
using namespace std;
typedef pair<int,int> result;
const int OutOfIntExc = 1,
NegIntExc = 2,
NotEquationExc = 3,
NotNumExc = 4,
LackNumExc = 5,
IterExceedExc = 6;
result equation(const string &s, int p = 0);
result expression(const string &s, int p = 0);
result factor(const string &s, int p = 0);
result term(const string &s, int p = 0);
result equation(const string &s, int p) { // {{{
if (s[p] == '=') { throw NotEquationExc; }
result r = expression(s, p);
if (s[r.p] != '=') { throw NotEquationExc; }
r.p++;
result t = expression(s, r.p);
t.value = (int)(r.value == t.value);
return t;
} // }}}
result expression(const string &s, int p) { // {{{
result r = factor(s, p);
while (s[r.p] == '+' or s[r.p] == '-') {
result r_ = factor(s, r.p+1);
r.value += (s[r.p] == '+' ? r_.value : - r_.value);
if (r.value < 0) { throw NegIntExc; }
r.p = r_.p;
}
return r;
} // }}}
result factor(const string &s, int p) { // {{{
result r = term(s, p);
while (s[r.p] == '*' or s[r.p] == '/') {
result r_ = term(s, r.p+1);
if (s[r.p] == '*') {
r.value *= r_.value;
} else {
if (r_.value == 0 or r.value % r_.value != 0) {
throw OutOfIntExc;
}
r.value /= r_.value;
}
r.p = r_.p;
}
return r;
} // }}}
result term(const string &s, int p) { // {{{
if (not isdigit(s[p])) { throw LackNumExc; }
int value = 0;
bool flag = false;
while (isdigit(s[p])) {
if (flag and value == 0) { throw NotNumExc; }
flag = true;
value = value * 10 + (s[p++] - '0');
}
return result(value, p);
} // }}}
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int H, W, n;
const int HMAX = 200, WMAX = 200, NMAX = 200;
char TABLE[HMAX][WMAX];
bool PRINTED[HMAX][WMAX], HBEGIN[HMAX][WMAX], VBEGIN[HMAX][WMAX];
char BLOCK[NMAX];
pair<int,int> BLANKS[NMAX];
bool legal(int x, int y) {
return 0 <= x and x < W and 0 <= y and y < H;
}
string getv(int x, int y) { // {{{
string str;
while (legal(x, y) and TABLE[x][y] != '#') {
str.push_back(TABLE[x][y]);
y++;
}
return str;
} // }}}
string geth(int x, int y) { // {{{
string str;
while (legal(x, y) and TABLE[x][y] != '#') {
str.push_back(TABLE[x][y]);
x++;
}
return str;
} // }}}
bool is_operand(char c) { // {{{
return c == '=' or c == '+' or c == '-' or c == '*' or c == '/';
} // }}}
bool is_illegal_operand() { // {{{
REP(y, H) REP(x, W) {
if (PRINTED[x][y]) continue;
if (not is_operand(TABLE[x][y])) continue;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
REP(i, 4) {
int nx = x + dx[i], ny = y + dy[i];
if (legal(nx, ny) and is_operand(TABLE[nx][ny])) {
return true;
}
}
}
REP(y, H) REP(x,W) {
if ((VBEGIN[x][y] or HBEGIN[x][y]) and is_operand(TABLE[x][y])) {
return true;
}
}
return false;
}
int hbadx, hbady, vbadx, vbady;
bool hbadflag, vbadflag;
string hbadeq, vbadeq;
bool solved() {
if (hbadflag and geth(hbadx, hbady) == hbadeq) return false;
if (vbadflag and geth(vbadx, vbady) == vbadeq) return false;
REP(y, H) REP(x, W) {
if (not HBEGIN[x][y]) continue;
string eq = geth(x, y);
try {
result e = equation(eq);
if (e.value == 0) {
hbadflag = true;
hbadx = x, hbady = y;
hbadeq = eq;
return false;
}
} catch (int ex) {
hbadflag = true;
hbadx = x, hbady = y;
hbadeq = eq;
return false;
}
}
REP(y, H) REP(x, W) {
if (not VBEGIN[x][y]) continue;
string eq = getv(x, y);
try {
result e = equation(eq);
if (e.value == 0) {
vbadflag = true;
vbadx = x, vbady = y;
vbadeq = eq;
return false;
}
} catch(int ex) {
vbadflag = true;
vbadx = x, vbady = y;
vbadeq = eq;
return false;
}
}
return true;
} // }}}
bool solve() { // {{{
sort(BLOCK, BLOCK + n);
do {
try {
for (int i = 0; i < n; i++) {
TABLE[BLANKS[i].first][BLANKS[i].second] = BLOCK[i];
if (VSOLVABLE[i] and incorrect
}
}
} catch (int ex) {
continue;
}
} while (next_permutation(BLOCK, BLOCK + n));
return false;
} // }}}
void init() { // {{{
REP(y, H) REP(x, W) {
hbadflag = vbadflag = false;
PRINTED[x][y] = false;
HBEGIN[x][y] = false;
VBEGIN[x][y] = false;
}
} // }}}
int main() {
while (cin >> H >> W and H + W) {
init();
REP(y, H) {
string row;
cin >> row;
REP(x, W) {
TABLE[x][y] = row[x];
PRINTED[x][y] = row[x] != '.';
}
}
int idx = 0;
REP(y, H) REP(x, W) {
if (TABLE[x][y]!='#' and legal(x+1,y) and TABLE[x+1][y]!='#'
and (!legal(x-1,y) or TABLE[x-1][y] == '#')) {
HBEGIN[x][y] = true;
}
if (TABLE[x][y]!='#' and legal(x,y+1) and TABLE[x][y+1]!='#'
and (!legal(x,y-1) or TABLE[x][y-1] == '#')) {
VBEGIN[x][y] = true;
}
if (not PRINTED[x][y]) {
BLANKS[idx] = make_pair(x, y);
idx++;
}
}
cin >> n;
REP(i, n) { cin >> BLOCK[i]; }
cout << (solve() ? "Yes" : "No") << endl;
}
}
// vim: set foldmethod=marker : | a.cc: In function 'bool solve()':
a.cc:185:13: error: 'VSOLVABLE' was not declared in this scope
185 | if (VSOLVABLE[i] and incorrect
| ^~~~~~~~~
a.cc:185:30: error: 'incorrect' was not declared in this scope
185 | if (VSOLVABLE[i] and incorrect
| ^~~~~~~~~
a.cc:185:39: error: expected ')' before '}' token
185 | if (VSOLVABLE[i] and incorrect
| ~ ^
| )
186 | }
| ~
a.cc:186:9: error: expected primary-expression before '}' token
186 | }
| ^
a.cc:188:5: error: expected 'catch' before '}' token
188 | } catch (int ex) {
| ^
a.cc:188:5: error: expected '(' before '}' token
188 | } catch (int ex) {
| ^
| (
a.cc:188:5: error: expected type-specifier before '}' token
a.cc:187:8: error: expected ')' before '}' token
187 | }
| ^
| )
188 | } catch (int ex) {
| ~
a.cc:188:5: error: expected '{' before '}' token
188 | } catch (int ex) {
| ^
a.cc:188:13: error: expected 'while' before '(' token
188 | } catch (int ex) {
| ^
a.cc:188:14: error: expected primary-expression before 'int'
188 | } catch (int ex) {
| ^~~
a.cc:188:14: error: expected ')' before 'int'
188 | } catch (int ex) {
| ~^~~
| )
a.cc:188:14: error: expected ';' before 'int'
188 | } catch (int ex) {
| ^~~
| ;
a.cc:188:20: error: expected initializer before ')' token
188 | } catch (int ex) {
| ^
a.cc:191:3: warning: no return statement in function returning non-void [-Wreturn-type]
191 | } while (next_permutation(BLOCK, BLOCK + n));
| ^
a.cc: At global scope:
a.cc:191:5: error: expected unqualified-id before 'while'
191 | } while (next_permutation(BLOCK, BLOCK + n));
| ^~~~~
a.cc:192:3: error: expected unqualified-id before 'return'
192 | return false;
| ^~~~~~
a.cc:193:1: error: expected declaration before '}' token
193 | } // }}}
| ^
|
s977154171 | p00608 | C++ | // AOJ 1022
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#define value first
#define p second
using namespace std;
typedef pair<int,int> result;
const int OutOfIntExc = 1,
NegIntExc = 2,
NotEquationExc = 3,
NotNumExc = 4,
LackNumExc = 5,
IterExceedExc = 6;
result equation(const string &s, int p = 0);
result expression(const string &s, int p = 0);
result factor(const string &s, int p = 0);
result term(const string &s, int p = 0);
result equation(const string &s, int p) { // {{{
if (s[p] == '=') { throw NotEquationExc; }
result r = expression(s, p);
if (s[r.p] != '=') { throw NotEquationExc; }
r.p++;
result t = expression(s, r.p);
t.value = (int)(r.value == t.value);
return t;
} // }}}
result expression(const string &s, int p) { // {{{
result r = factor(s, p);
while (s[r.p] == '+' or s[r.p] == '-') {
result r_ = factor(s, r.p+1);
r.value += (s[r.p] == '+' ? r_.value : - r_.value);
if (r.value < 0) { throw NegIntExc; }
r.p = r_.p;
}
return r;
} // }}}
result factor(const string &s, int p) { // {{{
result r = term(s, p);
while (s[r.p] == '*' or s[r.p] == '/') {
result r_ = term(s, r.p+1);
if (s[r.p] == '*') {
r.value *= r_.value;
} else {
if (r_.value == 0 or r.value % r_.value != 0) {
throw OutOfIntExc;
}
r.value /= r_.value;
}
r.p = r_.p;
}
return r;
} // }}}
result term(const string &s, int p) { // {{{
if (not isdigit(s[p])) { throw LackNumExc; }
int value = 0;
bool flag = false;
while (isdigit(s[p])) {
if (flag and value == 0) { throw NotNumExc; }
flag = true;
value = value * 10 + (s[p++] - '0');
}
return result(value, p);
} // }}}
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int H, W, n;
const int HMAX = 200, WMAX = 200, NMAX = 200;
char TABLE[HMAX][WMAX];
bool PRINTED[HMAX][WMAX], HBEGIN[HMAX][WMAX], VBEGIN[HMAX][WMAX];
char BLOCK[NMAX];
pair<int,int> BLANKS[NMAX];
bool legal(int x, int y) {
return 0 <= x and x < W and 0 <= y and y < H;
}
string getv(int x, int y) { // {{{
string str;
while (legal(x, y) and TABLE[x][y] != '#') {
str.push_back(TABLE[x][y]);
y++;
}
return str;
} // }}}
string geth(int x, int y) { // {{{
string str;
while (legal(x, y) and TABLE[x][y] != '#') {
str.push_back(TABLE[x][y]);
x++;
}
return str;
} // }}}
bool is_operand(char c) { // {{{
return c == '=' or c == '+' or c == '-' or c == '*' or c == '/';
} // }}}
bool is_illegal_operand() { // {{{
REP(y, H) REP(x, W) {
if (PRINTED[x][y]) continue;
if (not is_operand(TABLE[x][y])) continue;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
REP(i, 4) {
int nx = x + dx[i], ny = y + dy[i];
if (legal(nx, ny) and is_operand(TABLE[nx][ny])) {
return true;
}
}
}
REP(y, H) REP(x,W) {
if ((VBEGIN[x][y] or HBEGIN[x][y]) and is_operand(TABLE[x][y])) {
return true;
}
}
return false;
}
int hbadx, hbady, vbadx, vbady;
bool hbadflag, vbadflag;
string hbadeq, vbadeq;
bool solved() {
if (hbadflag and geth(hbadx, hbady) == hbadeq) return false;
if (vbadflag and geth(vbadx, vbady) == vbadeq) return false;
REP(y, H) REP(x, W) {
if (not HBEGIN[x][y]) continue;
string eq = geth(x, y);
try {
result e = equation(eq);
if (e.value == 0) {
hbadflag = true;
hbadx = x, hbady = y;
hbadeq = eq;
return false;
}
} catch (int ex) {
hbadflag = true;
hbadx = x, hbady = y;
hbadeq = eq;
return false;
}
}
REP(y, H) REP(x, W) {
if (not VBEGIN[x][y]) continue;
string eq = getv(x, y);
try {
result e = equation(eq);
if (e.value == 0) {
vbadflag = true;
vbadx = x, vbady = y;
vbadeq = eq;
return false;
}
} catch(int ex) {
vbadflag = true;
vbadx = x, vbady = y;
vbadeq = eq;
return false;
}
}
return true;
} // }}}
bool solve() { // {{{
sort(BLOCK, BLOCK + n);
do {
try {
for (int i = 0; i < n; i++) {
TABLE[BLANKS[i].first][BLANKS[i].second] = BLOCK[i];
if (VSOLVABLE[i] and incorrect
}
}
} catch (int ex) {
continue;
}
} while (next_permutation(BLOCK, BLOCK + n));
return false;
} // }}}
void init() { // {{{
REP(y, H) REP(x, W) {
hbadflag = vbadflag = false;
PRINTED[x][y] = false;
HBEGIN[x][y] = false;
VBEGIN[x][y] = false;
}
} // }}}
int main() { // {{{
while (cin >> H >> W and H + W) {
init();
REP(y, H) {
string row;
cin >> row;
REP(x, W) {
TABLE[x][y] = row[x];
PRINTED[x][y] = row[x] != '.';
}
}
int idx = 0;
REP(y, H) REP(x, W) {
if (TABLE[x][y]!='#' and legal(x+1,y) and TABLE[x+1][y]!='#'
and (!legal(x-1,y) or TABLE[x-1][y] == '#')) {
HBEGIN[x][y] = true;
}
if (TABLE[x][y]!='#' and legal(x,y+1) and TABLE[x][y+1]!='#'
and (!legal(x,y-1) or TABLE[x][y-1] == '#')) {
VBEGIN[x][y] = true;
}
if (not PRINTED[x][y]) {
BLANKS[idx] = make_pair(x, y);
idx++;
}
}
cin >> n;
REP(i, n) { cin >> BLOCK[i]; }
cout << (solve() ? "Yes" : "No") << endl;
}
} // }}}
// vim: set foldmethod=marker : | a.cc: In function 'bool solve()':
a.cc:185:13: error: 'VSOLVABLE' was not declared in this scope
185 | if (VSOLVABLE[i] and incorrect
| ^~~~~~~~~
a.cc:185:30: error: 'incorrect' was not declared in this scope
185 | if (VSOLVABLE[i] and incorrect
| ^~~~~~~~~
a.cc:185:39: error: expected ')' before '}' token
185 | if (VSOLVABLE[i] and incorrect
| ~ ^
| )
186 | }
| ~
a.cc:186:9: error: expected primary-expression before '}' token
186 | }
| ^
a.cc:188:5: error: expected 'catch' before '}' token
188 | } catch (int ex) {
| ^
a.cc:188:5: error: expected '(' before '}' token
188 | } catch (int ex) {
| ^
| (
a.cc:188:5: error: expected type-specifier before '}' token
a.cc:187:8: error: expected ')' before '}' token
187 | }
| ^
| )
188 | } catch (int ex) {
| ~
a.cc:188:5: error: expected '{' before '}' token
188 | } catch (int ex) {
| ^
a.cc:188:13: error: expected 'while' before '(' token
188 | } catch (int ex) {
| ^
a.cc:188:14: error: expected primary-expression before 'int'
188 | } catch (int ex) {
| ^~~
a.cc:188:14: error: expected ')' before 'int'
188 | } catch (int ex) {
| ~^~~
| )
a.cc:188:14: error: expected ';' before 'int'
188 | } catch (int ex) {
| ^~~
| ;
a.cc:188:20: error: expected initializer before ')' token
188 | } catch (int ex) {
| ^
a.cc:191:3: warning: no return statement in function returning non-void [-Wreturn-type]
191 | } while (next_permutation(BLOCK, BLOCK + n));
| ^
a.cc: At global scope:
a.cc:191:5: error: expected unqualified-id before 'while'
191 | } while (next_permutation(BLOCK, BLOCK + n));
| ^~~~~
a.cc:192:3: error: expected unqualified-id before 'return'
192 | return false;
| ^~~~~~
a.cc:193:1: error: expected declaration before '}' token
193 | } // }}}
| ^
|
s805465379 | p00608 | C++ | // AOJ 1022
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#define value first
#define p second
using namespace std;
typedef pair<int,int> result;
const int OutOfIntExc = 1,
NegIntExc = 2,
NotEquationExc = 3,
NotNumExc = 4,
LackNumExc = 5,
IterExceedExc = 6;
result equation(const string &s, int p = 0);
result expression(const string &s, int p = 0);
result factor(const string &s, int p = 0);
result term(const string &s, int p = 0);
result equation(const string &s, int p) { // {{{
if (s[p] == '=') { throw NotEquationExc; }
result r = expression(s, p);
if (s[r.p] != '=') { throw NotEquationExc; }
r.p++;
result t = expression(s, r.p);
t.value = (int)(r.value == t.value);
return t;
} // }}}
result expression(const string &s, int p) { // {{{
result r = factor(s, p);
while (s[r.p] == '+' or s[r.p] == '-') {
result r_ = factor(s, r.p+1);
r.value += (s[r.p] == '+' ? r_.value : - r_.value);
if (r.value < 0) { throw NegIntExc; }
r.p = r_.p;
}
return r;
} // }}}
result factor(const string &s, int p) { // {{{
result r = term(s, p);
while (s[r.p] == '*' or s[r.p] == '/') {
result r_ = term(s, r.p+1);
if (s[r.p] == '*') {
r.value *= r_.value;
} else {
if (r_.value == 0 or r.value % r_.value != 0) {
throw OutOfIntExc;
}
r.value /= r_.value;
}
r.p = r_.p;
}
return r;
} // }}}
result term(const string &s, int p) { // {{{
if (not isdigit(s[p])) { throw LackNumExc; }
int value = 0;
bool flag = false;
while (isdigit(s[p])) {
if (flag and value == 0) { throw NotNumExc; }
flag = true;
value = value * 10 + (s[p++] - '0');
}
return result(value, p);
} // }}}
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int H, W, n;
const int HMAX = 200, WMAX = 200, NMAX = 200;
char TABLE[HMAX][WMAX];
bool PRINTED[HMAX][WMAX], HBEGIN[HMAX][WMAX], VBEGIN[HMAX][WMAX];
char BLOCK[NMAX];
pair<int,int> BLANKS[NMAX];
bool legal(int x, int y) { // {{{
return 0 <= x and x < W and 0 <= y and y < H;
} // }}}
string getv(int x, int y) { // {{{
string str;
while (legal(x, y) and TABLE[x][y] != '#') {
str.push_back(TABLE[x][y]);
y++;
}
return str;
} // }}}
string geth(int x, int y) { // {{{
string str;
while (legal(x, y) and TABLE[x][y] != '#') {
str.push_back(TABLE[x][y]);
x++;
}
return str;
} // }}}
bool is_operand(char c) { // {{{
return c == '=' or c == '+' or c == '-' or c == '*' or c == '/';
} // }}}
bool is_illegal_operand() { // {{{
REP(y, H) REP(x, W) {
if (PRINTED[x][y]) continue;
if (not is_operand(TABLE[x][y])) continue;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
REP(i, 4) {
int nx = x + dx[i], ny = y + dy[i];
if (legal(nx, ny) and is_operand(TABLE[nx][ny])) {
return true;
}
}
}
REP(y, H) REP(x,W) {
if ((VBEGIN[x][y] or HBEGIN[x][y]) and is_operand(TABLE[x][y])) {
return true;
}
}
return false;
} // }}}
int hbadx, hbady, vbadx, vbady;
bool hbadflag, vbadflag;
string hbadeq, vbadeq;
bool solved() {
if (hbadflag and geth(hbadx, hbady) == hbadeq) return false;
if (vbadflag and geth(vbadx, vbady) == vbadeq) return false;
REP(y, H) REP(x, W) {
if (not HBEGIN[x][y]) continue;
string eq = geth(x, y);
try {
result e = equation(eq);
if (e.value == 0) {
hbadflag = true;
hbadx = x, hbady = y;
hbadeq = eq;
return false;
}
} catch (int ex) {
hbadflag = true;
hbadx = x, hbady = y;
hbadeq = eq;
return false;
}
}
REP(y, H) REP(x, W) {
if (not VBEGIN[x][y]) continue;
string eq = getv(x, y);
try {
result e = equation(eq);
if (e.value == 0) {
vbadflag = true;
vbadx = x, vbady = y;
vbadeq = eq;
return false;
}
} catch(int ex) {
vbadflag = true;
vbadx = x, vbady = y;
vbadeq = eq;
return false;
}
}
return true;
} // }}}
bool solve() { // {{{
sort(BLOCK, BLOCK + n);
do {
try {
for (int i = 0; i < n; i++) {
TABLE[BLANKS[i].first][BLANKS[i].second] = BLOCK[i];
if (VSOLVABLE[i] and incorrect
}
}
} catch (int ex) {
continue;
}
} while (next_permutation(BLOCK, BLOCK + n));
return false;
} // }}}
void init() { // {{{
REP(y, H) REP(x, W) {
hbadflag = vbadflag = false;
PRINTED[x][y] = false;
HBEGIN[x][y] = false;
VBEGIN[x][y] = false;
}
} // }}}
int main() { // {{{
while (cin >> H >> W and H + W) {
init();
REP(y, H) {
string row;
cin >> row;
REP(x, W) {
TABLE[x][y] = row[x];
PRINTED[x][y] = row[x] != '.';
}
}
int idx = 0;
REP(y, H) REP(x, W) {
if (TABLE[x][y]!='#' and legal(x+1,y) and TABLE[x+1][y]!='#'
and (!legal(x-1,y) or TABLE[x-1][y] == '#')) {
HBEGIN[x][y] = true;
}
if (TABLE[x][y]!='#' and legal(x,y+1) and TABLE[x][y+1]!='#'
and (!legal(x,y-1) or TABLE[x][y-1] == '#')) {
VBEGIN[x][y] = true;
}
if (not PRINTED[x][y]) {
BLANKS[idx] = make_pair(x, y);
idx++;
}
}
cin >> n;
REP(i, n) { cin >> BLOCK[i]; }
cout << (solve() ? "Yes" : "No") << endl;
}
} // }}}
// vim: set foldmethod=marker : | a.cc: In function 'bool solve()':
a.cc:185:13: error: 'VSOLVABLE' was not declared in this scope
185 | if (VSOLVABLE[i] and incorrect
| ^~~~~~~~~
a.cc:185:30: error: 'incorrect' was not declared in this scope
185 | if (VSOLVABLE[i] and incorrect
| ^~~~~~~~~
a.cc:185:39: error: expected ')' before '}' token
185 | if (VSOLVABLE[i] and incorrect
| ~ ^
| )
186 | }
| ~
a.cc:186:9: error: expected primary-expression before '}' token
186 | }
| ^
a.cc:188:5: error: expected 'catch' before '}' token
188 | } catch (int ex) {
| ^
a.cc:188:5: error: expected '(' before '}' token
188 | } catch (int ex) {
| ^
| (
a.cc:188:5: error: expected type-specifier before '}' token
a.cc:187:8: error: expected ')' before '}' token
187 | }
| ^
| )
188 | } catch (int ex) {
| ~
a.cc:188:5: error: expected '{' before '}' token
188 | } catch (int ex) {
| ^
a.cc:188:13: error: expected 'while' before '(' token
188 | } catch (int ex) {
| ^
a.cc:188:14: error: expected primary-expression before 'int'
188 | } catch (int ex) {
| ^~~
a.cc:188:14: error: expected ')' before 'int'
188 | } catch (int ex) {
| ~^~~
| )
a.cc:188:14: error: expected ';' before 'int'
188 | } catch (int ex) {
| ^~~
| ;
a.cc:188:20: error: expected initializer before ')' token
188 | } catch (int ex) {
| ^
a.cc:191:3: warning: no return statement in function returning non-void [-Wreturn-type]
191 | } while (next_permutation(BLOCK, BLOCK + n));
| ^
a.cc: At global scope:
a.cc:191:5: error: expected unqualified-id before 'while'
191 | } while (next_permutation(BLOCK, BLOCK + n));
| ^~~~~
a.cc:192:3: error: expected unqualified-id before 'return'
192 | return false;
| ^~~~~~
a.cc:193:1: error: expected declaration before '}' token
193 | } // }}}
| ^
|
s369085402 | p00608 | C++ | 5 5
4=..2
+#=#+
.-2=.
=#*#=
.-.=3
6
7 3 1 4 / 8
1 6
8..3=2
2
2 +
0 0 | a.cc:3:2: error: stray '#' in program
3 | +#=#+
| ^
a.cc:3:4: error: stray '#' in program
3 | +#=#+
| ^
a.cc:5:2: error: stray '#' in program
5 | =#*#=
| ^
a.cc:5:4: error: stray '#' in program
5 | =#*#=
| ^
a.cc:10:1: error: too many decimal points in number
10 | 8..3=2
| ^~~~
a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 5 5
| ^
|
s878919860 | p00608 | C++ | puts "Hello World" | a.cc:1:1: error: 'puts' does not name a type
1 | puts "Hello World"
| ^~~~
|
s876560726 | p00608 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;
typedef pair<int, LL> Result;
class ParseError{};
struct Parser{
Result expr(string s, int p){
Result r = term(s, p);
while(s[r.first] == '+' || s[r.first] == '-'){
Result t = term(s, r.first + 1);
if(s[r.first] == '+'){
r.second += t.second;
}else{
r.second -= t.second;
}
r.first = t.first;
}
return r;
}
Result term(string s, int p){
Result r = factor(s, p);
while(s[r.first] == '*' || s[r.first] == '/'){
Result t = factor(s, r.first + 1);
if(s[r.first] == '*'){
r.second *= t.second;
}else{
if(t.second == 0) throw ParseError();
r.second /= t.second;
}
r.first = t.first;
}
return r;
}
Result factor(string s, int p){
if(s[p] == '0'){
if(isdigit(s[p + 1])) throw ParseError();
return Result(p + 1, 0);
}else if(isdigit(s[p])){
LL num = 0;
while(isdigit(s[p])){
num = num * 10 + s[p++] - '0';
}
return Result(p, num);
}else{
throw ParseError();
}
}
};
LL parse(string s){
LL res = Parser().expr(s, 0).second;
return res;
}
char select[10];
bool used[10];
int H, W, L;
bool dfs(int k, vector<char>& vc, vector<string> check[10]){
if(k == L) return true;
REP(i, vc.size()) if(!used[i]){
select[k] = vc[i];
used[i] = true;
for(auto s : check[k]){
string s1, s2;
for(auto& c : s) {
if(islower(c)){
c = select[ c - 'a' ];
}
if(c == '='){
if(s2.size() > 0) goto NEXT;
swap(s1, s2);
}else{
s1 += c;
}
}
try{
if(parse(s1) != parse(s2)) goto NEXT;
}catch(ParseError e){
goto NEXT;
}
}
if(dfs(k + 1, vc, check)) return true;
NEXT:
used[i] = false;
}
return false;
}
int main(){
while(cin >> H >> W && H){
vector<string> grid(H);
REP(i, H) cin >> grid[i];
vector<int> bx, by;
REP(y, H) REP(x, W) if(grid[y][x] == '.') { bx.push_back(x); by.push_back(y); grid[y][x] = bx.size() - 1 + 'a';}
cin >> L;
vector<char> vc(L);
for(auto& c : vc) cin >> c;
sort(vc.begin(), vc.end());
vector<string> check[10];
REP(y, H) REP(x, W) if(grid[y][x] != '#'){
if(y < H - 1 && (y == 0 || grid[y - 1][x] == '#') && grid[y + 1][x] != '#'){
string s;
for(int dy = 0; y + dy < H && grid[y + dy][x] != '#'; dy++){
s += grid[y + dy][x];
}
int maxk = 0;
for(auto c : s) if(islower(c)) maxk = max(maxk, c - 'a');
check[maxk].push_back(s);
}
if(x < W - 1 && (x == 0 || grid[y][x - 1] == '#') && grid[y][x + 1] != '#'){
string s;
for(int dx = 0; x + dx < W && grid[y][x + dx] != '#'; dx++){
s += grid[y][x + dx];
}
int maxk = 0;
for(auto c : s) if(islower(c)) maxk = max(maxk, c - 'a');
check[maxk].push_back(s);
}
}
bool ans = dfs(0, vc, check);
if(ans) cout << "Yes" << endl;
else cout << "No" << endl;
}
return 0;
} | a.cc:55:15: error: 'char select [10]' redeclared as different kind of entity
55 | char select[10];
| ^
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179,
from /usr/include/stdlib.h:514,
from /usr/include/c++/14/cstdlib:79,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
from a.cc:1:
/usr/include/x86_64-linux-gnu/sys/select.h:102:12: note: previous declaration 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)'
102 | extern int select (int __nfds, fd_set *__restrict __readfds,
| ^~~~~~
a.cc: In function 'bool dfs(int, std::vector<char>&, std::vector<std::__cxx11::basic_string<char> >*)':
a.cc:61:17: warning: pointer to a function used in arithmetic [-Wpointer-arith]
61 | select[k] = vc[i];
| ^
a.cc:61:19: error: assignment of read-only location '*(select + ((sizetype)k))'
61 | select[k] = vc[i];
a.cc:67:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
67 | c = select[ c - 'a' ];
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:67:41: error: invalid conversion from 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to 'char' [-fpermissive]
67 | c = select[ c - 'a' ];
| ~~~~~~~~~~~~~~~~^
| |
| int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)
|
s717076813 | p00608 | C++ | #include <iostream>
#include <vector>
using namespace std;
#define rep(i, b) for( int i = 0; i < b; i++ )
typedef vector<char> vec;
// char op[5] = { '=', '-', '+' , '*', '/' };
// char num[10] = {'0','1','2','3','4','5','6','7','8','9'};
int main(){
int h, w;
while( cin >> h >> w, h ){
vector< vector<int> > exist( h, vector<int>(w) );
fill( exist.begin(), exist.end(), 0 );
vector< vec > grid( h, vec(w) );
rep(i, h){
rep(j, w){
char cell;
cin >> cell;
grid[i][j] = cell;
if( cell != '#' ) exist[i][j]++;
}
}
vector< vec > formula;
rep(i, h){
rep(j, w){
if( exist[i][j] && exist[i][j+1] ){
int k = 0;
vec fml;
while( exist[i][j+k] ){
fml.push_back( grid[i][j+k] );
exist[i][j+k]--;
k++;
}
formula.push_back(vec(fml));
}
if( exist[i][j] && exist[i+1][j] ){
int k = 0;
vec fml;
while( exist[i+k][j] ){
fml.push_back( grid[i+k][j] );
exist[i+k][j]--;
k++;
}
formula.push_back(vec(fml));
}
}
}
}
} | In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = vector<int>*; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/14/bits/stl_algobase.h:981:21: required from 'void std::__fill_a1(__gnu_cxx::__normal_iterator<_Iterator, _Container>, __gnu_cxx::__normal_iterator<_Iterator, _Container>, const _Tp&) [with _Ite = vector<int>*; _Cont = vector<vector<int> >; _Tp = int]'
981 | { std::__fill_a1(__first.base(), __last.base(), __value); }
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:998:21: required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = __gnu_cxx::__normal_iterator<vector<int>*, vector<vector<int> > >; _Tp = int]'
998 | { std::__fill_a1(__first, __last, __value); }
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1029:20: required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator<vector<int>*, vector<vector<int> > >; _Tp = int]'
1029 | std::__fill_a(__first, __last, __value);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:14:13: required from here
14 | fill( exist.begin(), exist.end(), 0 );
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:952:18: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'const int')
952 | *__first = __tmp;
| ~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/vector:72,
from a.cc:2:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'const int' to 'const std::vector<int>&'
211 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'const int' to 'std::vector<int>&&'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
788 | operator=(initializer_list<value_type> __l)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'const int' to 'std::initializer_list<int>'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
|
s186875678 | p00608 | C++ | #include<iostream>
#include<vector>
using namespace std;
#define INF (1<<24)
bool isNum(char ch){return ('0'<=ch&&ch<='9');}
struct calcStr{
string s;
int pos,len;
void init(){ pos=0;len=s.size(); }
int head2Num(){
int res=0;
while(1){
if(pos==len)break;
if('0'<=s[pos]&&s[pos]<='9'){
res*=10;
res+=(s[pos]-'0');
}else break;
pos++;
}
return res;
}
int getNum(){
int res=head2Num(),num;
while(1){
if(pos==len||s[pos]=='+'||s[pos]=='-')break;
char ch=s[pos++];
num=head2Num();
if(ch=='*')res*=num;
if(ch=='/')res/=num;
}
return res;
}
int getAns(){
int res=getNum(),num;
while(1){
if(pos==len||s[pos]=='=')break;
char ch=s[pos++];
num=getNum();
if(ch=='+')res+=num;
else if(ch=='-')res-=num;
}
return res;
}
};
int H,W,N,M;
string str;
string v;
char t[100][100];
char u[100];
bool solve();
bool check();
bool compute();
int main(){
while(1){
cin>>H>>W;
if(H==0||W==0)break;
M=0;
for(int i=0;i<H;i++){
cin>>str;
for(int j=0;j<W;j++){
t[i][j]=str[j];
if(t[i][j]=='.'){
t[i][j]='A'+M;
M++;
}
}
}
cin>>N;
for(int i=0;i<N;i++)cin>>u[i];
cout<<(solve()?"Yes":"No")<<endl;
}
return 0;
}
bool solve(){
sort(u,u+N);
do{
if(check())return true;
}while(next_permutation(u,u+N));
return false;
}
bool check(){
string str;
for(int i=0;i<H;i++){
v="";
for(int j=0;j<W;j++){
if(t[i][j]=='#'){
if(v.size()>=3)if(!compute())return false;
v="";
}else v.push_back(t[i][j]);
}
if(v.size()>=3)if(!compute())return false;
}
for(int i=0;i<W;i++){
v="";
for(int j=0;j<H;j++){
if(t[j][i]=='#'){
if(v.size()>=3)if(!compute())return false;
v="";
}else v.push_back(t[j][i]);
}
if(v.size()>=3)if(!compute())return false;
}
return true;
}
bool compute(){
for(int i=0;i<(int)v.size();i++)
if('A'<=v[i]&&v[i]<='Z')v[i]=u[v[i]-'A'];
string a="",b="";
bool flg=false;
b.push_back(v[0]);
for(int i=1;i<(int)v.size();i++){
if(!isNum(v[i-1])&&!isNum(v[i]))return false;
if(v[i]=='=')flg=true;
else if(flg)a.push_back(v[i]);
else b.push_back(v[i]);
}
if(!isNum(v[0])||!isNum(v[v.size()-1]))return false;
calcStr x,y;
x.s=a;
x.init();
y.s=b;
y.init();
return (x.getAns()==y.getAns());
} | a.cc: In function 'bool solve()':
a.cc:85:3: error: 'sort' was not declared in this scope; did you mean 'short'?
85 | sort(u,u+N);
| ^~~~
| short
a.cc:88:10: error: 'next_permutation' was not declared in this scope
88 | }while(next_permutation(u,u+N));
| ^~~~~~~~~~~~~~~~
|
s698145752 | p00609 | C++ | #include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
//vector<pair<int,int> >A[510][510];
vector<pair<int,int> >B[510][510];
int dx[]={1,1,1,0,0,0,-1,-1,-1};
int dy[]={1,0,-1,1,0,-1,1,0,-1};
int ax[110000];
int ay[110000];
int main(){
int a,b,c;
while(scanf("%d%d%d",&a,&b,&c),a+b){
for(int i=0;i<510;i++)
for(int j=0;j<510;j++){
// A[i][j].clear();
B[i][j].clear();
}
for(int i=0;i<a;i++){
int x,y;scanf("%d%d",&x,&y);
ax[i]=x;ay[i]=y;
// A[x/40][y/40].push_back(make_pair(x,y));
}
for(int i=0;i<b;i++){
int x,y;scanf("%d%d",&x,&y);
B[x/40][y/40].push_back(make_pair(x,y));
}
int ret=0;
for(int i=0;i<a;i++){
int x=ax[i]/45;
int y=ay[i]/45;
for(int j=0;j<8;j++){
int nx=x+dx[j];
int ny=y+dy[j];
if(nx<0||ny<0)continue;
for(int k=0;k<B[nx][ny].size();k++){
if(sqrt((ax[i]-B[nx][ny][k].first)*(ax[i]-B[nx][ny][k].first)+
(ay[i]-B[nx][ny][k].second)*(ay[i]-B[nx][ny][k].second))<=4.0*c)ret++;
}
}
}
printf("%d\n",ret);
}
} | a.cc: In function 'int main()':
a.cc:37:44: error: 'sqrt' was not declared in this scope
37 | if(sqrt((ax[i]-B[nx][ny][k].first)*(ax[i]-B[nx][ny][k].first)+
| ^~~~
|
s845582030 | p00609 | C++ | #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
#define X first
#define Y second
vector<P> A,B[100010];
int main(){
while(1){
int an,bn,r,ans=0,n=0;
int x,y;
vector<P>::iterator it1;
vector<P>::iterator it2;
cin>>an>>bn>>r;
if(an==0 && bn==0 && r==0)
break;
for(int i=0;i<an;i++){
cin>>x>>y;
A.push_back(P(x,y));
}
for(int i=0;i<bn;i++){
cin>>x>>y;
B[x].X=x;
B[x].Y=y;
}
for(int i=0;i<100010;i++){
sort(B[i].begin(),B[i].end());
B[i].X=i;
B[i].Y=10000;
}
for(int i=0;i<an;i++){
for(int j=-4*r;j<=4*r;j++){
n=sqrt(4*r*4*r-j*j);
if(A[i].X+j>=0 && A[i].X+j<=10000 && B[A[i].X+j].size()!=0){
it1=lower_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y-n));
it2=upper_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y+n));
if(B[A[i].X+j].begin()<=it1 && it1< B[A[i].X+j].end() && B[A[i].X+j].begin() <=it2 && it2 < B[A[i].X+j].end()){
ans+=it2-it1;
}
}
}
}
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:26:30: note: in expansion of macro 'X'
26 | B[x].X=x;
| ^
a.cc:8:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
8 | #define Y second
| ^~~~~~
a.cc:27:30: note: in expansion of macro 'Y'
27 | B[x].Y=y;
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:31:30: note: in expansion of macro 'X'
31 | B[i].X=i;
| ^
a.cc:8:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
8 | #define Y second
| ^~~~~~
a.cc:32:30: note: in expansion of macro 'Y'
32 | B[i].Y=10000;
| ^
|
s676737242 | p00609 | C++ | #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
#define X first
#define Y second
vector<P> A[100010],B[100010];
int main(){
while(1){
int an,bn,r,ans=0,n=0;
int x,y;
vector<P>::iterator it1;
vector<P>::iterator it2;
cin>>an>>bn>>r;
if(an==0 && bn==0 && r==0)
break;
for(int i=0;i<an;i++){
cin>>x>>y;
A[i].X=x;
A[i].Y=y;
}
for(int i=0;i<bn;i++){
cin>>x>>y;
B[x].push_back(P(x,y));
}
for(int i=0;i<100010;i++){
sort(B[i].begin(),B[i].end());
B[i].push_back(P(i,10000));
}
for(int i=0;i<an;i++){
for(int j=-4*r;j<=4*r;j++){
n=sqrt(4*r*4*r-j*j);
if(A[i].X+j>=0 && A[i].X+j<=10000 && B[A[i].X+j].size()!=0){
it1=lower_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y-n));
it2=upper_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y+n));
if(B[A[i].X+j].begin()<=it1 && it1< B[A[i].X+j].end() && B[A[i].X+j].begin() <=it2 && it2 < B[A[i].X+j].end()){
ans+=it2-it1;
}
}
}
}
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:22:30: note: in expansion of macro 'X'
22 | A[i].X=x;
| ^
a.cc:8:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
8 | #define Y second
| ^~~~~~
a.cc:23:30: note: in expansion of macro 'Y'
23 | A[i].Y=y;
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:37:41: note: in expansion of macro 'X'
37 | if(A[i].X+j>=0 && A[i].X+j<=10000 && B[A[i].X+j].size()!=0){
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:37:56: note: in expansion of macro 'X'
37 | if(A[i].X+j>=0 && A[i].X+j<=10000 && B[A[i].X+j].size()!=0){
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:37:77: note: in expansion of macro 'X'
37 | if(A[i].X+j>=0 && A[i].X+j<=10000 && B[A[i].X+j].size()!=0){
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:38:64: note: in expansion of macro 'X'
38 | it1=lower_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y-n));
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:38:84: note: in expansion of macro 'X'
38 | it1=lower_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y-n));
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:38:102: note: in expansion of macro 'X'
38 | it1=lower_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y-n));
| ^
a.cc:8:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
8 | #define Y second
| ^~~~~~
a.cc:38:111: note: in expansion of macro 'Y'
38 | it1=lower_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y-n));
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:40:64: note: in expansion of macro 'X'
40 | it2=upper_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y+n));
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:40:84: note: in expansion of macro 'X'
40 | it2=upper_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y+n));
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:40:102: note: in expansion of macro 'X'
40 | it2=upper_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y+n));
| ^
a.cc:8:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
8 | #define Y second
| ^~~~~~
a.cc:40:111: note: in expansion of macro 'Y'
40 | it2=upper_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y+n));
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:42:51: note: in expansion of macro 'X'
42 | if(B[A[i].X+j].begin()<=it1 && it1< B[A[i].X+j].end() && B[A[i].X+j].begin() <=it2 && it2 < B[A[i].X+j].end()){
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:42:85: note: in expansion of macro 'X'
42 | if(B[A[i].X+j].begin()<=it1 && it1< B[A[i].X+j].end() && B[A[i].X+j].begin() <=it2 && it2 < B[A[i].X+j].end()){
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:42:106: note: in expansion of macro 'X'
42 | if(B[A[i].X+j].begin()<=it1 && it1< B[A[i].X+j].end() && B[A[i].X+j].begin() <=it2 && it2 < B[A[i].X+j].end()){
| ^
a.cc:7:11: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
7 | #define X first
| ^~~~~
a.cc:42:141: note: in expansion of macro 'X'
42 | if(B[A[i].X+j].begin()<=it1 && it1< B[A[i].X+j].end() && B[A[i].X+j].begin() <=it2 && it2 < B[A[i].X+j].end()){
| ^
|
s417185355 | p00609 | C++ | #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
#define X first
#define Y second
vector<P> B[100010];
P A[100010]={};
int main(){
while(1){
B.clear();
int an,bn,r,ans=0,n=0;
int x,y;
vector<P>::iterator it1;
vector<P>::iterator it2;
cin>>an>>bn>>r;
if(an==0 && bn==0 && r==0)
break;
for(int i=0;i<an;i++){
cin>>x>>y;
A[i].X=x;
A[i].Y=y;
}
for(int i=0;i<bn;i++){
cin>>x>>y;
B[x].push_back(P(x,y));
}
for(int i=0;i<100010;i++){
sort(B[i].begin(),B[i].end());
B[i].push_back(P(i,10000));
}
for(int i=0;i<an;i++){
for(int j=-4*r;j<=4*r;j++){
n=sqrt(4*r*4*r-j*j);
if(A[i].X+j>=0 && A[i].X+j<=10000 && B[A[i].X+j].size()!=0){
it1=lower_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y-n));
it2=upper_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),P(A[i].X+j,A[i].Y+n));
if(B[A[i].X+j].begin()<=it1 && it1< B[A[i].X+j].end() && B[A[i].X+j].begin() <=it2 && it2 < B[A[i].X+j].end()){
ans+=it2-it1;
}
}
}
}
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:13:19: error: request for member 'clear' in 'B', which is of non-class type 'std::vector<std::pair<int, int> > [100010]'
13 | B.clear();
| ^~~~~
|
s216640945 | p00609 | C++ | #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
#define X first
#define Y second
vector<int> B[100010];
P A[100010];
int main(){
while(1){
B.clear();
int an,bn,r,ans=0,n=0;
int x,y;
vector<int>::iterator it1;
vector<int>::iterator it2;
cin>>an>>bn>>r;
if(an==0 && bn==0 && r==0)
break;
for(int i=0;i<an;i++){
cin>>x>>y;
A[i].X=x;
A[i].Y=y;
}
for(int i=0;i<bn;i++){
cin>>x>>y;
B[x].push_back(y);
}
for(int i=0;i<100010;i++){
if(B[i].size())
sort(B[i].begin(),B[i].end());
B[i].push_back(10000);
}
for(int i=0;i<an;i++){
for(int j=-4*r;j<=4*r;j++){
n=sqrt(4*r*4*r-j*j);
if(A[i].X+j>=0 && A[i].X+j<=10000 && B[A[i].X+j].size()){
it1=lower_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),A[i].Y-n);
it2=upper_bound(B[A[i].X+j].begin(),B[A[i].X+j].end(),A[i].Y+n);
if(B[A[i].X+j].begin()<=it1 && it1< B[A[i].X+j].end() && B[A[i].X+j].begin() <=it2 && it2 < B[A[i].X+j].end()){
ans+=it2-it1;
}
}
}
}
cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:13:19: error: request for member 'clear' in 'B', which is of non-class type 'std::vector<int> [100010]'
13 | B.clear();
| ^~~~~
|
s162573344 | p00609 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <vector>
#define or0(a) (a)<0?0:(a)
using namespace std;
int main(){
int an, bn, r, ans = 0, d, b0, b1;
vector< vector<int> > a;
scanf("%d %d %d", &an, &bn, &r);
a.resize(10000);
for (int i = 0; i < a.size(); i++){
a[i].resize(313);
}
while (an){
d = 16 * r * r;
for (int i = 0; i < an; i++){
int tmp1, tmp2;
scanf("%d %d", &tmp1, &tmp2);
a[tmp1][tmp2/32] |= 1<<(tmp2%32);
}
for (int i = 0; i < bn; i++){
scanf("%d %d", &b0, &b1);
for (int idxx = or0(b0 - 4 * r); idxx <= b0 + 4 * r && idxx < 10000; idxx++){
for (int idxy = or0(b1 - 4 * r); idxy <= b1 + 4 * r && idxy < 10000; idxy++){
if ((a[idxx][idxy/32]>>(idxy%32))&1){
if ((idxx - b0)*(idxx - b0) + (idxy - b1)*(idxy - b1) <= d){
ans++;
}
}
}
}
}
printf("%d\n", ans);
fill(a.begin, a.end,0);
ans = 0;
scanf("%d %d %d", &an, &bn, &r);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:36:21: error: no matching function for call to 'fill(<unresolved overloaded function type>, <unresolved overloaded function type>, int)'
36 | fill(a.begin, a.end,0);
| ~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate: 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)'
1022 | fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:1022:5: note: template argument deduction/substitution failed:
a.cc:36:21: note: couldn't deduce template parameter '_ForwardIterator'
36 | fill(a.begin, a.end,0);
| ~~~~^~~~~~~~~~~~~~~~~~
|
s468703293 | p00609 | C++ | #include <stdio.h>
#include <iostream>
#include <vector>
#define or0(a) (a)<0?0:(a)
using namespace std;
int main(){
int an, bn, r, ans = 0, d, b0, b1;
vector< vector<int> > a;
scanf("%d %d %d", &an, &bn, &r);
a.resize(10000);
for (int i = 0; i < a.size(); i++){
a[i].resize(313);
}
while (an){
d = 16 * r * r;
for (int i = 0; i < an; i++){
int tmp1, tmp2;
scanf("%d %d", &tmp1, &tmp2);
a[tmp1][tmp2 / 32] |= 1 << (tmp2 % 32);
}
for (int i = 0; i < bn; i++){
scanf("%d %d", &b0, &b1);
for (int idxx = or0(b0 - 4 * r); idxx <= b0 + 4 * r && idxx < 10000; idxx++){
for (int idxy = or0(b1 - 4 * r); idxy <= b1 + 4 * r && idxy < 10000; idxy++){
if ((a[idxx][idxy / 32] >> (idxy % 32)) & 1){
if ((idxx - b0)*(idxx - b0) + (idxy - b1)*(idxy - b1) <= d){
ans++;
}
}
}
}
}
printf("%d\n", ans);
fill(a.begin(), a.end(), 0);
ans = 0;
scanf("%d %d %d", &an, &bn, &r);
}
return 0;
} | In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = vector<int>*; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/14/bits/stl_algobase.h:981:21: required from 'void std::__fill_a1(__gnu_cxx::__normal_iterator<_Iterator, _Container>, __gnu_cxx::__normal_iterator<_Iterator, _Container>, const _Tp&) [with _Ite = vector<int>*; _Cont = vector<vector<int> >; _Tp = int]'
981 | { std::__fill_a1(__first.base(), __last.base(), __value); }
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:998:21: required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = __gnu_cxx::__normal_iterator<vector<int>*, vector<vector<int> > >; _Tp = int]'
998 | { std::__fill_a1(__first, __last, __value); }
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1029:20: required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator<vector<int>*, vector<vector<int> > >; _Tp = int]'
1029 | std::__fill_a(__first, __last, __value);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:35:7: required from here
35 | fill(a.begin(), a.end(), 0);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:952:18: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'const int')
952 | *__first = __tmp;
| ~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/vector:72,
from a.cc:3:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'const int' to 'const std::vector<int>&'
211 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'const int' to 'std::vector<int>&&'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
788 | operator=(initializer_list<value_type> __l)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'const int' to 'std::initializer_list<int>'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
|
s493893076 | p00609 | C++ | a | a.cc:1:1: error: 'a' does not name a type
1 | a
| ^
|
s168994886 | p00609 | C++ | g#include <bits/stdc++.h>
using namespace std;
#define whole(xs) (xs).begin(),(xs).end()
template<class T>
ostream& operator<<(ostream& os, const vector<T>& vs) {
if (vs.empty()) return os << "[]";
os << "[" << vs[0];
for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
return os << "]";
}
typedef short Long;
//typedef long long Long;
/* 領域木ライブラリ.
* Node : 領域木の各ノード
* construct(Point[] ps)
* : ps(x座標でソートされた点集合)をもとに領域木を作成.
* query(Node root, long sx, long sy, long gx, long gy, vector<Point>& result)
* : rootに含まれる点のうち, (sx <= x <= gx && sy <= y <= gy)なるもののをresultに入れる
*/
int ans;
struct Point {
Long x, y;
char type;
Point() {}
Point(Long x, Long y, char type='c') : x(x), y(y), type(type) {}
static bool compY(const Point& a, const Point& b) {
return a.y == b.y ? a.x < b.x : a.y < b.y;
}
};
Long dist2(const Point& a, const Point& b);
struct Node {
Node* parent;
shared_ptr<Node> left, right;
Long left_x, right_x;
vector<Point> ys;
};
ostream& operator<<(ostream& os, const Node& node) {
return os << "( [" << node.left_x << "," << node.right_x << "] -> " << node.ys;
}
shared_ptr<Node> construct(vector<Point>::iterator lb, vector<Point>::iterator ub) {
auto n = make_shared<Node>();
n->left_x = lb->x;
n->right_x = (ub - 1)->x;
if (ub - lb == 1) {
n->ys.clear(); n->ys.push_back(*lb);
return n;
}
auto mid = lb + (ub - lb) / 2;
auto l = construct(lb, mid),
r = construct(mid, ub);
l->parent = n.get();
r->parent = n.get();
n->left = l;
n->right = r;
size_t li = 0, ri = 0;
while (true) {
if (li >= l->ys.size() && ri >= r->ys.size()) break;
if (li >= l->ys.size()) n->ys.push_back(r->ys[ri++]);
else if (ri >= r->ys.size()) n->ys.push_back(l->ys[li++]);
else {
n->ys.push_back( l->ys[li].y < r->ys[ri].y ? l->ys[li++] : r->ys[ri++] );
}
}
return n;
}
int AN, BN, R;
vector<Point> A, B;
/* (sx <= x <= gx && sy <= y <= gy)なる点(x, y)の個数を返す
* 閉区間なの注意 */
void query(shared_ptr<Node>& root, Long sx, Long sy, Long gx, Long gy, const Point& p) {
if (gx < root->left_x || root->right_x < sx) {
// do nothing;
} else if (sx <= root->left_x && root->right_x <= gx) {
vector<Point>& ys = root->ys;
auto lb = upper_bound(whole(ys), Point(0, sy - 1), Point::compY);
auto ub = lower_bound(whole(ys), Point(0, gy + 1), Point::compY);
for (auto it = lb; it < ub; it++) {
if (it->type == 'a') continue;
if (dist2(*it, p) <= (4 * R) * (4 * R)) ans++;
}
//result.insert(result.end(), lb, ub);
} else {
query(root->left, sx, sy, gx, gy, p);
query(root->right, sx, sy, gx, gy, p);
}
}
bool input() {
cin >> AN >> BN >> R;
if (AN == 0 && BN == 0 && R == 0) return false;
A.clear(); B.clear();
A.resize(AN); B.resize(BN);
for (int i = 0; i < AN; i++) {
cin >> A[i].x >> A[i].y;
A[i].type = 'a';
}
for (int i = 0; i < BN; i++) {
cin >> B[i].x >> B[i].y;
B[i].type = 'b';
}
return true;
}
ostream& operator<<(ostream& os, const Point& p) {
return os << "(" << p.x << "," << p.y << ")";
}
bool operator<(const Point& a, const Point& b) {
return a.x == b.x ? a.y < b.y : a.x < b.x;
}
Long dist2(const Point& a, const Point& b) {
Long dx = a.x - b.x,
dy = a.y - b.y;
return dx * dx + dy * dy;
}
void solve() {
vector<Point> p = A;
B.insert(B.end(), A.begin(), A.end());
sort(whole(B));
auto rtree = construct(whole(B));
p.clear();
ans = 0;
for (int i = 0; i < AN; i++) {
Point& p = A[i];
query(rtree, p.x - 4 * R, p.y - 4 * R, p.x + 4 * R, p.y + 4 * R, p);
}
cout << ans << endl;
}
int main() {
while (input()) solve();
return 0;
} | a.cc:1:2: error: stray '#' in program
1 | g#include <bits/stdc++.h>
| ^
a.cc:1:1: error: 'g' does not name a type
1 | g#include <bits/stdc++.h>
| ^
a.cc:8:1: error: 'ostream' does not name a type
8 | ostream& operator<<(ostream& os, const vector<T>& vs) {
| ^~~~~~~
a.cc:40:5: error: 'shared_ptr' does not name a type
40 | shared_ptr<Node> left, right;
| ^~~~~~~~~~
a.cc:42:5: error: 'vector' does not name a type
42 | vector<Point> ys;
| ^~~~~~
a.cc:44:1: error: 'ostream' does not name a type
44 | ostream& operator<<(ostream& os, const Node& node) {
| ^~~~~~~
a.cc:47:1: error: 'shared_ptr' does not name a type
47 | shared_ptr<Node> construct(vector<Point>::iterator lb, vector<Point>::iterator ub) {
| ^~~~~~~~~~
a.cc:75:1: error: 'vector' does not name a type
75 | vector<Point> A, B;
| ^~~~~~
a.cc:79:6: error: variable or field 'query' declared void
79 | void query(shared_ptr<Node>& root, Long sx, Long sy, Long gx, Long gy, const Point& p) {
| ^~~~~
a.cc:79:12: error: 'shared_ptr' was not declared in this scope
79 | void query(shared_ptr<Node>& root, Long sx, Long sy, Long gx, Long gy, const Point& p) {
| ^~~~~~~~~~
a.cc:79:27: error: expected primary-expression before '>' token
79 | void query(shared_ptr<Node>& root, Long sx, Long sy, Long gx, Long gy, const Point& p) {
| ^
a.cc:79:30: error: 'root' was not declared in this scope
79 | void query(shared_ptr<Node>& root, Long sx, Long sy, Long gx, Long gy, const Point& p) {
| ^~~~
a.cc:79:41: error: expected primary-expression before 'sx'
79 | void query(shared_ptr<Node>& root, Long sx, Long sy, Long gx, Long gy, const Point& p) {
| ^~
a.cc:79:50: error: expected primary-expression before 'sy'
79 | void query(shared_ptr<Node>& root, Long sx, Long sy, Long gx, Long gy, const Point& p) {
| ^~
a.cc:79:59: error: expected primary-expression before 'gx'
79 | void query(shared_ptr<Node>& root, Long sx, Long sy, Long gx, Long gy, const Point& p) {
| ^~
a.cc:79:68: error: expected primary-expression before 'gy'
79 | void query(shared_ptr<Node>& root, Long sx, Long sy, Long gx, Long gy, const Point& p) {
| ^~
a.cc:79:72: error: expected primary-expression before 'const'
79 | void query(shared_ptr<Node>& root, Long sx, Long sy, Long gx, Long gy, const Point& p) {
| ^~~~~
a.cc: In function 'bool input()':
a.cc:98:5: error: 'cin' was not declared in this scope
98 | cin >> AN >> BN >> R;
| ^~~
a.cc:100:5: error: 'A' was not declared in this scope
100 | A.clear(); B.clear();
| ^
a.cc:100:16: error: 'B' was not declared in this scope
100 | A.clear(); B.clear();
| ^
a.cc: At global scope:
a.cc:113:1: error: 'ostream' does not name a type
113 | ostream& operator<<(ostream& os, const Point& p) {
| ^~~~~~~
a.cc: In function 'void solve()':
a.cc:126:5: error: 'vector' was not declared in this scope
126 | vector<Point> p = A;
| ^~~~~~
a.cc:126:17: error: expected primary-expression before '>' token
126 | vector<Point> p = A;
| ^
a.cc:126:19: error: 'p' was not declared in this scope
126 | vector<Point> p = A;
| ^
a.cc:126:23: error: 'A' was not declared in this scope
126 | vector<Point> p = A;
| ^
a.cc:127:5: error: 'B' was not declared in this scope
127 | B.insert(B.end(), A.begin(), A.end());
| ^
a.cc:128:5: error: 'sort' was not declared in this scope; did you mean 'short'?
128 | sort(whole(B));
| ^~~~
| short
a.cc:129:18: error: 'construct' was not declared in this scope; did you mean 'struct'?
129 | auto rtree = construct(whole(B));
| ^~~~~~~~~
| struct
a.cc:134:9: error: 'query' was not declared in this scope
134 | query(rtree, p.x - 4 * R, p.y - 4 * R, p.x + 4 * R, p.y + 4 * R, p);
| ^~~~~
a.cc:136:5: error: 'cout' was not declared in this scope
136 | cout << ans << endl;
| ^~~~
a.cc:136:20: error: 'endl' was not declared in this scope
136 | cout << ans << endl;
| ^~~~
|
s374922410 | p00609 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#pragma warning(disable:4996)
int n, m, r, x[100000], y[100000];
vector<int>dp[11000];
int main() {
while (true) {
cin >> n >> m >> r; if (n == 0)break;
for (int i = 0; i < 11000; i++)dp[i].clear();
for (int i = 0; i < n; i++)cin >> x[i] >> y[i];
for (int i = 0; i < m; i++) {
int AA, BB; cin >> AA >> BB;
dp[AA].push_back(BB);
}
int cnt = 0;
for (int i = 0; i < n; i++) {
for (int j = -r * 4; j <= r * 4; j++) {
int J = x[i] + j; if (J < 0)continue;
int L = sqrt(r*r*16 - j*j);
int P1 = y[i] - L, Q1 = y[i] + L;
int pos1 = lower_bound(dp[J].begin(), dp[J].end(), P1) - dp[J].begin();
int pos2 = lower_bound(dp[J].begin(), dp[J].end(), Q1 + 1) - dp[J].begin();
cnt += pos2 - pos1;
}
}
cout << cnt << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:21:41: error: 'sqrt' was not declared in this scope
21 | int L = sqrt(r*r*16 - j*j);
| ^~~~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.