submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s621978781 | p00189 | C++ | /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
| |
s341046443 | p00189 | C++ | #include <queue>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 9999999
typedef int Weight;
struct Edge {
int src, dst;
Weight weight;
Edge(int src, int dst, Weight weight) :
src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
bool shortestPath(const Graph &g,
Matrix &dist, vector<vector<int> > &prev) {
int n = g.size();
Array h(n+1);
REP(k,n) REP(i,n) FOR(e,g[i]) {
if (h[e->dst] > h[e->src] + e->weight) {
h[e->dst] = h[e->src] + e->weight;
if (k == n-1) return false; // negative cycle
}
}
dist.assign(n, Array(n, INF));
prev.assign(n, vector<int>(n, -2));
REP(s, n) {
priority_queue<Edge> Q;
Q.push(Edge(s, s, 0));
while (!Q.empty()) {
Edge e = Q.top(); Q.pop();
if (prev[s][e.dst] != -2) continue;
prev[s][e.dst] = e.src;
FOR(f,g[e.dst]) {
if (dist[s][f->dst] > e.weight + f->weight) {
dist[s][f->dst] = e.weight + f->weight;
Q.push(Edge(f->src, f->dst, e.weight + f->weight));
}
}
}
REP(u, n) dist[s][u] += h[u] - h[s];
}
}
vector<int> buildPath(const vector< vector<int> >& prev, int s, int t) {
vector<int> path;
for (int u = t; u >= 0; u = prev[s][u])
path.push_back(u);
reverse(ALL(path));
return path;
}
int main() {
int n;
while(cin>>n,n){
Graph g(10);
Matrix d;
vector<vector<int> > p;
REP(i,n){
int a,b,c;
cin>>a>>b>>c;
g[a].push_back(Edge(a,b,c));
g[b].push_back(Edge(b,a,c));
}
shortestPath(g,d,p);
int mn=INF,t,mi;
REP(i,d.size()){
if(d[i][0]==INF)continue;
t=0;
REP(j,d[i].size()){
if(d[i][j]==INF||i==j)continue;
t+=d[i][j];
}
if(t<mn)mn=t,mi=i;
}
cout<<mi<<" "<<mn<<endl;
}
return 0;
} | a.cc: In function 'std::vector<int> buildPath(const std::vector<std::vector<int> >&, int, int)':
a.cc:63:3: error: 'reverse' was not declared in this scope
63 | reverse(ALL(path));
| ^~~~~~~
a.cc: In function 'bool shortestPath(const Graph&, Matrix&, std::vector<std::vector<int> >&)':
a.cc:58:1: warning: control reaches end of non-void function [-Wreturn-type]
58 | }
| ^
|
s008987974 | p00189 | C++ | #include<iostream>
#include<queue>
#define HOME 10
#define ROAD 45
#define MAX 100000000
using namespace std;
int dis[HOME][HOME];
bool chk[HOME];
class Datum {
public:
int now;
int dis;
Datum(int n, int d) {now = n;dis = d;}
Datum() {}
};
bool operator<( const Datum& a, const Datum& b ) {
return a.dis < b.dis;
}
bool operator>( const Datum& a, const Datum& b ) {
return a.dis > b.dis;
}
int main () {
while ( true ) {
int n;
cin >> n;
if ( n == 0 )
break;
for ( int i=0; i<HOME;i ++ ) {
for ( int j=0; j<HOME; j++ ) {
dis[i][j] = MAX;
}
}
int find = -1;
for ( int i=0;i<n; i++ ) {
int from, to, distance;
cin >> from >> to >> distance;
if ( find < to )
find = to;
if ( find < from )
find = from;
dis[from][to] = distance;
dis[to][from] = distance;
dis[i][i] = 0;
}
n = find+1;
priority_queue<Datum, vector<Datum>, greater<Datum> > flow;
while( !flow.empty() ) {
flow.pop();
}
for ( int i=0 ; i<n; i++ ) {
while( !flow.empty() ) {
flow.pop();
}
flow.push(Datum(i,0));
int count = n;
memset( chk, false, n*sizeof(bool) );
while(!flow.empty()) {
Datum now;
now = flow.top();
flow.pop();
for ( int j=0; j<n; j++ ) {
if ( i != j ) {
if ( chk[j] )
continue;
if ( dis[now.now][j] + now.dis <= dis[i][j] ) {
dis[i][j] = dis[now.now][j] + now.dis;
dis[j][i] = dis[now.now][j] + now.dis;
if ( dis[now.now][j] == MAX )
continue;
chk[j] = true;
count--;
flow.push(Datum(j,dis[i][j]));
}
}
}
if ( count == 1 ) {
break;
}
}
}
int maxhome = -1;
int maxdis = MAX;
for ( int i=0; i<n; i++ ) {
int sum = 0;
for ( int j=0; j<n; j++ ) {
sum += dis[i][j];
}
if ( maxdis > sum ) {
maxdis = sum;
maxhome = i;
}
}
cout << maxhome << ' ' << maxdis << endl;
}
} | a.cc: In function 'int main()':
a.cc:76:25: error: 'memset' was not declared in this scope
76 | memset( chk, false, n*sizeof(bool) );
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<queue>
+++ |+#include <cstring>
3 | #define HOME 10
|
s383883825 | p00189 | C++ | #include<cstdio>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)
int main(){
while(1){
int n;
cin>>n;
if(n==0)break;
int dp[111][111]={0};
rep(i,111)rep(j,111)dp[i][j]=1000000000;
rep(i,n){
int a,b,c;
cin>>a>>b>>c;
dp[a][b]=c;
dp[b][a]=c;
}
rep(i,111)dp[i][i]=0;
rep(k,n){
rep(i,n){
rep(j,n){
dp[i][j] = min(dp[i][k]+dp[k][j],dp[i][j]);
}
}
}
int ans=1000000000;
rep(i,n){
int sum=0;
rep(j,m){
sum+=dp[i][j];
}
ans = min(ans,sum);
}
printf("%d\n",ans);
}
} | a.cc: In function 'int main()':
a.cc:42:31: error: 'm' was not declared in this scope
42 | rep(j,m){
| ^
a.cc:10:32: note: in definition of macro 'rep'
10 | #define rep(i,n) for(int i=0;i<n;i++)
| ^
|
s108704441 | p00189 | C++ | #include <iostream>
#include <vector>
#include <queue>
const int INF = INT_MAX/10;
using namespace std;
const int V_MAX = 10;
const int E_MAX = 45;
typedef pair<int, int> P; // v, cost
int main() {
int N;
while (cin >> N) {
int V = 0;
int d[V_MAX][V_MAX];
if (N == 0) break;
for (int i = 0; i < V_MAX; i++) {
for (int j = 0; j < V_MAX; j++) {
if (i == j) d[i][j] = 0;
else d[i][j] = INF;
}
}
for (int i = 0; i < N; i++) {
int a, b, c;
cin >> a >> b >> c;
d[a][b] = c;
d[b][a] = c;
V = max(V, a); V = max(V, b);
}
for (int k = 0; k <= V; k++) {
for (int i = 0; i <= V; i++) {
for (int j = 0; j <= V; j++) {
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
}
}
int m = INF;
int ans = -1;
for (int i = 0; i <= V; i++) {
int sum = 0;
for (int j = 0; j <= V; j++) {
if (i != j) {
if (d[i][j] != INF) {
sum += d[i][j];
}
}
}
if (sum < m) {
m = sum;
ans = i;
}
}
printf("%d %d\n", ans, m);
}
return 0;
} | a.cc:5:17: error: 'INT_MAX' was not declared in this scope
5 | const int INF = INT_MAX/10;
| ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
3 | #include <queue>
+++ |+#include <climits>
4 |
|
s538320030 | p00189 | C++ | #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }
const int MAX_M = 10;
struct Edge{ int u, v, cost; };
int dijkstra(vector<Edge>& edges, int m, int s)
{
vint d(m, INT_MAX);
d[s] = 0;
bool update = true;
while(update)
{
update = false;
rep(i, edges.size())
{
Edge e = edges[i];
if(d[e.u] != INT_MAX && d[e.u] + e.cost < d[e.v])
{
d[e.v] = d[e.u] + e.cost;
update = true;
}
if(d[e.v] != INT_MAX && d[e.v] + e.cost < d[e.u])
{
d[e.u] = d[e.v] + e.cost;
update = true;
}
}
}
return accumulate(ALL(d), 0);
}
int main()
{
int n;
while(cin >> n && n)
{
int cost = INT_MAX, index = 0, m = 0;
vector<Edge> edges(n);
rep(i, n)
{
cin >> edges[i].u >> edges[i].v >> edges[i].cost;
chmax(m, max(edges[i].u, edges[i].v) + 1);
}
rep(i, m)
{
int tmp = dijkstra(edges, m, i);
if(tmp < cost)
{
index = i;
cost = tmp;
}
}
cout << index << " " << cost << endl;
}
} | a.cc: In function 'int dijkstra(std::vector<Edge>&, int, int)':
a.cc:44:19: error: 'INT_MAX' was not declared in this scope
44 | vint d(m, INT_MAX);
| ^~~~~~~
a.cc:24:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
23 | #include <fstream>
+++ |+#include <climits>
24 | using namespace std;
a.cc: In function 'int main()':
a.cc:78:28: error: 'INT_MAX' was not declared in this scope
78 | int cost = INT_MAX, index = 0, m = 0;
| ^~~~~~~
a.cc:78:28: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:84:31: error: 'm' was not declared in this scope
84 | chmax(m, max(edges[i].u, edges[i].v) + 1);
| ^
a.cc:87:24: error: 'm' was not declared in this scope
87 | rep(i, m)
| ^
a.cc:32:41: note: in definition of macro 'REP'
32 | #define REP(i, x, n) for(int i = x; i < n; i++)
| ^
a.cc:87:17: note: in expansion of macro 'rep'
87 | rep(i, m)
| ^~~
a.cc:93:41: error: overloaded function with no contextual type information
93 | index = i;
| ^
a.cc:98:22: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and '<unresolved overloaded function type>')
98 | cout << index << " " << cost << endl;
| ~~~~~^~~~~~~~
In file included from /usr/include/c++/14/iostream:41,
from a.cc:7:
/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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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: |
s014656049 | p00189 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
int map[10][10];
int cmp(int i,int j,int k){
if(map[i][j]==-1){
if(map[i][k]>=0 && map[k][j]>=0)
return map[i][k]+map[k][j];
else
return -1;
}else
if(map[i][k]==-1 || map[k][j]==-1)
return map[i][j];
else
return min(map[i][j],map[i][k]+map[k][j]);
}
int main(){
for(int n;scanf("%d",&n),n;){
int m=0;
memset(map,-1,sizeof(map));
for(;n--;){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
m=m>a?m:a;m=n>b?m:b;
map[a][b] = map[b][a] = c;
}
for(int i=0; i<=m; i++)
map[i][i] = 0;
for(int k=0; k<=m; k++)
for(int i=0; i<=m; i++)
for(int j=0; j<=m; j++)
map[i][j] = cmp(i,j,k);
// for(int i=0; i<=m; i++){
// for(int j=0; j<=m; j++)
// printf("%3d ",map[i][j]);
// putchar('\n');
// }
int num,sum=-1;
for(int i=0; i<=m; i++){
int tsum=0;
for(int j=0; j<=m; j++)
tsum += map[i][j];
if(sum==-1||tsum<sum){
num=i; sum=tsum;
}
}
printf("%d %d\n",num,sum);
}
} | a.cc: In function 'int main()':
a.cc:24:5: error: 'memset' was not declared in this scope
24 | memset(map,-1,sizeof(map));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <algorithm>
+++ |+#include <cstring>
3 |
|
s440437440 | p00189 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
int map[10][10];
int cmp(int i,int j,int k){
if(map[i][j]==-1){
if(map[i][k]>=0 && map[k][j]>=0)
return map[i][k]+map[k][j];
else
return -1;
}else
if(map[i][k]==-1 || map[k][j]==-1)
return map[i][j];
else
return min(map[i][j],map[i][k]+map[k][j]);
}
int main(){
for(int n;scanf("%d",&n),n;){
int m=0;
memset(map,-1,sizeof(map));
for(;n--;){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
m=m>a?m:a;m=n>b?m:b;
map[a][b] = map[b][a] = c;
}
for(int i=0; i<=m; i++)
map[i][i] = 0;
for(int k=0; k<=m; k++)
for(int i=0; i<=m; i++)
for(int j=0; j<=m; j++)
map[i][j] = cmp(i,j,k);
// for(int i=0; i<=m; i++){
// for(int j=0; j<=m; j++)
// printf("%3d ",map[i][j]);
// putchar('\n');
// }
int num,sum=-1;
for(int i=0; i<=m; i++){
int tsum=0;
for(int j=0; j<=m; j++)
tsum += map[i][j];
if(sum==-1||tsum<sum){
num=i; sum=tsum;
}
}
printf("%d %d\n",num,sum);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:5: error: 'memset' was not declared in this scope
24 | memset(map,-1,sizeof(map));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <algorithm>
+++ |+#include <cstring>
3 |
|
s312782592 | p00189 | C++ | #include<queue>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
const int TOWN = 11;
const int ROAD = 50;
const int INF = 10000;
int d[TOWN][TOWN] ;
int n,a,b,c;
int main()
{
while(cin >> n && n)
{
memset(d,INF,sizeof(d));
int townnum = 0;
REP(n)
{
cin>> a >> b >> c;
d[a][b] = c;
d[b][a] = c;
d[i][i] = 0;
townnum = max(townnum,a);
townnum = max(townnum,b);
}
//cout << "town "<<townnum << endl;
rep(k,townnum+1)rep(i,townnum+1)rep(j,townnum+1)//if(d[i][j] != INF)
{
d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
d[j][i] = d[i][j];
}
int time = 1000000,town = 0;
rep(i,townnum+1)//town i
{
int sum = 0;
rep(j,townnum+1) sum += d[i][j];//i to j
//cout << sum << endl;
if(sum < time){ time = sum; town = i;}
}
cout << town << " " << time << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:19:15: error: 'cin' was not declared in this scope
19 | while(cin >> n && n)
| ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
4 | #include<cmath>
+++ |+#include <iostream>
5 | using namespace std;
a.cc:47:17: error: 'cout' was not declared in this scope
47 | cout << town << " " << time << endl;
| ^~~~
a.cc:47:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:47:48: error: 'endl' was not declared in this scope
47 | cout << town << " " << time << endl;
| ^~~~
a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
4 | #include<cmath>
+++ |+#include <ostream>
5 | using namespace std;
|
s987727469 | p00189 | C++ | #include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#define inf 1000000000
using namespace std;
unsigned long long d[10][10],sum[10];
int v;
int main()
{
int n;
while(cin>>n,n)
{
bool used[10];
memset(used,0,sizeof(used));
memset(d,0,sizeof(d));
memset(sum,0,sizeof(sum));
for(int i=0;i<n;i++)
{
int s,t,c;
cin>>s>>t>>c;
used[s]=used[t]=true;
d[s][t]=d[t][s]=c;
}
v=0;
for(int i=0;i<10;i++)
{
if(used[i]) v++;
for(int j=0;j<10;j++)
{
if(d[i][j]==0&&i!=j) d[i][j]=inf;
}
}
for(int k=0;k<v;k++)
{
for(int i=0;i<v;i++)
{
for(int j=0;j<v;j++) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}
}
int ans;
for(int i=0;i<v;i++)
{
for(int j=0;j<v;j++)
{
sum[i]+=d[i][j];
}
}
ans=min_element(sum,sum+v)-sum;
cout<<ans<<" "<<sum[ans]<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:52:21: error: 'min_element' was not declared in this scope
52 | ans=min_element(sum,sum+v)-sum;
| ^~~~~~~~~~~
|
s644484963 | p00189 | C++ | #include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#define inf 1000000000
using namespace std;
unsigned long long d[10][10],sum[10];
int v;
int main()
{
int n;
while(cin>>n,n)
{
bool used[10];
memset(used,0,sizeof(used));
memset(d,0,sizeof(d));
memset(sum,0,sizeof(sum));
for(int i=0;i<n;i++)
{
int s,t,c;
cin>>s>>t>>c;
used[s]=used[t]=true;
d[s][t]=d[t][s]=c;
}
v=0;
for(int i=0;i<10;i++)
{
if(used[i]) v++;
for(int j=0;j<10;j++)
{
if(d[i][j]==0&&i!=j) d[i][j]=inf;
}
}
for(int k=0;k<v;k++)
{
for(int i=0;i<v;i++)
{
for(int j=0;j<v;j++) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}
}
int ans;
for(int i=0;i<v;i++)
{
for(int j=0;j<v;j++)
{
sum[i]+=d[i][j];
}
}
ans=min_element(sum,sum+v)-sum;
cout<<ans<<" "<<sum[ans]<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:52:21: error: 'min_element' was not declared in this scope
52 | ans=min_element(sum,sum+v)-sum;
| ^~~~~~~~~~~
|
s138739990 | p00189 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
#define INF 10000
#define MAXV 45
int dist[MAXV][MAXV];
int main(void){
int n;
while(1){
int town=0;
cin >> n;
if(n==0)break;
memset(dist,INF,sizeof(int)*MAXV*MAXV);
for(int i=0; i<n; i++){
int from,to,cost;
cin >> from >> to >> cost;
dist[from][to] = cost;
dist[to][from] = cost;
town = max(town,max(to,from));
}
town++;
for(int i=0; i<town; i++)
dist[i][i] = 0;
for(int k=0; k<town; k++)
for(int i=0; i<town; i++)
for(int j=0; j<town; j++)
dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
/*
for(int i=0; i<town; i++){
for(int j=0; j<town; j++){
printf("%3d",dist[i][j]);
}
printf("\n");
}
*/
int mincost=INF;
int mintown;
for(int i=0; i<town; i++){
int cost=0;
for(int j=0; j<town; j++)
cost += dist[i][j];
if(mincost>cost){
mincost = cost;
mintown = i;
}
}
cout << mintown << " " << mincost << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:18:17: error: 'memset' was not declared in this scope
18 | memset(dist,INF,sizeof(int)*MAXV*MAXV);
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<algorithm>
+++ |+#include <cstring>
3 | using namespace std;
|
s621758160 | p00189 | C++ | #include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define INF 10000
#define MAXV 45
int dist[MAXV][MAXV];
int main(void){
int n;
while(1){
int town=0;
cin >> n;
if(n==0)break;
memset(dist,INF,sizeof(int)*MAXV*MAXV);
for(int i=0; i<n; i++){
int from,to,cost;
cin >> from >> to >> cost;
dist[from][to] = cost;
dist[to][from] = cost;
town = max(town,max(to,from));
}
town++;
for(int i=0; i<town; i++)
dist[i][i] = 0;
for(int k=0; k<town; k++)
for(int i=0; i<town; i++)
for(int j=0; j<town; j++)
dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
/*
for(int i=0; i<town; i++){
for(int j=0; j<town; j++){
printf("%3d",dist[i][j]);
}
printf("\n");
}
*/
int mincost=INF;
int mintown;
for(int i=0; i<town; i++){
int cost=0;
for(int j=0; j<town; j++)
cost += dist[i][j];
if(mincost>cost){
mincost = cost;
mintown = i;
}
}
cout << mintown << " " << mincost << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:19:17: error: 'memset' was not declared in this scope
19 | memset(dist,INF,sizeof(int)*MAXV*MAXV);
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<algorithm>
+++ |+#include <cstring>
3 | #include<string>
|
s632889701 | p00189 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
int main(){
while(true){
int n;
cin >> n;
if(n == 0){
break;
}
int* start = new int[n];
int* goal = new int[n];
int* cost = new int[n];
for(int i = 0; i < n; i++){
cin >> start[i] >> goal[i] >> cost[i];
}
int town = 0;
for(int i = 0; i < n; i++){
town = max(town ,start[i], goal[i]);
}
town++;
vector<vector<int> > dist(town, vector<int>(town, INT_MAX / 2));
for(int i = 0; i < n; i++){
dist[start[i]][goal[i]] = cost[i];
dist[goal[i]][start[i]] = cost[i];
}
for(int i = 0; i < town; i++){
dist[i][i] = 0;
}
for(int k = 0; k < town; k++){
for(int i = 0; i < town; i++){
for(int j = 0; j < town; j++){
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
}
}
int* total = new int[town];
int TOTAL = INT_MAX / 2;
int S = 0;
for(int i = 0; i < town; i++){
total[i] = 0;
}
for(int i = 0; i < town; i++){
for(int j = 0; j < town; j++){
total[i] += dist[i][j];
}
if(TOTAL > total[i]){
TOTAL = min(TOTAL, total[i]);
S = i;
}
}
cout << S << " " << TOTAL << endl;
delete [] start;
delete [] goal;
delete [] cost;
delete [] total;
}
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:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:28:14: required from here
28 | town = max(town ,start[i], goal[i]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function
306 | if (__comp(__a, __b))
| ~~~~~~^~~~~~~~~~
|
s495349641 | p00189 | C++ | >#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
using namespace std;
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))
#define eq ==
typedef long long ll;
typedef complex<double> point;
// up right down left
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};
const int NO = 1000000000;
int main(){
while(true){
int n;
cin >> n;
if(n==0)break;
vector<pair<pair<int,int>,int> > R;
int m=0;
rep(i,n){
int a,b,c;
cin >> a >> b >> c;
m = max(m,max(a,b));
R.push_back(mp(mp(a,b),c));
}
m++;
vector<vector<int> > V(m,vector<int>(m,NO));
rep(i,m){
V[i][i] = 0;
}
rep(i,n){
int a = R[i].first.first;
int b = R[i].first.second;
int c = R[i].second;
V[a][b] = V[b][a] = c;
}
cerr << __LINE__ << endl;
for(int k=0;k<m;k++){
for(int i=0;i<m;i++){
for(int j=0;j<m;j++){
V[i][j] = min(V[i][j],V[i][k]+V[k][j]);
}
}
}
int ret = -1;
int mi = NO;
for(int i=0;i<m;i++){
int s = 0;
for(int j=0;j<m;j++){
s += V[i][j];
}
if(mi > s){
mi = s;
ret = i;
}
}
cout << ret << " " << mi << endl;
}
return 0;
} | a.cc:1:2: error: stray '#' in program
1 | >#include <iostream>
| ^
a.cc:1:1: error: expected unqualified-id before '>' token
1 | >#include <iostream>
| ^
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/iomanip:41,
from a.cc:3:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
68 | typedef ptrdiff_t streamsize; // Signed integral type
| ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
40 | #include <cwchar> // For mbstate_t
+++ |+#include <cstddef>
41 |
In file included from /usr/include/c++/14/bits/char_traits.h:50,
from /usr/include/c++/14/string:42,
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/iomanip:42:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
In file included from /usr/include/stdio.h:34,
from /usr/include/c++/14/cstdio:42,
from a.cc:2:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
/usr/include/c++/14/bits/char_traits.h:144:61: error: 'std::size_t' has not been declared
144 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n);
| ^~~
/usr/include/c++/14/bits/char_traits.h:146:40: error: 'size_t' in namespace 'std' does not name a type
146 | static _GLIBCXX14_CONSTEXPR std::size_t
| ^~~~~~
/usr/include/c++/14/bits/char_traits.h:150:34: error: 'std::size_t' has not been declared
150 | find(const char_type* __s, std::size_t __n, const char_type& __a);
| ^~~
/usr/include/c++/14/bits/char_traits.h:153:52: error: 'std::size_t' has not been declared
153 | move(char_type* __s1, const char_type* __s2, std::size_t __n);
| ^~~
/usr/include/c++/14/bits/char_traits.h:156:52: error: 'std::size_t' has not been declared
156 | copy(char_type* __s1, const char_type* __s2, std::size_t __n);
| ^~~
/usr/include/c++/14/bits/char_traits.h:159:30: error: 'std::size_t' has not been declared
159 | assign(char_type* __s, std::size_t __n, char_type __a);
| ^~~
/usr/include/c++/14/bits/char_traits.h:187:59: error: 'std::size_t' has not been declared
187 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n)
| ^~~
/usr/include/c++/14/bits/char_traits.h: In static member function 'static constexpr int __gnu_cxx::char_traits<_CharT>::compare(const char_type*, const char_type*, int)':
/usr/include/c++/14/bits/char_traits.h:189:17: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
189 | for (std::size_t __i = 0; __i < __n; ++__i)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/bits/char_traits.h:189:33: error: '__i' was not declared in this scope; did you mean '__n'?
189 | for (std::size_t __i = 0; __i < __n; ++__i)
| |
s867957321 | p00189 | C++ | #include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<queue>
using namespace std;
const int MAX = 10;
const int INF = INT_MAX/3;
int main(){
ios::sync_with_stdio(false);
int cost[MAX][MAX];
bool existTown[MAX];
int n;
while(cin >> n && n != 0){
fill(*cost,*(cost+MAX),INF);
fill(existTown,existTown+MAX,false);
for(int i = 0;i < n;i++){
int a,b,c;
cin >> a >> b >> c;
cost[a][b] = cost[b][a] = c;
existTown[a] = existTown[b] = true;
}
for (int k = 0; k < MAX; ++k){
for (int j = 0; j < MAX; ++j){
for (int i = 0; i < MAX; ++i){
int sum = cost[i][k] + cost[k][j];
if(cost[i][j] > sum){
cost[i][j] = cost[j][i] = sum;
}
}
}
}
/*
for (int i = 0; i < MAX; ++i){
for (int j = 0; j < MAX; ++j){
if(cost[i][j] == INF)cout << INF;
else cout << cost[i][j];
cout << ' ';
}
cout << endl;
}
*/
int ans = 100;
int mini = INF;
for(int i = 0;i < MAX;i++){
if(!existTown[i])continue;
int sum = 0;
for(int j = 0;j < MAX;j++){
if(existTown[j] && j != i)sum += cost[i][j];
}
if(mini > sum){
mini = sum;
ans = i;
}
}
cout << ans << ' ' << mini << endl;
}
return 0;
} | a.cc:19:17: error: 'INT_MAX' was not declared in this scope
19 | const int INF = INT_MAX/3;
| ^~~~~~~
a.cc:15:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
14 | #include<utility>
+++ |+#include <climits>
15 | #include<queue>
|
s929311316 | p00189 | C++ | #include <iostream>
#include <set>
#include "procpn.hpp"
using namespace std;
using namespace procon;
int main(){
int e;
set<int> v;
int d[MAX_V][MAX_V];
while(cin >> e,e){
fill((int*)d,(int*)d + MAX_V * MAX_V,INF);
FOR(i,0,e){
int f,t,p;
cin >> f >> t >> p;
d[f][t] = p;
v.insert(f); v.insert(t);
}
FORI(i,v) d[*i][*i] = 0;
warshall_floyed(MAX_V,d);
int town = 0;
int m = INF;
FORI(i,v){
int t = 0;
FORI(j,v){
t += d[*i][*j];
}
if(m < t) continue;
m = t;
town = *i;
}
cout << town << " " << m << endl;
}
return 0;
} | a.cc:3:10: fatal error: procpn.hpp: No such file or directory
3 | #include "procpn.hpp"
| ^~~~~~~~~~~~
compilation terminated.
|
s305414491 | p00189 | C++ | #include <iostream>
#include <set>
#include "procpn.hpp"
using namespace std;
using namespace procon;
int main(){
int e;
set<int> v;
int d[MAX_V][MAX_V];
while(cin >> e,e){
fill((int*)d,(int*)d + MAX_V * MAX_V,INF);
FOR(i,0,e){
int f,t,p;
cin >> f >> t >> p;
d[f][t] = p;
v.insert(f); v.insert(t);
}
FORI(i,v) d[*i][*i] = 0;
warshall_floyed(MAX_V,d);
int town = 0;
int m = INF;
FORI(i,v){
int t = 0;
FORI(j,v){
t += d[*i][*j];
}
if(m < t) continue;
m = t;
town = *i;
}
cout << town << " " << m << endl;
}
return 0;
} | a.cc:3:10: fatal error: procpn.hpp: No such file or directory
3 | #include "procpn.hpp"
| ^~~~~~~~~~~~
compilation terminated.
|
s499828480 | p00189 | C++ | #include <cstring>
#include <iostream>
#include <queue>
using namespace std;
int n, m; // 道の数,街の数
int edges[10][10];
int dijkstra(int from, int to) {
bool visited[m];
fill(visited, visited + m, false);
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
que.push(make_pair(0, from));
visited[0] = true;
while (!que.empty()) {
pair<int, int> current = que.top();
que.pop();
const int dist = current.first;
const int pos = current.second;
if (pos == to) {
return dist;
}
for (int i = 0; i < m; i++) {
if (!visited[i] && edges[pos][i] != 0x7f7f7f7f) {
visited[i] = true;
que.push(make_pair(dist + edges[pos][i], i));
}
}
}
return -1;
}
int main() {
while (cin >> n, n) {
memset(edges, 0x7f, sizeof(edges));
for (int i = 0; i < n; i++) {
int a, b, c;
cin >> a >> b >> c;
edges[a][b] = edges[b][a] = c;
m = max(a, max(b, m));
}
m++;
int res, res_time = 0x7fffffff;
for (int i = 0; i < m; i++) {
int total = 0;
for (int j = 0; j < m; j++) {
total += dijkstra(i, j);
}
if (total < res_time) {
res_time = total;
res = i;
}
}
cout << res << ' ' << res_time << endl;
}
return 0;
}x | a.cc:64:2: error: 'x' does not name a type
64 | }x
| ^
|
s816492950 | p00189 | C++ | #include <iostream>
#include <map>
using namespace std;
#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x>y?y:x)
#define INF 1000000
typedef long long ll;
typedef map<ll,int> M;
ll cost[15][15];
int main()
{
int n;
ll sum;
int max=0;
M d;
while(cin>>n,n){
max=0;
for(int i=0;i<15;i++){
for(int j=0;j<15;j++){
cost[i][j]=(i==j?0:INF);
}
}
for(int i=0;i<n;++i){
int a,b
ll c;
cin>>a>>b>>c;
cost[a][b]=c;
cost[b][a]=c;
if(max<MAX(a,b))max=MAX(a,b);
}
for(int i=0;i<=max;i++){
for(int j=0;j<=max;j++){
for(int k=0;k<=max;k++){
cost[i][j]=MIN(cost[i][j],cost[i][k]+cost[k][j]);
}
}
}
for(int i=0;i<=max;i++){
sum=0;
for(int j=0;j<=max;j++){
sum+=cost[i][j];
}
d[sum]=i;
}
M::iterator it=d.begin();
cout<<(*it).second<<" "<<(*it).first<<endl;
d.clear();
}
return 0;
} | a.cc: In function 'int main()':
a.cc:29:25: error: expected initializer before 'll'
29 | ll c;
| ^~
a.cc:30:33: error: 'b' was not declared in this scope
30 | cin>>a>>b>>c;
| ^
a.cc:30:36: error: 'c' was not declared in this scope
30 | cin>>a>>b>>c;
| ^
|
s113708667 | p00189 | C++ | #include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
#define INF 100000000
int edges[20][20];
int dist[20][20];
int main(){
cin.sync_with_stdio(false);
while(1){
int N;
cin >> N;
if(N == 0) break;
memset(edges,0,sizeof(edges));
int ids[20];
int nids = 0;
for(int i=0;i<N;++i){
int x,y,c;
cin >> x >> y >> c;
int ix=-1;
int iy=-1;
for(int l=0;l<nids;++l){
if(ids[l]==x) ix = l;
if(ids[l]==y) iy = l;
}
if(ix<0){ ix = nids; ids[nids++]=x; }
if(iy<0){ iy = nids; ids[nids++]=y; }
edges[ix][iy] = edges[iy][ix] = c;
}
for(int i=0;i<nids;++i){
for(int j=0;j<nids;++j){
if(i==j)
dist[i][j] = 0;
else if(edges[i][j]>0)
dist[i][j] = edges[i][j];
else
dist[i][j] = INF;
}
}
for(int k=0;k<nids;++k)
for(int i=0;i<nids;++i)
for(int j=0;j<nids;++j)
dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
int ans = 0;
int msum = INF;
for(int i=0;i<nids;++i){
int sum = 0;
for(int j=0;j<nids;++j){
if(dis[i][j]==INF)continue;
sum += dist[i][j];
}
if(sum<=msum){
if(sum==msum && ids[i]<ids[ans])
ans = i;
else
ans = i;
msum = sum;
}
}
cout << ids[ans] << " " << msum << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:76:19: error: 'dis' was not declared in this scope; did you mean 'ids'?
76 | if(dis[i][j]==INF)continue;
| ^~~
| ids
|
s925842897 | p00190 | C++ | #include <bits/stdc++.h>
#ifndef INCLUDE_ZOBRIST_HASH_HPP
#define INCLUDE_ZOBRIST_HASH_HPP
#include <random>
#include <iostream>
#include <typeinfo>
namespace orislib {
template <typename T, int W, int H, int STATE>
struct ZobristHash {
typedef T hash_t;
ZobristHash() {
std::random_device rd;
std::mt19937 mt(rd());
std::uniform_int_distribution<T> dist;
for (int h = 0; h < H; h++) {
for (int w = 0; w < W; w++) {
for (int s = 0; s < STATE; s++) {
rands[h][w][s] = dist(mt);
}
}
}
}
template <typename TT>
hash_t hash(TT data[H][W]) {
hash_t r = 0;
for (int h = 0; h < H; h++) {
for (int w = 0; w < W; w++) {
r ^= rands[h][w][data[h][w]];
}
}
return r;
}
hash_t rands[H][W][STATE];
};
}
#endif
using namespace std;
using namespace orislib;
typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ \
template <typename T> \
inline
#define TTF_ \
template <typename T, typename F> \
inline
TT_ T sq(T x) { return x * x; }
TT_ T In() {
T x;
cin >> x;
return x;
}
TT_ void Out(T& x) { cout << x; }
TT_ void sort(T& v) { sort(begin(v), end(v)); }
TT_ void revs(T& v) { reverse(begin(v), end(v)); }
TT_ void uniq(T& v) {
sort(v);
v.erase(unique(begin(v), end(v)), end(v));
}
TT_ int ubnd(T& v, typename T::value_type& x) {
return upper_bound(begin(v), end(v), x) - begin(v);
}
TT_ int lbnd(T& v, typename T::value_type& x) {
return lower_bound(begin(v), end(v), x) - begin(v);
}
TTF_ void inpt(T& v, int n, F f) {
for (v.reserve(n); n--; v.emplace_back(f()))
;
}
TTF_ void show(T& v, F f, string d = " ", string e = "\n") {
int i = 0;
for (auto& x : v) i++&&(cout << d), f(x);
cout << e;
}
TT_ typename T::iterator minel(T& v) { return min_element(begin(v), end(v)); }
TT_ typename T::iterator maxel(T& v) { return max_element(begin(v), end(v)); }
inline void fast_io() {
ios::sync_with_stdio(0);
cin.tie(0);
}
inline int in() {
int x;
scanf("%d", &x);
return x;
}
inline ll pow_mod(ll a, ll k, ll m) {
ll r = 1;
for (; k > 0; a = a * a % m, k >>= 1)
if (k & 1) r = r * a % m;
return r;
}
inline ll mod_inv(ll a, ll p) { return pow_mod(a, p - 2, p); }
//}}} priority_queue queue deque front stringstream max_element min_element
//insert count make_tuple
struct Board {
Board() {}
Board(const vector<vector<int>>& v) {
memset(b, '#', sizeof(b));
for (int i = 0; i < 5; i++) b[i][5] = 0;
for (int i = 0; i < v[0].size(); i++) b[0][2 + i] = conv_hex(v[0][i]);
for (int i = 0; i < v[1].size(); i++) b[1][1 + i] = conv_hex(v[1][i]);
for (int i = 0; i < v[2].size(); i++) b[2][0 + i] = conv_hex(v[2][i]);
for (int i = 0; i < v[3].size(); i++) b[3][1 + i] = conv_hex(v[3][i]);
for (int i = 0; i < v[4].size(); i++) b[4][2 + i] = conv_hex(v[4][i]);
int it = 0;
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
if (b[i][j] == '0') {
cx[it] = j;
cy[it] = i;
it++;
}
}
}
turn = 0;
}
char conv_hex(int a) { return "0123456789ABCDEF"[a]; }
bool slide(int index, int dir) {
int px = cx[index], py = cy[index];
int nx = px + dx[dir], ny = py + dy[dir];
if (invalid(nx, ny)) return false;
if (b[ny][nx] == '#') return false;
if (b[ny][nx] == '0') return false;
swap(b[py][px], b[ny][nx]);
cx[index] = nx;
cy[index] = ny;
turn++;
return true;
}
bool is_ok() {
static const char cb[5][6] = {
"##0##", "#123#", "45678", "#9AB#", "##0##", };
return memcmp(cb, b, sizeof(cb)) == 0;
}
bool invalid(int x, int y) { return x < 0 || x >= 5 || y < 0 || y >= 5; }
char b[5][6];
int cx[2], cy[2];
int turn;
};
int main() {
ZobristHash<int, 6, 5, 256> zh;
int h;
while (h = in(), h != -1) {
vector<vector<int>> vs(5);
vs[0].emplace_back(h);
inpt(vs[1], 3, in);
inpt(vs[2], 5, in);
inpt(vs[3], 3, in);
inpt(vs[4], 1, in);
Board b(vs);
queue<Board> Q;
set<int> vis;
Q.push(b);
vis.insert(zh.hash(b.b));
while (!Q.empty()) {
Board bi = Q.front();
Q.pop();
if (bi.turn > 15) break;
if (bi.is_ok()) {
cout << bi.turn << endl;
goto END;
}
for (int i = 0; i < 2; i++) {
for (int d = 0; d < 4; d++) {
Board bii = bi;
if (!bii.slide(i, d)) continue;
int hv = zh.hash(bii.b);
if (vis.count(hv)) continue;
vis.insert(hv);
Q.push(bii);
}
}
}
}
cout << "NA" << endl;
END:
;
}
return 0;
} | a.cc:194:1: error: expected unqualified-id before 'return'
194 | return 0;
| ^~~~~~
a.cc:195:1: error: expected declaration before '}' token
195 | }
| ^
|
s269673887 | p00190 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
int dd[13][4] = {
{2,-1,-1,-1},
{2,5,-1,-1},
{0,1,3,6},
{2,7,-1,-1},
{5,-1,-1,-1},
{1,4,6,9},
{2,5,7,10},
{3,6,8,11},
{7,-1,-1,-1},
{5,10,-1,-1},
{6,9,11,12},
{7,10,-1,-1},
{10,-1,-1,-1}
};
int main() {
queue<string> que;
map<string, int> d;
que.push("abcdefghijkla");
d[ans] = 0;
while (!que.empty()) {
string now = que.front(); que.pop();
int cost = d[now];
if (cost > 10) break;
REP(i, 13) if (now[i] == 'a') {
REP(j, 4) {
if (dd[i][j] == -1) break;
swap(now[i], now[dd[i][j]]);
if (d.find(now) == d.end()) {
d[now] = cost + 1;
que.push(now);
}
swap(now[i], now[dd[i][j]]);
}
}
}
while (!que.empty()) que.pop();
int p[13];
while (cin >> p[0], ~p[0]) {
FOR(i, 1, 13) cin >> p[i];
string st = "";
REP(i, 13) st += p[i] + 'a';
map<string, int> d2;
que.push(st);
d2[st] = 0;
int ans = INF;
while (!que.empty()) {
string now = que.front(); que.pop();
int cost = d2[now];
if (cost > 11) break;
if (d.find(now) != d.end()) {
ans = d[now] + d2[now];
break;
}
REP(i, 13) if (now[i] == 'a') {
REP(j, 4) {
if (dd[i][j] == -1) break;
swap(now[i], now[dd[i][j]]);
if (d2.find(now) == d2.end()) {
d2[now] = cost + 1;
que.push(now);
}
swap(now[i], now[dd[i][j]]);
}
}
}
while (!que.empty()) que.pop();
if (ans != INF) cout << ans << endl;
else puts("NA");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:43:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
43 | d[ans] = 0;
| ^~~
| abs
|
s180124070 | p00190 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
#define N 5
#define REP(i, n) for ( int i = 0; i < (int)n; i++ )
#define LIMIT 20
static const int T[12][2] = {{-1, -1}, {1, 1}, {1, 2}, {1, 3}, {2, 0}, {2, 1},
{2, 2}, {2, 3}, {2, 4}, {3, 1}, {3, 2}, {3, 3}};
static const int g[N][N] = {{-1, -1, 0, -1, -1}, {-1, 1, 2, 3, -1},
{4, 5, 6, 7, 8}, {-1, 9, 10, 11, -1}, {-1, -1, 0, -1, -1}};
class Puzzle{
public:
int C[N][N], mdist; //manhatta distance
Puzzle(){}
bool swapAdj( int si, int sj, int ti, int tj ){
if ( ti < 0 || tj < 0 || ti >= N || tj >= N ) return false;
if ( C[ti][tj] <= 0 ) return false;
swap(C[ti][tj], C[si][sj]);
int tti = T[C[si][sj]][0];
int ttj = T[C[si][sj]][1];
mdist -= max(tti, ti)-min(tti, ti) + max(ttj, tj)-min(ttj, tj);
mdist += max(tti, si)-min(tti, si) + max(ttj, sj)-min(ttj, sj);
return true;
}
bool isGoal(){
REP(i, N) REP(j, N) if ( g[i][j] != C[i][j] ) return false;
return true;
}
int getMD(){ // get initial manhattan distance
int sum = 0;
int ti, tj;
REP(i, 5) REP(j, 5){
if ( C[i][j] <= 0 ) continue;
ti = T[C[i][j]][0];
tj = T[C[i][j]][1];
sum += (max(ti, i)-min(ti, i) + max(tj, j) - min(tj, j));
}
return sum;
}
};
int limit;
bool dfs( int depth, Puzzle P ){
if ( P.isGoal() ) return true;
if ( depth + P.getMD() > limit ) return false;
static const int di[4] = {0, -1, 0, 1};
static const int dj[4] = {1, 0, -1, 0};
REP(i, N) REP(j, N){
if ( P.C[i][j] != 0 ) continue;
REP(r, 4){
Puzzle v = P;
if ( !v.swapAdj(i, j, i+di[r], j+dj[r]) ) continue;
if ( dfs( depth + 1, v ) ) return true;
}
}
return false;
}
int idp(Puzzle source){
for ( limit = 0; limit <= LIMIT; limit++ ){
source.mdist = source.getMD();
if ( dfs(0, source) ) return limit;
}
return INT_MAX;
}
int main(){
Puzzle P;
int top;
while(1){
cin >> top;
if ( top == -1 ) break;
REP(j, N) P.C[0][j] = -1;
P.C[0][2] = top;
for(int i = 1; i < N; i++) REP(j, N){
if ( (i == 1 || i == 3) && (j == 0 || j == 4 ) ) P.C[i][j] = -1;
else if ( i == 4 && j != 2 ) P.C[i][j] = -1;
else cin >> P.C[i][j];
}
int cost = idp(P);
if ( cost == INT_MAX ) cout << "NA" << endl;
else cout << cost << endl;
}
return 0;
} | a.cc: In function 'int idp(Puzzle)':
a.cc:75:12: error: 'INT_MAX' was not declared in this scope
75 | return INT_MAX;
| ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
2 | #include<algorithm>
+++ |+#include <climits>
3 |
a.cc: In function 'int main()':
a.cc:94:22: error: 'INT_MAX' was not declared in this scope
94 | if ( cost == INT_MAX ) cout << "NA" << endl;
| ^~~~~~~
a.cc:94:22: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
|
s752933029 | p00190 | C++ | #include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
using namespace std;
#define NONE -1
#include <windows.h>
void print( const vector < vector <int> > &F )
{
for ( int i = 0; i < 5; i++ )
{
for ( int j = 0; j < 5; j++ )
{
cout << setw(3) << F[i][j];
}
cout << endl;
}
}
// »ÝÌóÔ
vector < vector <int> > F( 5, vector <int>(5,NONE) );
// S[
vector < vector <int> > GOAL( 5, vector <int>(5,NONE) );
// KâÏÝ
set < vector < vector <int> > > V;
// ó«Ìê
int empty_x[2];
int empty_y[2];
int now;
int getMD();
bool search( int );
bool search( int depth )
{
if ( F == GOAL )
return true;
if ( now + getMD() > depth )
return false;
now++;
for ( int e = 0; e < 2; e++ ) for ( int i = -1; i < 2; i++ ) for ( int j = -1; j < 2; j++ )
{
if ( i+j == 1 || i+j == -1 )
{
int ox = empty_x[e];
int oy = empty_y[e];
int tx = empty_x[e] + i;
int ty = empty_y[e] + j;
if ( ( tx >= 0 && tx <= 4 ) && ( ty >= 0 && ty <= 4 ) )
{
if ( F[ty][tx] != 0 && F[ty][tx] != NONE )
{
// ®©·
swap( F[oy][ox], F[ty][tx] );
// ¢JÌnÅ éÈçÎ
if ( V.find( F ) == V.end() )
{
if ( search( depth ) )
return true;
}
// ß·
swap( F[oy][ox], F[ty][tx] );
}
}
}
}
now--;
}
int getMD()
{
int md = 0;
for ( int i = 0; i < 5; i++ ) for ( int j = 0; j < 5; j++ )
{
if ( F[i][j] != GOAL[i][j] )
{
// T·
bool found = false;
for ( int k = 0; k < 5; k++ )
{
for ( int m = 0; m < 5; m++ )
{
// Á½
if ( F[i][j] == GOAL[k][m] )
{
md += abs(k-i) + abs(m-j);
found = true;
break;
}
}
if ( found ) break;
}
}
}
return md;
}
int main( void )
{
while ( 1 )
{
// S[ðìé
GOAL[0][2] = 0;
for ( int i = 0; i < 3; i++ )
GOAL[1][1+i] = i+1;
for ( int i = 0; i < 5; i++ )
GOAL[2][i] = 4 + i;
for ( int i = 0; i < 3; i++ )
GOAL[3][1+i] = 9 + i;
GOAL[4][2] = 0;
// üÍ
cin >> F[0][2];
if ( F[0][2] == -1 )
break;
for ( int i = 0; i < 3; i++ )
cin >> F[1][1+i];
for ( int i = 0; i < 5; i++ )
cin >> F[2][i];
for ( int i = 0; i < 3; i++ )
cin >> F[3][1+i];
cin >> F[4][2];
// óðT·
int empty_count = 0;
for ( int i = 0; i < 5; i++ )
{
for ( int j = 0; j < 5; j++ )
{
if ( F[i][j] == 0 )
{
empty_x[empty_count] = j;
empty_y[empty_count] = i;
empty_count++;
}
}
}
// ½[»[³DæTõ
V.insert( F );
now = 0;
bool goal_flag = false;
for ( int i = 0; i < 20; i++ )
{
if ( search( i ) )
{
goal_flag = true;
break;
}
}
if ( goal_flag )
cout << now << endl;
else
cout << "NA" << endl;
}
return 0;
} | a.cc:12:10: fatal error: windows.h: No such file or directory
12 | #include <windows.h>
| ^~~~~~~~~~~
compilation terminated.
|
s792823395 | p00190 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
#define N 5
#define REP(i, n) for ( int i = 0; i < (int)n; i++ )
#define LIMIT 20
// S[ÌÇ±É éÌ©
static const int T[12][2] = {
{-1, -1},
{1, 1},
{1, 2},
{1, 3},
{2, 0},
{2, 1},
{2, 2},
{2, 3},
{2, 4},
{3, 1},
{3, 2},
{3, 3}
};
// S[Ìzu
static const int g[N][N] = {
{-1, -1, 0, -1, -1},
{-1, 1, 2, 3, -1},
{ 4, 5, 6, 7, 8},
{-1, 9, 10, 11, -1},
{-1, -1, 0, -1, -1}
};
class Puzzle
{
public:
int C[N][N], mdist; //manhatta distance
Puzzle(){}
bool swapAdj( int si, int sj, int ti, int tj )
{
if ( ti < 0 || tj < 0 || ti >= N || tj >= N )
return false;
if ( C[ti][tj] <= 0 )
return false;
swap( C[ti][tj], C[si][sj] );
int tti = T[C[si][sj]][0];
int ttj = T[C[si][sj]][1];
mdist -= max(tti, ti)-min(tti, ti) + max(ttj, tj)-min(ttj, tj);
mdist += max(tti, si)-min(tti, si) + max(ttj, sj)-min(ttj, sj);
return true;
}
bool isGoal()
{
REP(i, N) REP(j, N)
if ( g[i][j] != C[i][j] )
return false;
return true;
}
// get initial manhattan distance
int getMD()
{
int sum = 0;
int ti, tj;
REP(i, 5) REP(j, 5)
{
if ( C[i][j] <= 0 )
continue;
ti = T[C[i][j]][0];
tj = T[C[i][j]][1];
sum += (max(ti, i)-min(ti, i) + max(tj, j) - min(tj, j));
}
return sum;
}
};
int limit;
bool dfs( int depth, Puzzle P )
{
if ( P.isGoal() )
return true;
if ( depth + P.getMD() > limit )
return false;
static const int di[4] = {0, -1, 0, 1};
static const int dj[4] = {1, 0, -1, 0};
REP(i, N) REP(j, N)
{
if ( P.C[i][j] != 0 )
continue;
REP(r, 4)
{
Puzzle v = P;
if ( !v.swapAdj(i, j, i+di[r], j+dj[r]) )
continue;
if ( dfs( depth + 1, v ) )
return true;
}
}
return false;
}
int idp(Puzzle source)
{
for ( limit = 0; limit <= LIMIT; limit++ )
{
source.mdist = source.getMD();
if ( dfs(0, source) )
return limit;
}
return INT_MAX;
}
int main()
{
Puzzle P;
int top;
while(1)
{
cin >> top;
if ( top == -1 ) break;
REP(j, N) P.C[0][j] = -1;
P.C[0][2] = top;
for(int i = 1; i < N; i++) REP(j, N)
{
if ( (i == 1 || i == 3) && (j == 0 || j == 4 ) )
P.C[i][j] = -1;
else if ( i == 4 && j != 2 )
P.C[i][j] = -1;
else
cin >> P.C[i][j];
}
int cost = idp(P);
if ( cost == INT_MAX )
cout << "NA" << endl;
else
cout << cost << endl;
}
return 0;
} | a.cc: In function 'int idp(Puzzle)':
a.cc:120:16: error: 'INT_MAX' was not declared in this scope
120 | return INT_MAX;
| ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
2 | #include<algorithm>
+++ |+#include <climits>
3 |
a.cc: In function 'int main()':
a.cc:146:30: error: 'INT_MAX' was not declared in this scope
146 | if ( cost == INT_MAX )
| ^~~~~~~
a.cc:146:30: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
|
s539239684 | p00190 | C++ | #include<iostream>
#include<map>
#include<deque>
using namespace std;
struct board{
char s[14];
int z1,z2;
bool operator<(const board& rhs)const{return strcmp(s,rhs.s)<0;}
};
int main(){
int d[13][5]={
{2,-1}, //0
{2,5,-1}, //1
{0,1,3,6,-1}, //2
{2,7,-1}, //3
{5,-1}, //4
{1,4,6,9,-1}, //5
{2,5,7,10,-1}, //6
{3,6,8,11,-1}, //7
{7,-1}, //8
{5,10,-1}, //9
{6,9,11,12,-1}, //10
{7,10,-1}, //11
{10,-1}, //12
};
board goal;
strcpy(goal.s,"0123456789AB0");
for(;;){
typedef map<board,int>SM;
SM stepmap;
deque<board> que;
board b0;
b0.z1=b0.z2=-1;
int dist=0;
for(int i=0;i<13;i++){
int v;
cin>>v;
if(v==-1)
return 0;
b0.s[i]="0123456789AB"[v];
if(v==0){
if(b0.z1==-1)
b0.z1=i;
else
b0.z2=i;
}else{
static int x[]={2,1,2,3,0,1,2,3,4,1,2,3,2};
static int y[]={0,1,1,1,2,2,2,2,2,3,3,3,4};
dist+=abs(x[v]-x[i])+abs(y[v]-y[i]);
}
}
b0.s[13]=0;
que.push_back(b0);
stepmap[b0]=1;
if(dist<=20){
while(!que.empty()){
board b=que.front();
if(strcmp(b.s,goal.s)==0){
break;
}
que.pop_front();
int step=stepmap[b];
if(step<=20){
for(int i=0;d[b.z1][i]!=-1;i++){
board bn=b;
bn.z1=d[b.z1][i];
if(bn.z1!=bn.z2){
swap(bn.s[b.z1],bn.s[bn.z1]);
int&ns=stepmap[bn];
if(!ns){
ns=step+1;
que.push_back(bn);
}
}
}
for(int i=0;d[b.z2][i]!=-1;i++){
board bn=b;
bn.z2=d[b.z2][i];
if(bn.z2!=bn.z1){
swap(bn.s[b.z2],bn.s[bn.z2]);
int&ns=stepmap[bn];
if(!ns){
ns=step+1;
que.push_back(bn);
}
}
}
}
}
}
if(stepmap[goal]==0)
cout<<"NA "<<endl;
else
cout<<stepmap[goal]-1<<endl;
}
} | a.cc: In member function 'bool board::operator<(const board&) const':
a.cc:8:54: error: 'strcmp' was not declared in this scope
8 | bool operator<(const board& rhs)const{return strcmp(s,rhs.s)<0;}
| ^~~~~~
a.cc:4:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<deque>
+++ |+#include <cstring>
4 | using namespace std;
a.cc: In function 'int main()':
a.cc:27:9: error: 'strcpy' was not declared in this scope
27 | strcpy(goal.s,"0123456789AB0");
| ^~~~~~
a.cc:27:9: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:58:36: error: 'strcmp' was not declared in this scope
58 | if(strcmp(b.s,goal.s)==0){
| ^~~~~~
a.cc:58:36: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s673247435 | p00190 | C++ | #include<iostream>
#include<map>
#include<deque>
#include<cstdlib>
using namespace std;struct B{int z[2];char s[14];bool operator<(const B&r)const{return strcmp(s,r.s)<0;}};int main(){int a[13][5]={{2,-1},{2,5,-1},{0,1,3,6,-1},{2,7,-1},{5,-1},{1,4,6,9,-1},{2,5,7,10,-1},{3,6,8,11,-1},{7,-1},{5,10,-1},{6,9,11,12,-1},{7,10,-1},{10,-1},},gx[]={2,1,2,3,0,1,2,3,4,1,2,3,2},gy[]={0,1,1,1,2,2,2,2,2,3,3,3,4},v,d,s,i,j;B g={0,0,"0123456789:;0"};for(;;){map<B,int>m;deque<B>q;B b={-1,-1};for(i=0;i<13;i++){cin>>v;if(v==-1)return 0;b.s[i]='0'+v;if(!v)b.z[b.z[0]!=-1]=i;}b.s[13]=0;m[b]=1;for(q.push_back(b);!q.empty();q.pop_front()){B&b=q.front();if(!strcmp(b.s,g.s))break;d=0;for(i=13;i--;){v=b.s[i]-'0';if(v)d+=abs(gx[v]-gx[i])+abs(gy[v]-gy[i]);}s=m[b];if(s+d<22)for(j=2;j--;)for(i=0;~a[b.z[j]][i];i++){B n=b;n.z[j]=a[b.z[j]][i];if(n.z[j]-n.z[1-j]){swap(n.s[b.z[j]],n.s[n.z[j]]);int&t=m[n];if(!t){t=s+1;q.push_back(n);}}}}m[g]?cout<<m[g]-1<<endl:cout<<"NA\n";}} | a.cc: In member function 'bool B::operator<(const B&) const':
a.cc:5:88: error: 'strcmp' was not declared in this scope
5 | using namespace std;struct B{int z[2];char s[14];bool operator<(const B&r)const{return strcmp(s,r.s)<0;}};int main(){int a[13][5]={{2,-1},{2,5,-1},{0,1,3,6,-1},{2,7,-1},{5,-1},{1,4,6,9,-1},{2,5,7,10,-1},{3,6,8,11,-1},{7,-1},{5,10,-1},{6,9,11,12,-1},{7,10,-1},{10,-1},},gx[]={2,1,2,3,0,1,2,3,4,1,2,3,2},gy[]={0,1,1,1,2,2,2,2,2,3,3,3,4},v,d,s,i,j;B g={0,0,"0123456789:;0"};for(;;){map<B,int>m;deque<B>q;B b={-1,-1};for(i=0;i<13;i++){cin>>v;if(v==-1)return 0;b.s[i]='0'+v;if(!v)b.z[b.z[0]!=-1]=i;}b.s[13]=0;m[b]=1;for(q.push_back(b);!q.empty();q.pop_front()){B&b=q.front();if(!strcmp(b.s,g.s))break;d=0;for(i=13;i--;){v=b.s[i]-'0';if(v)d+=abs(gx[v]-gx[i])+abs(gy[v]-gy[i]);}s=m[b];if(s+d<22)for(j=2;j--;)for(i=0;~a[b.z[j]][i];i++){B n=b;n.z[j]=a[b.z[j]][i];if(n.z[j]-n.z[1-j]){swap(n.s[b.z[j]],n.s[n.z[j]]);int&t=m[n];if(!t){t=s+1;q.push_back(n);}}}}m[g]?cout<<m[g]-1<<endl:cout<<"NA\n";}}
| ^~~~~~
a.cc:5:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include<cstdlib>
+++ |+#include <cstring>
5 | using namespace std;struct B{int z[2];char s[14];bool operator<(const B&r)const{return strcmp(s,r.s)<0;}};int main(){int a[13][5]={{2,-1},{2,5,-1},{0,1,3,6,-1},{2,7,-1},{5,-1},{1,4,6,9,-1},{2,5,7,10,-1},{3,6,8,11,-1},{7,-1},{5,10,-1},{6,9,11,12,-1},{7,10,-1},{10,-1},},gx[]={2,1,2,3,0,1,2,3,4,1,2,3,2},gy[]={0,1,1,1,2,2,2,2,2,3,3,3,4},v,d,s,i,j;B g={0,0,"0123456789:;0"};for(;;){map<B,int>m;deque<B>q;B b={-1,-1};for(i=0;i<13;i++){cin>>v;if(v==-1)return 0;b.s[i]='0'+v;if(!v)b.z[b.z[0]!=-1]=i;}b.s[13]=0;m[b]=1;for(q.push_back(b);!q.empty();q.pop_front()){B&b=q.front();if(!strcmp(b.s,g.s))break;d=0;for(i=13;i--;){v=b.s[i]-'0';if(v)d+=abs(gx[v]-gx[i])+abs(gy[v]-gy[i]);}s=m[b];if(s+d<22)for(j=2;j--;)for(i=0;~a[b.z[j]][i];i++){B n=b;n.z[j]=a[b.z[j]][i];if(n.z[j]-n.z[1-j]){swap(n.s[b.z[j]],n.s[n.z[j]]);int&t=m[n];if(!t){t=s+1;q.push_back(n);}}}}m[g]?cout<<m[g]-1<<endl:cout<<"NA\n";}}
a.cc: In function 'int main()':
a.cc:5:575: error: 'strcmp' was not declared in this scope
5 | using namespace std;struct B{int z[2];char s[14];bool operator<(const B&r)const{return strcmp(s,r.s)<0;}};int main(){int a[13][5]={{2,-1},{2,5,-1},{0,1,3,6,-1},{2,7,-1},{5,-1},{1,4,6,9,-1},{2,5,7,10,-1},{3,6,8,11,-1},{7,-1},{5,10,-1},{6,9,11,12,-1},{7,10,-1},{10,-1},},gx[]={2,1,2,3,0,1,2,3,4,1,2,3,2},gy[]={0,1,1,1,2,2,2,2,2,3,3,3,4},v,d,s,i,j;B g={0,0,"0123456789:;0"};for(;;){map<B,int>m;deque<B>q;B b={-1,-1};for(i=0;i<13;i++){cin>>v;if(v==-1)return 0;b.s[i]='0'+v;if(!v)b.z[b.z[0]!=-1]=i;}b.s[13]=0;m[b]=1;for(q.push_back(b);!q.empty();q.pop_front()){B&b=q.front();if(!strcmp(b.s,g.s))break;d=0;for(i=13;i--;){v=b.s[i]-'0';if(v)d+=abs(gx[v]-gx[i])+abs(gy[v]-gy[i]);}s=m[b];if(s+d<22)for(j=2;j--;)for(i=0;~a[b.z[j]][i];i++){B n=b;n.z[j]=a[b.z[j]][i];if(n.z[j]-n.z[1-j]){swap(n.s[b.z[j]],n.s[n.z[j]]);int&t=m[n];if(!t){t=s+1;q.push_back(n);}}}}m[g]?cout<<m[g]-1<<endl:cout<<"NA\n";}}
| ^~~~~~
a.cc:5:575: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s808831626 | p00190 | C++ | #include <stdlib.h>
using namespace std;
int p[5][5],x[11]={1,2,3,0,1,2,3,4,1,2,3},y[11]={1,1,1,2,2,2,2,2,3,3,3},s,sx[2],sy[2]
,mx[4]={1,0,-1,0},my[4]={0,-1,0,1},lt;
int search(int t,int mx2,int my2,int mc) {
int a,i,j,x2,y2,s2;
if (s==0) { if (lt>t) lt=t; return 1;}
for (i=0;i<2;i++) for (j=0;j<4;j++) {
x2=sx[i]+mx[j]; y2=sy[i]+my[j];
if (x2<0 || x2>4 || y2<0 || y2>4) continue;
if (p[y2][x2]<1 || ( mc==i && mx2==-mx[j] && my2==-my[j])) continue;
s2=abs(x2-x[p[y2][x2]-1])+abs(y2-y[p[y2][x2]-1])-abs(sx[i]-x[p[y2][x2]-1])-abs(sy[i]-y[p[y2][x2]-1]);
if (s+s2>lt-t) continue;
p[sy[i]][sx[i]]=p[y2][x2]; p[y2][x2]=0; s+=s2;
sx[i]=x2; sy[i]=y2;
a=search(t+1,mx[j],my[j],i);
sx[i]=x2-mx[j]; sy[i]=y2-my[j];
p[y2][x2]=p[sy[i]][sx[i]]; p[sy[i]][sx[i]]=0; s-=s2;
if (a==1) return 0;
}
return 0;
}
int main() {
int i,j,k;
for (i=0;i<5;i++) for (j=0;j<5;j++) p[i][j]=-1;
while (cin >> p[0][2] && p[0][2]!=-1) {
cin >> p[1][1] >> p[1][2] >> p[1][3];
cin >> p[2][0] >> p[2][1] >> p[2][2] >> p[2][3] >> p[2][4];
cin >> p[3][1] >> p[3][2] >> p[3][3];
cin >> p[4][2]; k=0; s=0;
for (i=0;i<5;i++) for (j=0;j<5;j++) {
if (p[i][j]==0) { sx[k++]=j; sy[k++]=i;}
if (p[i][j]>0) s+=abs(j-x[p[i][j]-1])+abs(i-y[p[i][j]-1]);
}
lt=21;
search(0,0,0,0);
if (lt==21) cout << "NA" << endl; else cout << lt << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:28:10: error: 'cin' was not declared in this scope
28 | while (cin >> p[0][2] && p[0][2]!=-1) {
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include <stdlib.h>
+++ |+#include <iostream>
2 | using namespace std;
a.cc:39:23: error: 'cout' was not declared in this scope
39 | if (lt==21) cout << "NA" << endl; else cout << lt << endl;
| ^~~~
a.cc:39:23: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:39:39: error: 'endl' was not declared in this scope
39 | if (lt==21) cout << "NA" << endl; else cout << lt << endl;
| ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
1 | #include <stdlib.h>
+++ |+#include <ostream>
2 | using namespace std;
a.cc:39:50: error: 'cout' was not declared in this scope
39 | if (lt==21) cout << "NA" << endl; else cout << lt << endl;
| ^~~~
a.cc:39:50: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:39:64: error: 'endl' was not declared in this scope
39 | if (lt==21) cout << "NA" << endl; else cout << lt << endl;
| ^~~~
a.cc:39:64: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
|
s238024611 | p00191 | Java | import java.util.*;
import java.math.BigDecimal;
public class AOJ_0191{
void run(){
Scanner sc = new Scanner(System.in);
while(true){
int n = sc.nextInt();
int m = sc.nextInt();
if(n == 0 && m == 0){
break;
}
double[][] g = new double[n][n];
for(int i = 0; i < n; i++){
for(int ii = 0; ii < n; ii++){
g[i][ii] = sc.nextDouble();
}
}
double[][] dp = new double[m][n];
Arrays.fill(dp[0], 1.);
for(int i = 1; i < m; i++){
for(int cur = 0; cur < n; cur++){
for(int pre = 0; pre < n; pre++){
dp[i][cur] = Math.max(dp[i][cur], dp[i-1][pre] * g[cur][pre]);
}
}
}
/*
for(double[] d: dp){
System.out.println(Arrays.toString(d));
}
*/
double max = 0;
for(double d: dp[m-1]){
max = Math.max(max, d);
}
System.out.println(new BigDecimal(max).setScale(2, BigDecimal.ROUND_HALF_UP));
}
}
public static void main(String[] args){
new AOJ_0191().run();
}
} | Main.java:4: error: class AOJ_0191 is public, should be declared in a file named AOJ_0191.java
public class AOJ_0191{
^
Note: Main.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
|
s360197911 | p00191 | C | #include<stdio.h>
double t[100][100];
double dp[100][100];
double ans(int num,int id,int n){
int i;
double tmp,t=0;
if(num==0) return 1;
if(dp[num][id]!=-1) return dp[num][id];
for(i=0;i<n;i++){
tmp=t[id][i] * ans(num-1,i,n);
if(t<tmp) t=tmp;
}
return dp[num][id]=t;
}
int main(){
int m,n;
int i,j;
double tmp,max;
while(scanf("%d%d",&n,&m),n!=0||m!=0){
for(i=0;i<100;i++)
for(j=0;j<100;j++)
dp[i][j] = -1;
for(i=0;i<n;i++)
for(j=0;j<m;j++)
scanf("%lf",&t[i][j]);
max=0;
for(i=0;i<n;i++){
tmp=ans(m-1,i,n);
if(max<tmp) max=tmp;
}
printf("%.2lf\n",max);
}
return 0;
} | main.c: In function 'ans':
main.c:14:10: error: subscripted value is neither array nor pointer nor vector
14 | tmp=t[id][i] * ans(num-1,i,n);
| ^
|
s417949171 | p00191 | C | #include<stdio.h>
#define Double double
#define Int int
#define For for
#define Scanf scanf
#define If if
#define Printf printf
#define Roop(i,n) for(i=0;i<n;i++)
#define Roop2(i,n) for(i=1;i<=n;i++)
#define Roop3(i,n) for(i=2;i<=n;i++)
int main(){
Int i,j,k,n,m;
Double max=0.0;
scanf("%d%d",&n,&m);
Roop(i,n)
Roop(j,n)
Scanf("%lf",&x[i][j]);
Roop2(i,n)
Roop(j,n)
dp[i][j]=(double)(i==0);
Roop3(i,m)
Roop(j,n)
Roop(k,n)
If(dp[i][j]<dp[i-1][k]*x[k][j])
dp[i][j]=dp[i-1][k]*x[k][j];
Roop(i,n)if(max<dp[m][i])max=dp[m][i];
Printf("%.2f\n",max);
return 0;
} | main.c: In function 'main':
main.c:18:16: error: 'x' undeclared (first use in this function)
18 | Scanf("%lf",&x[i][j]);
| ^
main.c:18:16: note: each undeclared identifier is reported only once for each function it appears in
main.c:22:4: error: 'dp' undeclared (first use in this function)
22 | dp[i][j]=(double)(i==0);
| ^~
|
s623734946 | p00191 | C | #include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int n, m;
while(scanf("%d %d\n", &n, &m), n || m){
long double g[n][n];
/* dp[a][b]??????a?????????b?????\?????????????????????a?????§????????????????????§??? */
long double dp[m][n];
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
scanf("%Lf", &g[i][j]);
}
}
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++){
dp[i][j] = 0;
}
}
for(int i = 0; i < n; i++) dp[0][i] = 1;
for(int i = 1; i < m; i++){
for(int j = 0; j < n; j++){
for(int k = 0; k < n; k++){
dp[i][j] = max(dp[i][j], dp[i - 1][k] * g[k][j]);
}
}
}
long double res = 0;
for(int i = 0; i < n; i++){
res = max(res, dp[m - 1][i]);
}
printf("%.2Lf\n", res);
}
return 0;
} | main.c:1:10: fatal error: cstdio: No such file or directory
1 | #include <cstdio>
| ^~~~~~~~
compilation terminated.
|
s722597338 | p00191 | C | 3 3
1.3 3.0 0.5
2.4 2.1 1.0
3.0 0.8 1.2
2 2
1.0 1.0
1.0 1.0
0 0 | main.c:1:1: error: expected identifier or '(' before numeric constant
1 | 3 3
| ^
|
s313496319 | p00191 | C | a=100;double x[a][a],y[a][a],r,z;
main(n,m,i,j,k){for(;scanf("%d%d",&n,&m),m;printf("%.2f\n",r)){
memset(x,0,sizeof(x));
for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%lf",y[i]+j);
for(j=0;j<n;j++)x[0][j]=1;
for(i=1;i<m;i++)for(j=0;j<n;j++)for(k=0;k<n;k++)if(x[i][j]<(z=x[i-1][k]*y[k][j]))x[i][j]=z;
for(r=j=0;j<n;j++)r=r<x[m-1][j]?x[m-1][j]:r;
}exit(0);} | main.c:1:1: warning: data definition has no type or storage class
1 | a=100;double x[a][a],y[a][a],r,z;
| ^
main.c:1:1: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
main.c:1:14: error: variably modified 'x' at file scope
1 | a=100;double x[a][a],y[a][a],r,z;
| ^
main.c:1:14: error: variably modified 'x' at file scope
main.c:1:22: error: variably modified 'y' at file scope
1 | a=100;double x[a][a],y[a][a],r,z;
| ^
main.c:1:22: error: variably modified 'y' at file scope
main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int]
2 | main(n,m,i,j,k){for(;scanf("%d%d",&n,&m),m;printf("%.2f\n",r)){
| ^~~~
main.c: In function 'main':
main.c:2:1: error: type of 'n' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'm' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'i' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'j' defaults to 'int' [-Wimplicit-int]
main.c:2:1: error: type of 'k' defaults to 'int' [-Wimplicit-int]
main.c:2:22: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
2 | main(n,m,i,j,k){for(;scanf("%d%d",&n,&m),m;printf("%.2f\n",r)){
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | a=100;double x[a][a],y[a][a],r,z;
main.c:2:22: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
2 | main(n,m,i,j,k){for(;scanf("%d%d",&n,&m),m;printf("%.2f\n",r)){
| ^~~~~
main.c:2:22: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:2:44: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
2 | main(n,m,i,j,k){for(;scanf("%d%d",&n,&m),m;printf("%.2f\n",r)){
| ^~~~~~
main.c:2:44: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:2:44: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:2:44: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:3:1: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration]
3 | memset(x,0,sizeof(x));
| ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'memset'
+++ |+#include <string.h>
1 | a=100;double x[a][a],y[a][a],r,z;
main.c:3:1: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch]
3 | memset(x,0,sizeof(x));
| ^~~~~~
main.c:3:1: note: include '<string.h>' or provide a declaration of 'memset'
main.c:8:2: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
8 | }exit(0);}
| ^~~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
+++ |+#include <stdlib.h>
1 | a=100;double x[a][a],y[a][a],r,z;
main.c:8:2: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
8 | }exit(0);}
| ^~~~
main.c:8:2: note: include '<stdlib.h>' or provide a declaration of 'exit'
|
s439528186 | p00191 | C++ | import java.util.Scanner;
import java.math.BigDecimal;
public class Main {
void doIt() {
Scanner stdIn = new Scanner(System.in);
while(true) {
int n = stdIn.nextInt();//肥料の種類
int m = stdIn.nextInt();//肥料を与える回数
if(n + m == 0) break;
double[][] table = new double[n][n];
for(int r = 0; r < n; r++) {
for(int c = 0; c < n; c++) {
table[r][c] = stdIn.nextDouble();
}
}
double[][] dp = new double[m][n];
for(int r = 0; r < dp[0].length; r++) {
dp[0][r] = 1;
}
for(int k = 1; k < m; k++) {
for(int r = 0; r < n; r++) {
for(int c = 0; c < m; c++) {
dp[k][c] = Math.max(dp[k][c], dp[k - 1][r] * table[r][c]);
}
}
}
double ans = -1;
for(int r = 0; r < dp[dp.length - 1].length; r++) {
ans = Math.max(ans, dp[dp.length - 1][r]);
}
BigDecimal answer = new BigDecimal(String.valueOf(ans));
ans = answer.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
System.out.printf("%1.2f\n", ans);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Main().doIt();
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.Scanner;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.math.BigDecimal;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
3 | public class Main {
| ^~~~~~
|
s154498065 | p00191 | C++ | #include <iostream>
#include <cstdio>
using namespace std;
double memo [101][102];
double mp[101][101];
double ans;
int n,m;
int cnt;
void saiki(double seki,double pseki,int mae,int kai) {
// cout <<"seki="<<seki<<" mae="<<mae<<" kai="<<kai<<endl;
cnt++;
if(kai == m && ans < seki) ans = seki;
if(kai == m && mae != -1) memo[kai][mae] = 1;
if(kai < m) {
for(int i=1;i<=n;i++) {
if(memo[kai+1][i] == -1) {
saiki(seki*mp[mae][i],seki,i,kai+1);
if(memo[kai][mae] < memo[kai+1][i]*mp[mae][i]) memo[kai][mae] = memo[kai+1][i]*mp[mae][i];
}
else {
if(memo[kai][mae] < memo[kai+1][i]*mp[mae][i])memo[kai][mae] = memo[kai+1][i]*mp[mae][i];
saiki(memo[kai][mae]*seki,-1,-1,m);
}
}
}
}
int main(){
while(1){
cin >> n>> m;
if(n == 0 && m == 0) break;
for(int i=0;i<=n;i++)
for(int j=0;j<=n;j++)
if(i == 0 || j == 0) mp[i][j] = 1;
else cin >> mp[i][j];
for(int i=0;i<=m;i++)
for(int j=0;j<=n;j++)
memo[i][j] = -1;
ans = 0;
int ans2=0;
for(int i=1;i<=n;i++) {
saiki(1,1,i,1);
for(int j=0;j<=n;j++){
if(ans2 < memo[1][i]) ans2 = memo[1][i];
memo[1][i] = memo[2][i]= -1;
}
?\?\ for(int j=0;j<=m;j++)for(int k=0;k<=n;k++)memo[j][k] = -1;
}
// cout << ans2 << endl;
printf("%.2f\n",ans);
//cout << cnt << endl;
}
return 0;
} | a.cc:57:7: error: stray '\' in program
57 | ?\?\ for(int j=0;j<=m;j++)for(int k=0;k<=n;k++)memo[j][k] = -1;
| ^
a.cc:57:9: error: stray '\' in program
57 | ?\?\ for(int j=0;j<=m;j++)for(int k=0;k<=n;k++)memo[j][k] = -1;
| ^
a.cc: In function 'int main()':
a.cc:57:6: error: expected primary-expression before '?' token
57 | ?\?\ for(int j=0;j<=m;j++)for(int k=0;k<=n;k++)memo[j][k] = -1;
| ^
a.cc:57:8: error: expected primary-expression before '?' token
57 | ?\?\ for(int j=0;j<=m;j++)for(int k=0;k<=n;k++)memo[j][k] = -1;
| ^
a.cc:57:11: error: expected primary-expression before 'for'
57 | ?\?\ for(int j=0;j<=m;j++)for(int k=0;k<=n;k++)memo[j][k] = -1;
| ^~~
a.cc:57:9: error: expected ':' before 'for'
57 | ?\?\ for(int j=0;j<=m;j++)for(int k=0;k<=n;k++)memo[j][k] = -1;
| ^ ~~~
| :
a.cc:57:11: error: expected primary-expression before 'for'
57 | ?\?\ for(int j=0;j<=m;j++)for(int k=0;k<=n;k++)memo[j][k] = -1;
| ^~~
a.cc:57:9: error: expected ':' before 'for'
57 | ?\?\ for(int j=0;j<=m;j++)for(int k=0;k<=n;k++)memo[j][k] = -1;
| ^ ~~~
| :
a.cc:57:11: error: expected primary-expression before 'for'
57 | ?\?\ for(int j=0;j<=m;j++)for(int k=0;k<=n;k++)memo[j][k] = -1;
| ^~~
a.cc:57:23: error: 'j' was not declared in this scope
57 | ?\?\ for(int j=0;j<=m;j++)for(int k=0;k<=n;k++)memo[j][k] = -1;
| ^
a.cc:57:44: error: 'k' was not declared in this scope
57 | ?\?\ for(int j=0;j<=m;j++)for(int k=0;k<=n;k++)memo[j][k] = -1;
| ^
|
s985587465 | p00191 | C++ | #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
int n,m;
while(cin>>n>>m,n+m){
vector<vector<double> > d(n,vector<double>(n));
vector<double> now(n,1),past(n,1);
rep(i,n)rep(j,n)scanf("%lf",&d[i][j]);
rep(times,m-1){
rep(i,n){
now[j] = 0;
rep(j,n){
// i is past , j is now
now[j] = max(now[j],past[i] * d[i][j]);
}
}
// rep(i,now.size())cout<<now[i]<<" ";cout<<endl;
past = now;
}
double ret = -1;
rep(i,now.size())ret=max(ret,now[i]);
printf("%.2lf\n",ret);
}
} | a.cc: In function 'int main()':
a.cc:28:13: error: 'j' was not declared in this scope
28 | now[j] = 0;
| ^
|
s618202679 | p00191 | C++ | p#include <iostream>
#include<iomanip>
#include<algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int n,m;
double ef[105][105];
double func(){
double ans=0,dp[105][105]={0};
for(int i=0;i<m;i++){
dp[0][i]=1;
}
for(int i=1;i<n;i++){
for(int j=0;j<m;j++){
for(int k=0;k<m;k++){
int tmp=0;
tmp=max(tmp,dp[i-1][k]*ef[k][j]);
}
dp[i][j]=tmp;
}
}
for(int i=0;i<m;i++){
ans=max(ans,dp[n-1][i]);
}
return ans;
}
int main(){
cout<<shosu(2);
while(1){
cin>>n>>m;
if(n==0&&m==0) break;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cin>>ef[i][j];
}
}
cout<<func()<<endl;
}
} | a.cc:1:2: error: stray '#' in program
1 | p#include <iostream>
| ^
a.cc:1:1: error: 'p' does not name a type
1 | p#include <iostream>
| ^
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/iomanip:41,
from a.cc:2:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
68 | typedef ptrdiff_t streamsize; // Signed integral type
| ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
40 | #include <cwchar> // For mbstate_t
+++ |+#include <cstddef>
41 |
In file included from /usr/include/c++/14/bits/char_traits.h:50,
from /usr/include/c++/14/string:42,
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/iomanip:42:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
In file included from /usr/include/wchar.h:35,
from /usr/include/c++/14/cwchar:44,
from /usr/include/c++/14/bits/postypes.h:40:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
/usr/include/c++/14/bits/char_traits.h:144:61: error: 'std::size_t' has not been declared
144 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n);
| ^~~
/usr/include/c++/14/bits/char_traits.h:146:40: error: 'size_t' in namespace 'std' does not name a type
146 | static _GLIBCXX14_CONSTEXPR std::size_t
| ^~~~~~
/usr/include/c++/14/bits/char_traits.h:150:34: error: 'std::size_t' has not been declared
150 | find(const char_type* __s, std::size_t __n, const char_type& __a);
| ^~~
/usr/include/c++/14/bits/char_traits.h:153:52: error: 'std::size_t' has not been declared
153 | move(char_type* __s1, const char_type* __s2, std::size_t __n);
| ^~~
/usr/include/c++/14/bits/char_traits.h:156:52: error: 'std::size_t' has not been declared
156 | copy(char_type* __s1, const char_type* __s2, std::size_t __n);
| ^~~
/usr/include/c++/14/bits/char_traits.h:159:30: error: 'std::size_t' has not been declared
159 | assign(char_type* __s, std::size_t __n, char_type __a);
| ^~~
/usr/include/c++/14/bits/char_traits.h:187:59: error: 'std::size_t' has not been declared
187 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n)
| ^~~
/usr/include/c++/14/bits/char_traits.h: In static member function 'static constexpr int __gnu_cxx::char_traits<_CharT>::compare(const char_type*, const char_type*, int)':
/usr/include/c++/14/bits/char_traits.h:189:17: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
189 | for (std::size_t __i = 0; __i < __n; ++__i)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/bits/char_traits.h:189:33: error: '__i' was not declared in this scope; did you mean '__n'?
189 | for (std::size_t __i = 0; __i < __n; ++__i)
| |
s529070968 | p00191 | C++ | #include <iostream>
#include<iomanip>
#include<algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int n,m;
double ef[105][105];
double func(){
double ans=0,dp[105][105]={0};
for(int i=0;i<m;i++){
dp[0][i]=1;
}
for(int i=1;i<n;i++){
for(int j=0;j<m;j++){
for(int k=0;k<m;k++){
int tmp=0;
tmp=max(tmp,dp[i-1][k]*ef[k][j]);
}
dp[i][j]=tmp;
}
}
for(int i=0;i<m;i++){
ans=max(ans,dp[n-1][i]);
}
return ans;
}
int main(){
cout<<shosu(2);
while(1){
cin>>n>>m;
if(n==0&&m==0) break;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cin>>ef[i][j];
}
}
cout<<func()<<endl;
}
} | a.cc: In function 'double func()':
a.cc:19:40: error: no matching function for call to 'max(int&, double)'
19 | tmp=max(tmp,dp[i-1][k]*ef[k][j]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:19:40: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
19 | tmp=max(tmp,dp[i-1][k]*ef[k][j]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:19:40: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
19 | tmp=max(tmp,dp[i-1][k]*ef[k][j]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:21:34: error: 'tmp' was not declared in this scope; did you mean 'tm'?
21 | dp[i][j]=tmp;
| ^~~
| tm
|
s688970301 | p00191 | C++ | #include <iostream>
#include<iomanip>
#include<algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int n,m;
double ef[105][105];
double func(){
double ans=0,dp[105][105]={0};
for(int i=0;i<m;i++){
dp[0][i]=1;
}
for(int i=1;i<n;i++){
for(int j=0;j<m;j++){
int tmp=0;
for(int k=0;k<m;k++){
tmp=max(tmp,dp[i-1][k]*ef[k][j]);
}
dp[i][j]=tmp;
}
}
for(int i=0;i<m;i++){
ans=max(ans,dp[n-1][i]);
}
return ans;
}
int main(){
cout<<shosu(2);
while(1){
cin>>n>>m;
if(n==0&&m==0) break;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cin>>ef[i][j];
}
}
cout<<func()<<endl;
}
} | a.cc: In function 'double func()':
a.cc:19:40: error: no matching function for call to 'max(int&, double)'
19 | tmp=max(tmp,dp[i-1][k]*ef[k][j]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:19:40: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
19 | tmp=max(tmp,dp[i-1][k]*ef[k][j]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:19:40: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
19 | tmp=max(tmp,dp[i-1][k]*ef[k][j]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
|
s013934435 | p00191 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
double c[100][100];
double dp[100][100];//i??\??????j???????????¬
signed main() {
int a, b;
while(scanf("%d%d", &a, &b),a|b) {
for (int d = 0; d < a; d++) {
for (int e = 0; e < a; e++) {
scanf("%lf", &c[d][e]);
}
}
memset(dp, 0, sizeof(dp));
for (int d = 0; d < a; d++)dp[0][d] = 1;
for (int d = 1; d < b; d++) {
for (int e = 0; e < a; e++) {//????????\
for (int f = 0; f < a; f++) {//????????\
dp[d][e] = max(dp[d][e], dp[d - 1][f] * c[f][e]);
}
}
}
double MAX = 0;
for (int d = 0; d < a; d++) {
MAX = max(MAX, dp[b - 1][d]);
}
printf("%.10lf\n", MAX);
}
} | a.cc: In function 'int main()':
a.cc:16:17: error: 'memset' was not declared in this scope
16 | memset(dp, 0, sizeof(dp));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<algorithm>
+++ |+#include <cstring>
4 | using namespace std;
a.cc: At global scope:
a.cc:31:1: error: expected declaration before '}' token
31 | }
| ^
|
s813297241 | p00191 | C++ | #include<iostream>
#include<cmath>
#include<vector>
using namespace std;
const double eps = 1.0e-10;
double eq(double a, double b){ //a==b
return abs(b-a)<eps;
}
double gt(double a, double b){ //a>b
return !eq(a,b) && a > b;
}
int main(){
while(true){
int n,m;
double answer = -1;
cin >> n >> m;
if( n == 0 && m == 0 ) break;
double table[n][n];
for(int i = 0; i < n; ++i){
for(int j = 0; j < n; ++j){
cin >> table[i][j];
}
}
double dp[n][m];
for(int i = 0; i < n; ++i){
dp[i][0] = 1.0;
}
for(int i = 1; i < m; ++i){
double maximum = -1;
for(int j = 0; j < n; ++j){
for(int k = 0; k < n; ++k){
double t = table[k][j] * dp[k][i-1];
if( gt(t,maximum) ){
t=maximum;
}
}
}
dp[j][i] = t;
}
for(int i = 0; i < n; ++i){
if( gt( dp[i][m-1], answer ) )
answer = greedy[i];
}
printf("%.2lf\n",answer);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:41:10: error: 'j' was not declared in this scope
41 | dp[j][i] = t;
| ^
a.cc:41:18: error: 't' was not declared in this scope
41 | dp[j][i] = t;
| ^
a.cc:46:18: error: 'greedy' was not declared in this scope
46 | answer = greedy[i];
| ^~~~~~
|
s592405615 | p00191 | C++ | #include <iostream>
using namespace std;
int n, m;
double map[100][100], Max;
void search( int prev, double point, int count )
{
if(count == m) {
if(Max < point) {
Max = point;
}
return;
}
for(int i=0; i < n; ++i)
serch(i, point*map[prev][i], count + 1);
}
int main( void )
{
while(cin >> n >> m, n | m) {
Max = 0;
for(int i=0; i < n; ++i)
for(int j=0; j < n; ++j) {
cin >> map[i][j];
}
for(int i=0; i < n; ++i)
search(i, 1.0, 1);
printf("%.2f\n", Max);
}
return 0;
} | a.cc: In function 'void search(int, double, int)':
a.cc:17:17: error: 'serch' was not declared in this scope; did you mean 'search'?
17 | serch(i, point*map[prev][i], count + 1);
| ^~~~~
| search
|
s971743148 | p00191 | C++ | #include <iostream>
using namespace std;
int n, m;
double map[100][100], Max;
void search( int prev, double point, int count )
{
if(count == m) {
if(Max < point) {
Max = point;
}
return;
}
for(int i=0; i < n; ++i)
serach(i, point*map[prev][i], count + 1);
}
int main( void )
{
while(cin >> n >> m, n | m) {
Max = 0;
for(int i=0; i < n; ++i)
for(int j=0; j < n; ++j) {
cin >> map[i][j];
}
for(int i=0; i < n; ++i)
search(i, 1.0, 1);
printf("%.2f\n", Max);
}
return 0;
} | a.cc: In function 'void search(int, double, int)':
a.cc:17:17: error: 'serach' was not declared in this scope; did you mean 'search'?
17 | serach(i, point*map[prev][i], count + 1);
| ^~~~~~
| search
|
s802013240 | p00191 | C++ | #include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;
double g[101][101];
double dp[101][101];
int main(){
int n,m;
while(cin>>n>>m){
if(n==0&&m==0) break;
for(int i=0; i<=m; ++i){
for(int j=0; j<n; ++j){
dp[i][j]=0;
}
}
for(int i=0; i<n; ++i){
for(int j=0; j<n; ++j){
cin >> g[i][j];
}
}
for(int i=0; i<n; ++i){
dp[1][i]=1.00;
}
for(int i=2; i<=m; ++i){
for(int j=0; j<n; ++j){
double tmp=dp[i][j];
for(int k=0; k<n; ++k){
tmp=max(tmp,dp[i-1][k]*g[k][j]);
}
dp[i][j]=tmp;
}
}
double ans=0;
for(int i=0; i<n; ++i){
ans=max(ans,dp[m][i]);
}
ans*=100;
ans+=0.5;
ans=int(ans);
a/=100;
printf("%.2f\n",ans);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:54:17: error: 'a' was not declared in this scope
54 | a/=100;
| ^
|
s924592714 | p00191 | C++ | #include <stdio.h>
using namespace std;
int main() {
int i,j,k,m,n,f;
double a,d[100][100],an[2][100];
while(cin >> n >> m) {
if (n==0 && m==0) break;
for (i=0;i<n;i++) { an[0][i]=1; for (j=0;j<n;j++) cin >> d[i][j];}
f=0;
for (k=0;k<m-1;k++) {
for (i=0;i<n;i++) { a=0;
for (j=0;j<n;j++) a=a < an[f][j]*d[j][i] ? an[f][j]*d[j][i] : a;
an[1-f][i]=a;
}
f=1-f;
}
for (i=0,a=0;i<n;i++) a= a < an[f][i] ? an[f][i] : a;
printf("%.2f\n",a);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:7:15: error: 'cin' was not declared in this scope
7 | while(cin >> n >> m) {
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include <stdio.h>
+++ |+#include <iostream>
2 | using namespace std;
|
s904209018 | p00192 | C++ | #include<iostream>
#include<vector>
using namespace std;
const int NIL = -1;
const int INF = 12000;
enum {UNDER, ABOVE};
int time;
class Car {
public:
int id, arrive, sojourn;
int leave;
Car(int i, int a, int s) :id(i), arrive(a), sojourn(s) {}
void park(int t) {leave = t + sojourn;}
int remain() {return leave - time;}
};
int main() {
int n, m;
while(cin >> m >> n, m | n) {
vector<vector<int>> parking(2, vector<int>(m, NIL));
vector<Car> car;
for(int i = 0; i < n; ++i) {
int t;
cin >> t;
car.push_back(Car(i, i * 10, t));
}
int head = 0;
vector<int> answer;
for(time = 0; answer.size() < n; ++time) {
// leave
for(int i = 0; i < m; ++i) {
int id = parking[UNDER][i];
if(id == NIL) continue;
if(car[id].leave > time) continue;
answer.push_back(id + 1);
parking[UNDER][i] = parking[ABOVE][i];
parking[ABOVE][i] = NIL;
}
// park
// empty
while(head < n && car[head].arrive <= time) {
bool in = false;
for(int i = 0; i < m; ++i) {
int id = parking[UNDER][i];
if(id != NIL) continue;
parking[UNDER][i] = head;
car[head].park(time);
++head;
in = true;
break;
}
if(!in) break;
}
// not empty
while(head < n && car[head].arrive <= time) {
int dif1 = INF, target1 = NIL;
int dif2 = INF, target2 = NIL;
for(int i = 0; i < m; ++i) {
if(parking[ABOVE][i] != NIL) continue;
int id = parking[UNDER][i];
if(car[id].remain() >= car[head].sojourn) {
if(dif1 > car[id].remain() - car[head].sojourn) {
dif1 = car[id].remain() - car[head].sojourn;
target1 = i;
}
} else {
if(dif2 > car[head].sojourn - car[id].remain()) {
dif2 = car[head].sojourn - car[id].remain();
target2 = i;
}
}
}
bool in = false;
if(target1 != NIL) {
parking[ABOVE][target1] = parking[UNDER][target1];
parking[UNDER][target1] = head;
car[head].park(time);
++head;
in = true;
} else if (target2 != NIL) {
parking[ABOVE][target2] = parking[UNDER][target2];
parking[UNDER][target2] = head;
car[head].park(time);
++head;
in = true;
}
if(!in) break;
}
}
for(int i = 0; i < n; ++i) cout << (i == 0 ? "" : " ") << answer[i];
cout << endl;
}
} | a.cc:9:5: error: 'int time' redeclared as different kind of entity
9 | int time;
| ^~~~
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In member function 'int Car::remain()':
a.cc:17:32: error: invalid operands of types 'int' and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator-'
17 | int remain() {return leave - time;}
| ~~~~~ ^ ~~~~
| | |
| int time_t(time_t*) noexcept {aka long int(long int*) noexcept}
a.cc: In function 'int main()':
a.cc:33:18: error: assignment of function 'time_t time(time_t*)'
33 | for(time = 0; answer.size() < n; ++time) {
| ~~~~~^~~
a.cc:33:44: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
33 | for(time = 0; answer.size() < n; ++time) {
| ^~~~
a.cc:33:44: error: lvalue required as increment operand
a.cc:38:34: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
38 | if(car[id].leave > time) continue;
a.cc:45:48: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
45 | while(head < n && car[head].arrive <= time) {
a.cc:51:36: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive]
51 | car[head].park(time);
| ^~~~
| |
| time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc:16:19: note: initializing argument 1 of 'void Car::park(int)'
16 | void park(int t) {leave = t + sojourn;}
| ~~~~^
a.cc:59:48: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
59 | while(head < n && car[head].arrive <= time) {
a.cc:81:36: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive]
81 | car[head].park(time);
| ^~~~
| |
| time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc:16:19: note: initializing argument 1 of 'void Car::park(int)'
16 | void park(int t) {leave = t + sojourn;}
| ~~~~^
a.cc:87:36: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive]
87 | car[head].park(time);
| ^~~~
| |
| time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc:16:19: note: initializing argument 1 of 'void Car::park(int)'
16 | void park(int t) {leave = t + sojourn;}
| ~~~~^
|
s122898086 | p00192 | C++ | #include <bits/stdc++.h>
using namespace std;
????
class Car{
public:
????int id, in_time, rest_time;
????Car(){}
????Car(int a, int b, int c): id(a), in_time(b), rest_time(c){}
};
????
const int INF = (1<<28);
????
int m, n;
queue<Car> que;
Car pa[20];
vector<int> ans;
????
void init(){
????for(int i=0;i<m*2;i++) pa[i] = Car(-1, -1, -1);
????while(!que.empty()) que.pop();
????ans.clear();
}
????
bool full_park(){
????for(int i=0;i<m*2;i++) if(pa[i].id == -1) return false;
????return true;
}
??
void car_in(int t){
????while(!que.empty()){
????????Car c = que.front();
????????if(c.in_time > t || full_park()) break;
????????int pos = -1;
????????for(int i=1;i<m*2;i+=2){
????????????if(pos == -1 && pa[i].id == -1 && pa[i-1].id == -1) pos = i;
????????}
????????if(pos != -1){
????????????pa[pos] = c;
????????????que.pop();
????????????continue;
????????}
????????int valm = INF;
????????pos = -1;
????????for(int i=0;i<m*2;i+=2){
????????????if(pa[i].id != -1) continue;
????????????if(pa[i+1].rest_time >= c.rest_time){
????????????????if(valm > abs(pa[i+1].rest_time - c.rest_time)){
????????????????????valm = abs(pa[i+1].rest_time - c.rest_time);
????????????????????pos = i;
????????????????}
????????????}
????????}
????????if(pos != -1){
????????????pa[pos] = c;
????????????que.pop();
????????????continue;
????????}
????????valm = INF;
????????pos = -1;
????????for(int i=0;i<m*2;i+=2){
????????????if(pa[i].id != -1) continue;
????????????if(valm > abs(pa[i+1].rest_time - c.rest_time)){
????????????????valm = abs(pa[i+1].rest_time - c.rest_time);
????????????????pos = i;
????????????}
????????}
????????if(pos != -1){
????????????pa[pos+1].rest_time = c.rest_time;
????????????pa[pos] = c;
????????????que.pop();
????????????continue;
????????}
????}
}
??
void car_out(int t){
????while(1){
????????int valm = INF;
????????int ex_pos = -1;
????????for(int i=0;i<m*2;i++){
????????????if(pa[i].id == -1) continue;
????????????if(pa[i].rest_time > 0) continue;
????????????if(valm > pa[i].rest_time){
????????????????valm = pa[i].rest_time;
????????????????ex_pos = i;
????????????}
????????}
????????if(ex_pos == -1) break;
????????ans.push_back(pa[ex_pos].id);
????????pa[ex_pos] = Car(-1, -1, -1);
????}
}
??
bool is_empty(){
????for(int i=0;i<m*2;i++) if(pa[i].id != -1) return false;
????return true;
}
??
main(){
????while(cin >> m >> n && (m|n)){
????????init();
????????for(int i=0;i<n;i++){
????????????Car in = Car(i+1, i*10, 0);
????????????cin >> in.rest_time;
????????????que.push(in);
????????}
????????for(int t=0;;t+=1){
????????????if(t > 0 && is_empty()) break;
????????????for(int i=0;i<m*2;i++){
????????????????if(pa[i].id == -1) continue;
????????????????pa[i].rest_time -= 1;
????????????}
????????????car_out(t);
????????????car_in(t);
????????}
????????cout << ans[0];
????????for(int i=1;i<ans.size();i++) cout << " " << ans[i];
????????cout << endl;
????}
} | a.cc:4:1: error: expected unqualified-id before '?' token
4 | ????
| ^
a.cc:11:1: error: expected unqualified-id before '?' token
11 | ????
| ^
a.cc:13:1: error: expected unqualified-id before '?' token
13 | ????
| ^
a.cc:15:7: error: 'Car' was not declared in this scope
15 | queue<Car> que;
| ^~~
a.cc:15:10: error: template argument 1 is invalid
15 | queue<Car> que;
| ^
a.cc:15:10: error: template argument 2 is invalid
a.cc:16:1: error: 'Car' does not name a type
16 | Car pa[20];
| ^~~
a.cc:18:1: error: expected unqualified-id before '?' token
18 | ????
| ^
a.cc:24:1: error: expected unqualified-id before '?' token
24 | ????
| ^
a.cc:29:1: error: expected unqualified-id before '?' token
29 | ??
| ^
a.cc:76:1: error: expected unqualified-id before '?' token
76 | ??
| ^
a.cc:94:1: error: expected unqualified-id before '?' token
94 | ??
| ^
a.cc:99:1: error: expected unqualified-id before '?' token
99 | ??
| ^
|
s058609855 | p00192 | C++ | #include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;
int n,m;
int ans[100],na;
struct S{
int t[2],id[2];
S()
{
rep(i,2)id[i]=0;
}
void next()
{
rep(i,2)if(id[i])t[i]--;
rep(i,2)if(id[i])
{
if(t[i]<=0)ans[na++]=id[i],id[i]=0;
return;
}
}
void put(int cid,int time)
{
int p=id[1]?0:1;
id[p]=cid; t[p]=time;
}
int diff(int time)
{
return abs(time-t[1]);
}
};
S spc[10];
int pfind(queue<int> &Data)
{
rep(i,m)if(!spc[i].id[1])return i;
int mn=inf,nTime=Data.front(),ret=-1;
rep(i,m)if(!spc[i].id[0]&&spc[i].t[1]>=nTime)
if(mn>spc[i].diff(nTime))
{
mn=spc[i].diff(nTime); ret=i;
}
if(ret!=-1)return ret;
rep(i,m)if(!spc[i].id[0]&&mn>spc[i].diff(nTime))
mn=spc[i].diff(nTime),ret=i;
return ret;
}
int main()
{
while(scanf("%d%d",&m,&n),m)
{
rep(i,m)spc[i].id=0;
int time=0,id=1; na=0;
queue<int> ID,Data;
while(na<n)
{
if(id<=n&&time==0)
{
int tmp; scanf("%d",&tmp);
ID.push(id); Data.push(tmp); id++;
}
while(!ID.empty())
{
int next=pfind(Data);
if(next==-1)break;
spc[next].put(ID.front(),Data.front());
ID.pop(); Data.pop();
}
time++;
if(time==10)time=0;
rep(i,m)spc[i].next();
}
rep(i,na)printf("%d%c",ans[i],i==n-1?'\n':' ');
}
return 0;
} | a.cc: In function 'int main()':
a.cc:83:34: error: incompatible types in assignment of 'int' to 'int [2]'
83 | rep(i,m)spc[i].id=0;
| ~~~~~~~~~^~
|
s629747844 | p00192 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef pair < int , int > Pi;
#define fr first
#define sc second
vector< stack < Pi > > park;
queue< Pi > sleep;
vector< int > ans;
set< int > out_time;
int exit_F5;
void parking(const int& now){
while(!sleep.empty()){
const int id = sleep.front().fr, time = sleep.front().sc;
int mpos = -1, pospos = -1;
bool flag = false;
for(int i = 0 ; i < park.size() ; i++ ){
if(park[i].empty()){
park[i].push(Pi( id, time));
out_time.insert(time + now);
sleep.pop();
flag = true;
break;
}else if(park[i].size() == 1){
if(park[i].top().sc >= time && ( mpos == -1 || park[i].top().sc < park[mpos].top().sc)){
mpos = i;
}
if(pospos == -1 || park[i].top().sc > park[pospos].top().sc){
pospos = i;
}
}
}
if(flag) continue;
if(~mpos){
park[mpos].push( Pi( id, time));
out_time.insert(time + now);
sleep.pop();
}else if(~pospos){
park[pospos].push( Pi( id, time));
out_time.insert(time + now);
sleep.pop();
}else break;
}
}
void next(const int& ntime){
for(int i = 0 ; i < park.size() ; i++ ){
if(park[i].empty()) continue;
else if(park[i].size() == 2){
Pi p = park[i].top();
park[i].pop();
park[i].top().sc -= ntime;
p.sc -= ntime;
park[i].push(p);
}else{
park[i].top().sc -= ntime;
}
}
}
void out(const int& in, const int& ot){
set<int>::iterator ue = out_time.lower_bound(in), sita = out_time.upper_bound(ot);
int pretime = in;
//時刻をinに合わせる
next( in - exit_F5);
exit_F5 = in;
while(ue != sita){
int nowtime = *ue;
next(nowtime - pretime);
exit_F5 = nowtime;
for(int i = 0 ; i < park.size() ; i++ ){
while(!park[i].empty()){
if(park[i].top().sc <= 0){
ans.push_back(park[i].top().fr);
park[i].pop();
} else break;
}
}
pretime = nowtime;
ue++;
}
}
int main(){
int m, n;
while( cin >> m >> n , m){
exit_F5 = 0; //最終更新
park.resize( m, stack< Pi >());
for(int i = 0 ; i < n ; i++ ){
int t;
cin >> t;
sleep.push(Pi( i + 1, t));
if(i) out(i * 10, i * 10); //同時刻発車
parking(i * 10);
out(i * 10 + 1, (i + 1) * 10 - 1);
}
out(n * 10, *(--out_time.end()));
for(int i = 0 ; i < ans.size() ; i++ ){
cout << (i ? " ": "") << ans[i];
}
cout << endl;
ans.clear();
out_time.clear();
}
} | a.cc:8:13: error: 'std::queue<std::pair<int, int> > sleep' redeclared as different kind of entity
8 | queue< Pi > sleep;
| ^~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
from /usr/include/signal.h:328,
from /usr/include/c++/14/csignal:42,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
from a.cc:1:
/usr/include/unistd.h:464:21: note: previous declaration 'unsigned int sleep(unsigned int)'
464 | extern unsigned int sleep (unsigned int __seconds);
| ^~~~~
a.cc: In function 'void parking(const int&)':
a.cc:16:16: error: request for member 'empty' in 'sleep', which is of non-class type 'unsigned int(unsigned int)'
16 | while(!sleep.empty()){
| ^~~~~
a.cc:17:26: error: request for member 'front' in 'sleep', which is of non-class type 'unsigned int(unsigned int)'
17 | const int id = sleep.front().fr, time = sleep.front().sc;
| ^~~~~
a.cc:23:34: error: no matching function for call to 'std::pair<int, int>::pair(const int&, time_t (&)(time_t*) noexcept)'
23 | park[i].push(Pi( id, time));
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:913:28: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]'
913 | explicit constexpr pair(pair<_U1, _U2>&& __p)
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:913:28: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:902:19: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]'
902 | constexpr pair(pair<_U1, _U2>&& __p)
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:902:19: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:891:28: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && (! _ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]'
891 | explicit constexpr pair(_U1&& __x, _U2&& __y)
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:891:28: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:890:38: error: no type named 'type' in 'struct std::enable_if<false, bool>'
890 | bool>::type=false>
| ^~~~~
/usr/include/c++/14/bits/stl_pair.h:881:19: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && _ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]'
881 | constexpr pair(_U1&& __x, _U2&& __y)
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:881:19: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:880:38: error: no type named 'type' in 'struct std::enable_if<false, bool>'
880 | bool>::type=true>
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:869:9: note: candidate: 'template<class _U2, typename std::enable_if<std::__and_<std::is_pointer<int>, std::__not_<std::is_reference<_Tp> >, std::is_constructible<int, _U1>, std::__not_<std::is_constructible<int, const _U1&> >, std::__not_<std::is_convertible<_U1, int> > >::value, bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(__zero_as_null_pointer_constant, _U2&&, ...) [with typename std::enable_if<std::__and_<std::is_pointer<_Tp>, std::__not_<std::is_reference<_U1> >, std::is_constructible<_T2, _U2>, std::__not_<std::is_constructible<_T1, const _U1&> >, std::__not_<std::is_convertible<_U2, _T2> > >::value, bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]'
869 | pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:869:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:866:38: error: no type named 'type' in 'struct std::enable_if<false, bool>'
866 | bool> = false>
| ^~~~~
/usr/include/c++/14/bits/stl_pair.h:856:9: note: candidate: 'template<class _U2, typename std::enable_if<std::__and_<std::is_pointer<int>, std::__not_<std::is_reference<_Tp> >, std::is_constructible<int, _U1>, std::__not_<std::is_constructible<int, const _U1&> >, std::is_convertible<_U1, int> >::value, bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(__zero_as_null_pointer_constant, _U2&&, ...) [with typename std::enable_if<std::__and_<std::is_pointer<_Tp>, std::__not_<std::is_reference<_U1> >, std::is_constructible<_T2, _U2>, std::__not_<std::is_constructible<_T1, const _U1&> >, std::is_convertible<_U2, _T2> >::value, bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]'
856 | pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:856:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:853:38: error: no type named 'type' in 'struct std::enable_if<false, bool>'
853 | bool> = true>
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:843:9: note: candidate: 'template<class _U1, typename std::enable_if<std::__and_<std::__not_<std::is_reference<_Tp> >, std::is_pointer<int>, std::is_constructible<int, _U1>, std::__not_<std::is_constructible<int, const _U1&> >, std::__not_<std::is_convertible<_U1, int> > >::value, bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, __zero_as_null_pointer_constant, ...) [with typename std::enable_if<std::__and_<std::__not_<std::is_reference<_U1> >, std::is_pointer<_T2>, std::is_constructible<_T1, _U1>, std::__not_<std::is_constructible<_T1, const _U1&> >, std::__not_<std::is_convertible<_U1, _T1> > >::value, bool>::type <anonymous> = _U1; _T1 = int; _T2 = int]'
843 | pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:843:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:840:38: error: no type named 'type' in 'struct std::enable_if<false, bool>'
840 | bool> = false>
| ^~~~~
/usr/include/c++/14/bits/stl_pair.h:830:9: note: candidate: 'template<class _U1, typename std::enable_if<std::__and_<std::__not_<std::is_reference<_Tp> >, std::is_pointer<int>, std::is_constructible<int, _U1>, std::__not_<std::is_constructible<int, const _U1&> >, std::is_convertible<_U1, int> >::value, bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, __zero_as_null_pointer_constant, ...) [with typename std::enable_if<std::__and_<std::__not_<std::is_reference<_U1> >, std::is_pointer<_T2>, std::is_constructible<_T1, _U1>, std::__not_<std::is_constructible<_T1, const _U1&> >, std::is_convertible<_U1, _T1> >::value, bool>::type <anonymous> = _U1; _T1 = int; _T2 = int]'
830 | pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:830:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:827:38: error: no type named 'type' in 'struct std::enable_if<false, bool>'
827 | bool> = true>
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:789:28: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyConvertiblePair<_U1, _U2>())), bool>::type <a |
s466723157 | p00193 | Java | 6 6
6
1 1
6 1
3 2
3 5
1 6
5 6
2
1 3
5 3
6 6
6
3 2
3 5
6 1
1 1
1 6
5 6
2
2 3
5 3
0 0 | Main.java:1: error: class, interface, enum, or record expected
6 6
^
1 error
|
s193977925 | p00193 | Java | import java.util.*;
public class DevenEleven {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
for(int m,n,x,a[][];(n=s.nextInt())>0;){
m=s.nextInt();
x=s.nextInt();
a=new int[n][m];
Deque<int[]>q=new ArrayDeque<int[]>();
for(int i=0;i<x;++i){
int u=s.nextInt()-1,v=s.nextInt()-1;
a[u][v]=1;
q.add(new int[]{u,v,1});
}
int[][]dn={{-1,-1,-1,0,0,1},{-1,0,0,1,1,1}};
int[][]dm={{-1,0,1,-1,1,0},{0,-1,1,-1,0,1}};
while(!q.isEmpty()){
int[]t=q.poll();
for(int i=0;i<6;++i){
int u=t[0]+dn[t[1]%2][i],v=t[1]+dm[t[1]%2][i];
if(0<=u&&u<n&&0<=v&&v<m&&a[u][v]<1){
q.add(new int[]{u,v,a[u][v]=t[2]+1});
}
}
}
int r=0;
for(x=s.nextInt();x-->0;){
int u=s.nextInt()-1,v=s.nextInt()-1;
if(a[u][v]>1){
int[][] tmp = new int[n][];
for(int i=0;i<n;++i)
tmp[i]=Arrays.copyOf(a[i],m);
tmp[u][v]=1;
q.add(new int[]{u,v,1});
int c=1;
while(!q.isEmpty()){
int[]t=q.poll();
for(int i=0;i<6;++i){
int u1=t[0]+dn[t[1]%2][i],v1=t[1]+dm[t[1]%2][i];
if(0<=u1&&u1<n&&0<=v1&&v1<m&&tmp[u1][v1]>t[2]+1){
++c;
q.add(new int[]{u1,v1,tmp[u1][v1]=t[2]+1});
}
}
}
r=r>c?r:c;
}
}
System.out.println(r);
}
}
} | Main.java:3: error: class DevenEleven is public, should be declared in a file named DevenEleven.java
public class DevenEleven {
^
1 error
|
s386126077 | p00193 | C | #include<cstdio>
#include<cstring>
#include<utility>
#include<algorithm>
#include<queue>
using namespace std;
typedef struct pos
{
int x,y,cost;
bool operator ()(pos const& a, pos const& b) const
{
return a.cost>b.cost;
}
}pos;
int M,N,S,T,m[101][101],i,j,p,q,R,t;
int bfs(int x,int y,int abj)
{
int i,c=1,mx[2][6]={{-1,0,1,0,-1,-1},{0,1,1,1,0,-1}},
my[2][6]={{-1,-1,0,1,1,0},{-1,-1,0,1,1,0}};
priority_queue<pos,vector<pos>,pos>Q;
m[y][x]=0;
pos tmp={x,y,0};
Q.push(tmp);
while(!Q.empty())
{
tmp=Q.top();Q.pop();
for(i=0;i<abj;i++)
{
if(0<=tmp.y+my[tmp.y%2][i]&&tmp.y+my[tmp.y%2][i]<M&&0<=tmp.x+mx[tmp.y%2][i]&&tmp.x+mx[tmp.y%2][i]<N)
if(m[tmp.y+my[tmp.y%2][i]][tmp.x+mx[tmp.y%2][i]]>tmp.cost+1)
{
m[tmp.y+my[tmp.y%2][i]][tmp.x+mx[tmp.y%2][i]]=tmp.cost+1;
pos tmp2={tmp.x+mx[tmp.y%2][i],tmp.y+my[tmp.y%2][i],tmp.cost+1};
c++;
Q.push(tmp2);
}
}
}
return c;
}
int main()
{
for(i=0;i<100;i++)
for(j=0;j<100;j++)
{
}
for(;~scanf("%d%d%d",&M,&N,&S),M;)
{
memset(m,0x7,sizeof(m));
for(i=0;i<S;i++)
{
scanf("%d%d",&p,&q);
bfs(p-1,q-1,6);
}
for(R=0,scanf("%d",&T),j=0;j<T;j++)
{
scanf("%d%d",&p,&q);
t=bfs(p-1,q-1,6);
R=t<R?R:t;
}
printf("%d\n",R);
}
return 0;
} | main.c:1:9: fatal error: cstdio: No such file or directory
1 | #include<cstdio>
| ^~~~~~~~
compilation terminated.
|
s053000118 | p00193 | C++ | #include <bits/stdc++.h>
using namespace std;
??
#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)
??
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
??
const int INF = 1001001001;
??
int dist(pii a, pii b)
{
????????int dy = a.first - b.first;
????????int dx = a.second - b.second;
????????if(0 <= dy*dx){
????????????????dy = abs(dy);
????????????????dx = abs(dx);
????????????????return dy + max(0, dx - (dy+1-min(a.first,b.first)%2)/2);
????????}
????????else{
????????????????dy = abs(dy);
????????????????dx = abs(dx);
????????????????return dy + max(0, dx - (dy + min(a.first, b.first)%2)/2);
????????}
}
??
int main()
{
????????int m, n;
????????while(scanf("%d%d", &m, &n), m){
????????????????int s;
????????????????scanf("%d", &s);
????????????????pii conv[10];
????????????????rep(i, s)
????????????????????????scanf("%d%d", &conv[i].second, &conv[i].first);
??????????????????
????????????????int d[101][101];
????????????????rep(i, n) rep(j, m){
????????????????????????d[i+1][j+1] = INF;
????????????????????????rep(k, s)
????????????????????????????????d[i+1][j+1] = min(d[i+1][j+1], dist(pii(i+1, j+1), conv[k]));
????????????????}
??????????????????
????????????????int t, ans = 0;
????????????????scanf("%d", &t);
????????????????rep(i, t){
????????????????????????int x, y;
????????????????????????scanf("%d%d", &x, &y);
??????????????????????????
????????????????????????int cnt = 0;
????????????????????????rep(j, n) rep(k, m)
????????????????????????????????cnt += dist(pii(j+1, k+1), pii(y, x)) < d[j+1][k+1];
????????????????????????ans = max(ans, cnt);
????????????????}
????????????????printf("%d\n", ans);
????????}
????????return 0;
} | a.cc:3:1: error: expected unqualified-id before '?' token
3 | ??
| ^
a.cc:11:1: error: expected unqualified-id before '?' token
11 | ??
| ^
a.cc:13:1: error: expected unqualified-id before '?' token
13 | ??
| ^
a.cc:29:1: error: expected unqualified-id before '?' token
29 | ??
| ^
|
s519720753 | p00193 | C++ | #include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
using namespace std;
typedef pair <int, int> PII;
typedef PII Node;
typedef queue <Node> Queue;
typedef vector <int> VI;
typedef vector <VI> VVI;
typedef set<PII> SPII;
int w, h;
const int inf = 1<<24;
const int odx[6] = { 0, 1, 1, 1, 0, -1 };
const int ody[6] = { -1, -1, 0, 1, 1, 0 };
const int edx[6] = { -1, 0, 1, 0, -1, -1 };
const int edy[6] = { -1, -1, 0, 1, 1, 0 };
int bfs( VVI& M, int X, int Y ) {
SPII V;
V.clear();
Queue Q;
Node start( X, Y );
Q.push( start );
M[Y][X] = 0;
while ( !Q.empty() ) {
Node node = Q.front();
Q.pop();
int x = node.first;
int y = node.second;
if ( V.find( PII( x, y ) ) == V.end() ) {
V.insert( PII( x, y ) );
answer++;
}
for ( int i = 0; i < 6; i++ ) {
int nx = x + ( y%2==0 ? edx[i] : odx[i] );
int ny = y + ( y%2==0 ? edy[i] : ody[i] );
if ( nx < 0 || nx >= w || ny < 0 || ny >= h ) continue;
if ( M[y][x] + 1 >= M[ny][nx] ) continue;
M[ny][nx] = M[y][x] + 1;
Node nnode( nx, ny );
Q.push( nnode );
}
}
return V.size();
}
int main() {
while ( cin >> w >> h ) {
VVI M( h+1, VI( w+1, inf ) );
int s;
cin >> s;
for ( int i = 0; i < s; i++ ) {
int x, y;
cin >> x >> y;
x--;
y--;
bfs( M, x, y );
}
int answer = 0;
VVI backup = M;
int t;
cin >> t;
for ( int i = 0; i < t; i++ ) {
M = backup;
int x, y;
cin >> x >> y;
x--;
y--;
answer = max( answer, bfs( M, x, y ) );
}
cout << answer << endl;
}
return 0;
} | a.cc: In function 'int bfs(VVI&, int, int)':
a.cc:49:13: error: 'answer' was not declared in this scope
49 | answer++;
| ^~~~~~
|
s291117274 | p00193 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int,int> pii;
int n,m;
int s,t;
pii ps[101];
// »ê¼êÌÀW©çêÔߢRrjÖÌ£
int dists[101][101];
const int INF=1000000000;
pii cand[101];
bool used[101][101];
bool noSet[101][101];
const int dy[2][6]={{-1,-1,0,1,1,0},{-1,-1,0,1,1,0}};
const int dx[2][6]={{-1,0,1,0,-1,-1},{0,1,1,1,0,-1}};
int calcDist(pii &p1,pii &p2){
return 0;
}
int updateMinDist(int sx,int sy,bool isSearch=true){
memset(used,0,sizeof(used));
queue<pii> q[2];
int cur=0;
int nxt=1;
int cnt=0;
pii sp=pii(sy,sx);
used[sy][sx]=true;
dists[sy][sx]=0;
int res=1;
q[cur].push(sp);
while(q[cur].size()){
while(q[cur].size()){
pii p=q[cur].front();q[cur].pop();
for(int i=0;i<6;i++){
int ny=dy[p.first%2][i]+p.first;
int nx=dx[p.first%2][i]+p.second;
if(ny>=0&&nx>=0&&ny<n&&nx<m&&!used[ny][nx]){
used[ny][nx]=true;
q[nxt].push(pii(ny,nx));
if(isSearch)
dists[ny][nx]=min(dists[ny][nx],cnt+1);
else{
if(dists[ny][nx]>cnt+1){
res++;
}
}
}
}
}
cnt++;
swap(cur,nxt);
}
return res;
}
int main(){
while(cin>>m>>n&&(m|n)){
memset(noSet,0,sizeof(noSet));
cin>>s;
for(int i=0;i<101;i++)for(int j=0;j<101;j++)dists[i][j]=INF;
for(int i=0;i<s;i++){
cin>>ps[i].second>>ps[i].first;
ps[i].second--;
ps[i].first--;
noSet[ps[i].first][ps[i].second]=true;
}
for(int k=0;k<s;k++)updateMinDist(ps[k].second,ps[k].first);
cin>>t;
for(int i=0;i<t;i++){
cin>>cand[i].second>>cand[i].first;
cand[i].second--;
cand[i].first--;
}
int res=0;
for(int i=0;i<t;i++){
int cnt=0;
//if(used[cand[i].first][cand[i].second])continue;
// ¡Ìê©çe_ÜÅÌ£ðvZµAߢàÌÌÝÌp
cnt=updateMinDist(cand[i].second,cand[i].first,false);
res=max(res,cnt);
}
cout<<res<<endl;
}
return 0;
} | a.cc: In function 'int updateMinDist(int, int, bool)':
a.cc:28:5: error: 'memset' was not declared in this scope
28 | memset(used,0,sizeof(used));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <queue>
+++ |+#include <cstring>
5 |
a.cc: In function 'int main()':
a.cc:65:9: error: 'memset' was not declared in this scope
65 | memset(noSet,0,sizeof(noSet));
| ^~~~~~
a.cc:65:9: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s124237645 | p00193 | C++ | #include <cstdio>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
#define INF (1<<30)
typedef pair<int,int> _P;
typedef pair<_P,int> P;
int map[100][100];
bool vst[100][100];
int dx1[6]={-1,0,1,0,-1,-1},dy1[6]={-1,-1,0,1,1,0};
int dx2[6]={0,1,1,1,0,-1},dy2[6]={-1,-1,0,1,1,0};
int main() {
int m,n,s,t;
while(scanf("%d",&m),m) {
scanf("%d",&n);
scanf("%d",&s);
for(int j=0;j<n;j++) {
for(int i=0;i<m;i++) {
map[i][j]=INF;
}
}
for(int i=0;i<s;i++) {
int x,y;
scanf("%d %d",&x,&y);x--;y--;
memset(vst,false,sizeof(vst));
map[x][y]=0;
vst[x][y]=true;
queue<P> que;
que.push(P(_P(x,y),0));
while(!que.empty()) {
P p=que.front();que.pop();
int *dx,*dy;
if((p.first.second+1)%2) dx=dx1,dy=dy1;
else dx=dx2,dy=dy2;
for(int i=0;i<6;i++) {
int nx=p.first.first+dx[i],ny=p.first.second+dy[i];
if(0<=nx&&nx<m&&0<=ny&&ny<n&&!vst[nx][ny]) {
vst[nx][ny]=true;
map[nx][ny]=min(p.second+1,map[nx][ny]);
que.push(P(_P(nx,ny),p.second+1));
}
}
}
}
scanf("%d",&t);
int ans=0;
for(int i=0;i<t;i++) {
int x,y;
scanf("%d %d",&x,&y);x--;y--;
memset(vst,false,sizeof(vst));
vst[x][y]=true;
queue<P> que;
que.push(P(_P(x,y),0));
int count=0;
while(!que.empty()) {
P p=que.front();que.pop();
int *dx,*dy;
if(p.second<map[p.first.first][p.first.second]) count++;
if((p.first.second+1)%2) dx=dx1,dy=dy1;
else dx=dx2,dy=dy2;
for(int i=0;i<6;i++) {
int nx=p.first.first+dx[i],ny=p.first.second+dy[i];
if(0<=nx&&nx<m&&0<=ny&&ny<n&&!vst[nx][ny]) {
vst[nx][ny]=true;
que.push(P(_P(nx,ny),p.second+1));
}
}
}
if(ans<count) ans=count;
}
printf("%d\n",ans);
}
} | a.cc: In function 'int main()':
a.cc:31:25: error: 'memset' was not declared in this scope
31 | memset(vst,false,sizeof(vst));
| ^~~~~~
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 |
a.cc:56:25: error: 'memset' was not declared in this scope
56 | memset(vst,false,sizeof(vst));
| ^~~~~~
a.cc:56:25: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s327043066 | p00193 | C++ | include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int dx[2][6] = { {-1, 0, 1,-1,-1,0 } , {-1,0,0,1,1,1} };
int dy[2][6] = { { 0, 1, 0, 1,-1,-1} , {0,1,-1,0,1,-1} };
class P{
public:
int x;
int y;
int cost;
P(){}
P(int x,int y,int cost):x(x),y(y),cost(cost){}
};
int m,n,s;
int field[128][128];
int cp[128][128];
int res;
void bfs(int x,int y,int index){
bool vis[128][128]={{0}};
queue< P > Q;
Q.push(P(x,y,1));
field[x][y] = 1;
res = 0;
while( Q.size() ){
P p = Q.front();Q.pop();
for(int i = 0; i < 6; i++){
int nx = p.x+dx[p.y%2][i];
int ny = p.y+dy[p.y%2][i];
if(vis[p.x][p.y]++)continue;
if(nx < 0 || nx > m-1 || ny < 0 || ny > n-1)continue;
if(field[nx][ny] > p.cost+1){
field[nx][ny] = p.cost+1;
if(index == s+1){
res++;
}
Q.push(P(nx,ny,p.cost+1));
}
else if(field[nx][ny] == p.cost+1){
field[nx][ny] = -1;
}
}
}
return ;
}
void init(){
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++){
cp[i][j] = field[i][j];
}
}
}
void copy(){
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++){
field[i][j] = cp[i][j];
}
}
}
void output(){
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++){
printf("%3d",field[i][j]);
}
puts("");
}
return ;
}
int main(){
while(scanf("%d",&m),m){
scanf("%d",&n);
scanf("%d",&s);
for(int i = 0; i < 120; i++){
for(int j = 0; j < 120; j++){
field[i][j] = 99;
}
}
for(int i = 0; i < s; i++){
int x,y;
scanf("%d%d",&x,&y);
x--;y--;
//output();
bfs(x,y,i+1);
}
int t;
scanf("%d",&t);
init();
int ans = -10000;
for(int i = 0; i < t; i++){
int x,y;
scanf("%d%d",&x,&y);
x--;y--;
bfs(x,y,s+1);
//output();
ans = max(res,ans);
copy();
}
printf("%d\n",ans);
}
return 0;
} | a.cc:1:1: error: 'include' does not name a type
1 | include<cstdio>
| ^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared
295 | template <typename _Tp, size_t = sizeof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared
984 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope
1451 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
63 | #include <bits/version.h>
+++ |+#include <cstddef>
64 |
/usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid
1451 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared
1453 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope
1454 | struct extent<_Tp[_Size], 0>
| ^~~~~
/usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid
1454 | struct extent<_Tp[_Size], 0>
| ^
/usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~
/usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid
1455 | : public integral_constant<size_t, _Size> { };
| ^
/usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid
/usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared
1457 | template<typename _Tp, unsigned _Uint, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope
1458 | struct extent<_Tp[_Size], _Uint>
| ^~~~~
/usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid
1458 | struct extent<_Tp[_Size], _Uint>
| ^
/usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope
1463 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid
1463 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type
1857 | { static constexpr size_t __size = sizeof(_Tp); };
| ^~~~~~
/usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~~~~
/usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~
/usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp'
1860 | struct __select;
| ^~~~~~~~
/usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared
1862 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^~~
/usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^
/usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared
1866 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| ^~~
/usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| |
s037877978 | p00194 | C++ | #include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a,b) (0<=a&&a<b)
#define Y1 b1[0]-'a'
#define X1 b1[2]-'1'
#define Y2 b2[0]-'a'
#define X2 b2[2]-'1'
using namespace std;
int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
int m,n,ds,ns,nc,nj,sy,sx,gy,gx,t,
S[25][25],D[25][25][25][25]; bool V[25][25][110][4]; char b1[99],b2[99];
void dfs(int y,int x,int t,int d){
V[y][x][t][d]=1;
int ny,nx,c,nt,nd;
rep(i,4){
nd=d+i&3,ny=y+dy[nd],nx=x+dx[nd];
if(!ck(ny,m)||!ck(nx,n)continue;
c=D[y][x][ny][nx],nt=t+c;
if((!S[ny][nx]||nd%2==nt/S[ny][nx]%2)&&i!=2
&&nt<101&&c&&!V[ny][nx][nt][nd])dfs(ny,nx,nt,nd);
}
}
int main(){
while(cin>>m>>n,m){
cin>>ds; rep(i,m)rep(j,n){
S[i][j]=0; rep(k,m)rep(l,n)D[i][j][k][l]=ds;
rep(t,110)rep(d,4)V[i][j][t][d]=0;
}
cin>>ns; rep(i,ns)cin>>b1>>t,S[Y1][X1]=t;
cin>>nc; rep(i,nc)cin>>b1>>b2,D[Y1][X1][Y2][X2]=D[Y2][X2][Y1][X1]=0;
cin>>nj; rep(i,nj)cin>>b1>>b2>>t,D[Y1][X1][Y2][X2]+=t,D[Y2][X2][Y1][X1]+=t;
cin>>b1>>b2,sy=Y1,sx=X1,gy=Y2,gx=X2;
rep(d,4)dfs(sy,sx,0,d);
rep(t,101)rep(d,4)if(V[gy][gx][t][d]){
cout<<t<<endl; goto END;
}
END:;
}
return 0;
} | a.cc: In function 'void dfs(int, int, int, int)':
a.cc:17:40: error: expected ';' before 'continue'
17 | if(!ck(ny,m)||!ck(nx,n)continue;
| ^~~~~~~~
a.cc:18:41: error: expected ')' before ';' token
18 | c=D[y][x][ny][nx],nt=t+c;
| ^
| )
a.cc:17:19: note: to match this '('
17 | if(!ck(ny,m)||!ck(nx,n)continue;
| ^
|
s019713957 | p00194 | C++ |
priority_queue<NODE> Q;
Q.push(NODE(start,P(start.x-1,start.y),0));
while(Q.size()){
NODE q = Q.top(); Q.pop();
//usleep(30000);
if(memo[q.cost][q.cur.y][q.cur.x])continue;
else memo[q.cost][q.cur.y][q.cur.x] = true;
if(q.cur.x == goal.x && q.cur.y == goal.y){
cout << q.cost << endl;
break;
}
rep(i,4){
int dir = i/2;
P nextP = P(q.cur.x+dx[i],q.cur.y+dy[i]);
int nextCost = q.cost + add[q.cur.y][q.cur.x][nextP.y][nextP.x] + d;
if(
nextCost > 100 ||
!correct(nextP.x,nextP.y) ||
binary_search(stop.begin(),stop.end(),make_pair(q.cur,nextP)) ||
(nextP.x == q.prev.x && nextP.y == q.prev.y) ||
(data[nextCost][nextP.y][nextP.x] != -1 && data[nextCost][nextP.y][nextP.x] == dir)
){
continue;
}
Q.push( NODE(nextP,q.cur,nextCost) );
}
}
}
} | a.cc:2:17: error: 'priority_queue' does not name a type
2 | priority_queue<NODE> Q;
| ^~~~~~~~~~~~~~
a.cc:3:17: error: 'Q' does not name a type
3 | Q.push(NODE(start,P(start.x-1,start.y),0));
| ^
a.cc:4:17: error: expected unqualified-id before 'while'
4 | while(Q.size()){
| ^~~~~
a.cc:30:9: error: expected declaration before '}' token
30 | }
| ^
a.cc:31:1: error: expected declaration before '}' token
31 | }
| ^
|
s080449367 | p00195 | C | #include <stdio.h>
int main(void)
{
int x, a, b, c, d ;
while (1) {
scanf("%d%d", & a, & b) ;
if (a == 0 && b == 0 || c = a + b) {
break ;
}
d = 0 ;
for (x = 1 ; x < 5 ; x ++) {
scanf("%d%d", & a, & b) ;
if (a + b > c) {
c = a + b;
d = x ;
}
}
printf("%c %d\n", 'A' + d, c) ;
}
return 0 ;
}
| main.c: In function 'main':
main.c:8:35: error: lvalue required as left operand of assignment
8 | if (a == 0 && b == 0 || c = a + b) {
| ^
|
s015024534 | p00195 | C | #include<stdio.h>
char returnsname(int);
int main(void){
int i,sum,a,b,c;
int top,topn;
i = 0;
top = 0;
while(1){
scanf(" %d %d",&a,&b);
if(a == 0 && b == 0){
break;
}
c = a + b;
if(top < c){
top = c;
topn = i + 1;
}
i++;
if(i==5){
switch(topn){
case 1:
return('A');
break;
case 2:
return('B');
break;
case 3:
return('C');
break;
case 4:
return('D');
break;
case 5:
return('E');
break;
}
printf("%c %d\n",returnsname(topn),top);
i = 1;
top = 0;
}
}
return(0);
} | /usr/bin/ld: /tmp/cc6rbhsH.o: in function `main':
main.c:(.text+0xc5): undefined reference to `returnsname'
collect2: error: ld returned 1 exit status
|
s744366371 | p00195 | C | #include<stdio.h>
int main(void){
int i,sum,a,b,c;
int top,topn;
i = 0;
top = 0;
while(1){
scanf(" %d %d",&a,&b);
if(a == 0 && b == 0){
break;
}
c = a + b;
if(top < c){
top = c;
topn = i + 1;
}
i++;
if(i==5){
switch(topn){
case 1:
return('A');
break;
case 2:
return('B');
break;
case 3:
return('C');
break;
case 4:
return('D');
break;
case 5:
return('E');
break;
}
printf("%c %d\n",returnsname(topn),top);
i = 1;
top = 0;
}
}
return(0);
} | main.c: In function 'main':
main.c:46:42: error: implicit declaration of function 'returnsname' [-Wimplicit-function-declaration]
46 | printf("%c %d\n",returnsname(topn),top);
| ^~~~~~~~~~~
|
s778249184 | p00195 | C | #include<stdio.h>
int main(){
int a[5],x,y,max;
while(scanf("%d %d",&x,&y),x||y){
max=0;
a[0]=x+y;
for(i=1;i<5;i++){
scanf("%d %d",&x,&y);
a[i]=x+y;
}
for(i=0;i<5;i++)
if(max<a[i])
max=a[i];
for(i=0;i<5;i++)
if(a[i]==max)
printf("%c %d\n",'A'+i.max);
}
return 0;
} | main.c: In function 'main':
main.c:7:5: error: 'i' undeclared (first use in this function)
7 | for(i=1;i<5;i++){
| ^
main.c:7:5: note: each undeclared identifier is reported only once for each function it appears in
|
s038009421 | p00195 | C | #include<stdio.h>
int main(){
int a[5],x,y,max,i;
while(scanf("%d %d",&x,&y),x||y){
max=0;
a[0]=x+y;
for(i=1;i<5;i++){
scanf("%d %d",&x,&y);
a[i]=x+y;
}
for(i=0;i<5;i++)
if(max<a[i])
max=a[i];
for(i=0;i<5;i++)
if(a[i]==max)
printf("%c %d\n",'A'+i.max);
}
return 0;
} | main.c: In function 'main':
main.c:16:23: error: request for member 'max' in something not a structure or union
16 | printf("%c %d\n",'A'+i.max);
| ^
|
s336852232 | p00195 | C | include <stdio.h>
main(){
int data[5];
int i, max, a, b, ans;
while(1){
scanf("%d %d", &a, &b);
if(a==0 && b==0) break;
data[0]=a+b;
for(i=1;i<5;i++){
scanf("%d %d", &a, &b);
data[i]=a+b;
}
max=-1;
for(i=0;i<5;i++){
if(max<data[i]){
max=data[i];
ans=i;
}
}
printf("%c %d\n", ans+'A', max);
}
return 0;
} | main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
1 | include <stdio.h>
| ^
|
s743117966 | p00195 | C | #include <stdio.h>
int main(void){
int a[5],s,b,c,d,e,f,g,h,i,j,k,l,n,m;
j=0;
a[5]=0;
for(n=0;n<10;n++){
scanf("%d %d",&b,&c);
scanf("%d %d",&d,&e);
scanf("%d %d",&f,&g);
scanf("%d %d",&h,&k);
scanf("%d %d",&l,&m);
a[0]=b+c;
a[1]=d+e;
a[2]=f+g;
a[3]=h+k;
a[4]=l+m;
for(i=0;i<5;i++){
for(j=i+1;j<5;j++){
if(a[i]<a[j])
t=a[i];
a[i]=a[j];
a[j]=a[i];
}
}
printf("%d",a[0]);
}
return 0;
} | main.c: In function 'main':
main.c:27:11: error: 't' undeclared (first use in this function)
27 | t=a[i];
| ^
main.c:27:11: note: each undeclared identifier is reported only once for each function it appears in
|
s076975201 | p00195 | C | #include <stdio.h>
int main(void) {
int gozen,gogo;
int kazu[5];
int maxmise;
int maxkazu;
int i;
while(1) {
scanf("%d %d",&gozen,&gogo);
if(gozen==0 && gogo==)break;
kazu[0]=gozen+gogo;
for(i=1;i<5;i++) {
scanf("%d %d",&gozen,&gogo);
kazu[i]=gozen+gogo;
}
maxmise=0;
maxkazu=kazu[0];
for(i=0;i<5;i++) {
if(kazu[i]>maxkazu) {
maxkazu=kazu[i];
maxmise=i;
}
}
printf("%c %d\n",'A'+maxmise,maxkazu);
}
return 0;
} | main.c: In function 'main':
main.c:11:38: error: expected expression before ')' token
11 | if(gozen==0 && gogo==)break;
| ^
|
s372173083 | p00195 | C++ | #include<iostream>
using namespace std;
int main(){
int shop[5];
char ans;int answer;
while(true){
int s1,s2;
cin>>s1>>s2;
if(s1==0&&s2==0)break;
shop[0]=s1+s2;
for(int i=1;i<5;i++){
cin>>s1>>s2;
shop[i]=s1+s2;
}
for(int i=0;i<5;i++)cout<<shop[i]<<endl;
answer=0
for(int i=0;i<5;i++){
answer=max(shop[i],answer);
}
if(answer==shop[0])ans='A';
if(answer==shop[1])ans='B';
if(answer==shop[2])ans='C';
if(answer==shop[3])ans='D';
if(answer==shop[4])ans='E';
cout<<ans<<" "<<answer<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:20:17: error: expected ';' before 'for'
20 | answer=0
| ^
| ;
21 | for(int i=0;i<5;i++){
| ~~~
a.cc:21:21: error: 'i' was not declared in this scope
21 | for(int i=0;i<5;i++){
| ^
|
s694608453 | p00195 | C++ | #include<iostream>
#include<cstdio>
#include<string>
#include<map>
using namespace std;
int main(){
pair<int,char>shop[5];
int am[5],pm[5];
while(1){
cin >> am[0] >> pm[0];
if(am[0] == 0 && pm[0] == 0)break;
for(int i=1;i<5;i++){
cin >> am[i] >> pm[i];
}
for(int i=0;i<5;i++){
shop[i].first = am[i] + pm[i];
shop[i].second = 'A' + i;
}
sort(shop,shop+5);
cout << shop[4].second << ' ' << shop[4].first << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:5: error: 'sort' was not declared in this scope; did you mean 'short'?
24 | sort(shop,shop+5);
| ^~~~
| short
|
s722736791 | p00195 | C++ | #include<iostream>
#include<cstdio>
#include<string>
#include<map>
using namespace std;
int main(){
pair<int,char>shop[5];
int am[5],pm[5];
while(1){
cin >> am[0] >> pm[0];
if(am[0] == 0 && pm[0] == 0)break;
for(int i=1;i<5;i++){
cin >> am[i] >> pm[i];
}
for(int i=0;i<5;i++){
shop[i].first = am[i] + pm[i];
shop[i].second = 'A' + i;
}
sort(shop,shop+5);
cout << shop[4].second << ' ' << shop[4].first << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:5: error: 'sort' was not declared in this scope; did you mean 'short'?
24 | sort(shop,shop+5);
| ^~~~
| short
|
s541950826 | p00195 | C++ | #include<iostream>
#include<cstdio>
#include<string>
#include<map>
using namespace std;
int main(){
pair<int,char>shop[5];
int am[5],pm[5];
while(1){
cin >> am[0] >> pm[0];
if(am[0] == 0 && pm[0] == 0)break;
for(int i=1;i<5;i++){
cin >> am[i] >> pm[i];
}
for(int i=0;i<5;i++){
shop[i].first = am[i] + pm[i];
shop[i].second = 'A' + i;
}
sort(shop,shop+5);
cout << shop[4].second << ' ' << shop[4].first << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:5: error: 'sort' was not declared in this scope; did you mean 'short'?
24 | sort(shop,shop+5);
| ^~~~
| short
|
s280280485 | p00195 | C++ | #include<iostream>
#include<cstdio>
#include<string>
#include<map>
using namespace std;
int main(){
pair<int,char> shop[5];
int am[5],pm[5];
while(1){
cin >> am[0] >> pm[0];
if(am[0] == 0 && pm[0] == 0)break;
for(int i=1;i<5;i++){
cin >> am[i] >> pm[i];
}
for(int i=0;i<5;i++){
shop[i].first = am[i] + pm[i];
shop[i].second = 'A' + i;
}
sort(shop,shop+5);
cout << shop[4].second << ' ' << shop[4].first << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:5: error: 'sort' was not declared in this scope; did you mean 'short'?
24 | sort(shop,shop+5);
| ^~~~
| short
|
s987504719 | p00195 | C++ | using System;
class Program {
static void Main() {
char[] chars = { 'A', 'B', 'C', 'D', 'E' };
while (true) {
var maxNo = 0;
var maxCount = 0;
for (var i = 0; i < 5; i++) {
var l = Console.ReadLine().Split(' ');
var count = int.Parse(l[0]) + int.Parse(l[1]);
if (count == 0)
return;
if (count > maxCount) {
maxNo = i;
maxCount = count;
}
}
Console.WriteLine(chars[maxNo] + " " + maxCount);
}
}
} | a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:27:2: error: expected ';' after class definition
27 | }
| ^
| ;
a.cc: In static member function 'static void Program::Main()':
a.cc:5:13: error: structured binding declaration cannot have type 'char'
5 | char[] chars = { 'A', 'B', 'C', 'D', 'E' };
| ^~
a.cc:5:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:5:13: error: empty structured binding declaration
a.cc:5:16: error: expected initializer before 'chars'
5 | char[] chars = { 'A', 'B', 'C', 'D', 'E' };
| ^~~~~
a.cc:8:13: error: 'var' was not declared in this scope
8 | var maxNo = 0;
| ^~~
a.cc:9:17: error: expected ';' before 'maxCount'
9 | var maxCount = 0;
| ^~~~~~~~
a.cc:11:22: error: expected ';' before 'i'
11 | for (var i = 0; i < 5; i++) {
| ^
a.cc:11:29: error: 'i' was not declared in this scope
11 | for (var i = 0; i < 5; i++) {
| ^
a.cc:12:21: error: expected ';' before 'l'
12 | var l = Console.ReadLine().Split(' ');
| ^
a.cc:13:21: error: expected ';' before 'count'
13 | var count = int.Parse(l[0]) + int.Parse(l[1]);
| ^~~~~
a.cc:15:21: error: 'count' was not declared in this scope
15 | if (count == 0)
| ^~~~~
a.cc:18:21: error: 'count' was not declared in this scope
18 | if (count > maxCount) {
| ^~~~~
a.cc:18:29: error: 'maxCount' was not declared in this scope
18 | if (count > maxCount) {
| ^~~~~~~~
a.cc:19:21: error: 'maxNo' was not declared in this scope
19 | maxNo = i;
| ^~~~~
a.cc:24:13: error: 'Console' was not declared in this scope
24 | Console.WriteLine(chars[maxNo] + " " + maxCount);
| ^~~~~~~
a.cc:24:31: error: 'chars' was not declared in this scope; did you mean 'char'?
24 | Console.WriteLine(chars[maxNo] + " " + maxCount);
| ^~~~~
| char
a.cc:24:37: error: 'maxNo' was not declared in this scope
24 | Console.WriteLine(chars[maxNo] + " " + maxCount);
| ^~~~~
a.cc:24:52: error: 'maxCount' was not declared in this scope
24 | Console.WriteLine(chars[maxNo] + " " + maxCount);
| ^~~~~~~~
|
s543639246 | p00195 | C++ | #include<stdio>
int main(void)
{
int a[5],b[5];
int i,max,sum[5];
char c2,c[5]={'A','B','C','D','E'};
while (scanf("%d %d",&a[0],&b[0])!=EOF){
if(a[0]==0&&b[0]==0) break;
sum[0]=a[0]+b[0];
max=sum[0];
c2='A';
for(i=1;i<5;i++){
scanf("%d %d",&a[i],&b[i]);
sum[i]=a[i]+b[i];
}
for(i=0;i<5;i++){
if(max<=sum[i]){
max=sum[i];
c2=c[i];
}
}
printf("%c %d\n",c2,max);
}
return 0
}
| a.cc:1:9: fatal error: stdio: No such file or directory
1 | #include<stdio>
| ^~~~~~~
compilation terminated.
|
s400318022 | p00195 | C++ | #include<stdio>
int main(void)
{
int a[5],b[5];
int i,max,sum[5];
char c2,c[5]={'A','B','C','D','E'};
while (scanf("%d %d",&a[0],&b[0])!=EOF){
if(a[0]==0&&b[0]==0) break;
sum[0]=a[0]+b[0];
max=sum[0];
c2='A';
for(i=1;i<5;i++){
scanf("%d %d",&a[i],&b[i]);
sum[i]=a[i]+b[i];
}
for(i=0;i<5;i++){
if(max<sum[i]){
max=sum[i];
c2=c[i];
}
}
printf("%c %d\n",c2,max);
}
return 0
}
| a.cc:1:9: fatal error: stdio: No such file or directory
1 | #include<stdio>
| ^~~~~~~
compilation terminated.
|
s052493791 | p00195 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
enum tol { a, b, c, d, e };
vector<tol>l;
vector<int>ll;
int a1, a2;
while (cin >> a1 >> a2){
if (a1 == 0 && a2 == 0)break;
int o[5];
int oo[5];
a1 += a2;
o[0] = a1;
for (int i = 1; i < 5; i++) {
cin >> a1 >> a2;
a1 += a2;
o[i] = a1;
}
for (int i = 0; i < 5; i++)oo[i] = o[i];
sort(oo, oo + 5);
if (oo[4] == o[0]) {
l.push_back(a);
ll.push_back(o[0];)
}
else if (oo[4] == o[1]) {
l.push_back(b);
ll.push_back(o[1]);
}
else if (oo[4] == o[2]) {
l.push_back(c);
ll.push_back(o[2]);
}
else if (oo[4] == o[3]) {
l.push_back(d);
ll.push_back(o[3]);
}
else if (oo[4] == o[4]) {
l.push_back(e);
ll.push_back(o[4]);
}
}
for (int p = 0; p < l.size();p++){
if (l[p] == a)cout << "A";
else if (l[p] == b)cout << "B";
else if (l[p] == c)cout << "C";
else if (l[p] == d)cout << "D";
else if (l[p] == e)cout << "E";
cout << ' ' << ll[p] << endl;
cout << endl;
}
char ch;
cin >> ch;
} | a.cc: In function 'int main()':
a.cc:25:42: error: expected ')' before ';' token
25 | ll.push_back(o[0];)
| ~ ^
| )
a.cc:25:43: error: expected primary-expression before ')' token
25 | ll.push_back(o[0];)
| ^
|
s865379504 | p00195 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
enum tol { a, b, c, d, e };
vector<tol>l;
vector<int>ll;
int a1, a2;
while (cin >> a1 >> a2){
if (a1 == 0 && a2 == 0)break;
int o[5];
int oo[5];
a1 += a2;
o[0] = a1;
for (int i = 1; i < 5; i++) {
cin >> a1 >> a2;
a1 += a2;
o[i] = a1;
}
for (int i = 0; i < 5; i++)oo[i] = o[i];
sort(oo, oo + 5);
if (oo[4] == o[0]) {
l.push_back(a);
ll.push_back(o[0];)
}
else if (oo[4] == o[1]) {
l.push_back(b);
ll.push_back(o[1]);
}
else if (oo[4] == o[2]) {
l.push_back(c);
ll.push_back(o[2]);
}
else if (oo[4] == o[3]) {
l.push_back(d);
ll.push_back(o[3]);
}
else if (oo[4] == o[4]) {
l.push_back(e);
ll.push_back(o[4]);
}
}
for (int p = 0; p < l.size();p++){
if (l[p] == a)cout << "A";
else if (l[p] == b)cout << "B";
else if (l[p] == c)cout << "C";
else if (l[p] == d)cout << "D";
else if (l[p] == e)cout << "E";
cout << ' ' << ll[p] << endl;
cout << endl;
}
char ch;
cin >> ch;
} | a.cc: In function 'int main()':
a.cc:25:42: error: expected ')' before ';' token
25 | ll.push_back(o[0];)
| ~ ^
| )
a.cc:25:43: error: expected primary-expression before ')' token
25 | ll.push_back(o[0];)
| ^
|
s510082146 | p00195 | C++ | #include<iostream>
using namespace std;
int main() {
int s,a,d,c;
while(cin>>a>>d,a)) {
s=a+d;c=0;
for(int i=1;i<5;i++) {
cin>>a>>d;
if(s<a+d)s=a+d,c=i;
}
cout<<(char)(c+'A')<<' '<<s<<endl;
}
} | a.cc: In function 'int main()':
a.cc:5:19: error: expected primary-expression before ')' token
5 | while(cin>>a>>d,a)) {
| ^
|
s485602897 | p00195 | C++ | #include<stdio.h>
#include<string.h>
int main(void)
{
int a[5],b[5],d,i,j;
char c[5]="ABCDE";
scanf("%d %d",&a[0],&b[0]);
while(a[i]!=0 || b[i]!=0){
d=0; j=0;
for(i=1;i<5;i++){
scanf("%d %d",&a[i],&b[i]);
if(a[i]+b[i]>d){
d=a[i]+b[i]; j=i;
}
}
printf("%c %d\n",c[j],d);
i=0;
scanf("% %d",&a[i],&b[i]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:6:19: error: initializer-string for 'char [5]' is too long [-fpermissive]
6 | char c[5]="ABCDE";
| ^~~~~~~
|
s026736071 | p00195 | C++ | #include<stdio.h>
#include<string.h>
int main(void)
{
int a[5],b[5],d,i,j;
char c[5]="ABCDE";
scanf("%d %d",&a[0],&b[0]);
while(a[i]!=0 || b[i]!=0){
j=0; d=0;
if(a[i]+b[i]>d){
d=a[i]+b[i]; j=i;
}
for(i=1;i<5;i++){
scanf("%d %d",&a[i],&b[i]);
if(a[i]+b[i]>d){
d=a[i]+b[i]; j=i;
}
}
printf("%c %d\n",c[j],d);
i=0;
scanf("% %d",&a[i],&b[i]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:6:19: error: initializer-string for 'char [5]' is too long [-fpermissive]
6 | char c[5]="ABCDE";
| ^~~~~~~
|
s029384493 | p00195 | C++ | #include<stdio.h>
#include<string.h>
int main(void)
{
int a[5],b[5],d,i,j;
char c[5]="ABCDE";
scanf("%d %d",&a[0],&b[0]);
while(a[0]!=0 || b[0]!=0){
j=0; d=a[0]+b[0];
for(i=1;i<5;i++){
scanf("%d %d",&a[i],&b[i]);
if(a[i]+b[i]>d){
d=a[i]+b[i]; j=i;
}
}
printf("%c %d\n",c[j],d);
scanf("% %d",&a[0],&b[0]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:6:19: error: initializer-string for 'char [5]' is too long [-fpermissive]
6 | char c[5]="ABCDE";
| ^~~~~~~
|
s899752481 | p00195 | C++ | #include<stdio.h>
#include<string.h>
int main(void)
{
int a[5],b[5],d,i,j;
char c[5]="ABCDE";
scanf("%d %d",&a[0],&b[0]);
while(a[0]!=0 || b[0]!=0){
j=0; d=a[0]+b[0];
for(i=1;i<5;i++){
scanf("%d %d",&a[i],&b[i]);
if(a[i]+b[i]>d){
d=a[i]+b[i]; j=i;
}
}
printf("%c %d\n",c[j],d);
scanf("% %d",&a[0],&b[0]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:6:19: error: initializer-string for 'char [5]' is too long [-fpermissive]
6 | char c[5]="ABCDE";
| ^~~~~~~
|
s625278917 | p00195 | C++ | #include <iostream>
#include <string>
using namespace std;
int GetMaxs(int date[], int n){
int max=0, maxn=0;
for(int i=0; i<n; i++){
if(max<date[i]){
max = date[i];
maxn = i;
}
}
return (maxn);
}
int main(void){
int m[5],am,pm;
string s;
while(cin>>am>>pm,am){
m[0] = am + pm;
for(int i=1; i<5; i++){
cin>>am>>pm;
m[i] = am + pm;
}
s = 'A' + GetMaxs(m,5);
cout << s << " " << date[Getmax(m,5)] <<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:25:37: error: 'date' was not declared in this scope
25 | cout << s << " " << date[Getmax(m,5)] <<endl;
| ^~~~
a.cc:25:42: error: 'Getmax' was not declared in this scope; did you mean 'GetMaxs'?
25 | cout << s << " " << date[Getmax(m,5)] <<endl;
| ^~~~~~
| GetMaxs
|
s482208400 | p00196 | Java | import java.util.*;
/* 19:08 ~  */
public class Main {
static class Team{
String name;
int win , lose , other;
public Team(String n , int[] result) {
this.name = n;
this.win = result[0];
this.lose = result[1];
this.other = result[2];
}
}
static void sort( ArrayList<Team> list , int left , int right) {
ArrayList<Team> copy = new ArrayList<Team>();
        if (left <= right) {
            Team p = list.get((left+right)/2);
            int l = left;
            int r = right;
            
            while(l <= r) {
                while(list.get(l).win < p.win){ l++; }
                while(list.get(r).win > p.win){ r--; }
                if (l <= r) {
                    Team tmp = list.get(l);
                    list.set(l,list.get(r));
                    list.set(r,tmp);
                    l++; 
                    r--;
                }
            }
    
            sort(list, left, r);
            sort(list, l, right);
        }
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(!sc.hasNext("0")) {
ArrayList<Team> list = new ArrayList<Team>();
int n = sc.nextInt();
for ( int i = 0; i < n; i++ ) {
String name = sc.next();
int[] result = new int[3];
for ( int j = 0; j < n - 1; j++ )
result[sc.nextInt()]++;
Team t = new Team(name,result);
list.add(t);
}
sort(list,0,list.size()-1);
Collections.reverse(list);
for ( int i = 0; i < list.size(); i++ )
System.out.println(list.get(i).name);
}
}
} | Main.java:20: error: illegal start of expression
        if (left <= right) {
^
Main.java:20: error: illegal character: '#'
        if (left <= right) {
^
Main.java:20: error: illegal start of expression
        if (left <= right) {
^
Main.java:20: error: illegal character: '#'
        if (left <= right) {
^
Main.java:20: error: illegal start of expression
        if (left <= right) {
^
Main.java:20: error: illegal character: '#'
        if (left <= right) {
^
Main.java:20: error: illegal start of expression
        if (left <= right) {
^
Main.java:20: error: illegal character: '#'
        if (left <= right) {
^
Main.java:21: error: illegal start of expression
            Team p = list.get((left+right)/2);
^
Main.java:21: error: illegal character: '#'
            Team p = list.get((left+right)/2);
^
Main.java:21: error: illegal start of expression
            Team p = list.get((left+right)/2);
^
Main.java:21: error: illegal character: '#'
            Team p = list.get((left+right)/2);
^
Main.java:21: error: illegal start of expression
            Team p = list.get((left+right)/2);
^
Main.java:21: error: illegal character: '#'
            Team p = list.get((left+right)/2);
^
Main.java:21: error: illegal start of expression
            Team p = list.get((left+right)/2);
^
Main.java:21: error: illegal character: '#'
            Team p = list.get((left+right)/2);
^
Main.java:21: error: illegal start of expression
            Team p = list.get((left+right)/2);
^
Main.java:21: error: illegal character: '#'
            Team p = list.get((left+right)/2);
^
Main.java:21: error: illegal start of expression
            Team p = list.get((left+right)/2);
^
Main.java:21: error: illegal character: '#'
            Team p = list.get((left+right)/2);
^
Main.java:22: error: illegal start of expression
            int l = left;
^
Main.java:22: error: illegal character: '#'
            int l = left;
^
Main.java:22: error: illegal start of expression
            int l = left;
^
Main.java:22: error: illegal character: '#'
            int l = left;
^
Main.java:22: error: illegal start of expression
            int l = left;
^
Main.java:22: error: illegal character: '#'
            int l = left;
^
Main.java:22: error: illegal start of expression
            int l = left;
^
Main.java:22: error: illegal character: '#'
            int l = left;
^
Main.java:22: error: illegal start of expression
            int l = left;
^
Main.java:22: error: illegal character: '#'
            int l = left;
^
Main.java:22: error: illegal start of expression
            int l = left;
^
Main.java:22: error: illegal character: '#'
            int l = left;
^
Main.java:23: error: illegal start of expression
            int r = right;
^
Main.java:23: error: illegal character: '#'
            int r = right;
^
Main.java:23: error: illegal start of expression
            int r = right;
^
Main.java:23: error: illegal character: '#'
            int r = right;
^
Main.java:23: error: illegal start of expression
            int r = right;
^
Main.java:23: error: illegal character: '#'
            int r = right;
^
Main.java:23: error: illegal start of expression
            int r = right;
^
Main.java:23: error: illegal character: '#'
            int r = right;
^
Main.java:23: error: illegal start of expression
            int r = right;
^
Main.java:23: error: illegal character: '#'
            int r = right;
^
Main.java:23: error: illegal start of expression
            int r = right;
^
Main.java:23: error: illegal character: '#'
            int r = right;
^
Main.java:24: error: illegal start of expression
            
^
Main.java:24: error: illegal character: '#'
            
^
Main.java:24: error: illegal start of expression
            
^
Main.java:24: error: illegal character: '#'
            
^
Main.java:24: error: illegal start of expression
            
^
Main.java:24: error: illegal character: '#'
            
^
Main.java:24: error: illegal start of expression
            
^
Main.java:24: error: illegal character: '#'
            
^
Main.java:24: error: illegal start of expression
            
^
Main.java:24: error: illegal character: '#'
            
^
Main.java:24: error: illegal start of expression
            
^
Main.java:24: error: illegal character: '#'
            
^
Main.java:24: error: illegal start of expression
            
^
Main.java:24: error: illegal character: '#'
            
^
Main.java:25: error: illegal start of expression
            while(l <= r) {
^
Main.java:25: error: illegal character: '#'
            while(l <= r) {
^
Main.java:25: error: illegal start of expression
            while(l <= r) {
^
Main.java:25: error: illegal character: '#'
            while(l <= r) {
^
Main.java:25: error: illegal start of expression
            while(l <= r) {
^
Main.java:25: error: illegal character: '#'
            while(l <= r) {
^
Main.java:25: error: illegal start of expression
            while(l <= r) {
^
Main.java:25: error: illegal character: '#'
            while(l <= r) {
^
Main.java:25: error: illegal start of expression
            while(l <= r) {
^
Main.java:25: error: illegal character: '#'
            while(l <= r) {
^
Main.java:25: error: illegal start of expression
            while(l <= r) {
^
Main.java:25: error: illegal character: '#'
            while(l <= r) {
^
Main.java:26: error: illegal start of expression
                while(list.get(l).win < p.win){ l++; }
^
Main.java:26: error: illegal character: '#'
                while(list.get(l).win < p.win){ l++; }
^
Main.java:26: error: illegal start of expression
                while(list.get(l).win < p.win){ l++; }
^
Main.java:26: error: illegal character: '#'
                while(list.get(l).win < p.win){ l++; }
^
Main.java:26: error: illegal start of expression
                while(list.get(l).win < p.win){ l++; }
^
Main.java:26: error: illegal character: '#'
                while(list.get(l).win < p.win){ l++; }
^
Main.java:26: error: illegal start of expression
                while(list.get(l).win < p.win){ l++; }
^
Main.java:26: error: illegal character: '#'
                while(list.get(l).win < p.win){ l++; }
^
Main.java:26: error: illegal start of expression
                while(list.get(l).win < p.win){ l++; }
^
Main.java:26: error: illegal character: '#'
                while(list.get(l).win < p.win){ l++; }
|
s264492389 | p00196 | C | #include <stdio.h>
int struct a{
char name;
int score[10],win,lose;
};
int main(){
int n,j,i,top=0,b,con=0;
while(1){
scanf("%d",&n);
if(n==0) break;
struct a p[10];
for(i=0;i<n;i++){
p[i].win=0;
p[i].lose=0;
scanf("%c",&p[i].name);
for(j=0;j<n-1;j++){
scanf("%d",&p[i].score[j]);
if(p[i].score[j]==0) p[i].win+=1;
else if(p[i].score[j]==1) p[i].lose+=1;
}
}
for(i=0;i<n;i++){
b=-1;
for(j=0;j<n;j++){
if(top<p[j].win){
top=p[j].win;
con=j;
}
else if((top=p[j].win&&b>p[j].lose)||(top=p[j].win&&b>-1)){
b=p[j].lose;
con=j;
}
}
printf("%c\n",p[con].name);
p[con].win=-1;
for(j=0;j<n;j++){
if(p[j].win!=-1){
top=p[j].win;
con=j;
break;
}
}
}
}
return 0;
} | main.c:2:5: error: two or more data types in declaration specifiers
2 | int struct a{
| ^~~~~~
main.c:5:1: warning: useless type name in empty declaration
5 | };
| ^
|
s594012370 | p00196 | C | main(){
while(1){
int n,j,i,top=0,b,con=0;
scanf("%d",&n);
if(n==0) break;
struct a p[10];
for(i=0;i<n;i++){
p[i].win=0;
p[i].lose=0;
scanf("%s",p[i].name);
for(j=0;j<n-1;j++){
scanf("%d",&p[i].score[j]);
if(p[i].score[j]==0) p[i].win+=1;
else if(p[i].score[j]==1) p[i].lose+=1;
}
}
for(i=0;i<n;i++){
b=100;
for(j=n-1;j>=0;j--){
if(top<p[j].win){
top=p[j].win;
con=j;
}
else if((top==p[j].win&&b>p[j].lose)||(top==p[j].win&&b==100)){
b=p[j].lose;
con=j;
}
}
printf("%s\n",p[con].name);
p[con].win=-1;
for(j=0;j<n;j++){
if(p[j].win!=-1){
top=p[j].win;
con=j;
break;
}
}
}
}
return 0;
} | main.c:1:1: error: return type defaults to 'int' [-Wimplicit-int]
1 | main(){
| ^~~~
main.c: In function 'main':
main.c:4:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
4 | scanf("%d",&n);
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | main(){
main.c:4:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
4 | scanf("%d",&n);
| ^~~~~
main.c:4:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:6:14: error: array type has incomplete element type 'struct a'
6 | struct a p[10];
| ^
main.c:30:7: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
30 | printf("%s\n",p[con].name);
| ^~~~~~
main.c:30:7: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:30:7: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:30:7: note: include '<stdio.h>' or provide a declaration of 'printf'
|
s560448194 | p00196 | C | 1. #include <iostream>
2. using namespace std;
3.
4. int main()
5. {
6. int n;
7. while (cin >> n, n)
8. {
9. char name[10];
10. int win[10] = {0};
11. int lose[10] = {0};
12.
13. for (int i = 0; i < n; i++)
14. {
15. cin >> name[i];
16. for (int j = 0; j < n - 1; j++)
17. {
18. int s;
19. cin >> s;
20. if (s == 0)
21. win[i]++;
22. if (s == 1)
23. lose[i]++;
24. }
25. }
26.
27. for (int i = n - 1; i > -1; i--)
28. for (int j = 0; j < n - i; j++)
29. for (int k = 0; k < n; k++)
30. if (win[k] == i && lose[k] == j)
31. cout << name[k] << endl;
32.
33. }
34.
35. return 0;
36. } | main.c:1:4: error: expected identifier or '(' before numeric constant
1 | 1. #include <iostream>
| ^~
main.c:1:7: error: stray '#' in program
1 | 1. #include <iostream>
| ^
main.c:3:4: error: expected identifier or '(' before numeric constant
3 | 3.
| ^~
|
s732929802 | p00196 | C | #include <iostream>
#include <cstdio>
using namespace std;
int i,j,make[100],kati[100];
char name[100];
void change(){
int tmp1,tmp2;
char tmp3;
tmp1 = kati[i];
kati[i] = kati[j];
kati[j] = tmp1;
tmp2 = make[i];
make[i] = make[j];
make[j] = tmp2;
tmp3 = name[i];
name[i] = name[j];
name[j] = tmp3;
}
int main(){
int n,s;
while(1){
cin >> n;
if( n == 0 )break;
for( i = 0;i < n ; i++){
kati[i] = 0;
make[i] = 0;
}
for( i = 0 ; i < n ; i++ ){
cin >> name[i];
for( j = 0; j < n-1 ; j++ ){
cin >> s;
if(s == 0)kati[i]++;
if(s == 1)make[i]++;
}
}
for( i = 0; i < n-1 ; i++){
for( j = i+1; j < n ; j++){
if(kati[i] < kati[j] ){
change();
}
}
}
// for(i = 0;i < n ;i++)cout << name[i] << endl;
for( i = 0; i < n-1 ; i++){
for( j = i+1; j < n ; j++){
if(( kati[i]==kati[j] )&&( make[i] > make[j] )){
change();
}
}
}
for(i = 0;i < n ;i++)cout << name[i] << endl;
}
return 0;
} | main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s495028415 | p00196 | C++ | #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
using namespace std;
int main(void)
{
char name[10];
int toku[9][5],n,make,hiki,sum[9],touroku[9];
int flg[9];
while(1) {
cin>>n;
if(n==0) break;
for(int i=0;i<n;i++) {
cin>>name[i];
for(int j=0;j<n-1;j++) {
cin>>toku[i][j];
}
}
for(int i=0;i<n;i++) {sum[i]=0;touroku[i]=0;}
for(int i=0;i<n;i++) {
kati=0;make=0;
for(int j=0;j<n-1;j++) {
if(toku[i][j]==0) kati++;
if(toku[i][j]==1) make++;
}
sum[i]=kati+(make*-1);
}
for(int i=0;i<n;i++) touroku[i]=sum[i];
sort(sum,sum+n,greater<int>());
for(int i=0;i<n;i++) flg[i]=0;
for(int i=0;i<n;i++) {
for(int j=0;j<n;j++) {
if(sum[i]==touroku[j] && flg[j]==0) {
cout<<name[j]<<endl;
flg[j]=1;
break;
}
}
}
}
} | a.cc: In function 'int main()':
a.cc:26:25: error: 'kati' was not declared in this scope
26 | kati=0;make=0;
| ^~~~
|
s711830524 | p00196 | C++ | #include<stdio.h>
int main(void)
{
int n,i,j,a[10][9],b[10],w,flg[10];
char name[10],x;
while(1){
scanf("%d",&n);
if(n==0) break;
for(i=0;i<n;i++){
scanf(" %c",&name[i]);
for(j=0;j<n-1;j++){
scanf(" %d",&a[i][j]);
}
}
for(i=0;i<n;i++) b[i]=0,flg=i;
for(i=0;i<n;i++){
for(j=0;j<n-1;j++){
if(a[i][j]==0) b[i]=b[i]+10;
else if(a[i][j]==2) b[i]=b[i]+1;
}
}
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
if(b[i]<b[j]){
w=b[i];
b[i]=b[j];
b[j]=w;
x=name[i];
name[i]=name[j];
name[j]=x;
w=flg[i];
flg[i]=flg[j];
flg[j]=w;
}
}
}
for(i=0;i<n-1;i++){
if(b[i]==b[i+1]&&flg[i]>flg[i+1]){
w=b[i];
b[i]=b[i+1];
b[i+1]=w;
x=name[i];
name[i]=name[i+1];
name[i+1]=x;
w=flg[i];
flg[i]=flg[i+1];
flg[i+1]=w;
}
for(i=0;i<n;i++) printf("%c\n",name[i]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:15:44: error: incompatible types in assignment of 'int' to 'int [10]'
15 | for(i=0;i<n;i++) b[i]=0,flg=i;
| ~~~^~
a.cc:52:2: error: expected '}' at end of input
52 | }
| ^
a.cc:3:1: note: to match this '{'
3 | {
| ^
|
s577202665 | p00196 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef pair<char,pair<int,int> > p;
int main() {
int n;
while(cin>>n,n){
vector<p>a;
for(int i=0;i<n;i++){
p data;cin>>data.first;
data.second.first=0;
data.second.second=0;
for(int j=0;j<n-1;j++){
int p;cin>>p;
if(p==0)data.second.first++;
else if(p==1)data.second.second++;
}
a.push_back(data);
}
for(int i=0;i<n;i++){
int f=0;
for(int j=1;j<a.size();j++){
if(a[j].second.first>a[f].second.first)f=j;
else if(a[j].second.first==a[f].second.first&&a[j].second.first<a[f].second.first)f=j;
}
cout<<a[f].first<<endl;
v.erase(v.begin()+f);
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:26:25: error: 'v' was not declared in this scope
26 | v.erase(v.begin()+f);
| ^
|
s993623155 | p00196 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class team
{
public:
team(){c=w=l=0;}
char c;
int w,l;
operator<(const team& t) const
{
return w!=t.w ? w>t.w : l<t.l;
}
};
int main()
{
int n,s;
while(cin >> n, n)
{
vector<team> v;
for(int j=0; j<n; j++)
{
team t;
cin >> t.c;
for(int i=0; i<n-1; i++)
{
cin >> s;
if(s==0) { t.w++; }
if(s==1) { t.l++; }
}
v.push_back(t);
}
stable_sort(v.begin(), v.end());
for(int i=0; i<v.size(); i++)
{
cout << v[i].c << endl;
}
}
return 0;
} | a.cc:15:17: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive]
15 | operator<(const team& t) const
| ^~~~~~~~
|
s377841713 | p00196 | C++ | include<iostream>
#include<cstdlib>
#define MAX 10
using namespace std;
struct datum {
char name;
int win;
int lose;
};
datum data[MAX];
int compare ( const void * a, const void * b ) {
const datum x = *((datum*)a);
const datum y = *((datum*)b);
if ( x.win == y.win )
return x.lose - y.lose;
return y.win - x.win;
}
int main () {
while ( true ) {
int n;
cin >> n;
if ( n == 0 )
break;
for ( int i=0; i<n; i++ ) {
cin >> data[i].name;
int win, lose;
win = 0;
lose = 0;
int now;
for ( int j=0; j<n-1; j++ ) {
cin >> now ;
if ( now == 0 )
win++;
if ( now == 1 )
lose++;
}
data[i].win = win;
data[i].lose = lose;
}
qsort ( data, n, sizeof(datum), compare);
for ( int i=0; i<n; i++ ) {
cout << data[i].name << endl;
}
}
} | a.cc:1:1: error: 'include' does not name a type
1 | include<iostream>
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:28:17: error: 'cin' was not declared in this scope
28 | cin >> n;
| ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
2 | #include<cstdlib>
+++ |+#include <iostream>
3 | #define MAX 10
a.cc:51:25: error: 'cout' was not declared in this scope
51 | cout << data[i].name << endl;
| ^~~~
a.cc:51:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:51:49: error: 'endl' was not declared in this scope
51 | cout << data[i].name << endl;
| ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
2 | #include<cstdlib>
+++ |+#include <ostream>
3 | #define MAX 10
|
s421551163 | p00196 | C++ | #include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
using namespace std;
bool hikaku(const pair<int,string>& A,const pair<int,string>& B){
return A.first > B.first;
}
int main(){
int n,k,win,lose,les;
string s;
while(cin >> n,n){
vector<pair<int,string> >p; // vector < pair <string, int> >p;
for(int i=0;i<n;i++){
cin >> s ;// cin >> s;
les = 0;
for(int j=0;j<n-1;j++){
cin >> k;
if(k==0)
les+=10;//les++;
if(k==2)//if(k==1)
les+=1;
}
p.push_back( make_pair(les,s) );
}
stable_sort(p.begin(),p.end(),hikaku );
//stable_sprt(p.begin(),p.end(),greater<pair<string , int> >);
for(int i=0;i<n;i++)c
cout << p[i].second<<endl;
}
} | a.cc: In function 'int main()':
a.cc:32:37: error: 'c' was not declared in this scope
32 | for(int i=0;i<n;i++)c
| ^
|
s959211565 | p00196 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main(){
int n;
while(cin >> n && n){
vector<string> a;
vector< pair<int,int> > v;
for(int i = 0 ; i < n ; i++){
string name;
cin >> name;
a.push_back(name);
int w = 0;
for(int j = 0 ; j < n - 1 ; j++){
int t;
cin >> t;
if( t == 0 ) w += 10000;
if( t == 2 ) w += 1;
}
v.push_back(make_pair(-w,i));
}
sort(v.begin(),v.end());
for(int i = 0 ; i < v.size() ; i++){
cout << a[v[i].second] << endl;
}
}
} | a.cc: In function 'int main()':
a.cc:23:17: error: 'sort' was not declared in this scope; did you mean 'short'?
23 | sort(v.begin(),v.end());
| ^~~~
| short
|
s964775197 | p00196 | C++ | #include <iostream>
using namespace std;
int main(){
int n;
while(cin >> n){
if(n == 0){
break;
}
pair<pair<int,int>,pair<int,char> > t[n];
for(int i = 0; i < n; i++){
t[i].second.first = i;
cin >> t[i].second.second;
t[i].first.first = 0;
t[i].first.second = 0;
for(int j = 0; j < n - 1; j++){
int x;
cin >> x;
if(x == 0) t[i].first.first--;
else if(x == 1) t[i].first.second++;
}
}
sort(t, t + n);
for(int i = 0; i < n; i++){
cout << t[i].second.second << endl;
}
}
} | a.cc: In function 'int main()':
a.cc:30:5: error: 'sort' was not declared in this scope; did you mean 'short'?
30 | sort(t, t + n);
| ^~~~
| short
|
s056423628 | p00196 | C++ | #include<iostream>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,string> PP;
int n,m;
PP t[10];
int main(){
while(cin>>n&&n){
for(int i=0;i<n;i++){
cin>>t[i].second;
t[i].first.first=t[i].first.second=0;
for(int j=0;j<n;j++){
if(i==j)continue;
cin>>m;
if(m==0)t[i].first.first--;
else if(m==1)t[i].first.second++;
}
}
sort(t,t+n);
for(int i=0;i<n;i++){cout<<t[i].second<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:19:5: error: 'sort' was not declared in this scope; did you mean 'short'?
19 | sort(t,t+n);
| ^~~~
| short
a.cc:23:2: error: expected '}' at end of input
23 | }
| ^
a.cc:7:11: note: to match this '{'
7 | int main(){
| ^
|
s288676679 | p00196 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,string> PP;
int n,m;
PP t[10];
int main(){
while(cin>>n&&n){
for(int i=0;i<n;i++){
cin>>t[i].second;
t[i].first.first=t[i].first.second=0;
for(int j=0;j<n;j++){
if(i==j)continue;
cin>>m;
if(m==0)t[i].first.first--;
else if(m==1)t[i].first.second++;
}
}
sort(t,t+n);
for(int i=0;i<n;i++){cout<<t[i].second<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:2: error: expected '}' at end of input
24 | }
| ^
a.cc:8:11: note: to match this '{'
8 | int main(){
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.