submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s348704966 | p00708 | C++ | import java.io.IOException;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.List;
public class Main {
int[] par;
class Ball {
double x, y, z;
double r;
Ball(double x, double y, double z, double r) {
this.x = x;
this.y = y;
this.z = z;
this.r = r;
}
}
class Edge implements Comparable<Edge>{
double len;
int x, y;
Edge(double len, int x, int y) {
this.len = len;
this.x = x;
this.y = y;
}
@Override
public int compareTo(Edge o) {
if (this.len - o.len > 0) return 1;
if (this.len - o.len < 0) return -1;
return 0;
}
}
double dist(Ball a, Ball b) {
double res = 0;
res = Math.hypot(Math.abs(a.x - b.x), Math.abs(a.y - b.y));
res = Math.hypot(res, Math.abs(a.z - b.z));
return res;
}
boolean isTouching(Ball a, Ball b) {
return dist(a, b) < a.r + b.r;
}
void union(int x, int y) {
x = root(x);
y = root(y);
par[x] = y;
}
boolean find(int x, int y) {
return root(x) == root(y);
}
int root(int x) {
if (par[x] == x) return x;
return root(par[x]);
}
void run() {
MyScanner sc = new MyScanner();
while (true) {
int n = sc.nextInt();
if (n == 0) {
break;
}
Ball[] b = new Ball[n];
for (int i = 0; i < n; i++) {
b[i] = new Ball(sc.nextDouble(), sc.nextDouble(), sc.nextDouble(), sc.nextDouble());
}
par = new int[n];
for (int i = 0; i < n; i++) {
par[i] = i;
}
List<Edge> list = new LinkedList<Edge>();
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (!isTouching(b[i], b[j])) {
list.add(new Edge(dist(b[i], b[j]) - b[i].r - b[j].r, i, j));
} else {
union(i, j);
}
}
}
double sum = 0;
Collections.sort(list);
for (Edge E: list) {
if (!find(E.x, E.y)) {
union(E.x, E.y);
sum += E.len;
}
}
System.out.println(sum);
}
}
public static void main(String[] args) {
new Main().run();
}
public void mapDebug(int[][] a) {
System.out.println("--------map display---------");
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
System.out.printf("%3d ", a[i][j]);
}
System.out.println();
}
System.out.println("----------------------------" + '\n');
}
class MyScanner {
int read() {
try {
return System.in.read();
} catch (IOException e) {
throw new InputMismatchException();
}
}
boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
boolean isEndline(int c) {
return c == '\n' || c == '\r' || c == -1;
}
int nextInt() {
return Integer.parseInt(next());
}
int[] nextIntArray(int n) {
int[] array = new int[n];
for (int i = 0; i < n; i++)
array[i] = nextInt();
return array;
}
long nextLong() {
return Long.parseLong(next());
}
long[] nextLongArray(int n) {
long[] array = new long[n];
for (int i = 0; i < n; i++)
array[i] = nextLong();
return array;
}
double nextDouble() {
return Double.parseDouble(next());
}
double[] nextDoubleArray(int n) {
double[] array = new double[n];
for (int i = 0; i < n; i++)
array[i] = nextDouble();
return array;
}
String next() {
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}
String[] nextStringArray(int n) {
String[] array = new String[n];
for (int i = 0; i < n; i++)
array[i] = next();
return array;
}
String nextLine() {
int c = read();
while (isEndline(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isEndline(c));
return res.toString();
}
}
} | a.cc:32:17: error: stray '@' in program
32 | @Override
| ^
a.cc:1:1: error: 'import' does not name a type
1 | import java.io.IOException;
| ^~~~~~
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.util.Collections;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.util.InputMismatchException;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.util.LinkedList;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.util.List;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: expected unqualified-id before 'public'
7 | public class Main {
| ^~~~~~
|
s620173846 | p00708 | C++ | import java.io.IOException;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.List;
public class Main {
int[] par;
class Ball {
double x, y, z;
double r;
Ball(double x, double y, double z, double r) {
this.x = x;
this.y = y;
this.z = z;
this.r = r;
}
}
class Edge implements Comparable<Edge>{
double len;
int x, y;
Edge(double len, int x, int y) {
this.len = len;
this.x = x;
this.y = y;
}
public int compareTo(Edge o) {
if (this.len - o.len > 0) return 1;
if (this.len - o.len < 0) return -1;
return 0;
}
}
double dist(Ball a, Ball b) {
double res = 0;
res = Math.hypot(Math.abs(a.x - b.x), Math.abs(a.y - b.y));
res = Math.hypot(res, Math.abs(a.z - b.z));
return res;
}
boolean isTouching(Ball a, Ball b) {
return dist(a, b) < a.r + b.r;
}
void union(int x, int y) {
x = root(x);
y = root(y);
par[x] = y;
}
boolean find(int x, int y) {
return root(x) == root(y);
}
int root(int x) {
if (par[x] == x) return x;
return root(par[x]);
}
void run() {
MyScanner sc = new MyScanner();
while (true) {
int n = sc.nextInt();
if (n == 0) {
break;
}
Ball[] b = new Ball[n];
for (int i = 0; i < n; i++) {
b[i] = new Ball(sc.nextDouble(), sc.nextDouble(), sc.nextDouble(), sc.nextDouble());
}
par = new int[n];
for (int i = 0; i < n; i++) {
par[i] = i;
}
List<Edge> list = new LinkedList<Edge>();
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (!isTouching(b[i], b[j])) {
list.add(new Edge(dist(b[i], b[j]) - b[i].r - b[j].r, i, j));
} else {
union(i, j);
}
}
}
double sum = 0;
Collections.sort(list);
for (Edge E: list) {
if (!find(E.x, E.y)) {
union(E.x, E.y);
sum += E.len;
}
}
System.out.println(sum);
}
}
public static void main(String[] args) {
new Main().run();
}
public void mapDebug(int[][] a) {
System.out.println("--------map display---------");
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
System.out.printf("%3d ", a[i][j]);
}
System.out.println();
}
System.out.println("----------------------------" + '\n');
}
class MyScanner {
int read() {
try {
return System.in.read();
} catch (IOException e) {
throw new InputMismatchException();
}
}
boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
boolean isEndline(int c) {
return c == '\n' || c == '\r' || c == -1;
}
int nextInt() {
return Integer.parseInt(next());
}
int[] nextIntArray(int n) {
int[] array = new int[n];
for (int i = 0; i < n; i++)
array[i] = nextInt();
return array;
}
long nextLong() {
return Long.parseLong(next());
}
long[] nextLongArray(int n) {
long[] array = new long[n];
for (int i = 0; i < n; i++)
array[i] = nextLong();
return array;
}
double nextDouble() {
return Double.parseDouble(next());
}
double[] nextDoubleArray(int n) {
double[] array = new double[n];
for (int i = 0; i < n; i++)
array[i] = nextDouble();
return array;
}
String next() {
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}
String[] nextStringArray(int n) {
String[] array = new String[n];
for (int i = 0; i < n; i++)
array[i] = next();
return array;
}
String nextLine() {
int c = read();
while (isEndline(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isEndline(c));
return res.toString();
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.io.IOException;
| ^~~~~~
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.util.Collections;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.util.InputMismatchException;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.util.LinkedList;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.util.List;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: expected unqualified-id before 'public'
7 | public class Main {
| ^~~~~~
|
s706322110 | p00708 | C++ | #include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
const int MAX = 100;
int par[MAX];
int rnk[MAX];
int nodeNum[MAX];
void init(int n) {
for(int i = 0; i < n; i++) {
par[i] = i;
rnk[i] = 0;
nodeNum[i] = 1;
}
}
int find(int x) {
if(par[x] == x) {
return x;
}
else {
return par[x] = find(par[x]);
}
}
void unite(int x, int y) {
x = find(x);
y = find(y);
if(x == y) return;
if(rnk[x] < rnk[y]) {
par[x] = y;
}
else {
par[y] = x;
if(rnk[x] == rnk[y]) rnk[x]++;
}
nodeNum[x] = nodeNum[y] = nodeNum[x] + nodeNum[y];
}
bool same(int x, int y) {
return find(x) == find(y);
}
typedef double W;
struct edge {
int u, v;
W cost;
};
bool comp(const edge& e1, const edge& e2) {
return e1.cost < e2.cost;
}
vector<edge> es;
W kruskal(int V, int E) {
sort(es.begin(), es.end(), comp);
init(V);
W res = 0;
for(int i = 0; i < E; i++) {
edge e = es[i];
if(!same(e.u, e.v)) {
unite(e.u, e.v);
res += e.cost;
}
}
return res;
}
double x[100], y[100], z[100], r[100];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
while(cin >> N, N) {
for(int i = 0; i < N; i++) {
cin >> x[i] >> y[i] >> z[i] >> r[i];
}
es.clear();
for(int i = 0; i < N; i++) {
for(int j = i + 1; j < N; j++) {
double d = sqrt((x[i] - x[j]) * (x[i] - x[j]) +
(y[i] - y[j]) * (y[i] - y[j]) +
(z[i] - z[j]) * (z[i] - z[j]));
d = max(0.0, d - r[i] - r[j]);
es.push_back(edge{ i, j, d });
}
}
double ans = kruskal(N, es.size());
cout << setprecision(12) << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:91:44: error: 'sqrt' was not declared in this scope
91 | double d = sqrt((x[i] - x[j]) * (x[i] - x[j]) +
| ^~~~
|
s166609785 | p00708 | C++ | #include <queue>
#include <vector>
#include <iostream>
using namespace std;
// ------ Class ------ //
class Graph2 {
public:
// ------ Variables ------ //
static const long double INF = 1000000000000000000;
int V, E; vector<vector<pair<int, long double> > > G;
// ------ Constructors ------ //
Graph2() : V(0), E(0), G(vector<vector<pair<int, long double> > >()) {}
Graph2(int v) : V(v), E(0), G(vector<vector<pair<int, long double> > >(v)) {}
Graph2(vector<vector<pair<int, long double> > > g) : V(g.size()), G(g) { for (int i = 0; i < g.size(); i++) E += g[i].size(); }
// ------ Basic Functions ------ //
int size() { return V; }
void add1(int v1, int v2, long double w) { G[v1].push_back(make_pair(v2, w)); E++; }
void add2(int v1, int v2, long double w) { add1(v1, v2, w); add1(v2, v1, w); }
// ------ Operators ------ //
bool operator==(const Graph2& g) const { return G == g.G; }
bool operator!=(const Graph2& g) const { return G != g.G; }
vector<pair<int, long double> > operator[](int x) { return G[x]; }
// ------ Algorithms ------ //
long double minspan() {
vector<long double> d(V, INF);
vector<bool> used(V, false);
priority_queue<pair<long doubleg, int> > que;
for (int i = 0; i < V; i++) d[i] = INF;
d[0] = 0; que.push(make_pair(0, 0));
while (!que.empty()) {
pair<long double, int> pa = que.top(); que.pop();
int u = pa.second; used[u] = true;
for (int i = 0; i < G[u].size(); i++) {
int v = G[u][i].first;
if (d[v] > G[u][i].second && !used[v]) {
d[v] = G[u][i].second; que.push(make_pair(-d[v], v));
}
}
}
long double sum = 0;
for (int i = 0; i < V; i++) sum += d[i];
return sum;
}
};
// ------ Main ------ //
int n; long double x[111], y[111], x[111], r[111];
int main() {
while(cin >> n, n) {
for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i] >> r[i];
Graph2 G(n);
for(int i = 0; i < n; i++) {
for(int j = i + 1; j < n; j++) {
long double dist = sqrtl((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) + (z[i] - z[j]) * (z[i] - z[j]));
G.add2(i, j, (dist > r[i] + r[j]) ? (dist - r[i] - r[j]) : 0)
}
}
cout << G.minspan() << endl;
}
} | a.cc:9:34: error: 'constexpr' needed for in-class initialization of static data member 'const long double Graph2::INF' of non-integral type [-fpermissive]
9 | static const long double INF = 1000000000000000000;
| ^~~
a.cc: In member function 'long double Graph2::minspan()':
a.cc:31:54: error: wrong number of template arguments (1, should be 2)
31 | priority_queue<pair<long doubleg, int> > que;
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/deque:62,
from /usr/include/c++/14/queue:62,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
89 | struct pair;
| ^~~~
a.cc:31:56: error: template argument 1 is invalid
31 | priority_queue<pair<long doubleg, int> > que;
| ^
a.cc:31:56: error: template argument 2 is invalid
a.cc:31:56: error: template argument 3 is invalid
a.cc:33:31: error: request for member 'push' in 'que', which is of non-class type 'int'
33 | d[0] = 0; que.push(make_pair(0, 0));
| ^~~~
a.cc:34:29: error: request for member 'empty' in 'que', which is of non-class type 'int'
34 | while (!que.empty()) {
| ^~~~~
a.cc:35:57: error: request for member 'top' in 'que', which is of non-class type 'int'
35 | pair<long double, int> pa = que.top(); que.pop();
| ^~~
a.cc:35:68: error: request for member 'pop' in 'que', which is of non-class type 'int'
35 | pair<long double, int> pa = que.top(); que.pop();
| ^~~
a.cc:40:68: error: request for member 'push' in 'que', which is of non-class type 'int'
40 | d[v] = G[u][i].second; que.push(make_pair(-d[v], v));
| ^~~~
a.cc: At global scope:
a.cc:50:36: error: redefinition of 'long double x [111]'
50 | int n; long double x[111], y[111], x[111], r[111];
| ^
a.cc:50:20: note: 'long double x [111]' previously declared here
50 | int n; long double x[111], y[111], x[111], r[111];
| ^
a.cc: In function 'int main()':
a.cc:53:67: error: 'z' was not declared in this scope
53 | for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i] >> r[i];
| ^
a.cc:57:123: error: 'z' was not declared in this scope
57 | long double dist = sqrtl((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) + (z[i] - z[j]) * (z[i] - z[j]));
| ^
a.cc:57:52: error: 'sqrtl' was not declared in this scope; did you mean 'strtol'?
57 | long double dist = sqrtl((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) + (z[i] - z[j]) * (z[i] - z[j]));
| ^~~~~
| strtol
a.cc:58:94: error: expected ';' before '}' token
58 | G.add2(i, j, (dist > r[i] + r[j]) ? (dist - r[i] - r[j]) : 0)
| ^
| ;
59 | }
| ~
|
s695563805 | p00708 | C++ | #include <queue>
#include <vector>
#include <iostream>
using namespace std;
// ------ Class ------ //
class Graph2 {
public:
// ------ Variables ------ //
static const long double INF = 1000000000000000000.0L;
int V, E; vector<vector<pair<int, long double> > > G;
// ------ Constructors ------ //
Graph2() : V(0), E(0), G(vector<vector<pair<int, long double> > >()) {}
Graph2(int v) : V(v), E(0), G(vector<vector<pair<int, long double> > >(v)) {}
Graph2(vector<vector<pair<int, long double> > > g) : V(g.size()), G(g) { for (int i = 0; i < g.size(); i++) E += g[i].size(); }
// ------ Basic Functions ------ //
int size() { return V; }
void add1(int v1, int v2, long double w) { G[v1].push_back(make_pair(v2, w)); E++; }
void add2(int v1, int v2, long double w) { add1(v1, v2, w); add1(v2, v1, w); }
// ------ Operators ------ //
bool operator==(const Graph2& g) const { return G == g.G; }
bool operator!=(const Graph2& g) const { return G != g.G; }
vector<pair<int, long double> > operator[](int x) { return G[x]; }
// ------ Algorithms ------ //
long double minspan() {
vector<long double> d(V, INF);
vector<bool> used(V, false);
priority_queue<pair<long double, int> > que;
for (int i = 0; i < V; i++) d[i] = INF;
d[0] = 0; que.push(make_pair(0, 0));
while (!que.empty()) {
pair<long double, int> pa = que.top(); que.pop();
int u = pa.second; used[u] = true;
for (int i = 0; i < G[u].size(); i++) {
int v = G[u][i].first;
if (d[v] > G[u][i].second && !used[v]) {
d[v] = G[u][i].second; que.push(make_pair(-d[v], v));
}
}
}
long double sum = 0;
for (int i = 0; i < V; i++) sum += d[i];
return sum;
}
};
// ------ Main ------ //
int n; long double x[111], y[111], z[111], r[111];
int main() {
while(cin >> n, n) {
for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i] >> r[i];
Graph2 G(n);
for(int i = 0; i < n; i++) {
for(int j = i + 1; j < n; j++) {
long double dist = sqrtl((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) + (z[i] - z[j]) * (z[i] - z[j]));
G.add2(i, j, (dist > r[i] + r[j]) ? (dist - r[i] - r[j]) : 0)
}
}
cout << G.minspan() << endl;
}
} | a.cc:9:34: error: 'constexpr' needed for in-class initialization of static data member 'const long double Graph2::INF' of non-integral type [-fpermissive]
9 | static const long double INF = 1000000000000000000.0L;
| ^~~
a.cc: In function 'int main()':
a.cc:57:52: error: 'sqrtl' was not declared in this scope; did you mean 'strtol'?
57 | long double dist = sqrtl((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) + (z[i] - z[j]) * (z[i] - z[j]));
| ^~~~~
| strtol
a.cc:58:94: error: expected ';' before '}' token
58 | G.add2(i, j, (dist > r[i] + r[j]) ? (dist - r[i] - r[j]) : 0)
| ^
| ;
59 | }
| ~
|
s372908776 | p00708 | C++ | #include <cmath>
#include <queue>
#include <vector>
#include <iostream>
#define INF 1e16
using namespace std;
// ------ Class ------ //
class Graph2 {
public:
// ------ Variables ------ //
int V, E; vector<vector<pair<int, long double> > > G;
// ------ Constructors ------ //
Graph2() : V(0), E(0), G(vector<vector<pair<int, long double> > >()) {}
Graph2(int v) : V(v), E(0), G(vector<vector<pair<int, long double> > >(v)) {}
Graph2(vector<vector<pair<int, long double> > > g) : V(g.size()), G(g) { for (int i = 0; i < g.size(); i++) E += g[i].size(); }
// ------ Basic Functions ------ //
int size() { return V; }
void add1(int v1, int v2, long double w) { G[v1].push_back(make_pair(v2, w)); E++; }
void add2(int v1, int v2, long double w) { add1(v1, v2, w); add1(v2, v1, w); }
// ------ Operators ------ //
bool operator==(const Graph2& g) const { return G == g.G; }
bool operator!=(const Graph2& g) const { return G != g.G; }
vector<pair<int, long double> > operator[](int x) { return G[x]; }
// ------ Algorithms ------ //
long double minspan() {
vector<long double> d(V, INF);
vector<bool> used(V, false);
priority_queue<pair<long double, int> > que;
for (int i = 0; i < V; i++) d[i] = INF;
d[0] = 0; que.push(make_pair(0, 0));
while (!que.empty()) {
pair<long double, int> pa = que.top(); que.pop();
int u = pa.second; used[u] = true;
for (int i = 0; i < G[u].size(); i++) {
int v = G[u][i].first;
if (d[v] > G[u][i].second && !used[v]) {
d[v] = G[u][i].second; que.push(make_pair(-d[v], v));
}
}
}
long double sum = 0;
for (int i = 0; i < V; i++) sum += d[i];
return sum;
}
};
// ------ Main ------ //
int n; long double x[111], y[111], z[111], r[111];
int main() {
while(cin >> n, n) {
for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i] >> r[i];
Graph2 G(n);
for(int i = 0; i < n; i++) {
for(int j = i + 1; j < n; j++) {
long double dist = sqrtl((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) + (z[i] - z[j]) * (z[i] - z[j]));
G.add2(i, j, (dist > r[i] + r[j]) ? (dist - r[i] - r[j]) : 0)
}
}
cout << G.minspan() << endl;
}
} | a.cc: In function 'int main()':
a.cc:59:94: error: expected ';' before '}' token
59 | G.add2(i, j, (dist > r[i] + r[j]) ? (dist - r[i] - r[j]) : 0)
| ^
| ;
60 | }
| ~
|
s269277963 | p00708 | C++ | #include <bits/stdc++.h>
using namespace std;
#define MAX_V 100
#define MAX_E 10000
int V,E,par[MAX_V],rank[MAX_V];
struct Colony{
double x,y,z,r;
Colony(){}
Colony(double x,double y,double z,double r) : x(x),y(y),z(z),r(r) {}
};
struct Edge{
int u,v;
double dist;
Edge(){}
Edge(int u,int v,double dist) : u(u),v(v),dist(dist) {}
};
bool comp(const Edge &e1,const Edge &e2){
return e1.dist < e2.dist;
}
Edge es[MAX_E];
void init(){
for(int i = 0 ; i < V ; i++){
par[i] = i;
rank[i] = 0;
}
}
int find(int x){
if(par[x] == x){
return x;
}
return par[x] = find(par[x]);
}
void unite(int x,int y){
x = find(x);
y = find(y);
if(x == y) return;
if(rank[x] < rank[y]){
par[x] = y;
}else{
par[y] = x;
if(rank[x] == rank[y]){
rank[x]++;
}
}
}
bool same(int x,int y){
return find(x) == find(y);
}
double kruskal(){
sort(es,es+E,comp);
init();
double res = 0.0;
for(int i = 0 ; i < E ; i++){
Edge e = es[i];
if(!same(e.u,e.v)){
unite(e.u,e.v);
res += e.dist;
}
}
return res;
}
double getDist(const Colony &c1,const Colony &c2){
return sqrt(pow(c1.x-c2.x,2)+pow(c1.y-c2.y,2)+pow(c1.z-c2.z,2))-c1.r-c2.r;
}
int main(){
while(cin >> V,V){
E = 0;
double x,y,z,r;
Colony C[MAX_V];
for(int i = 0 ; i < V ; i++){
cin >> x >> y >> z >> r;
C[i] = Colony(x,y,z,r);
}
for(int i = 0 ; i < V ; i++){
for(int j = i+1 ; j < V ; j++){
double dist = getDist(C[i],C[j]);
es[E++] = Edge(i,j,max(dist,0.0));
}
}
printf("%.3f\n",kruskal());
}
return 0;
} | a.cc: In function 'void init()':
a.cc:32:9: error: reference to 'rank' is ambiguous
32 | rank[i] = 0;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
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,
from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:8:20: note: 'int rank [100]'
8 | int V,E,par[MAX_V],rank[MAX_V];
| ^~~~
a.cc: In function 'void unite(int, int)':
a.cc:49:8: error: reference to 'rank' is ambiguous
49 | if(rank[x] < rank[y]){
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:8:20: note: 'int rank [100]'
8 | int V,E,par[MAX_V],rank[MAX_V];
| ^~~~
a.cc:49:18: error: reference to 'rank' is ambiguous
49 | if(rank[x] < rank[y]){
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:8:20: note: 'int rank [100]'
8 | int V,E,par[MAX_V],rank[MAX_V];
| ^~~~
a.cc:53:12: error: reference to 'rank' is ambiguous
53 | if(rank[x] == rank[y]){
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:8:20: note: 'int rank [100]'
8 | int V,E,par[MAX_V],rank[MAX_V];
| ^~~~
a.cc:53:23: error: reference to 'rank' is ambiguous
53 | if(rank[x] == rank[y]){
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:8:20: note: 'int rank [100]'
8 | int V,E,par[MAX_V],rank[MAX_V];
| ^~~~
a.cc:54:13: error: reference to 'rank' is ambiguous
54 | rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:8:20: note: 'int rank [100]'
8 | int V,E,par[MAX_V],rank[MAX_V];
| ^~~~
|
s906227903 | p00708 | C++ | #include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
struct edge {
int p, q;
double d;
bool operator<(const edge &e) const { return d < e.d; }
};
int N;
double X[100], Y[100], Z[100], R[100];
double dist(int i, int j) {
double dx = X[i] - X[j];
double dy = Y[i] - Y[j];
double dz = Z[i] - Z[j];
return max(sqrt(dx * dx + dy * dy + dz * dz) - R[i] - R[j], 0.0);
}
int find(int *a, int i) { return a[i] == i ? i : (a[i] = find(a, a[i])); }
void unite(int *a, int i, int j) { if(find(a, i) != find(a, j)) a[find(a, i)] = find(a, j); }
int main(void) {
while(cin >> N, N) {
REP(i, 0, N) cin >> X[i] >> Y[i] >> Z[i] >> R[i];
vector<edge> e;
REP(i, 0, N) REP(j, i + 1, N) e.push_back((edge) { i, j, dist(i, j) });
sort(e.begin(), e.end());
double ans = 0.0;
int g[100];
REP(i, 0, N) g[i] = i;
REP(i, 0, e.size()) if(find(g, e[i].p) != find(g, e[i].q)) {
ans += e[i].d;
unite(g, e[i].p, e[i].q);
}
printf("%.5lf\n", ans);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:33:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
33 | sort(e.begin(), e.end());
| ^~~~
| sqrt
|
s045113192 | p00708 | C++ | #include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
#define MAX 100
typedef pair<int,int> pii;
typedef pair<double,pii> pp;
struct union_find {
int rnk[MAX], par[MAX];
union_find(int n) { for(int i = 0; i < n; i++) rnk[i] = 1, par[i] = i; }
int find(int x) {
if(x == par[x]) return x;
else return par[x] = find(par[x]);
}
bool unite(int x, int y) {
x = find(x); y = find(y);
if(x == y) return false;
if(rnk[x] > rnk[y]) par[y] = x;
else{
par[x] = y;
if(rnk[x] == rnk[y]) rnk[y]++;
}
return true;
}
};
inline double cor(vector<double> a, vector<double> b) {
double ret = sqrt((a[0]-b[0])*(a[0]-b[0]) + (a[1]-b[1])*(a[1]-b[1]) + (a[2]-b[2])*(a[2]-b[2]));
ret -= a[3]+b[3];
if (ret <= 0) return 0;
else return ret;
}
int main(void) {
int n;
while (cin>>n && n) {
vector<vector<double> > v(n, vector<double>(4));
for (int i = 0; i < n; i++) cin >> v[i][0] >> v[i][1] >> v[i][2] >> v[i][3];
vector<vector<double> > l(n, vector<double>(n));
priority_queue<pp, vector<pp>, greater<pp> > que;
union_find uf(n);
for (int i = 0; i < n-1; i++) {
for (int j = i+1; j < n; j++) {
pp t = make_pair(cor(v[i],v[j]), make_pair(i,j));
que.push(t);
}
}
double ans = 0;
while (!que.empty()) {
pp t = que.top();
que.pop();
if (uf.unite(t.second.first, t.second.second)) ans += t.first;
}
printf("%.8lf\n", ans);
}
} | a.cc: In function 'double cor(std::vector<double>, std::vector<double>)':
a.cc:35:18: error: 'sqrt' was not declared in this scope
35 | double ret = sqrt((a[0]-b[0])*(a[0]-b[0]) + (a[1]-b[1])*(a[1]-b[1]) + (a[2]-b[2])*(a[2]-b[2]));
| ^~~~
|
s757659797 | p00708 | C++ | #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
using namespace std;
#define INF 1<<28
const double eps=1e-8 ;
double sqrt1(double a)
{
return a*a;
}
double x[123],y[123],z[142],r[231];
double dis(int i,int j)
{
return sqrt(sqrt1(x[i]-x[j])+sqrt1(y[i]-y[j])+sqrt1(z[i]-z[j]));
}
int vis[1230];
double map[123][123];
double d[1001];
int n;
int prim()
{
double ans = 0 ;
for(int i = 1 ; i <= n ; i++)
{
d[i] = INF ;
vis[i] = false ;
}
d[1] = 0 ;
for(int i = 1 ; i <= n ; i++)
{
int minn = INF ;
int flag = 0 ;
for(int j = 1 ; j <= n ; j++)
{
if(minn > d[j]&&!vis[j])
{
minn = d[j] ;
flag = j ;
}
}
if(minn >= INF)
break;
ans += minn ;
vis[flag] = true ;
for(j = 1 ; j <= n ; j++)
{
if(!vis[j]&&d[j]>map[flag][j])
d[j] = map[flag][j] ;
}
}
printf("%.3lf\n",ans);
}
int main()
{
while(cin>>n)
{
if(n==0)break;
memset(map,0,sizeof(map));
for(int i=1;i<=n;i++)
{
cin>>x[i]>>y[i]>>z[i]>>r[i];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
//printf("%lf----------\n",dis(i,j));
if(dis(i,j)-r[i]-r[j]<=0)
map[i][j]=0;
else if(dis(i,j)-r[i]-r[j]>eps)
map[i][j]=dis(i,j)-r[i]-r[j];
}
}
prim();
}
return 0;
} | a.cc: In function 'int prim()':
a.cc:53:13: error: 'j' was not declared in this scope
53 | for(j = 1 ; j <= n ; j++)
| ^
a.cc:60:1: warning: no return statement in function returning non-void [-Wreturn-type]
60 | }
| ^
|
s158818605 | p00708 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
using vd=vector<double>;
using data=tuple<double,int,int>;
double hypot3(double x,double y,double z){
return sqrt(x*x+y*y+z*z);
}
double dist(vd a, vd b){
auto d=hypot3(a[0]-b[0],a[1]-b[1],a[2]-b[2]);
return max(d-a[3]-b[3],0.0);
}
struct UnionFind{
vi p;
UnionFind(int s):p(s,-1){}
void union(int a,int b){
a=root(a);b=root(b);
if(a!=b){
if(p[b]<p[a])swap(a,b);
p[a]+=p[b];p[b]=a;
}
}
bool same(int a,int b){return root(a)==root(b);}
int root(int a){return p[a]<0?a:p[a]=root(p[a]);}
};
int main(){
int n;
while(cin>>n,n){
vector<vd> cell(n,vd(4));
vector<data> edge;
rep(i,n) {
rep(j,4) cin>>cell[i][j];
rep(j,i) edge.emplace_back(dist(cell[i],cell[j]),i,j);
}
sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
UnionFind uf(n);
double ans=0;
for(auto e:edge){
double d; int a,b;
tie(d,a,b)=e;
if(!uf.same(a,b)){
ans+=d;
uf.unite(a,b);
}
}
cout.precision(3);
cout<<fixed<<ans<<endl;
}
return 0;
}
| a.cc:32:19: error: expected identifier before '(' token
32 | void union(int a,int b){
| ^
a.cc:32:20: error: expected unqualified-id before 'int'
32 | void union(int a,int b){
| ^~~
a.cc:32:20: error: expected ')' before 'int'
32 | void union(int a,int b){
| ~^~~
| )
a.cc: In function 'int main()':
a.cc:47:28: error: template argument 1 is invalid
47 | vector<data> edge;
| ^
a.cc:47:28: error: template argument 2 is invalid
a.cc:50:39: error: request for member 'emplace_back' in 'edge', which is of non-class type 'int'
50 | rep(j,i) edge.emplace_back(dist(cell[i],cell[j]),i,j);
| ^~~~~~~~~~~~
a.cc:9:18: error: request for member 'begin' in 'edge', which is of non-class type 'int'
9 | #define all(a) a.begin(),a.end()
| ^~~~~
a.cc:52:22: note: in expansion of macro 'all'
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ^~~
a.cc:9:28: error: request for member 'end' in 'edge', which is of non-class type 'int'
9 | #define all(a) a.begin(),a.end()
| ^~~
a.cc:52:22: note: in expansion of macro 'all'
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ^~~
a.cc:52:35: error: reference to 'data' is ambiguous
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:19:7: note: 'using data = class std::tuple<double, int, int>'
19 | using data=tuple<double,int,int>;
| ^~~~
a.cc:52:35: error: 'data' has not been declared
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ^~~~
a.cc:52:42: error: reference to 'data' is ambiguous
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:19:7: note: 'using data = class std::tuple<double, int, int>'
19 | using data=tuple<double,int,int>;
| ^~~~
a.cc:52:42: error: 'data' has not been declared
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ^~~~
a.cc: In lambda function:
a.cc:52:63: error: no matching function for call to 'get<0>(int&)'
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ~~~~~~^~~
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:1250:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
1250 | get(pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: template argument deduction/substitution failed:
a.cc:52:63: note: mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ~~~~~~^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)'
1255 | get(pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: template argument deduction/substitution failed:
a.cc:52:63: note: mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ~~~~~~^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)'
1260 | get(const pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: template argument deduction/substitution failed:
a.cc:52:63: note: mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ~~~~~~^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)'
1265 | get(const pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: template argument deduction/substitution failed:
a.cc:52:63: note: mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ~~~~~~^~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2445:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)'
2445 | get(tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2445:5: note: template argument deduction/substitution failed:
a.cc:52:63: note: mismatched types 'std::tuple<_Elements ...>' and 'int'
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ~~~~~~^~~
/usr/include/c++/14/tuple:2451:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)'
2451 | get(const tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2451:5: note: template argument deduction/substitution failed:
a.cc:52:63: note: mismatched types 'const std::tuple<_Elements ...>' and 'int'
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ~~~~~~^~~
/usr/include/c++/14/tuple:2457:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)'
2457 | get(tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2457:5: note: template argument deduction/substitution failed:
a.cc:52:63: note: mismatched types 'std::tuple<_Elements ...>' and 'int'
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ~~~~~~^~~
/usr/include/c++/14/tuple:2466:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&)'
2466 | get(const tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2466:5: note: template argument deduction/substitution failed:
a.cc:52:63: note: mismatched types 'const std::tuple<_Elements ...>' and 'int'
52 | sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});
| ~~~~~~^~~
In file included from /usr/include/c++/14/fu |
s297997089 | p00708 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
class UnionFindTree{
private:
// indexツづ個青板づ個親ツノツーツド
vector<int> par;
// indexツづーツ債ェツづつキツづゥツ姪伉づ個δ可δ督ク
vector<int> rank;
// ツ姪伉づ個催妥・ツ値
int treeSize;
public:
UnionFindTree(int initTreeSize = 1000){
// ツ暗クツ青板づ与ツつヲツづァツづェツつスツ値ツづーツ催妥・ツ格ツ納ツ青板づつキツづゥUnionFindTreeツづ個催ャツ青ャ
treeSize = initTreeSize;
init();
}
void init(){
for(int i = 0; i < treeSize; i++){
par.push_back(i);
rank.push_back(0);
}
}
// ツ与ツつヲツづァツづェツつスツ青板つェツ格ツ納ツつウツづェツづつ「ツづゥツ姪伉づ個δ仰ーツトツづーツ探ツ催オ
int find(int x){
if(par[x] == x){
return x;
}
else{
return par[x] = find(par[x]);
}
}
void unite(int x,int y){
x = find(x);
y = find(y);
if(x == y)
return;
if(rank[x] < rank[y]){
par[x] = y;
}
else{
par[y] = x;
if(rank[y] == rank[x]){
rank[x]++;
}
}
}
bool same(int x,int y){
return find(x) == find(y);
}
};
class Circle{
public:
double x,y,z,r;
Circle(){}
Circle(double x_,double y_,double z_,double r_){
x=x_;
y=y_;
z=z_;
r=r_;
}
};
const int MAX_V = 200;
double cost[MAX_V][MAX_V];
double mincost[MAX_V];
bool used[MAX_V];
int V;
const int INF = 10000000;
double prim(){
for(int i = 0; i < V; i++){
mincost[i] = INF;
used[i] = false;
}
mincost[0] = 0;
double res = 0;
while(1){
int v = -1;
// Xツづ可堕ョツつウツづ按つ「ツ陳クツ点ツづ個つ、ツつソXツつゥツづァツづ個陛督づ個コツスツトツつェツ催渉ャツづ可づ按づゥツ点ツづーツ探ツつキ
for(int u = 0; u < V; u++){
if(!used[u] && (v == -1 || mincost[u] < mincost[v])){
v = u;
}
}
if(v == -1)
break;
used[v] = true;
res += mincost[v];
for(int u = 0; u < V; u++){
mincost[u] = min(mincost[u],cost[v][u]);
}
}
return res;
}
int main(){
int n;
while(cin>>n&&n!=0){
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
cost[i][j]=INF;
}
}
V=n;
vector<Circle> vc;
for(int i = 0; i < n; i++){
Circle c;
cin>>c.x>>c.y>>c.z>>c.r;
vc.push_back(c);
}
UnionFindTree uft(n);
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(i==j)
continue;
double dist=(vc[i].x-vc[j].x)*(vc[i].x-vc[j].x)
+(vc[i].y-vc[j].y)*(vc[i].y-vc[j].y)
+(vc[i].z-vc[j].z)*(vc[i].z-vc[j].z);
// ツ重ツづ按づづつ「ツづゥ
if(EQ(dist,(vc[i].r+vc[j].r)*(vc[i].r+vc[j].r))||(dist<(vc[i].r+vc[j].r)*(vc[i].r+vc[j].r))){
uft.unite(i,j);
break;
}
}
}
// ツ重ツづ按づづつ「ツづゥツづÍRXg0Ìm[hð£ÁĨ
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(i==j)
continue;
if(uft.same(i,j)){
cost[i][j]=0;
}
else{
double dist=sqrt((vc[i].x-vc[j].x)*(vc[i].x-vc[j].x)
+(vc[i].y-vc[j].y)*(vc[i].y-vc[j].y)
+(vc[i].z-vc[j].z)*(vc[i].z-vc[j].z));
cost[i][j]=dist-(vc[i].r+vc[j].r);
}
}
}
double res=prim();
printf("%.5f\n",res);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:164:53: error: 'sqrt' was not declared in this scope
164 | double dist=sqrt((vc[i].x-vc[j].x)*(vc[i].x-vc[j].x)
| ^~~~
|
s229988549 | p00708 | C++ | #include<iostream>
#include<vector>
#include<cfloat>
#include<cmath>
#include<set>
using namespace std;
#define NONE DBL_MAX
struct Sphere{
double x,y,z,r;
};
double dist(Sphere a, Sphere b)
{
double d=sqrt( pow(a.x-b.x,2.0)+pow(a.y-b.y,2.0)+pow(a.z-b.z,2.0) );
return a.r+b.r<d?d-a.r-b.r:0.0;
}
double prim(vector< vector<double> >v)
{
double sum=0.0;
int n=v.size();
set<int>selected;
set<int>::iterator it;
double mincost;
int mini;
selected.insert(0);
while(selected.size()!=n){
mincost=INT_MAX;
for(it=selected.begin();it!=selected.end();it++){
for(int i=0;i<n;i++){
if(selected.find(i)!=selected.end())continue;
if(v[*it][i]==NONE)continue;
if(v[*it][i]>=mincost)continue;
mincost=v[*it][i];
mini=i;
}
}
if(mini==NONE)break;
sum+=mincost;
selected.insert(mini);
}
return sum;
}
int main()
{
int n;
double x,y,z,r;
while(cin>>n,n){
vector<Sphere>list(n);
vector< vector<double> >A(n,vector<double>(n,NONE));
for(int i=0;i<n;i++)cin>>list[i].x>>list[i].y>>list[i].z>>list[i].r;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
A[i][j]=A[j][i]=dist(list[i],list[j]);
}
}
printf("%.3f\n",prim(A));
}
} | a.cc: In function 'double prim(std::vector<std::vector<double> >)':
a.cc:30:13: error: 'INT_MAX' was not declared in this scope
30 | mincost=INT_MAX;
| ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
5 | #include<set>
+++ |+#include <climits>
6 | using namespace std;
|
s759014173 | p00708 | C++ | #include <iostream>
#include <cmath>
using namespace std;
struct station{
double x,y,z,r;
};
double dist(station &a,station &b){
return pow(pow(a.x-b.x,2)+pow(a.y-b.y,2)+pow(a.z-b.z,2),0.5)-a.r-b.r;
}
int uft[100];
void init(){
for(int i = 0; i < 100; ++i) uft[i] = i;
}
int find(int v){
if(uft[v] == v) return v;
else return uft[v] = find(uft[v]);
}
void uni(int v,int w){
uft[find(w)] = find(v);
}
typedef pair<double,pair<int,int> > P;
int main(){
int n;
while(cin >> n,n){
init();
station s[100];
for(int i = 0; i < n; ++i){
cin >> s[i].x >> s[i].y >> s[i].z >> s[i].r;
}
P p[10000];
int m = 0;
for(int i = 0; i < n; ++i)for(int j = 0; j < n; ++j){
double d = dist(s[i],s[j]);
if(d > 0) p[m++] = P(d,pair<int,int>(i,j));
else uni(i,j);
}
sort(p,p+m);
double sum = 0;
for(int i = 0; i < m; ++i){
if(find(p[i].second.first) != find(p[i].second.second)){
sum += p[i].first;
uni(p[i].second.first,p[i].second.second);
}
}
printf("%.3f\n",sum);
}
} | a.cc: In function 'int main()':
a.cc:37:17: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
37 | sort(p,p+m);
| ^~~~
| sqrt
|
s415878078 | p00708 | C++ | //kruskal tree
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <cmath>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<double,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
int x=root(a),y=root(b);
if(x==y)return 0;
parent[x]=y;
return 1;
}
int main(){
int i,j;
double x,y,z;
for(;cin>>n,n;){
vector<tuple<double,double,double> >v;
for(i=0;i<n;i++)cin>>x>>y>>z,v.push_back(make_tuple(x,y,z));
for(m=i=0;i<n;i++)for(j=i+1,j<n;j++){
for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
a[m]=i,b[m]=j,node[m].first=x,node[m].second=m++;
}
sort(node,node+m);
for(i=0;i<n;i++)parent[i]=i;
for(x=i=0;i<m;i++)if(unite(a[node[i].second],b[node[i].second]))x+=node[i].first;
cout<<x<<endl;
}
} | a.cc: In function 'int main()':
a.cc:21:19: error: 'n' was not declared in this scope
21 | for(;cin>>n,n;){
| ^
a.cc:24:21: error: 'm' was not declared in this scope
24 | for(m=i=0;i<n;i++)for(j=i+1,j<n;j++){
| ^
a.cc:24:52: error: expected ';' before ')' token
24 | for(m=i=0;i<n;i++)for(j=i+1,j<n;j++){
| ^
| ;
a.cc:25:31: error: 'k' was not declared in this scope
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ^
a.cc:25:57: error: no matching function for call to 'get<k>(__gnu_cxx::__alloc_traits<std::allocator<std::tuple<double, double, double> >, std::tuple<double, double, double> >::value_type&)'
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
1250 | get(pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)'
1255 | get(pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)'
1260 | get(const pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)'
1265 | get(const pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2445:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)'
2445 | get(tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2445:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2451:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)'
2451 | get(const tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2451:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2457:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)'
2457 | get(tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2457:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2466:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&)'
2466 | get(const tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2466:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:138:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(array<_Tp, _Nm>&)'
138 | get(array<_Tp, _Nm>&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:138:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:142:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(array<_Tp, _Nm>&&)'
142 | get(array<_Tp, _Nm>&&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:142:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:146:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const array<_Tp, _Nm>&)'
146 | get(const array<_Tp, _Nm>&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:146:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:150:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const array<_Tp, _Nm>&&)'
150 | get(const array<_Tp, _Nm>&&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:150:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_T1, _T2>&)'
1272 | get(pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_T1, _T2>&)'
1277 | get(const pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1282:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_T1, _T2>&&)'
1282 | get(pair<_Tp, _Up>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1282:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1287:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_T1, _T2>&&)'
1287 | get(const pair<_Tp, _Up>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1287:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_Up, _Tp>&)'
1292 | get(pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_Up, _Tp>&)'
1297 | get(const pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1302:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_Up, _Tp>&&)'
1302 | get(pair<_Up, _Tp>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1302:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1307:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_Up, _Tp>&&)'
1307 | get(const pair<_Up, _Tp>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1307:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2476:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&)' (deleted)
2476 | get(const tuple<_Elements...>&) = delete;
| ^~~
/usr/include/c++/14/tuple:2476:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2483:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(tuple<_Elements ...>&)'
2483 | get(tuple<_Types...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2483:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2494:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(tuple<_Elements ...>&&)'
2494 | get(tuple<_Types...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2494:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2505:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const tuple<_Elements ...>&)'
2505 | get(const tuple<_Types...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2505:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2517:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const tuple<_Elements ...>&&)'
2517 | get(const tuple<_Types...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2517:5: note: template argument deduction/substitution failed:
a.cc:25:70: error: no matching function for call to 'get<k>(__gnu_cxx::__alloc_traits<std::allocator<std::tuple<double, double |
s671190205 | p00708 | C++ | //kruskal tree
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <cmath>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<double,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
int x=root(a),y=root(b);
if(x==y)return 0;
parent[x]=y;
return 1;
}
int main(){
int i,j;
double x,y,z;
for(;cin>>n,n;){
vector<tuple<double,double,double> >v;
for(i=0;i<n;i++)cin>>x>>y>>z,v.push_back(make_tuple(x,y,z));
for(m=i=0;i<n;i++)for(j=i+1,j<n;j++){
for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
a[m]=i,b[m]=j,node[m].first=x,node[m].second=m++;
}
sort(node,node+m);
for(i=0;i<n;i++)parent[i]=i;
for(x=i=0;i<m;i++)if(unite(a[node[i].second],b[node[i].second]))x+=node[i].first;
cout<<x<<endl;
}
} | a.cc: In function 'int main()':
a.cc:21:19: error: 'n' was not declared in this scope
21 | for(;cin>>n,n;){
| ^
a.cc:24:21: error: 'm' was not declared in this scope
24 | for(m=i=0;i<n;i++)for(j=i+1,j<n;j++){
| ^
a.cc:24:52: error: expected ';' before ')' token
24 | for(m=i=0;i<n;i++)for(j=i+1,j<n;j++){
| ^
| ;
a.cc:25:31: error: 'k' was not declared in this scope
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ^
a.cc:25:57: error: no matching function for call to 'get<k>(__gnu_cxx::__alloc_traits<std::allocator<std::tuple<double, double, double> >, std::tuple<double, double, double> >::value_type&)'
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
1250 | get(pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)'
1255 | get(pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)'
1260 | get(const pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)'
1265 | get(const pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2445:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)'
2445 | get(tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2445:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2451:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)'
2451 | get(const tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2451:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2457:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)'
2457 | get(tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2457:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2466:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&)'
2466 | get(const tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2466:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:138:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(array<_Tp, _Nm>&)'
138 | get(array<_Tp, _Nm>&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:138:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:142:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(array<_Tp, _Nm>&&)'
142 | get(array<_Tp, _Nm>&&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:142:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:146:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const array<_Tp, _Nm>&)'
146 | get(const array<_Tp, _Nm>&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:146:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:150:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const array<_Tp, _Nm>&&)'
150 | get(const array<_Tp, _Nm>&&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:150:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_T1, _T2>&)'
1272 | get(pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_T1, _T2>&)'
1277 | get(const pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1282:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_T1, _T2>&&)'
1282 | get(pair<_Tp, _Up>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1282:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1287:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_T1, _T2>&&)'
1287 | get(const pair<_Tp, _Up>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1287:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_Up, _Tp>&)'
1292 | get(pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_Up, _Tp>&)'
1297 | get(const pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1302:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_Up, _Tp>&&)'
1302 | get(pair<_Up, _Tp>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1302:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:1307:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_Up, _Tp>&&)'
1307 | get(const pair<_Up, _Tp>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1307:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2476:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&)' (deleted)
2476 | get(const tuple<_Elements...>&) = delete;
| ^~~
/usr/include/c++/14/tuple:2476:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2483:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(tuple<_Elements ...>&)'
2483 | get(tuple<_Types...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2483:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2494:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(tuple<_Elements ...>&&)'
2494 | get(tuple<_Types...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2494:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2505:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const tuple<_Elements ...>&)'
2505 | get(const tuple<_Types...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2505:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/tuple:2517:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const tuple<_Elements ...>&&)'
2517 | get(const tuple<_Types...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2517:5: note: template argument deduction/substitution failed:
a.cc:25:70: error: no matching function for call to 'get<k>(__gnu_cxx::__alloc_traits<std::allocator<std::tuple<double, double |
s628939524 | p00708 | C++ | //kruskal tree
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <cmath>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<double,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
int x=root(a),y=root(b);
if(x==y)return 0;
parent[x]=y;
return 1;
}
int main(){
int i,j,k,m,n;
double x,y,z;
for(;cin>>n,n;){
vector<tuple<double,double,double> >v;
for(i=0;i<n;i++)cin>>x>>y>>z,v.push_back(make_tuple(x,y,z));
for(m=i=0;i<n;i++)for(j=i+1;j<n;j++){
for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
a[m]=i,b[m]=j,node[m].first=x,node[m].second=m++;
}
sort(node,node+m);
for(i=0;i<n;i++)parent[i]=i;
for(x=i=0;i<m;i++)if(unite(a[node[i].second],b[node[i].second]))x+=node[i].first;
cout<<x<<endl;
}
} | a.cc: In function 'int main()':
a.cc:25:57: error: no matching function for call to 'get<k>(__gnu_cxx::__alloc_traits<std::allocator<std::tuple<double, double, double> >, std::tuple<double, double, double> >::value_type&)'
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
1250 | get(pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: template argument deduction/substitution failed:
a.cc:25:57: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:57: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)'
1255 | get(pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: template argument deduction/substitution failed:
a.cc:25:57: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:57: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)'
1260 | get(const pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: template argument deduction/substitution failed:
a.cc:25:57: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:57: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)'
1265 | get(const pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: template argument deduction/substitution failed:
a.cc:25:57: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:57: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2445:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)'
2445 | get(tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2445:5: note: template argument deduction/substitution failed:
a.cc:25:57: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:57: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
/usr/include/c++/14/tuple:2451:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)'
2451 | get(const tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2451:5: note: template argument deduction/substitution failed:
a.cc:25:57: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:57: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
/usr/include/c++/14/tuple:2457:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)'
2457 | get(tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2457:5: note: template argument deduction/substitution failed:
a.cc:25:57: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:57: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
/usr/include/c++/14/tuple:2466:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&)'
2466 | get(const tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2466:5: note: template argument deduction/substitution failed:
a.cc:25:57: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:57: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:138:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(array<_Tp, _Nm>&)'
138 | get(array<_Tp, _Nm>&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:138:5: note: template argument deduction/substitution failed:
a.cc:25:57: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:57: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_pair.h:142:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(array<_Tp, _Nm>&&)'
142 | get(array<_Tp, _Nm>&&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:142:5: note: template argument deduction/substitution failed:
a.cc:25:57: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:57: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<k>(v[i])-get<k>(v[j]));
| ~~~~~~^~~~~~
/usr/include/c++/14/bits/s |
s298055818 | p00708 | C++ | //kruskal tree
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <cmath>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<double,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
int x=root(a),y=root(b);
if(x==y)return 0;
parent[x]=y;
return 1;
}
int main(){
int i,j,k,m,n;
double x,y,z;
for(;cin>>n,n;){
vector<tuple<double,double,double> >v;
for(i=0;i<n;i++)cin>>x>>y>>z,v.push_back(make_tuple(x,y,z));
for(m=i=0;i<n;i++)for(j=i+1;j<n;j++){
for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
a[m]=i,b[m]=j,node[m].first=x,node[m].second=m++;
}
sort(node,node+m);
for(i=0;i<n;i++)parent[i]=i;
for(x=i=0;i<m;i++)if(unite(a[node[i].second],b[node[i].second]))x+=node[i].first;
cout<<x<<endl;
}
} | a.cc: In function 'int main()':
a.cc:25:66: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ^
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:68: error: no matching function for call to 'get<k>(__gnu_cxx::__alloc_traits<std::allocator<std::tuple<double, double, double> >, std::tuple<double, double, double> >::value_type&)'
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ~~~~~~~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
1250 | get(pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: template argument deduction/substitution failed:
a.cc:25:68: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ~~~~~~~~~~~~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:55: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)'
1255 | get(pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: template argument deduction/substitution failed:
a.cc:25:68: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ~~~~~~~~~~~~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:55: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)'
1260 | get(const pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: template argument deduction/substitution failed:
a.cc:25:68: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ~~~~~~~~~~~~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:55: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)'
1265 | get(const pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: template argument deduction/substitution failed:
a.cc:25:68: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ~~~~~~~~~~~~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:55: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ^~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2445:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)'
2445 | get(tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2445:5: note: template argument deduction/substitution failed:
a.cc:25:68: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ~~~~~~~~~~~~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:55: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ^~~~~~~~~~~~
/usr/include/c++/14/tuple:2451:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)'
2451 | get(const tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2451:5: note: template argument deduction/substitution failed:
a.cc:25:68: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ~~~~~~~~~~~~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:55: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ^~~~~~~~~~~~
/usr/include/c++/14/tuple:2457:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)'
2457 | get(tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2457:5: note: template argument deduction/substitution failed:
a.cc:25:68: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ~~~~~~~~~~~~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:55: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ^~~~~~~~~~~~
/usr/include/c++/14/tuple:2466:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&)'
2466 | get(const tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2466:5: note: template argument deduction/substitution failed:
a.cc:25:68: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ~~~~~~~~~~~~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:55: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:138:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(array<_Tp, _Nm>&)'
138 | get(array<_Tp, _Nm>&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:138:5: note: template argument deduction/substitution failed:
a.cc:25:68: error: the value of 'k' is not usable in a constant expression
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ~~~~~~~~~~~~~~~~~^~~~~~
a.cc:19:17: note: 'int k' is not const
19 | int i,j,k,m,n;
| ^
a.cc:25:55: note: in template argument for type 'long unsigned int'
25 | for(x=k=0;k<3;k++)x+=fabs(get<(const int)k>(v[i])-get<k>(v[j]));
| ^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:142:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(array<_Tp, _Nm>&&)'
142 | get(array<_Tp, _Nm>&&) noexcep |
s027040673 | p00708 | C++ | //kruskal tree
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<double,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
int x=root(a),y=root(b);
if(x==y)return 0;
parent[x]=y;
return 1;
}
int main(){
int i,j,k,m,n;
double x,y,z,r;
for(;cin>>n,n;){
vector<vector<double> >v;
for(i=0;i<n;i++)scanf("%lf%lf%lf%lf",x,y,z,r),v.push_back({x,y,z,r});
for(i=0;i<n;i++)parent[i]=i;
for(m=i=0;i<n;i++)for(j=i+1;j<n;j++){
for(x=k=0;k<3;k++)x+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
x=sqrt(x)-v[i][3]-v[j][3];
if(x<=0)unite(i,j);
else a[m]=i,b[m]=j,node[m].first=x,node[m++].second=m;
}
sort(node,node+m);
for(x=i=0;i<m;i++)if(unite(a[node[i].second],b[node[i].second]))x+=node[i].first;
printf("%.3f\n",x);
}
} | a.cc: In function 'int main()':
a.cc:20:14: error: 'cin' was not declared in this scope
20 | for(;cin>>n,n;){
| ^~~
a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
5 | #include <cstdio>
+++ |+#include <iostream>
6 | using namespace std;
|
s055065161 | p00708 | C++ | //kruskal tree
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<double,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
int x=root(a),y=root(b);
if(x==y)return 0;
parent[x]=y;
return 1;
}
int main(){
int i,j,k,m,n,q;
double x,y,z,r,t;
for(;scanf("%d",&n),n;){
vector<vector<double> >v(n);
for(q=m=i=0;i<n;i++){
scanf("%lf%lf%lf%lf",&x,&y,&z,&r),v[i]=push_back({x,y,z,r}),parent[i]=i;
for(j=0;j<i;j++){
for(x=k=0;k<3;k++)x+=(t=v[i][k]-v[j][k])*t;
x=sqrt(x)-v[i][3]-v[j][3];
if(x<=0){if(unite(i,j))q++;}
else a[m]=i,b[m]=j,node[m].first=x,node[m++].second=m;
}
}
sort(node,node+m);
for(x=i=0;i<m&&q<n-1;i++)if(unite(a[node[i].second],b[node[i].second]))x+=node[i].first,q++;
printf("%.3f\n",x);
}
} | a.cc: In function 'int main()':
a.cc:23:64: error: 'push_back' was not declared in this scope
23 | scanf("%lf%lf%lf%lf",&x,&y,&z,&r),v[i]=push_back({x,y,z,r}),parent[i]=i;
| ^~~~~~~~~
|
s485111976 | p00708 | C++ | #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
//container util
//------------------------------------------
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
double x[111], y[111], z[111], r[111];
double d[111][111];
int visit[111];
int main(){
int n;
while(cin>>n, n){
memset(visit, 0, sizeof(visit));
REP(i,n)cin>>x[i]>>y[i]>>z[i]>>r[i];
REP(i,n)FOR(j,i+1,n)d[i][j] = d[j][i] = max(sqrt(pow(x[i]-x[j], 2.0)+pow(y[i]-y[j], 2.0)+pow(z[i]-z[j], 2.0))-r[i]-r[j], 0.0);
priority_queue<pair<double, PII>, vector<pair<double,PII> >, greater<pair<double,PII> > > q;
visit[0]=1;
FOR(i,1,n)q.push(MP(d[0][i], MP(0, i)));
double ret = 0.0;
while(!q.empty()){
pair<double, PII> tmp;
tmp = q.top();
q.pop();
if(visit[tmp.second.second])continue;
ret += tmp.first;
visit[tmp.second.second] = 1;
REP(i,n)if(i!=tmp.second.second)q.push(MP(d[tmp.second.second][i], MP(tmp.second.second, i)));
}
printf("%.3f\n", ret;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:88:37: error: expected ')' before ';' token
88 | printf("%.3f\n", ret;
| ~ ^
| )
|
s507730904 | p00708 | C++ | #include<iostream>
#include<stdio>
#include<cmath>
using namespace std;
double x[100], y[100], z[100], r[100];
int n,m,MX=(1<<20),a,b,c,t,mn,hozon;
double map[100][100];
double sumcor;
int p[100];
double d[100];
int visited[100];
// i, j の距離を求める
double compute(int i, int j) {
double ret;
ret = sqrt( (x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]) + (z[i] - z[j])*(z[i] - z[j]) ) - (r[i] + r[j]);
if (ret < 0) ret = 0;
return ret;
}
int main() {
double res = 0;
while(1) {
cin >> n;
if (n == 0) break;
for(int i=0; i < n; i++) {
cin >> x[i]; cin >> y[i]; cin >> z[i]; cin >> r[i];
}
visited[t] = 1;
// init p, d, visited, map, res
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
map[i][j] = MX;
}
p[i] = 0;
d[i] = MX;
visited[i] = 0;
}
res = 0;
// 2つのセル間の距離を算出
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if (i == j) continue;
map[i][j] = compute(i, j);
}
}
d[0] = 0;
t = 0;
while(1){
mn = MX;
// Target更新
for (int i = 0; i < n; i++) {
if (d[i] < mn && visited[i] == 0) {
mn = d[i];
t = i;
}
}
if ( mn == MX ) break; // 終了判定
visited[t] = 1;
res += d[t];
//
for(int v = 0; v < n; v++){
if(map[t][v] < d[v] && visited[v] == 0){
d[v] = map[t][v];
p[v] = t;
}
}
}
printf("%lf\n", res);
}
return 0;
} | a.cc:2:9: fatal error: stdio: No such file or directory
2 | #include<stdio>
| ^~~~~~~
compilation terminated.
|
s333376958 | p00708 | C++ | #include<iostream>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
const int MAX = 101;
bool used[MAX];
struct data{double x,y,z,r;};
struct State{
data d;
double t;
int n;
State(){}
State(data d, double t, int n):d(d),t(t),n(n){}
bool operator < (const State& s) const {return t > s.t;}
};
int N;
vector<data> V;
void init(){
V.clear();
V.resize(N);
fill(used,used+MAX,false);
}
void input(){
for(int i = 0; i < N; i++)
cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
}
double getDis(data d1, data d2){
return sqrt(pow(d1.x-d2.x,2.0)+pow(d1.y-d2.y,2.0)+pow(d1.z-d2.z,2.0));
}
void solve(){
priority_queue<State> Q;
Q.push(State(V[0],0,0));
double ans = 0;
while(!Q.empty()){
State now = Q.top();
Q.pop();
if(used[now.n]) continue;
used[now.n] = true;
ans += now.t;
for(int i = 0; i < N; i++){
double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
if(!used[i]) Q.push(State(V[i],dis,i));
}
}
printf("%.3f\n",ans);
}
int main(){
while(cin >> N && N){
init();
input();
solve();
}
return 0;
} | a.cc:13:3: error: reference to 'data' is ambiguous
13 | data d;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:8: note: 'struct data'
11 | struct data{double x,y,z,r;};
| ^~~~
a.cc:17:13: error: expected ')' before 'd'
17 | State(data d, double t, int n):d(d),t(t),n(n){}
| ~ ^~
| )
a.cc:22:12: error: template argument 1 is invalid
22 | vector<data> V;
| ^
a.cc:22:12: error: template argument 2 is invalid
a.cc: In function 'void init()':
a.cc:25:5: error: request for member 'clear' in 'V', which is of non-class type 'int'
25 | V.clear();
| ^~~~~
a.cc:26:5: error: request for member 'resize' in 'V', which is of non-class type 'int'
26 | V.resize(N);
| ^~~~~~
a.cc: In function 'void input()':
a.cc:32:13: error: invalid types 'int[int]' for array subscript
32 | cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
| ^
a.cc:32:23: error: invalid types 'int[int]' for array subscript
32 | cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
| ^
a.cc:32:33: error: invalid types 'int[int]' for array subscript
32 | cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
| ^
a.cc:32:43: error: invalid types 'int[int]' for array subscript
32 | cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
| ^
a.cc: At global scope:
a.cc:36:15: error: reference to 'data' is ambiguous
36 | double getDis(data d1, data d2){
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:8: note: 'struct data'
11 | struct data{double x,y,z,r;};
| ^~~~
a.cc:36:24: error: reference to 'data' is ambiguous
36 | double getDis(data d1, data d2){
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:8: note: 'struct data'
11 | struct data{double x,y,z,r;};
| ^~~~
a.cc:36:31: error: expression list treated as compound expression in initializer [-fpermissive]
36 | double getDis(data d1, data d2){
| ^
a.cc: In function 'void solve()':
a.cc:41:17: error: invalid types 'int[int]' for array subscript
41 | Q.push(State(V[0],0,0));
| ^
a.cc:54:35: error: 'struct State' has no member named 'd'
54 | double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
| ^
a.cc:54:38: error: invalid types 'int[int]' for array subscript
54 | double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
| ^
a.cc:54:41: error: 'getDis' cannot be used as a function
54 | double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
| ^
a.cc:54:47: error: 'struct State' has no member named 'd'
54 | double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
| ^
a.cc:54:52: error: invalid types 'int[int]' for array subscript
54 | double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
| ^
a.cc:55:34: error: invalid types 'int[int]' for array subscript
55 | if(!used[i]) Q.push(State(V[i],dis,i));
| ^
|
s741727746 | p00708 | C++ | #include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAX = 101;
bool used[MAX];
struct data{double x,y,z,r;};
struct State{
data d;
double t;
int n;
State(){}
State(data d, double t, int n):d(d),t(t),n(n){}
bool operator < (const State& s) const {return t > s.t;}
};
int N;
vector<data> V;
void init(){
V.clear();
V.resize(N);
fill(used,used+MAX,false);
}
void input(){
for(int i = 0; i < N; i++)
cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
}
double getDis(data d1, data d2){
return sqrt(pow(d1.x-d2.x,2.0)+pow(d1.y-d2.y,2.0)+pow(d1.z-d2.z,2.0));
}
void solve(){
priority_queue<State> Q;
Q.push(State(V[0],0,0));
double ans = 0;
while(!Q.empty()){
State now = Q.top();
Q.pop();
if(used[now.n]) continue;
used[now.n] = true;
ans += now.t;
for(int i = 0; i < N; i++){
double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
if(!used[i]) Q.push(State(V[i],dis,i));
}
}
printf("%.3f\n",ans);
}
int main(){
while(cin >> N && N){
init();
input();
solve();
}
return 0;
} | a.cc:14:3: error: reference to 'data' is ambiguous
14 | data d;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:12:8: note: 'struct data'
12 | struct data{double x,y,z,r;};
| ^~~~
a.cc:18:13: error: expected ')' before 'd'
18 | State(data d, double t, int n):d(d),t(t),n(n){}
| ~ ^~
| )
a.cc:23:12: error: template argument 1 is invalid
23 | vector<data> V;
| ^
a.cc:23:12: error: template argument 2 is invalid
a.cc: In function 'void init()':
a.cc:26:5: error: request for member 'clear' in 'V', which is of non-class type 'int'
26 | V.clear();
| ^~~~~
a.cc:27:5: error: request for member 'resize' in 'V', which is of non-class type 'int'
27 | V.resize(N);
| ^~~~~~
a.cc: In function 'void input()':
a.cc:33:13: error: invalid types 'int[int]' for array subscript
33 | cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
| ^
a.cc:33:23: error: invalid types 'int[int]' for array subscript
33 | cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
| ^
a.cc:33:33: error: invalid types 'int[int]' for array subscript
33 | cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
| ^
a.cc:33:43: error: invalid types 'int[int]' for array subscript
33 | cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
| ^
a.cc: At global scope:
a.cc:37:15: error: reference to 'data' is ambiguous
37 | double getDis(data d1, data d2){
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:12:8: note: 'struct data'
12 | struct data{double x,y,z,r;};
| ^~~~
a.cc:37:24: error: reference to 'data' is ambiguous
37 | double getDis(data d1, data d2){
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:12:8: note: 'struct data'
12 | struct data{double x,y,z,r;};
| ^~~~
a.cc:37:31: error: expression list treated as compound expression in initializer [-fpermissive]
37 | double getDis(data d1, data d2){
| ^
a.cc: In function 'void solve()':
a.cc:42:17: error: invalid types 'int[int]' for array subscript
42 | Q.push(State(V[0],0,0));
| ^
a.cc:55:35: error: 'struct State' has no member named 'd'
55 | double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
| ^
a.cc:55:38: error: invalid types 'int[int]' for array subscript
55 | double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
| ^
a.cc:55:41: error: 'getDis' cannot be used as a function
55 | double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
| ^
a.cc:55:47: error: 'struct State' has no member named 'd'
55 | double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
| ^
a.cc:55:52: error: invalid types 'int[int]' for array subscript
55 | double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
| ^
a.cc:56:34: error: invalid types 'int[int]' for array subscript
56 | if(!used[i]) Q.push(State(V[i],dis,i));
| ^
|
s369619756 | p00708 | C++ | #include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>
#include <map>
using namespace std;
//// MACRO ////
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define allof(c) c.begin(), c.end()
#define partof(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
#define countof(a) (sizeof(a)/sizeof(a[0]))
#define PREDIACTE(t,a) [](const t & a) -> bool
#define COMPARISON(t,a,b) [](const t & a, const t & b) -> bool
// start up //
void solve();
int main() { solve(); return 0; }
//// prime ////
vector<unsigned char> isPrime;
vector<int> primes;
void initPrimes(int n)
{
isPrime = vector<unsigned char>(n + 1, true);
isPrime[0] = isPrime[1] = false;
FOR(i, 2, n + 1)
{
if (!isPrime[i]) continue;
primes.push_back(i);
for (int j = i * 2; j <= n; j += i)
isPrime[j] = false;
}
}
//// iota iterator ////
struct iotait
{
int n;
iotait(int n = 0) : n(n) { }
iotait &operator ++() { ++n; return *this; }
int operator *() { return n; }
};
//// geo ////
struct P3
{
double x, y, z;
P3(double x=0, double y=0, double z=0) : x(x), y(y), z(z) { }
P3 operator +() const { return *this; }
P3 operator +(const P3 &_) const { return P3(x+_.x, y+_.y, z+_.z); }
P3 operator -() const { return P3(-x, -y, -z); }
P3 operator -(const P3 &_) const { return *this + -_; }
P3 operator *(double _) const { return P3(x*_,y*_,z*_); }
P3 operator /(double _) const { return P3(x/_,y/_,z/_); }
double dot(const P3 &_) const { return x*_.x + y*_.y + z*_.z; }
P3 cross(const P3 &_) const { return P3(y*_.z-z*_.y, z*_.x-x*_.z, x*_.y-y*_.x); }
double sqlength() const { return x*x+y*y+z*z; }
double length() const { return sqrt(sqlength()); }
P3 direction() const { return *this / length(); }
};
struct Sphere
{
P3 c;
double r;
Sphere(double x, double y, double z, double r) : c(x,y,z), r(r) { }
};
//// graph ////
struct Path
{
int from;
int to;
double cost;
Path(int from, int to, double cost) : from(from), to(to), cost(cost) { }
bool operator < (const Path &rhs) const { return cost < rhs.cost; }
bool operator > (const Path &rhs) const { return cost > rhs.cost; }
};
// prim //
pair<double, vector<int>> prim(const vector<vector<double>> &costTable)
{
int N = costTable.size();
priority_queue<Path, vector<Path>, greater<Path>> q;
q.push(Path(0, 0, 0));
vector<int> parent(N, -1);
double totalCost = 0;
while (!q.empty())
{
Path cur = q.top(); q.pop();
int i = cur.from;
if (parent[i] != -1) continue;
parent[i] = cur.from;
totalCost += cur.cost;
REP(j,N) if (parent[i] == -1) q.push(Path(i,j,costTable[i][j]));
}
return make_pair(totalCost, parent);
}
//// i/o ////
template <class T>
class vevector : public vector<vector<T>>
{
public:
vevector(int n = 0, int m = 0) : vector<vector<T>>(n, vector<T>(m)) { };
vevector(int n, int m, const T &initial) : vector<vector<T>>(n, vector<T>(m, initial)) { };
using vector<vector<T>>::operator [];
T& operator [](const POINT &index) { return (*this)[index.real()][index.imag()]; }
};
template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vevector<T> read(int n, int m) { vevector<T> v; REP(i,n) v.push_back(read<T>(m)); return v; }
template <class T> vevector<T> readjag(int n) { vevector<T> v; REP(i,n) v.push_back(read<T>(read<int>())); return v; }
template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }
template <class T> void write(const vector<T> &v)
{
ostringstream ss;
for (auto x : v) ss << x << ' ';
auto s = ss.str();
cout << s.substr(0, s.length() - 1) << endl;
}
struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__
/// template end ///
void solve()
{
REP (testcase, INF)
{
// よみこみ
READ(int, N);
if (!N) { break; }
vector<Sphere> spheres;
REP(i,N) { READ(double, x,y,z,r); spheres.push_back(Sphere(x,y,z,r)); }
// cost[i][j] = 球i - 球j 間に廊下を作った時のコスト表
vevector<double> costTable(N, N);
REP(i,N) REP(j,N)
{
Sphere &si = spheres[i], &sj = spheres[j];
costTable[i][j] = max((si.c - sj.c).length() - (si.r + sj.r), 0.0);
}
// 最少全域木
double totalCost = prim(costTable).first;
write(totalCost);
}
} | a.cc:125:30: error: 'POINT' does not name a type
125 | T& operator [](const POINT &index) { return (*this)[index.real()][index.imag()]; }
| ^~~~~
a.cc: In member function 'T& vevector<T>::operator[](const int&)':
a.cc:125:67: error: request for member 'real' in 'index', which is of non-class type 'const int'
125 | T& operator [](const POINT &index) { return (*this)[index.real()][index.imag()]; }
| ^~~~
a.cc:125:81: error: request for member 'imag' in 'index', which is of non-class type 'const int'
125 | T& operator [](const POINT &index) { return (*this)[index.real()][index.imag()]; }
| ^~~~
a.cc: In function 'void solve()':
a.cc:162:37: error: invalid types 'double[int]' for array subscript
162 | costTable[i][j] = max((si.c - sj.c).length() - (si.r + sj.r), 0.0);
| ^
|
s004994149 | p00709 | C++ | #include <map>
#include <queue>
#include <string>
#include <vector>
#include <iostream>
#include <functional>
using namespace std;
struct state
{
vector<string> v;
int dist1;
int dist2;
state(vector<string> v1, int d1, int d2) : v(v1), dist1(d1), dist2(d2) { }
};
bool operator<(const state& s1, const state& s2) { return s1.dist1 + s1.dist2 < s2.dist1 + s2.dist2; }
bool operator<(const state& s1, const state& s2) { return s1.dist1 + s1.dist2 < s2.dist1 + s2.dist2; }
int W, H; vector<string> start;
map<vector<string>, bool> M;
int getdistance(vector<string> v)
{
int ret = 0;
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
if (v[i][j] == '.')
{
ret++;
}
}
}
return ret;
}
int main()
{
while (true)
{
scanf("%d", &W);
scanf("%d", &H);
M.clear();
if (W == 0 && H == 0) break;
start = vector<string>(H);
for (int i = 0; i < H; i++) cin >> start[i];
priority_queue<state, vector<state>, greater<state> > que;
que.push(state(start, 0, getdistance(start))); M[start] = true;
while (!que.empty())
{
state s1 = que.top(); que.pop();
if (s1.dist2 == 0)
{
printf("%d\n", s1.dist1); break;
}
for (int i = 1; i <= 10; i++)
{
for (int j = 0; j <= H - i; j++)
{
for (int k = 0; k <= W - i; k++)
{
vector<string> v2 = s1.v;
bool flag = true;
for (int l = j; l < j + i; l++)
{
for (int m = k; m < k + i; m++)
{
if (v2[i][j] == '*')
{
flag = true; break;
}
else
{
v2[i][j] = '+';
}
}
if (flag) break;
}
if (!M[v2])
{
M[v2] = true;
que.push(state(v2, s1.dist1 + 1, getdistance(v2)));
}
}
}
}
}
}
return 0;
} | a.cc:21:6: error: redefinition of 'bool operator<(const state&, const state&)'
21 | bool operator<(const state& s1, const state& s2) { return s1.dist1 + s1.dist2 < s2.dist1 + s2.dist2; }
| ^~~~~~~~
a.cc:20:6: note: 'bool operator<(const state&, const state&)' previously defined here
20 | bool operator<(const state& s1, const state& s2) { return s1.dist1 + s1.dist2 < s2.dist1 + s2.dist2; }
| ^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_tree.h:65,
from /usr/include/c++/14/map:62,
from a.cc:1:
/usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = state]':
/usr/include/c++/14/bits/predefined_ops.h:196:23: required from 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<state*, std::vector<state> >; _Value = state; _Compare = std::greater<state>]'
196 | { return bool(_M_comp(*__it, __val)); }
| ~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<state*, vector<state> >; _Distance = long int; _Tp = state; _Compare = __gnu_cxx::__ops::_Iter_comp_val<greater<state> >]'
140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:216:23: required from 'void std::push_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<state*, vector<state> >; _Compare = greater<state>]'
216 | std::__push_heap(__first, _DistanceType((__last - __first) - 1),
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
217 | _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:747:16: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = state; _Sequence = std::vector<state>; _Compare = std::greater<state>; value_type = state]'
747 | std::push_heap(c.begin(), c.end(), comp);
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:62:11: required from here
62 | que.push(state(start, 0, getdistance(start))); M[start] = true;
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:395:20: error: no match for 'operator>' (operand types are 'const state' and 'const state')
395 | { return __x > __y; }
| ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/bits/stl_tree.h:63:
/usr/include/c++/14/bits/stl_pair.h:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:395:20: note: 'const state' is not derived from 'const std::pair<_T1, _T2>'
395 | { return __x > __y; }
| ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
462 | operator>(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:395:20: note: 'const state' is not derived from 'const std::reverse_iterator<_Iterator>'
395 | { return __x > __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
507 | operator>(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:395:20: note: 'const state' is not derived from 'const std::reverse_iterator<_Iterator>'
395 | { return __x > __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1714 | operator>(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:395:20: note: 'const state' is not derived from 'const std::move_iterator<_IteratorL>'
395 | { return __x > __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1774 | operator>(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:395:20: note: 'const state' is not derived from 'const std::move_iterator<_IteratorL>'
395 | { return __x > __y; }
| ~~~~^~~~~
|
s347385479 | p00709 | C++ | #include<bits/stdc++.h>
using namespace std;
int p[10][10], s[10][10];
vector< vector< int > > st;
map< vector< int >, int > dp;
int W, H;
int dfs(int x, int y)
{
if(dp.count(st)) return (dp[st]);
if(y == H) return (0);
if(x == W) return (dfs(0, y + 1));
if(p[y][x] == 0) return (dfs(x + 1, y));
int ret = 1 << 30;
if(st[y][x] == 0) ret = min(ret, dfs(x + 1, y));
vector< pair< int, int > > beet;
for(int i = 0; i < s[y][x]; i++) {
for(int j = 0; j < s[y][x]; j++) {
if(st[y + i][x + j] == 1) {
beet.emplace_back(y + i, x + j);
st[y + i][x + j] = 0;
}
}
}
if(beet.size()) {
ret = min(ret, dfs(x + 1, y) + 1);
for(auto &p : beet) st[p.first][p.second] = 1;
}
return (dp[st] = ret);
}
int main()
{
while(cin >> W >> H, W) {
st.resize(H);
for(int i = 0; i < H; i++) {
st[i].resize(W);
for(int j = 0; j < W; j++) {
cin >> p[i][j];
st[i][j] = p[i][j];
}
}
for(int i = 0; i < H; i++) {
for(int j = 0; j < W; j++) {
for(int k = min(H - i, W - j); k >= 1; k--) {
bool flag = true;
for(int l = 0; l < k; l++) {
for(int m = 0; m < k; m++) flag &= p[i + l][j + m];
}
if(flag) {
s[i][j] = k;
break;
}
}
}
}
cout << dfs(0, 0) << endl;
}
} | a.cc: In function 'int dfs(int, int)':
a.cc:13:14: error: no matching function for call to 'std::map<std::vector<int>, int>::count(std::vector<std::vector<int> >&)'
13 | if(dp.count(st)) return (dp[st]);
| ~~~~~~~~^~~~
In file included from /usr/include/c++/14/map:63,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:1270:9: note: candidate: 'template<class _Kt> decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::count(const _Kt&) const [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >]'
1270 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
| ^~~~~
/usr/include/c++/14/bits/stl_map.h:1270:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((const std::map<std::vector<int>, int>*)this)->std::map<std::vector<int>, int>::_M_t.std::_Rb_tree<std::vector<int>, std::pair<const std::vector<int>, int>, std::_Select1st<std::pair<const std::vector<int>, int> >, std::less<std::vector<int> >, std::allocator<std::pair<const std::vector<int>, int> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::vector<int>, int>::count(const _Kt&) const [with _Kt = std::vector<std::vector<int> >]':
a.cc:13:14: required from here
13 | if(dp.count(st)) return (dp[st]);
| ~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_map.h:1270:65: error: no matching function for call to 'std::_Rb_tree<std::vector<int>, std::pair<const std::vector<int>, int>, std::_Select1st<std::pair<const std::vector<int>, int> >, std::less<std::vector<int> >, std::allocator<std::pair<const std::vector<int>, int> > >::_M_count_tr(const std::vector<std::vector<int> >&) const'
1270 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
| ~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/map:62:
/usr/include/c++/14/bits/stl_tree.h:1311:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_count_tr(const _Kt&) const [with _Req = _Kt; _Key = std::vector<int>; _Val = std::pair<const std::vector<int>, int>; _KeyOfValue = std::_Select1st<std::pair<const std::vector<int>, int> >; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >]'
1311 | _M_count_tr(const _Kt& __k) const
| ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1311:9: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/14/string:49,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using std::__has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = std::less<std::vector<int> >; _SfinaeType = std::vector<std::vector<int> >]':
/usr/include/c++/14/bits/stl_tree.h:1309:9: required by substitution of 'template<class _Kt> decltype (((const std::map<std::vector<int>, int>*)this)->std::map<std::vector<int>, int>::_M_t.std::_Rb_tree<std::vector<int>, std::pair<const std::vector<int>, int>, std::_Select1st<std::pair<const std::vector<int>, int> >, std::less<std::vector<int> >, std::allocator<std::pair<const std::vector<int>, int> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::vector<int>, int>::count(const _Kt&) const [with _Kt = std::vector<std::vector<int> >]'
1309 | typename _Req = __has_is_transparent_t<_Compare, _Kt>>
| ^~~~~~~~
a.cc:13:14: required from here
13 | if(dp.count(st)) return (dp[st]);
| ~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_function.h:1427:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::vector<int> >, std::vector<std::vector<int> >, void>'
1427 | using __has_is_transparent_t
| ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1264:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::size_type std::map<_Key, _Tp, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; size_type = long unsigned int; key_type = std::vector<int>]'
1264 | count(const key_type& __x) const
| ^~~~~
/usr/include/c++/14/bits/stl_map.h:1264:29: note: no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'const std::map<std::vector<int>, int>::key_type&' {aka 'const std::vector<int>&'}
1264 | count(const key_type& __x) const
| ~~~~~~~~~~~~~~~~^~~
a.cc:13:30: error: no match for 'operator[]' (operand types are 'std::map<std::vector<int>, int>' and 'std::vector<std::vector<int> >')
13 | if(dp.count(st)) return (dp[st]);
| ^
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; mapped_type = int; key_type = std::vector<int>]'
504 | operator[](const key_type& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'const std::map<std::vector<int>, int>::key_type&' {aka 'const std::vector<int>&'}
504 | operator[](const key_type& __k)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; mapped_type = int; key_type = std::vector<int>]'
524 | operator[](key_type&& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'std::map<std::vector<int>, int>::key_type&&' {aka 'std::vector<int>&&'}
524 | operator[](key_type&& __k)
| ~~~~~~~~~~~^~~
a.cc:32:13: error: no match for 'operator[]' (operand types are 'std::map<std::vector<int>, int>' and 'std::vector<std::vector<int> >')
32 | return (dp[st] = ret);
| ^
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; mapped_type = int; key_type = std::vector<int>]'
504 | operator[](const key_type& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'const std::map<std::vector<int>, int>::key_type&' {aka 'const std::vector<int>&'}
504 | operator[](const key_type& __k)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; mapped_type = int; key_type = std::vector<int>]'
524 | operator[](key_type&& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'std::map<std::vector<int>, int>::key_type&&' {aka 'std::vector<int>&&'}
524 | operator[](key_type&& __k)
| ~~~~~~~~~~~^~~
|
s037238514 | p00709 | C++ | #include<bits/stdc++.h>
using namespace std;
int p[10][10], s[10][10];
vector< vector< int > > st;
map< vector< int >, int > dp;
int W, H;
int dfs(int x, int y)
{
if(dp.count(st)) return (dp[st]);
if(y == H) return (0);
if(x == W) return (dfs(0, y + 1));
if(p[y][x] == 0) return (dfs(x + 1, y));
int ret = 1 << 30;
if(st[y][x] == 0) ret = min(ret, dfs(x + 1, y));
vector< pair< int, int > > beet;
for(int i = 0; i < s[y][x]; i++) {
for(int j = 0; j < s[y][x]; j++) {
if(st[y + i][x + j] == 1) {
beet.emplace_back(y + i, x + j);
st[y + i][x + j] = 0;
}
}
}
if(beet.size()) {
ret = min(ret, dfs(x + 1, y) + 1);
for(auto &p : beet) st[p.first][p.second] = 1;
}
return (dp[st] = ret);
}
int main()
{
while(cin >> W >> H, W) {
st.resize(H);
for(int i = 0; i < H; i++) {
st[i].resize(W);
for(int j = 0; j < W; j++) {
cin >> p[i][j];
st[i][j] = p[i][j];
}
}
for(int i = 0; i < H; i++) {
for(int j = 0; j < W; j++) {
for(int k = min(H - i, W - j); k >= 1; k--) {
bool flag = true;
for(int l = 0; l < k; l++) {
for(int m = 0; m < k; m++) flag &= p[i + l][j + m];
}
if(flag) {
s[i][j] = k;
break;
}
}
}
}
cout << dfs(0, 0) << endl;
}
} | a.cc: In function 'int dfs(int, int)':
a.cc:13:14: error: no matching function for call to 'std::map<std::vector<int>, int>::count(std::vector<std::vector<int> >&)'
13 | if(dp.count(st)) return (dp[st]);
| ~~~~~~~~^~~~
In file included from /usr/include/c++/14/map:63,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:1270:9: note: candidate: 'template<class _Kt> decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::count(const _Kt&) const [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >]'
1270 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
| ^~~~~
/usr/include/c++/14/bits/stl_map.h:1270:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((const std::map<std::vector<int>, int>*)this)->std::map<std::vector<int>, int>::_M_t.std::_Rb_tree<std::vector<int>, std::pair<const std::vector<int>, int>, std::_Select1st<std::pair<const std::vector<int>, int> >, std::less<std::vector<int> >, std::allocator<std::pair<const std::vector<int>, int> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::vector<int>, int>::count(const _Kt&) const [with _Kt = std::vector<std::vector<int> >]':
a.cc:13:14: required from here
13 | if(dp.count(st)) return (dp[st]);
| ~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_map.h:1270:65: error: no matching function for call to 'std::_Rb_tree<std::vector<int>, std::pair<const std::vector<int>, int>, std::_Select1st<std::pair<const std::vector<int>, int> >, std::less<std::vector<int> >, std::allocator<std::pair<const std::vector<int>, int> > >::_M_count_tr(const std::vector<std::vector<int> >&) const'
1270 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
| ~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/map:62:
/usr/include/c++/14/bits/stl_tree.h:1311:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_count_tr(const _Kt&) const [with _Req = _Kt; _Key = std::vector<int>; _Val = std::pair<const std::vector<int>, int>; _KeyOfValue = std::_Select1st<std::pair<const std::vector<int>, int> >; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >]'
1311 | _M_count_tr(const _Kt& __k) const
| ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1311:9: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/14/string:49,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using std::__has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = std::less<std::vector<int> >; _SfinaeType = std::vector<std::vector<int> >]':
/usr/include/c++/14/bits/stl_tree.h:1309:9: required by substitution of 'template<class _Kt> decltype (((const std::map<std::vector<int>, int>*)this)->std::map<std::vector<int>, int>::_M_t.std::_Rb_tree<std::vector<int>, std::pair<const std::vector<int>, int>, std::_Select1st<std::pair<const std::vector<int>, int> >, std::less<std::vector<int> >, std::allocator<std::pair<const std::vector<int>, int> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::vector<int>, int>::count(const _Kt&) const [with _Kt = std::vector<std::vector<int> >]'
1309 | typename _Req = __has_is_transparent_t<_Compare, _Kt>>
| ^~~~~~~~
a.cc:13:14: required from here
13 | if(dp.count(st)) return (dp[st]);
| ~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_function.h:1427:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::vector<int> >, std::vector<std::vector<int> >, void>'
1427 | using __has_is_transparent_t
| ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1264:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::size_type std::map<_Key, _Tp, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; size_type = long unsigned int; key_type = std::vector<int>]'
1264 | count(const key_type& __x) const
| ^~~~~
/usr/include/c++/14/bits/stl_map.h:1264:29: note: no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'const std::map<std::vector<int>, int>::key_type&' {aka 'const std::vector<int>&'}
1264 | count(const key_type& __x) const
| ~~~~~~~~~~~~~~~~^~~
a.cc:13:30: error: no match for 'operator[]' (operand types are 'std::map<std::vector<int>, int>' and 'std::vector<std::vector<int> >')
13 | if(dp.count(st)) return (dp[st]);
| ^
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; mapped_type = int; key_type = std::vector<int>]'
504 | operator[](const key_type& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'const std::map<std::vector<int>, int>::key_type&' {aka 'const std::vector<int>&'}
504 | operator[](const key_type& __k)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; mapped_type = int; key_type = std::vector<int>]'
524 | operator[](key_type&& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'std::map<std::vector<int>, int>::key_type&&' {aka 'std::vector<int>&&'}
524 | operator[](key_type&& __k)
| ~~~~~~~~~~~^~~
a.cc:32:13: error: no match for 'operator[]' (operand types are 'std::map<std::vector<int>, int>' and 'std::vector<std::vector<int> >')
32 | return (dp[st] = ret);
| ^
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; mapped_type = int; key_type = std::vector<int>]'
504 | operator[](const key_type& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'const std::map<std::vector<int>, int>::key_type&' {aka 'const std::vector<int>&'}
504 | operator[](const key_type& __k)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; mapped_type = int; key_type = std::vector<int>]'
524 | operator[](key_type&& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'std::vector<std::vector<int> >' to 'std::map<std::vector<int>, int>::key_type&&' {aka 'std::vector<int>&&'}
524 | operator[](key_type&& __k)
| ~~~~~~~~~~~^~~
|
s630348650 | p00709 | C++ | #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
struct Info{
int table[10][10],num;
};
int W,H,ans;
int first_table[10][10],max_size[10][10];
bool rangeCheck(int row,int col){
if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1)return true;
else{
return false;
}
}
void copyTable(Info& to,int from[10][10],int base_row){
for(int row = base_row; row < H; row++){
for(int col = 0; col < W; col++)to.table[row][col] = from[row][col];
}
}
void recursive(Info info,int base_row,int base_col){
if(info.num == ans)return;
if(base_row == H){ //??¨???????????????????????§?????£?????´???
ans = min(ans,info.num);
return;
}
//printf("ans:%d\n",ans);
Info next_info;
if(info.table[base_row][base_col] == -1){ //????????????????¶???????????????§????????´???
copyTable(next_info,info.table,base_row);
next_info.num = info.num;
//???????????????????????????????§?
if(base_col == W-1){
recursive(next_info,base_row+1,0);
}else{
recursive(next_info,base_row,base_col+1);
}
return;
}
//?°?????????¨???1???????????°??????????????????????????????????????????[[????????§??????????????????????????????????????]]
int new_num = 0;
for(int i = 0; i < max_size[base_row][base_col]; i++){
for(int k = 0; k < max_size[base_row][base_col]; k++){
if(info.table[base_row+i][base_col+k] == 0){
new_num++;
}
}
}
if(new_num == 0){ //??°?????????????????????????????????
copyTable(next_info,info.table,base_row);
next_info.num = info.num;
//???????????????????????????????§?
if(base_col == W-1){
recursive(next_info,base_row+1,0);
}else{
recursive(next_info,base_row,base_col+1);
}
}else{
//????????????(?????????????????¢???????????????????????´?????????):???dfs??§??°????°????????????????????????±???????????????
if(info.table[base_row][base_col] != 0){
Info next_not;
copyTable(next_not,info.table,base_row);
next_not.num = info.num;
int must_add = 0;
bool FLG = false;
//?°?????????¨??????????????§??????????????????????????°????¨????
for(int row = base_row; row < H; row++){
for(int col = 0; col < W; col++){
if(next_not.table[row][col] == 0 && first_table[row][col] == 1){
must_add++;
}else if(next_not.table[row][col] == 0 && first_table[row][col] > 1){
FLG = true;
}
}
}
if(FLG)must_add++;
if(next_not.num+must_add < ans){
if(base_col == W-1){
recursive(next_not,base_row+1,0);
}else{
recursive(next_not,base_row,base_col+1);
}
}
}
copyTable(next_info,info.table);
next_info.num = info.num+1;
//????????????????????????
for(int i = 0; i < max_size[base_row][base_col]; i++){
for(int k = 0; k < max_size[base_row][base_col]; k++){
next_info.table[base_row+i][base_col+k]++;
}
}
int must_add = 0;
bool FLG = false;
//?°?????????¨??????????????§??????????????????????????°????¨????
for(int row = base_row; row < H; row++){
for(int col = 0; col < W; col++){
if(next_info.table[row][col] == 0 && first_table[row][col] == 1){
must_add++;
}else if(next_info.table[row][col] == 0 && first_table[row][col] > 1){
FLG = true;
}
}
}
if(FLG)must_add++;
if(next_info.num+must_add < ans){
if(base_col == W-1){
recursive(next_info,base_row+1,0);
}else{
recursive(next_info,base_row,base_col+1);
}
}
}
}
void func(){
for(int row = 0; row < H; row++){
for(int col = 0; col < W; col++){
scanf("%d",&first_table[row][col]);
first_table[row][col] -= 1;
}
}
bool FLG;
int size;
//?????????????????????????????§????????????????±???????
for(int row = 0; row < H; row++){
for(int col = 0; col < W; col++){
if(first_table[row][col] == -1){
max_size[row][col] = 0;
}else{
size = 1;
FLG = true;
while(true){
for(int i = 0; i < size; i++){
for(int k = 0; k < size; k++){
if(rangeCheck(row+i,col+k) == false || first_table[row+i][col+k] == -1){
FLG = false;
break;
}
}
if(!FLG)break;
}
if(!FLG){
size -= 1;
break;
}
size++;
}
max_size[row][col] = size;
//1??????????????????????????????????????????????????????????????????????????§?????????????????§??????????????´?????????????????????????????????
for(int i = 0; i < size; i++){
for(int k = 0; k < size; k++){
first_table[row+i][col+k]++;
}
}
}
}
}
Info start;
start.num = 0;
for(int row = 0; row < H; row++){
for(int col = 0; col < W; col++){
if(first_table[row][col] == -1){
start.table[row][col] = -1;
}else{
start.table[row][col] = 0;
}
}
}
ans = BIG_NUM;
recursive(start,0,0);
printf("%d\n",ans);
}
int main(){
while(true){
scanf("%d %d",&W,&H);
if(W == 0 && H == 0)break;
func();
}
return 0;
} | a.cc: In function 'void recursive(Info, int, int)':
a.cc:124:26: error: too few arguments to function 'void copyTable(Info&, int (*)[10], int)'
124 | copyTable(next_info,info.table);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:36:6: note: declared here
36 | void copyTable(Info& to,int from[10][10],int base_row){
| ^~~~~~~~~
|
s362669438 | p00709 | C++ | struct Info{
short table[10][10],num;
};
short W,H,ans,POW[11];
short first_table[10][10],max_size[10][10];
bool rangeCheck(short row,short col){
if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1)return true;
else{
return false;
}
}
inline void copyTable(Info& to,short from[10][10],short base_row){
for(short row = base_row; row < H; row++){
for(short col = 0; col < W; col++)to.table[row][col] = from[row][col];
}
}
void recursive(Info info,short base_row,short base_col,short pre_must_add){
if(info.num == ans)return;
if(base_row == H){ //??¨???????????????????????§?????£?????´???
//ans = min(ans,info.num);
ans = info.num;
return;
}
if(info.table[base_row][base_col] == -1){ //????????????????¶???????????????§????????´???
//???????????????????????????????§?
if(base_col == W-1){
recursive(info,base_row+1,0,pre_must_add);
}else{
recursive(info,base_row,base_col+1,pre_must_add);
}
return;
}
//?°?????????¨???1???????????°??????????????????????????????????????????[[????????§??????????????????????????????????????]]
short new_num = 0;
for(short i = 0; i < max_size[base_row][base_col]; i++){
for(short k = 0; k < max_size[base_row][base_col]; k++){
if(info.table[base_row+i][base_col+k] == 0){
new_num++;
break;
}
}
if(new_num != 0)break;
}
if(new_num == 0){ //??°?????????????????????????????????
if(base_col == W-1){
recursive(info,base_row+1,0,pre_must_add);
}else{
recursive(info,base_row,base_col+1,pre_must_add);
}
}else{
//????????????(?????????????????¢???????????????????????´?????????):???dfs??§??°????°????????????????????????±???????????????
if(info.table[base_row][base_col] != 0){
if(base_col == W-1){
recursive(info,base_row+1,0,pre_must_add);
}else{
recursive(info,base_row,base_col+1,pre_must_add);
}
}
//????????????????????????
for(short i = 0; i < max_size[base_row][base_col]; i++){
for(short k = 0; k < max_size[base_row][base_col]; k++){
info.table[base_row+i][base_col+k]++;
}
}
short must_add = 0;
bool FLG = false;
//?°?????????¨??????????????§??????????????????????????°????¨????
for(short row = base_row; row < H; row++){
for(short col = 0; col < W; col++){
if(info.table[row][col] == 0 && first_table[row][col] == 1){
must_add++;
}else if(info.table[row][col] == 0 && first_table[row][col] > 1){
FLG = true;
}
}
}
if(FLG)must_add++;
info.num++;
if(info.num+must_add < ans){
if(base_col == W-1){
recursive(info,base_row+1,0,must_add);
}else{
recursive(info,base_row,base_col+1,must_add);
}
}
}
}
void func(){
for(short row = 0; row < H; row++){
for(short col = 0; col < W; col++){
scanf("%d",&first_table[row][col]);
first_table[row][col] -= 1;
}
}
bool FLG;
short size;
//?????????????????????????????§????????????????±???????
for(short row = 0; row < H; row++){
for(short col = 0; col < W; col++){
if(first_table[row][col] == -1){
max_size[row][col] = 0;
}else{
size = 1;
FLG = true;
while(true){
for(short i = 0; i < size; i++){
for(short k = 0; k < size; k++){
if(rangeCheck(row+i,col+k) == false || first_table[row+i][col+k] == -1){
FLG = false;
break;
}
}
if(!FLG)break;
}
if(!FLG){
size -= 1;
break;
}
size++;
}
max_size[row][col] = size;
//1??????????????????????????????????????????????????????????????????????????§?????????????????§??????????????´?????????????????????????????????
for(short calc_size = 1; calc_size <= size; calc_size++){
for(short i = 0; i < calc_size; i++){
for(short k = 0; k < size; k++){
first_table[row+i][col+k]++;
}
}
}
}
}
}
Info start;
start.num = 0;
short pre_must_add = 0;
FLG = false;
for(short row = 0; row < H; row++){
for(short col = 0; col < W; col++){
if(first_table[row][col] == -1){
start.table[row][col] = -1;
}else{
if(first_table[row][col] == 1){
pre_must_add++;
}else{
FLG = true;
}
start.table[row][col] = 0;
}
}
}
if(FLG)pre_must_add++;
ans = BIG_NUM;
recursive(start,0,0,pre_must_add);
prshortf("%d\n",ans);
}
short main(){
for(short i = 0; i < 11; i++)POW[i] = pow(2,i);
while(true){
scanf("%d %d",&W,&H);
if(W == 0 && H == 0)break;
func();
}
return 0;
} | a.cc: In function 'void func()':
a.cc:114:25: error: 'scanf' was not declared in this scope
114 | scanf("%d",&first_table[row][col]);
| ^~~~~
a.cc:184:15: error: 'BIG_NUM' was not declared in this scope
184 | ans = BIG_NUM;
| ^~~~~~~
a.cc:188:9: error: 'prshortf' was not declared in this scope; did you mean 'short'?
188 | prshortf("%d\n",ans);
| ^~~~~~~~
| short
At global scope:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:193:47: error: 'pow' was not declared in this scope
193 | for(short i = 0; i < 11; i++)POW[i] = pow(2,i);
| ^~~
a.cc:196:17: error: 'scanf' was not declared in this scope
196 | scanf("%d %d",&W,&H);
| ^~~~~
|
s366363352 | p00709 | C++ | #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <functional>
#include <cassert>
typedef long long ll;
using namespace std;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010
int h, w;
int t[SIZE][SIZE], t2[SIZE][SIZE];
int max_size[11][11] = {};
int covered[11][11] = {};
set<pair<pair<ll,ll>,int> > visited;
int ans;
void dfs(int y, int x, int counter = 0, ll hash = 0, ll hash2 = 0){
//debug(ans);
int diff[11][11] = {};
if(ans <= counter) return;
if(visited.find({{hash,hash2},y*w+x}) != visited.end()) return;
if(y == h){
ans = min(ans, counter);
return;
}
if(max_size[y][x] == 0 || covered[y][x])
dfs(y + (x == w-1), (x + 1)%w, counter, hash);
if(max_size[y][x] != 0){
ll newhash = hash, newhash2 = hash2;
int diffcounter = 0;
for(int i=0;i<max_size[y][x];i++)
for(int j=0;j<max_size[y][x];j++)
if(covered[y+i][x+j] == 0){
diff[y+i][x+j] = covered[y+i][x+j] = 1;
newhash ^= t[y+i][x+j];
newhash2 ^= t2[y+i][x+j];
diffcounter++;
}
if(diffcounter)
dfs(y + (x == w-1), (x + 1)%w, counter+1, newhash);
for(int i=0;i<max_size[y][x];i++)
for(int j=0;j<max_size[y][x];j++)
if(diff[y+i][x+j] == 1){
covered[y+i][x+j] = 0;
}
}
visited.insert({{hash,hash2},y*w+x});
}
bool solve(){
int sp[11][11] = {};
int p[11][11];
debug(clock());
scanf("%d%d", &w, &h);
if(h == 0) return false;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
scanf("%d", p[i]+j);
sp[i][j] = p[i][j];
}
}
for(int i=h;i>0;i--)
for(int j=0;j<=w;j++)
sp[i-1][j] += sp[i][j];
for(int i=0;i<=h;i++)
for(int j=w;j>0;j--)
sp[i][j-1] += sp[i][j];
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
int p = min(h-i, w-j);
max_size[i][j] = 0;
for(int k=1;k<=p;k++){
if(sp[i][j] + sp[i+k][j+k] - sp[i+k][j] - sp[i][j+k] == k*k) max_size[i][j] = k;
//debug(sp[i][j] + sp[i+k][j+k] - sp[i+k][j] - sp[i][j+k]);
}
//debug(max_size[i][j]);
}
}
debug(clock());
visited = set<pair<pair<ll,ll>,int> >();
ans = INF;
dfs(0,0);
printf("%d\n", ans);
return true;
}
int main(){
std::random_device rd;
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
t[i][j] = ((ll)rd() << 32) + rd();
t2[i][j] = ((ll)rd() << 32) + rd();
}
}
debug(clock());
while(solve());
return 0;
}
| /tmp/ccSphcN5.o: in function `dfs(int, int, int, long long, long long)':
a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccSphcN5.o
a.cc:(.text+0x62): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccSphcN5.o
a.cc:(.text+0xd3): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/ccSphcN5.o
a.cc:(.text+0x122): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccSphcN5.o
a.cc:(.text+0x132): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccSphcN5.o
a.cc:(.text+0x16b): relocation truncated to fit: R_X86_64_PC32 against symbol `max_size' defined in .bss section in /tmp/ccSphcN5.o
a.cc:(.text+0x1a6): relocation truncated to fit: R_X86_64_PC32 against symbol `covered' defined in .bss section in /tmp/ccSphcN5.o
a.cc:(.text+0x230): relocation truncated to fit: R_X86_64_PC32 against symbol `max_size' defined in .bss section in /tmp/ccSphcN5.o
a.cc:(.text+0x2af): relocation truncated to fit: R_X86_64_PC32 against symbol `covered' defined in .bss section in /tmp/ccSphcN5.o
a.cc:(.text+0x2fa): relocation truncated to fit: R_X86_64_PC32 against symbol `covered' defined in .bss section in /tmp/ccSphcN5.o
a.cc:(.text+0x342): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s715508089 | p00709 | C++ | #include<iostream>
#include<vector>
#include<queue>
#include<set>
using namespace std;
#define FOR(i, b, e) for ( int i = b; i <= e; i++ )
#define rep(i, n) for ( int i = 0; i < (int)n; i++)
#define MAX 10
int cnt, H, W, limit, maxw;
int T[MAX][MAX], K[MAX][MAX], C[MAX][MAX], X[MAX][MAX];
vector<pair<int, int> > v;
int MD(){
int sum = 0;
rep(i, H) rep(j, W){
if ( C[i][j] && X[i][j] == 0 ) sum++;
}
return sum/(maxw*maxw);
}
bool dfs(int pos, int cost){
bool solved = true;
rep(i, H) rep(j, W) if ( C[i][j] && X[i][j] == 0 ) solved = false;
if ( solved ) return true;
if ( pos >= v.size() ) return false;
if ( cost + MD() >= limit ) return false;
for ( int i = v[pos].first+1; i < H; i++ ) rep(j, W){
if ( C[i][j] && X[i][j] == 0 ) return false;
}
int tmp[MAX][MAX];
if ( dfs(pos+1, cost) ) return true;
rep(i, H) rep(j, W) tmp[i][j] = X[i][j];
int pi = v[pos].first;
int pj = v[pos].second;
int w = T[pi][pj];
FOR(y, pi-w+1, pi) FOR(x, pj-w+1, pj) X[y][x]++;
if ( dfs(pos+1, cost+1) ) return true;
rep(i, H) rep(j, W) X[i][j] = tmp[i][j];
return false;
}
int idp(){
if ( maxw == 0 ) return 0;
for ( limit = MD(); limit < 100; limit++){
if ( dfs(0, 0) ) return limit;
}
}
void compute(){
bool U[MAX][MAX], V[MAX][MAX];
rep(i, H) rep(j, W) U[i][j] = true;
rep(i, H) rep(j, W) V[i][j] = false;
rep(i, H) rep(j, W) T[i][j] = K[i][j] = X[i][j] = 0;
rep(i, H) T[i][0] = (C[i][0])?1:0;
rep(j, W) T[0][j] = (C[0][j])?1:0;
FOR(i, 1, H-1) FOR(j, 1, W-1){
if ( C[i][j] ){
T[i][j] = min(T[i-1][j-1], min(T[i-1][j], T[i][j-1])) +1;
} else T[i][j] = 0;
}
rep(i, H) rep(j, W){
int w = T[i][j];
FOR(pi, i-(w-1), i) FOR(pj, j-(w-1), j) {
if ( i == pi && j == pj ) continue;
int l = max(i-pi, j-pj);
if ( w-l >= T[pi][pj] ) U[pi][pj] = false;
}
}
rep(i, H) rep(j, W){
if ( U[i][j] && T[i][j] ){
FOR(y, i-T[i][j]+1, i) FOR(x, j-T[i][j]+1, j) K[y][x]++;
}
}
v.clear();
rep(i, H) rep(j, W){
if ( U[i][j] && T[i][j] ){
bool f = false;
FOR(y, i-T[i][j]+1, i) FOR(x, j-T[i][j]+1, j){
if ( K[y][x] == 1 ) f = true;
}
if ( f ){
FOR(y, i-T[i][j]+1, i) FOR(x, j-T[i][j]+1, j) X[y][x]++;
cnt++;
T[i][j] = 0;
}
}
}
maxw = 0;
rep(i, H) rep(j, W){
if ( T[i][j] > 0 && U[i][j]){
maxw = max(maxw, T[i][j]);
v.push_back(make_pair(i, j));
}
}
reverse(v.begin(), v.end());
}
main(){
while( cin >> W >> H ){
if ( W == 0 && H == 0 ) break;
rep(i, H) rep(j, W) cin >> C[i][j];
cnt = 0;
compute();
cout << idp() + cnt << endl;
}
} | a.cc: In function 'void compute()':
a.cc:109:3: error: 'reverse' was not declared in this scope
109 | reverse(v.begin(), v.end());
| ^~~~~~~
a.cc: At global scope:
a.cc:112:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
112 | main(){
| ^~~~
a.cc: In function 'int idp()':
a.cc:54:1: warning: control reaches end of non-void function [-Wreturn-type]
54 | }
| ^
|
s323752682 | p00709 | C++ | #include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<functional>
#define N 11
#define INF (1<<27)
using namespace std;
const int di[] = {-1,1,1,-1};
const int dj[] = {1,1,-1,-1};
int maxSizes[N][N];
int oneCount;
set<int,greater<int> > squareSizes;
int bestAns = INF;
int minHW;
int getHeuristic(int H, int W, int M[N][N])
{
int maxSize = *(squareSizes.begin());
maxSize *= maxSize;
return (oneCount / maxSize) + (oneCount%maxSize>0);
}
void calc(int H, int W, int M[N][N]){
for(int i = 0; i < H; ++i){
for(int j = 0; j < W; ++j){
if(M[i][j] == 1) oneCount++;
int size = 0;
for(size = 1; size <= minHW; ++size){
for(int m = i; m<size+i; m++){
for(int n = j; n<size+j; n++){
if( m<0||n<0||m>=H||n>=W||M[m][n]==0 ){
--size;
goto next;
}
}
}
if(i+size>=H||j+size>=W)break;
next:;
maxSizes[i][j] = size;
squareSizes.insert( size );
}
}
}
return ;
}
void solve(int H, int W, int pos, int M[N][N], int depth){
/*
printf("now i = %d, now j = %d, h = %d\n", pos/W, pos%W,getHeuristic(H,W,M));
for(int k = 0; k < H; ++k){
for(int l = 0; l < W; ++l){
if(l>0)putchar(' ');
printf("%d", M[k][l]);
}
putchar('\n');
}
putchar('\n');
*/
// completed.
bool bComp=true;
for(int i = 0; i < H; ++i){
for(int j = 0; j < W; ++j){
if(M[i][j]==1){
bComp=false;
goto end;
}
}
}
end:;
if(bComp){
bestAns = min(bestAns, depth);
return ;
}
// back
if(depth+getHeuristic(H,W,M)>=bestAns){
return ;
}
// embed carpet
for(int p = pos; p < H*W; ++p){
int i = p / W;
int j = p % W;
if( M[i][j] == 0 ){
continue;
}else if( M[i][j] >= 1 ){
int size = maxSizes[i][j];
bool valid=false;
for(int m = i; m<size+i; m++){
for(int n = j; n<size+j; n++){
if(M[m][n]==1){
valid=true;
M[m][n]=depth;
}
}
}
if( valid ){
squareSize.erase( squareSize.find( size ) );
solve(H,W,p+1,M,depth+1);
squareSize.insert( size );
}
for(int m = i; m<size+i; m++){
for(int n = j; n<size+j; n++){
if(M[m][n]==depth){
M[m][n]=1;
}
}
}
if( M[i][j] > 1 )
solve(H,W,p+1,M,depth+1);
return ;
}
}
}
int main()
{
while(true){
int cnt=0;
int W,H;
scanf("%d%d", &W, &H);
if(W==H&&H==0)break;
int M[N][N];
for(int i = 0; i < H; ++i){
for(int j = 0; j < W; ++j){
scanf("%d", &M[i][j]);
}
}
bestAns=INF;
minHW = min(H,W);
oneCount = 0;
squareSizes.clear();
calc(H,W,M);
solve(H,W,0,M,2);
printf("%d\n", bestAns-2);
}
return 0;
} | a.cc: In function 'void solve(int, int, int, int (*)[11], int)':
a.cc:104:9: error: 'squareSize' was not declared in this scope; did you mean 'squareSizes'?
104 | squareSize.erase( squareSize.find( size ) );
| ^~~~~~~~~~
| squareSizes
|
s591754646 | p00709 | C++ | #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;
typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef vector<int> VI;
typedef vector<VI> VVI;
template<class T> T gcd( T a, T b ) {
return !b ? a : gcd( b, a % b );
}
template<class T> T lcm( T a, T b ) {
return a / gcd( a, b ) * b;
}
template<class T> string print_v( vector<T> v ) {
OSS oss;
for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end();
++it_i ) {
oss << *it_i << ", ";
}
return oss.str();
}
const int ks = 1;
const int kr[ks] = { -1, -1, 1, -1 };
const int kc[ks] = { -1, -1, -1, -1 };
int w, h;
void print( VVI T ) {
for ( int i = 0; i < h; ++ i ) {
for ( int j = 0; j < w; ++ j ) {
cout << T[i][j] << ",";
}
cout << endl;
}
cout << endl;
}
VVI flip( VVI T, int r, int c ) {
VVI NT = T;
int cand = 0;
int cl = 0;
int ck;
for ( int L = min( w, h ); L > 0; -- L ) {
for ( int k = 0; k < ks; ++ k ) {
int cnt = 0;
for ( int i = 0; i < L; ++ i ) {
for ( int j = 0; j < L; ++ j ) {
int nr = r + i * kr[k];
int nc = c + j * kc[k];
if ( nr < 0 || nr >= h ) goto IGNORE;
if ( nc < 0 || nc >= w ) goto IGNORE;
if ( T[nr][nc] == 0 ) goto IGNORE;
if ( T[nr][nc] == 1 ) cnt ++;
}
}
if ( cnt > cand ) {
cand = cnt;
ck = k;
cl = L;
}
IGNORE:;
}
}
for ( int i = 0; i < cl; ++ i ) {
for ( int j = 0; j < cl; ++ j ) {
int nr = r + i * kr[ck];
int nc = c + j * kc[ck];
NT[nr][nc] = 2;
}
}
return NT;
}
int main() {
while ( cin >> w >> h && w ) {
VVI T( h, VI( w ) );
for ( int i = 0; i < h; ++ i ) {
for ( int j = 0; j < w; ++ j ) {
cin >> T[i][j];
}
}
int res = 0;
for ( int i = h - 1; i >= 0; -- i ) {
for ( int j = w - 1; j >= 0; -- j ) {
if ( T[i][j] != 1 ) continue;
T = flip( T, i, j );
// cout << i << ", " << j << ": " << ret.first << endl;
res ++;
// cout << "before: " << endl;
// print( T );
// cout << "after: " << endl;
// print( ret.second );
// cout << endl;
}
}
cout << res << endl;
}
return 0;
} | a.cc:39:36: error: too many initializers for 'const int [1]'
39 | const int kr[ks] = { -1, -1, 1, -1 };
| ^
a.cc:40:37: error: too many initializers for 'const int [1]'
40 | const int kc[ks] = { -1, -1, -1, -1 };
| ^
|
s003505653 | p00710 | Java | import java.util.Scanner;
public static void main(String[] args)
{
Scanner stdIn = new Scanner(System.in);
int[] x = new int[50];
int[] y = new int[50];
while(true)
{
int n = stdIn.nextInt();
int r = stdIn.nextInt();
if(n==0 && r==0)
{
break;
}
for(int i=0;i<n;i++)
{
x[i] = n-i;
}
for(int i=0;i<r;i++)
{
int s = stdIn.nextInt();
int t = stdIn.nextInt();
if(s+t<=n+1)
{
for(int j=0;j<t;j++)
{
y[j] = x[s+j-1];
}
for(int j=0;j<s;j++)
{
y[t+j] = x[j];
}
for(int j=0;j<s+t;j++)
{
x[j] = y[j];
}
}
}
System.out.println(x[0]);
}
}
} | Main.java:3: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args)
^
(use --enable-preview to enable unnamed classes)
Main.java:54: error: class, interface, enum, or record expected
}
^
2 errors
|
s313932689 | p00710 | Java | import java.util.Scanner;
public class Icpc{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
for(int i=0;i>-1;i++){
int num=sc.nextInt();
if(num==0){
break;
}else{
int ave=0;
int max=0;
int min=1000;
int sum=0;
int[] score =new int[num];
//Input scores
for(int j=0;j<num;j++){
score[j]=sc.nextInt();
if(j==0){
max=score[0];
min=score[0];
}
sum+=score[j];
if(score[j]>max){
max=score[j];
}else if(score[j]<min){
min=score[j];
}
ave=(sum-max-min)/(num-2);
}
System.out.println(ave);
}
}
}
} | Main.java:2: error: class Icpc is public, should be declared in a file named Icpc.java
public class Icpc{
^
1 error
|
s903844921 | p00710 | Java | import java.util.Scanner;
public class Main{
public static void main(String[] args){
int n,r,i,p,c;
String hana,tempa,tampb;
Scanner sc = new Scanner(System.in);
hana=null;
tempa=null;
tempb=null;
while(true){
n=sc.nextInt();
r=sc.nextInt();
if(n==0&&r==0){
break;
}
for(i=0;i<n;i++){
hana.charAt(i)='1'+i;
}
for(i=0;i<r;i++){
p=sc.nextInt();
c=sc.nextInt();
tempa=hana.substring(0,p-1);
tempb=hana.substring(p-1+c,s.length());
hana=hana.substring(p-1,p-1+c);
hana=hana+tempa+tempb;
}
System.out.printf("%c\n",hana.charAt(0));
hana=null;
}
}
} | Main.java:16: error: cannot find symbol
tempb=null;
^
symbol: variable tempb
location: class Main
Main.java:29: error: unexpected type
hana.charAt(i)='1'+i;
^
required: variable
found: value
Main.java:37: error: cannot find symbol
tempb=hana.substring(p-1+c,s.length());
^
symbol: variable tempb
location: class Main
Main.java:37: error: cannot find symbol
tempb=hana.substring(p-1+c,s.length());
^
symbol: variable s
location: class Main
Main.java:41: error: cannot find symbol
hana=hana+tempa+tempb;
^
symbol: variable tempb
location: class Main
5 errors
|
s202186526 | p00710 | Java | import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigDecimal;
import java.math.BigInteger;
public class Main{
static PrintWriter out;
static InputReader ir;
static final int INF=Integer.MAX_VALUE;
static final long LINF=Long.MAX_VALUE;
static void solve(){
while(true){
int n=ir.nextInt();
int r=ir.nextInt();
if((n|r)==0) return;
int ord=new int[n];
for(int i=0;i<n;i++) ord[i]=i;
while(r-->0){
int p=ir.nextInt();
int c=ir.nextInt();
int[] rem=new int[p-1];
for(int i=0;i<p-1;i++) rem[i]=ord[i];
for(int i=0;i<c;i++) ord[i]=ord[p+i-1];
for(int i=c;i<c+p-1;i++) ord[i]=rem[i-c];
}
out.println(ord[0]+1);
}
}
public static void main(String[] args) throws Exception{
ir=new InputReader(System.in);
out=new PrintWriter(System.out);
solve();
out.flush();
}
static class InputReader {
private InputStream in;
private byte[] buffer=new byte[1024];
private int curbuf;
private int lenbuf;
public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
public boolean hasNextByte() {
if(curbuf>=lenbuf){
curbuf= 0;
try{
lenbuf=in.read(buffer);
}catch(IOException e) {
throw new InputMismatchException();
}
if(lenbuf<=0) return false;
}
return true;
}
private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
public boolean hasNext(){skip(); return hasNextByte();}
public String next(){
if(!hasNext()) throw new NoSuchElementException();
StringBuilder sb=new StringBuilder();
int b=readByte();
while(!isSpaceChar(b)){
sb.appendCodePoint(b);
b=readByte();
}
return sb.toString();
}
public int nextInt() {
if(!hasNext()) throw new NoSuchElementException();
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
int res=0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public long nextLong() {
if(!hasNext()) throw new NoSuchElementException();
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
long res = 0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public double nextDouble(){return Double.parseDouble(next());}
public BigInteger nextBigInteger(){return new BigInteger(next());}
public BigDecimal nextBigDecimal(){return new BigDecimal(next());}
public int[] nextIntArray(int n){
int[] a=new int[n];
for(int i=0;i<n;i++) a[i]=nextInt();
return a;
}
public long[] nextLongArray(int n){
long[] a=new long[n];
for(int i=0;i<n;i++) a[i]=nextLong();
return a;
}
public char[][] nextCharMap(int n,int m){
char[][] map=new char[n][m];
for(int i=0;i<n;i++) map[i]=next().toCharArray();
return map;
}
}
} | Main.java:24: error: incompatible types: int[] cannot be converted to int
int ord=new int[n];
^
Main.java:25: error: array required, but int found
for(int i=0;i<n;i++) ord[i]=i;
^
Main.java:30: error: array required, but int found
for(int i=0;i<p-1;i++) rem[i]=ord[i];
^
Main.java:31: error: array required, but int found
for(int i=0;i<c;i++) ord[i]=ord[p+i-1];
^
Main.java:31: error: array required, but int found
for(int i=0;i<c;i++) ord[i]=ord[p+i-1];
^
Main.java:32: error: array required, but int found
for(int i=c;i<c+p-1;i++) ord[i]=rem[i-c];
^
Main.java:34: error: array required, but int found
out.println(ord[0]+1);
^
7 errors
|
s967980910 | p00710 | Java | import java.util.*;
public class prob1129 {
public static void main(String[] args) {
// TODO ?????????????????????????????????????????????
Scanner in = new Scanner(System.in);
while(true){
int n = in.nextInt();
int r = in.nextInt();
if(n*r==0){
break;
}
Vector<Integer> card = new Vector<Integer>();
for (int i = 1; i <= n; i++) {
card.add(i);
}
for (int i = 0; i < r; i++) {
int p = in.nextInt();
int c = in.nextInt();
int pp = n-p-c+1;
for (int j = pp; c>0; c--) {
card.add(card.get(pp));
card.remove(j);
}
}
System.out.println(card.elementAt(n-1));
}
}
} | Main.java:3: error: class prob1129 is public, should be declared in a file named prob1129.java
public class prob1129 {
^
1 error
|
s372137475 | p00710 | Java | import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class MAIN {
static Scanner br = new Scanner(System.in);
static List<Integer> tmp = new ArrayList<Integer>();
public static void main(String[] args) throws IOException {
int yamahuda[];
while (true) {
// ?±±???????????°n
int n = br.nextInt();
yamahuda = new int[n];
// ??????????????°r
int r = br.nextInt();
// 0 0?????´???break;
if (n == 0 && r == 0) {
break;
}
// ?±±????????????n????????????
for (int i = 0; i < n; i++) {
yamahuda[i] = n - i;
}
// ?±±???????????£?????????
for (int i = 0; i < r; i++) {
shuffle(yamahuda);
}
System.out.println(yamahuda[0]);
}
}
public static int[] shuffle(int[] yamahuda) throws IOException {
// p??¨c?????\???
int p = br.nextInt();
int c = br.nextInt();
tmp.clear();
if (p - 1 < c) {
// ?????????????±±???????????????????????????tmp???????´?
for (int i = 0; i < c; i++) {
tmp.add(yamahuda[p - 1 + i]);
}
for (int i = 0; i < p - 1; i++) {
yamahuda[c + i] = yamahuda[i];
}
for (int i = 0; i < c; i++) {
yamahuda[i] = tmp.get(i);
}
} else {
// ???????????????
for (int i = 0; i < p - 1; i++) {
tmp.add(yamahuda[i]);
}
for (int i = 0; i < c; i++) {
yamahuda[i] = yamahuda[p - 1 + i];
}
for (int i = 0; i < p - 1; i++) {
yamahuda[c + i] = tmp.get(i);
}
}
return yamahuda;
}
} | Main.java:6: error: class MAIN is public, should be declared in a file named MAIN.java
public class MAIN {
^
1 error
|
s164857473 | p00710 | Java | import java.util.ArrayList;
import java.util.Scanner;
public class test {
public static void main(String[] args) {
solve();
}
private static void solve() {
// TODO ?????????????????????????????????????????????
Scanner scn = new Scanner(System.in);
ArrayList<Integer> deck = new ArrayList<Integer>();
ArrayList<Integer> deckout = new ArrayList<Integer>();
while(true){
int n = scn.nextInt();
int r = scn.nextInt();
if(n==0&&r==0) break;
for(int k=0;k<n;k++){
deck.add(n-k);
}
for(int k=0;k<r;k++){
int p = scn.nextInt();
int c = scn.nextInt();
for(int i=0;i<c;i++){
deck.add(0,deck.remove(p-2+c));
}
}
deckout.add(deck.get(0));
deck.clear();
}
for(Integer i:deckout){
System.out.println(i);
}
scn.close();
}
} | Main.java:4: error: class test is public, should be declared in a file named test.java
public class test {
^
1 error
|
s824580860 | p00710 | Java | import java.util.Scanner;
class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
while(true) {
int n = sc.nextInt();
int r = sc.nextInt();
int cards[] = new int[n];
if(n == 0 && r == 0) {
break;
}
for(int i = 0; i < n; i++) {
cards[i] = n - i;
}
for(int i = 0; i < r; i++) {
int p = sc.nextInt();
int c = sc.nextInt();
int temp[] = new int[c];
for(int j = 0; j < c; j++) {
temp[j] = cards[p - 1 + j];
}
for(int j = p - 2; j >= 0; j--) {
cards[c + j] = cards[j];
}
for(int j = 0; j < c; j++) {
cards[j] = temp[j];
}
}
System.out.crintln(cards[0]);
}
}
} | Main.java:35: error: cannot find symbol
System.out.crintln(cards[0]);
^
symbol: method crintln(int)
location: variable out of type PrintStream
1 error
|
s860876035 | p00710 | Java | import java.util.Scanner;
class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
while(true) {
int n = sc.nextInt();
int r = sc.nextInt();
int cards[] = new int[n];
if(n == 0 && r == 0) {
break;
}
for(int i = 0; i < n; i++) {
cards[i] = n - i;
}
for(int i = 0; i < r; i++) {
int p = sc.nextInt();
int c = sc.nextInt();
int temp[] = new int[c];
for(int j = 0; j < c; j++) {
temp[j] = cards[p - 1 + j];
}
for(int j = p - 2; j >= 0; j--) {
cards[c + j] = cards[j];
}
for(int j = 0; j < c; j++) {
cards[j] = temp[j];
}
}
System.out.crintln(cards[0]);
}
}
} | Main.java:35: error: cannot find symbol
System.out.crintln(cards[0]);
^
symbol: method crintln(int)
location: variable out of type PrintStream
1 error
|
s707055166 | p00710 | Java | 4
4 | Main.java:1: error: class, interface, enum, or record expected
4
^
1 error
|
s044154963 | p00710 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int n = sc.nextInt();
int r = sc.nextInt();
if (n==0&&r==0) {
break;
}
int[] a=new int[n];
for(int i=0;i<n;i++){
a[i]=i+1;
}
for(int j=0;j<r;j++){
int p=sc.nextInt();
int c=sc.nextInt();
int[] buffer=new int[n];
for(int i=0;i<c;i++){
buffer[i]=a[n-p-i];
}
for(int i=1;i<p;i++){
a[n-p-c+i]=a[n-p+i];
}
for(int i=0;i<c;i++){
a[n-i-1]=buffer[i];
}
}
System.out.println(a[n-1]);
}
} | Main.java:32: error: reached end of file while parsing
}
^
1 error
|
s116484206 | p00710 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int n = sc.nextInt();
int r = sc.nextInt();
if (n==0&&r==0) {
break;
}
int[] a=new int[n];
for(int i=0;i<n;i++){
a[i]=i+1;
}
for(int j=0;j<r;j++){
int p=sc.nextInt();
int c=sc.nextInt();
int[] buffer=new int[n];
for(int i=0;i<c;i++){
buffer[i]=a[n-p-i];
}
for(int i=1;i<p;i++){
a[n-p-c+i]=a[n-p+i];
}
for(int i=0;i<c;i++){
a[n-i-1]=buffer[i];
}
}
System.out.println(a[n-1]);
}
} | Main.java:32: error: reached end of file while parsing
}
^
1 error
|
s805816347 | p00710 | Java | import java.util.Scanner;
public class Test {
static Scanner input = new Scanner(System.in);
public static void main(String[] prgs) {
int[] before = new int[51];
int[] temp = new int[51];
while(input.hasNext()) {
int n = input.nextInt(), r = input.nextInt();
if(n == 0 && r == 0)
break;
for(int i = n, j = 1; i >= 1 && j <= n; i--, j++) { //Initialize
before[j] = i;
}
for(int i = 1; i <= r; i++) {
int p = input.nextInt(), c = input.nextInt();
for(int j = 1; j <= p - 1; j++) {
temp[j] = before[j];
}
for(int k = p; k <= p + c - 1; k++) {
before[k - p + 1] = before[k];
}
for(int j = c + 1, k = 1; j <= p + c - 1 && k <= p - 1; j++, k++) {
before[j] = temp[k];
}
}
System.out.println(before[1]);
}
}
}
| Main.java:3: error: class Test is public, should be declared in a file named Test.java
public class Test {
^
1 error
|
s868076374 | p00710 | Java | public class Main {
public static void main(String[] agrs) {
Scanner sc = new Scanner(System.in);
for(;;){
int n = sc.nextInt();//输入数组数
int r = sc.nextInt();//输入循环几次
if( n==0 && r==0) {
break;
}
int[] input = new int[n];
for(int i = 0; i < n ; i++){
input[i] = n - i;
}
for(int i = 0; i < r ; i++){
int p = sc.nextInt()-1;//输入顶牌交换的地方
int c = sc.nextInt(); //下层交换地方
int[] deck = input.clone();
for(int j = 0 ; j < c ; j++){
deck[j] = input[j+p];
}
for(int j = 0; j < p ; j ++){
deck[j+c] = input[j];
}
input = deck;
}
System.out.println(input[0]);
}
}
}
| Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s127052998 | p00710 | Java | public class Main {
public static void main(String[] agrs) {
Scanner sc = new Scanner(System.in);
for(;;){
int n = sc.nextInt();
int r = sc.nextInt();
if( n==0 && r==0) {
break;
}
int[] input = new int[n];
for(int i = 0; i < n ; i++){
input[i] = n - i;
}
for(int i = 0; i < r ; i++){
int p = sc.nextInt()-1;
int c = sc.nextInt();
int[] deck = input.clone();
for(int j = 0 ; j < c ; j++){
deck[j] = input[j+p];
}
for(int j = 0; j < p ; j ++){
deck[j+c] = input[j];
}
input = deck;
}
System.out.println(input[0]);
}
}
}
| Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s787208247 | p00710 | Java | public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(true) {
int n = sc.nextInt();
int r = sc.nextInt();
if(n==0 && r==0) break;
int i,j;
int huda[] = new int[n];
for(i=0;i<n;i++){
huda[i] = n-i;
}
for(i=0;i<r;i++) {
int p = sc.nextInt();
int c = sc.nextInt();
int rep[] = new int[c];
for(j=0;j<c;j++){
rep[j] = huda[j+p];
}
for(j=p-1;j>=0;j--){
huda[j] = huda[j+c];
}
for(j=0;j<c;j++){
huda[j] = rep[j];
}
}
System.out.println(huda[0]);
}
}
}
| Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s226042658 | p00710 | Java | import java.util.Scanner;
public class Main{
public static void main(String[] args){
try(Scanner sc = new Scanner(System.in)){
while(true){
int n = sc.nextInt();
int r = sc.nextInt();
if(n==0 && r==0) break;
int[] card = new int[n];
for(int i=0;i<n;i++){
card[i]=n-i;
}
for(int i=0;i<r;i++){
int p = sc.nextInt();
int c = sc.nextInt();
int[] new_card = new int[p-1];
for(int j=0;j<p-1;j++){
new_card[j] = card[j];
}
for(int j=0;j<c;j++){
card[j] = card[p-1+j];
}
for(int j=0;j<p-1;j++){
card[c+j] = new_card[j];
}
}
System.out.println(card[i]);
}
}
}
}
| Main.java:34: error: cannot find symbol
System.out.println(card[i]);
^
symbol: variable i
location: class Main
1 error
|
s090958629 | p00710 | Java | import java.util.Scanner;
public class Main{
public static void main(String[] args){
try(Scanner sc = new Scanner(System.in)){
while(true){
int n = sc.nextInt();
int r = sc.nextInt();
if(n==0 && r==0) break;
int[] card = new int[n];
for(int i=0;i<n;i++){
card[i]=n-i;
}
for(int i=0;i<r;i++){
int p = sc.nextInt();
int c = sc.nextInt();
int[] new_card = new int[p-1];
for(int j=0;j<p-1;j++){
new_card[j] = card[j];
}
for(int j=0;j<c;j++){
card[j] = card[p-1+j];
}
for(int j=0;j<p-1;j++){
card[c+j] = new_card[j];
}
}
System.out.println(card[i]);
}
}
}
}
| Main.java:34: error: cannot find symbol
System.out.println(card[i]);
^
symbol: variable i
location: class Main
1 error
|
s071400542 | p00710 | Java | import java.util.Scanner;
public class Main5{
public static void main(String[] args){
try(Scanner sc = new Scanner(System.in)){
while(true){
int n = sc.nextInt();
int r = sc.nextInt();
if(n==0 && r==0) break;
int[] card = new int[n];
for(int i=0;i<n;i++){
card[i]=n-i;
}
for(int i=0;i<r;i++){
int p = sc.nextInt();
int c = sc.nextInt();
int[] new_card = new int[p-1];
for(int j=0;j<p-1;j++){
new_card[j] = card[j];
}
for(int j=0;j<c;j++){
card[j] = card[p-1+j];
}
for(int j=0;j<p-1;j++){
card[c+j] = new_card[j];
}
}
System.out.println(card[0]);
}
}
}
}
| Main.java:3: error: class Main5 is public, should be declared in a file named Main5.java
public class Main5{
^
1 error
|
s150456777 | p00710 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();//枚数
int r = sc.nextInt();//回数
int[] huda = new int[n];
for(int i=0;i<n;i++) huda[i] = i+1;
for(int i=0;i<r;i++){
int p = sc.nextInt();//上から何枚
int c = sc.nextInt();//ここまで
int[] temp = new int[p];
for(int i=0;i<p;i++) temp[i] = huda[i];
for(int i=0;i<c;i++) huda[i] = huda[i+p-1];
for(int i=0;i<p;i++) huda[c+i] = temp[i];
}
System.out.println(huda[0]);
}
}
| Main.java:15: error: variable i is already defined in method main(String[])
for(int i=0;i<p;i++) temp[i] = huda[i];
^
Main.java:16: error: variable i is already defined in method main(String[])
for(int i=0;i<c;i++) huda[i] = huda[i+p-1];
^
Main.java:17: error: variable i is already defined in method main(String[])
for(int i=0;i<p;i++) huda[c+i] = temp[i];
^
3 errors
|
s042488623 | p00710 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();//枚数
int r = sc.nextInt();//回数
if(0==n && 0==r) break;
int[] huda = new int[n];
for(int i=0;i<n;i++) huda[i] = i+1;
for(int i=0;i<r;i++){
int p = sc.nextInt();//上から何枚
int c = sc.nextInt();//ここまで
int[] temp = new int[p];
for(int i=0;i<p;i++) temp[i] = huda[i];
for(int i=0;i<c;i++) huda[i] = huda[i+p-1];
for(int i=0;i<p;i++) huda[c+i] = temp[i];
}
System.out.println(huda[0]);
}
}
| Main.java:8: error: break outside switch or loop
if(0==n && 0==r) break;
^
Main.java:16: error: variable i is already defined in method main(String[])
for(int i=0;i<p;i++) temp[i] = huda[i];
^
Main.java:17: error: variable i is already defined in method main(String[])
for(int i=0;i<c;i++) huda[i] = huda[i+p-1];
^
Main.java:18: error: variable i is already defined in method main(String[])
for(int i=0;i<p;i++) huda[c+i] = temp[i];
^
4 errors
|
s393653609 | p00710 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true){
int n = sc.nextInt();//枚数
int r = sc.nextInt();//回数
if(0==n && 0==r) break;
int[] huda = new int[n];
for(int i=0;i<n;i++) huda[i] = i+1;
for(int i=0;i<r;i++){
int p = sc.nextInt();//上から何枚
int c = sc.nextInt();//ここまで
int[] temp = new int[p];
for(int i=0;i<p;i++) temp[i] = huda[i];
for(int i=0;i<c;i++) huda[i] = huda[i+p-1];
for(int i=0;i<p;i++) huda[c+i] = temp[i];
}
System.out.println(huda[0]);
}
}
}
| Main.java:17: error: variable i is already defined in method main(String[])
for(int i=0;i<p;i++) temp[i] = huda[i];
^
Main.java:18: error: variable i is already defined in method main(String[])
for(int i=0;i<c;i++) huda[i] = huda[i+p-1];
^
Main.java:19: error: variable i is already defined in method main(String[])
for(int i=0;i<p;i++) huda[c+i] = temp[i];
^
3 errors
|
s616167054 | p00710 | Java | import java.util.Scanner;
public class Main{
public static void main(String[]argc){
Scanner sc = new Scanner(System.in);
int[] card1 = new int[50];
int[] card2 = new int[50;
while(true){
int n = sc.nextInt();
int r = sc.nextInt();
if(n==0&&r==0)
break;
for(int i=0;i<n;i++){
card1[i] = n-i;
}
for(int x=0;x<r;x++){
int p = sc.nextInt();
int c = sc.nextInt();
for(int j=0;j<p-1;j++){
card2[j] = card1[j];
}
for(int k=0;k<c;k++){
card1[k] = card1[k+p-1];
}
for(int m=c;m<c+p-1;m++){
card1[m] = card2[m-c];
}
}
System.out.println(card1[0]);
}
}
}
| Main.java:6: error: ']' expected
int[] card2 = new int[50;
^
1 error
|
s985340968 | p00710 | Java | import java.util.Scanner;
public class Main{
public static void main(String[]argc){
Scanner sc = new Scanner(System.in);
int[] card1 = new int[50];
int[] card2 = new int[50;
while(true){
int n = sc.nextInt();
int r = sc.nextInt();
if(n==0&&r==0)
break;
for(int i=0;i<n;i++){
card1[i] = n-i;
}
for(int x=0;x<r;x++){
int p = sc.nextInt();
int c = sc.nextInt();
for(int j=0;j<p-1;j++){
card2[j] = card1[j];
}
for(int k=0;k<c;k++){
card1[k] = card1[k+p-1];
}
for(int m=c;m<c+p-1;m++){
card1[m] = card2[m-c];
}
}
System.out.println(card1[0]);
}
}
}
| Main.java:6: error: ']' expected
int[] card2 = new int[50;
^
1 error
|
s533116161 | p00710 | Java | import java.util.Scanner;
public class Main{
public static void main(String[]argc){
Scanner sc = new Scanner(System.in);
int[] card1 = new int[50];
int[] card2 = new int[50;
while(true){
int n = sc.nextInt();
int r = sc.nextInt();
if(n==0&&r==0)
break;
for(int i=0;i<n;i++){
card1[i] = n-i;
}
for(int x=0;x<r;x++){
int p = sc.nextInt();
int c = sc.nextInt();
for(int j=0;j<p-1;j++){
card2[j] = card1[j];
}
for(int k=0;k<c;k++){
card1[k] = card1[k+p-1];
}
for(int m=c;m<c+p-1;m++){
card1[m] = card2[m-c];
}
}
System.out.println(card1[0]);
}
}
}
| Main.java:6: error: ']' expected
int[] card2 = new int[50;
^
1 error
|
s003645908 | p00710 | Java |
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class HanafudaShuffle {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
List<Integer> array = new ArrayList<Integer>();
while (true) {
int N = sc.nextInt();
int r = sc.nextInt();
if (N == 0 && r == 0) {
break;
}
array.clear();
for (int i = 0; i < N; i++) {
array.add(N - i);
}
while (!(r == 0)) {
r--;
int p = sc.nextInt();
int c = sc.nextInt();
int pop = 0;
for (int ii = 0; ii < r; ii++) {
array.add(0, array.get(p + c - 2));
array.remove(p + c-1);
}
}
System.out.println((array.get(0)+1));
}
}
}
| Main.java:7: error: class HanafudaShuffle is public, should be declared in a file named HanafudaShuffle.java
public class HanafudaShuffle {
^
1 error
|
s773365259 | p00710 | Java | import java.util.ArrayList;
import java.util.Scanner;
class M1129 {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
while (true){
int n=scan.nextInt();
int r=scan.nextInt();
if(n==0 && r==0){
break;
}
ArrayList list=new ArrayList();
for (int i=0;i<n;i++){
list.add(n-i);
}
for (int i=0;i<r;i++){
// for(int j=0;j<list.size();j++){
// System.out.print(list.get(j)+" ");
// }
// System.out.println("");
int p=scan.nextInt();
int c=scan.nextInt();
for (int j=0;j<c;j++){
//data[p-1+j],data[0+j]
int temp= (int) list.get(p-1+j);
list.remove(p-1+j);
list.add(0+j,temp);
}
}
System.out.println(list.get(0));
}
}
}
| Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
|
s344451891 | p00710 | Java | import java.util.Scanner;
public class Main{
public static void main(String[] args){
int p,n,r,c,i,j,k;
int[] card = new int[51];
int[] dummy = new int[51];
Scanner s = new Scanner(System.in);
while(true){
n = s.nextInt();
r = s.nextInt();
if(n==0&&r==0)break;
for(i=0;i<n;i++)card[i]=n-i;
for(i=0;i<r;i++){
p = s.nextInt();
c = s.nextInt();
for(j=0;j<p-1;j++)dummy[j]=card[j];
for(j=0;j<c;j++)card[j]=card[j+p-1];
for(j=0;j<p-1;j++)card[j+c]=dummy[j];
}
System.out.println(card[0]);
}
}
}
Compile Error Logs:
ステータス
Judge: 1/1 JAVA CPU: 00:17 sec Memory: 38220 KB Length: 709 B 2018-04-23 13:55
テストケースの判定結果
Case # Verdict CPU Time Memory In Out Case Name
Case #1 : Accepted 00:17 38220 17774 1052 judge_data
< prev | / | next >
Judge Input # ( | ) Judge Output # ( | )
| Main.java:26: error: class, interface, enum, or record expected
Compile Error Logs:
^
Main.java:31: error: illegal character: '#'
Case # Verdict CPU Time Memory In Out Case Name
^
Main.java:32: error: illegal character: '#'
Case #1 : Accepted 00:17 38220 17774 1052 judge_data
^
Main.java:36: error: illegal character: '#'
Judge Input # ( | ) Judge Output # ( | )
^
Main.java:36: error: illegal character: '#'
Judge Input # ( | ) Judge Output # ( | )
^
5 errors
|
s347079252 | p00710 | Java | import java.util.*;
public class Hanafuda_Shuffle {
static int n, r, p, c;
static Scanner sc = new Scanner(System.in);
static int[] Hanafuda, temp;
public static void main(String[] args) {
while(read()){
}
}
static boolean read(){
/**
* ScannerNXÌnextInt()Å®lÌÇÝݪūܷB
*/
n = sc.nextInt(); r = sc.nextInt();
/**
* âè¶æèAnÆrªÆàÉ0ÈçfalseðԵܷB@
*/
if(n == 0 && r == 0)
return false;
/**
* ÔDÌzñAHanafudaÆAêIÉDððï³¹ézñ
* tempðõµÜ·B¡ñA0 < n <= 50 ÈÌÅ50ÜÅõ·éÆ
* âèÍð¯Ü·ªAHanafuda[0]ðg¢½È¢ÌÅ51ÜÅpӵܷB
*/
Hanafuda = new int[51];
temp = new int[51];
/**
* HanafudazñÌú»B
* Hanafuda[n]ÉÍ1AHanafuda[1]ÉÍnðüêÜ·B
*/
for(int i = 1; i <= n; i++){
Hanafuda[i] = n - i + 1;
temp[i] = 0;
}
/**
* rñApÆcª±ÌÅnextInt()ÅÇÝÝÜ·B
* pÆcðêñÇÝÞ½ÑÉAVbt·éÌÅA
* »Ì½ÑÉsolve()ÖðÄÑÜ·B
*/
for(int i = 0; i < r; i++){
p = sc.nextInt(); c = sc.nextInt();
solve();
}
/**
* rñÇÝñÅAVbtµ½ ÆÅAêÔãÌDð\¦µÜ·B
*/
System.out.println(Hanafuda[1]);
/**
* ±êŪIíÁ½ÌÅtrueðԵܷB
*/
return true;
}
static void solve(){
/**
* HanafudazñÌã©çp-1ÚÜÅðAtempzñÉÞð³¹Ü·B
*/
for(int i = 1; i <= p-1; i++)
temp[i] = Hanafuda[i];
/**
* HanafudazñÌpÚ©çp+c-1ÚÜÅðÚ®µÜ·B
*/
for(int i = p; i < p+c; i++)
Hanafuda[i-p+1] = Hanafuda[i];
/**
* tempzñɦªµÄ¨¢½J[hðA é׫êÉߵܷB
* ¼OÌìÆÅHanafuda[c]ÜŪÜÁÄ¢éÌÅA
* ÍHanafuda[c+1]©çÅ·B
*/
for(int i = 1; i <= p-1; i++)
Hanafuda[c+i] = temp[i];
}
} | Main.java:2: error: class Hanafuda_Shuffle is public, should be declared in a file named Hanafuda_Shuffle.java
public class Hanafuda_Shuffle {
^
1 error
|
s637858224 | p00710 | Java | import java.util.*;
public class P1129 {
Scanner sc;
void run() {
sc = new Scanner(System.in);
while(true) {
int n = sc.nextInt();
int r = sc.nextInt();
LinkedList<Integer> list = new LinkedList<Integer>();
for (int i=0;i<n;i++)
list.add(i+1);
for (int i=0;i<r;i++) {
int p = sc.nextInt();
int c = sc.nextInt();
for (int j=0;j<c;j++) {
list.addLast(list.remove(n-(p-1+c)));
}
}
System.out.println(list.getLast());
}
}
public static void main(String[] args) {
new P1129().run();
}
} | Main.java:2: error: class P1129 is public, should be declared in a file named P1129.java
public class P1129 {
^
1 error
|
s987009949 | p00710 | Java | import java.util.*;
public class Main {
private static Scanner sc = new Scanner(System.in);
public static void main(String...args) {
while(sc.hasNext()) {
final int n = sc.nextInt();
final int r = sc.nextInt();
if (n == 0 && r == 0)
break;
solve(n, r);
}
}
private static int case_num = 1;
private static void solve(final int n, final int r) {
final int[] p = new int[r];
final int[] c = new int[r];
for(int i = 0; i < n; i++) {
p[i] = sc.nextInt();
c[i] = sc.nextInt();
}
int ans = 0;
for(int i = r - 1; i >= 0; i--)
if(ans < p - 1)
ans += c;
else if(ans <= p + c)
ans -= p - 1;
System.out.println(ans+1);
}
} | Main.java:24: error: bad operand types for binary operator '-'
if(ans < p - 1)
^
first type: int[]
second type: int
Main.java:25: error: bad operand types for binary operator '+'
ans += c;
^
first type: int
second type: int[]
Main.java:26: error: bad operand types for binary operator '+'
else if(ans <= p + c)
^
first type: int[]
second type: int[]
Main.java:27: error: bad operand types for binary operator '-'
ans -= p - 1;
^
first type: int[]
second type: int
4 errors
|
s465527282 | p00710 | Java |
import java.util.Scanner;
public class Hanafuda {
public static void main(String[] args){
Scanner sn = new Scanner(System.in);
int n, r;
while( (n = sn.nextInt())!=0 && (r = sn.nextInt()) != 0 ){
int[] array = rangeArray(n);
for(int i = 0; i < r; i++){
shuffle(array, sn.nextInt(), sn.nextInt());
}
System.out.println(topOf(array));
}
}
static void shuffle(int[] a, int _p, int c){
int p =_p-1;
int[] p2c = new int[c];
for(int i = 0; i < c; i++) p2c[i] = a[p+i];
for(int i = 0; p != i; i++) a[(p+c-1)-i] = a[(p-1)-i];
for(int i = 0; i < c; i++) a[i] = p2c[i];
}
static void printArray(int[] a){
for(int i = 0; i < a.length; i++) System.out.print(a[i]+" ");
System.out.println();
}
static int[] rangeArray(int n){
int[] a = new int[n];
for(int i = 0; i < a.length; i++) a[i] = n-i;
return a;
}
static int topOf(int[] a){ return a[0];}
} | Main.java:4: error: class Hanafuda is public, should be declared in a file named Hanafuda.java
public class Hanafuda {
^
1 error
|
s857500786 | p00710 | Java | import java.util.Scanner;
import java.util.ArrayList;
public class aoj_1129 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int n = sc.nextInt();
int r = sc.nextInt();
if (n == 0) {
break;
}
ArrayList<Integer> cards = new ArrayList<Integer>();
for (int i = n; i >= 1; i--) {
cards.add(i);
}
for (int i = 0; i < r; i++) {
int p = sc.nextInt();
int c = sc.nextInt();
for (int j = c; j >= 1; j--) {
int k = cards.remove(p - 1 + c - 1);
cards.add(0, k);
}
}
System.out.println(cards.get(0));
}
}
} | Main.java:4: error: class aoj_1129 is public, should be declared in a file named aoj_1129.java
public class aoj_1129 {
^
1 error
|
s833275959 | p00710 | C | #include <stdio.h>
#include <stdlib.h>
void shuffle(int *card,int p,int c);
int main(void){
int i,j,n,r,p,c;
int *card;
while(1){
x = scanf("%d %d",&n,&r);
if((n == 0) && (r == 0)){
break;
}
card = (int *)calloc(n,sizeof(int));
if(card == NULL){
printf("メモリが確保できません\n");
return -1;
}
for(i = 0;i < n; i++){
card[i] = n - i;
}
for(i = 0;i < r; i++){
x = scanf("%d %d",&p,&c);
shuffle(card,p,c);
}
printf("%d\n",card[0]);
free(card);
}
return 0;
}
void shuffle(int *card,int p,int c){
int box[50],i;
for(i = 0; i < c; i++){
box[i] = card[p + i - 1];
}
for(i = 0; i < p; i++){
card[p - 2 + c - i] = card[p - 2 - i];
}
for(i = 0; i < c; i++){
card[i] = box[i];
}
} | main.c: In function 'main':
main.c:11:17: error: 'x' undeclared (first use in this function)
11 | x = scanf("%d %d",&n,&r);
| ^
main.c:11:17: note: each undeclared identifier is reported only once for each function it appears in
|
s014953067 | p00710 | C | #include <stdio.h>
int main(){
int i, j, n, r, p, c, A[52], B[52];
while(1){
scanf("%d %d",&n,&r);
if( n == 0 && r == 0 ){ break;}
for(i=n ; i>0 ; i--){
A[n-i]=i;
B[n-i]=i;
}
for( i=0 ; i < r ; i++){
scanf("%d %d",&p,&c);
for( j = 0 ; j <= p-1 ; j++)
B[j+c]=A[j];
for( j = p-1 ; j < p-1+c ; j++)
B[j-(p-1)]=A[j];
for( j = 0 ; j < n ; j++ )
A[j]=B[j];
}
printf("%d\n",B[0]);
}
return 0; | main.c: In function 'main':
main.c:22:1: error: expected declaration or statement at end of input
22 | return 0;
| ^~~~~~
|
s744219640 | p00710 | C |
#include <stdio.h>
int main(){
int n, r, p, c, i;
for(;;){
int N[50];
scanf("%d %d", &n, &r);
if( n == 0 && r == 0){
break
}
for( i = 0; i < n; i++){
N[i] = n-i;
}
//cut
for( ; r > 0; r--){
scanf("%d %d", &p, &c);
int copy[50];
for( i = 0; i < p-1+c; i++){
copy[i] = N[i];
}
for( i = 0; i < p-1+c; i++){
if( i < c){
N[i] = copy[p-1+i];
}
else{
N[i] = copy[i-c];
}
}
}
printf("%d\n", N[0]);
}
return 0;
} | main.c: In function 'main':
main.c:13:18: error: expected ';' before '}' token
13 | break
| ^
| ;
14 | }
| ~
|
s552445293 | p00710 | C | #include<stdio.h>
int main(void)
{
int n,r,p,c;
int card[51];
int tem[51];
while(scanf("%d%d",&n,&r),n+r){
for(i=1;i<=n;i++){
card[i]=i;
}
for(i=0;i<r;i++){
scanf("%d%d",&p,&c);
for(j=n-p+1;j>n-p+1-c;j--){
tem[j]=card[j];
}
for(j++;j+c<=n;j++){
card[j]=card[j+c];
}
for(j--;j<=n;j++){
card[j]=tem[j-p+1];
}
printf("%d",card[n]);
return 0;
} | main.c: In function 'main':
main.c:11:5: error: 'i' undeclared (first use in this function)
11 | for(i=1;i<=n;i++){
| ^
main.c:11:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:17:5: error: 'j' undeclared (first use in this function)
17 | for(j=n-p+1;j>n-p+1-c;j--){
| ^
main.c:29:1: error: expected declaration or statement at end of input
29 | }
| ^
main.c:29:1: error: expected declaration or statement at end of input
|
s345668130 | p00710 | C | #include<stdio.h>
int main(void)
{
int n,r,p,c,i,j;
int card[51];
int tem[51];
while(scanf("%d%d",&n,&r),n+r){
for(i=1;i<=n;i++){
card[i]=i;
}
for(i=0;i<r;i++){
scanf("%d%d",&p,&c);
for(j=n-p+1;j>n-p+1-c;j--){
tem[j]=card[j];
}
for(j++;j+c<=n;j++){
card[j]=card[j+c];
}
for(j--;j<=n;j++){
card[j]=tem[j-p+1];
}
printf("%d",card[n]);
return 0;
} | main.c: In function 'main':
main.c:29:1: error: expected declaration or statement at end of input
29 | }
| ^
main.c:29:1: error: expected declaration or statement at end of input
|
s858295882 | p00710 | C | #include<stdio.h>
int main(void)
{
int n,r,p,c,i,j;
int card[51];
int tem[51];
while(scanf("%d%d",&n,&r),n+r){
for(i=1;i<=n;i++){
card[i]=i;
}
for(i=0;i<r;i++){
scanf("%d%d",&p,&c);
for(j=n-p+1;j>n-p+1-c;j--){
tem[j]=card[j];
}
for(j++;j+c<=n;j++){
card[j]=card[j+c];
}
for(j--;j<=n;j++){
card[j]=tem[j-p+1];
}
printf("%d",card[n]);
}
return 0;
} | main.c: In function 'main':
main.c:30:1: error: expected declaration or statement at end of input
30 | }
| ^
|
s158249427 | p00710 | C | #include <stdio.h>
#include <string.h>
void shuffle(int card[50],int p,int c){
int d[50],i;
memcpy(d,card.sizeof(int));
for(i = 0;i < c;i++){
d[i] = card[p - 1 + i];
}
for(i = 0; i < p - 1;i++){
d[c + i] = card[i];
}
memcpy(card,d,sizeof(int));
}
int main(void){
int n,r,p,c,i,card[50];
while(1){
scanf("%d %d",&n,&r);
if(n == 0 && r == 0) break;
for(i = 0; i < n;i++){
card[i] = i;
}
for(i = 0;i < n; i++){
scanf("%d %d",&p,&c);
shuffle(card,p,c);
}
printf("%d\n",(n + 1 - card[0]));
}
return 0;
}
| main.c: In function 'shuffle':
main.c:6:23: error: expected identifier before 'sizeof'
6 | memcpy(d,card.sizeof(int));
| ^~~~~~
main.c:6:9: error: too few arguments to function 'memcpy'
6 | memcpy(d,card.sizeof(int));
| ^~~~~~
In file included from main.c:2:
/usr/include/string.h:43:14: note: declared here
43 | extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
| ^~~~~~
|
s946404394 | p00710 | C | #include <stdio.h>
#include <string.h>
void shuffle(int card[50],int p,int c){
int d[50],i;
memcpy(d,card.50 * sizeof(int));
for(i = 0;i < c;i++){
d[i] = card[p - 1 + i];
}
for(i = 0; i < p - 1;i++){
d[c + i] = card[i];
}
memcpy(card,d,50 * sizeof(int));
}
int main(void){
int n,r,p,c,i,card[50];
while(1){
scanf("%d %d",&n,&r);
if(n == 0 && r == 0) break;
for(i = 0; i < n;i++){
card[i] = i;
}
for(i = 0;i < n; i++){
scanf("%d %d",&p,&c);
shuffle(card,p,c);
}
printf("%d\n",(n + 1 - card[0]));
}
return 0;
}
| main.c: In function 'shuffle':
main.c:6:22: error: expected ')' before numeric constant
6 | memcpy(d,card.50 * sizeof(int));
| ~ ^~~
| )
main.c:6:9: error: too few arguments to function 'memcpy'
6 | memcpy(d,card.50 * sizeof(int));
| ^~~~~~
In file included from main.c:2:
/usr/include/string.h:43:14: note: declared here
43 | extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
| ^~~~~~
|
s306502165 | p00710 | C | #include <stdio.h>
#include <stdlib.h>
void shuffle(int *array,int n,int p,int c); //?±±???????????£???????????????
int main(void) {
int n = 10; //tmp
int p,c;
//n???????????????
int array[n],i; //??????????????????
for(i=0;i<n;i++){
array[i] = i+1;
}
//p??¨c???????????????
while(fscanf(buf,"%d%d",p,c) != EOF){
shuffle(&array[0],n,p,c);
}
printf("%d\n",array[n-1]);
for(i=0;i<n;i++){
printf("%d ",array[i]);
}
}
void shuffle(int *array,int n,int p,int c){
int tmp[c];
int i,j=0,k;
for(i=n-p-c+1;i<=n-p;i++){ //???????????????????????????
tmp[j++] = *(array + i);
}
i = n-p-c+1;
for(k=n-p+1;k<n;k++){ //????????????????????????
*(array + i) = *(array + k);
i++;
}
for(j=0;j<c;j++){ //???????????????????????????????????????
*(array + i) = tmp[j];
i++;
}
} | main.c: In function 'main':
main.c:16:22: error: 'buf' undeclared (first use in this function)
16 | while(fscanf(buf,"%d%d",p,c) != EOF){
| ^~~
main.c:16:22: note: each undeclared identifier is reported only once for each function it appears in
|
s207230534 | p00710 | C | #include <stdio.h>
int main(void){
char inputs[6], tmp[51];
int inputs_shuffle[51][2], inputs_nr[2], stack[52];
int loop1, loop2, loop3;
while(1){
inputs_nr[0] = '\0';
inputs_nr[1] = '\0';
for(loop1 = 0; loop1 < 51; loop1++)
inputs_shuffle[loop1][0] = '\0';
inputs_shuffle[loop1][1] = '\0';
}
for(loop1 = 0; loop1 < 52; loop1++){
stack[loop1] = '\0';
}
while((inputs_nr[0] == '\0') || (inputs_nr[1] == '\0')){ // get <n r>
// printf("input 'n r'\n");
scanf("%d %d", &loop1, &loop2);
inputs_nr[0] = loop1;
inputs_nr[1] = loop2;
if((inputs_nr[0] == 0) && (inputs_nr[1] == 0)) break;
if((inputs_nr[0] < 1) || (inputs_nr[0] > 50)){
// printf("<n> must be more than 1 and less than 50.\n");
inputs_nr[0] = '\0'; // 1 <= n <= 50
inputs_nr[1] = '\0';
}
if((inputs_nr[1] < 1) || (inputs_nr[1] > 50)){
// printf("<r> must be more than 1 and less than 50.\n");
inputs_nr[1] = '\0'; // 1 <= r <= 50
inputs_nr[0] = '\0';
}
}
if((inputs_nr[0] == 0) && (inputs_nr[1] == 0)) break;
for(loop1 = 0; loop1 < inputs_nr[1]; loop1++){ // get <p c>
// printf("input 'p c'[%d]\n", loop1 + 1);
scanf("%d %d", &loop2, &loop3);
inputs_shuffle[loop1][0] = loop2;
inputs_shuffle[loop1][1] = loop3;
if((inputs_shuffle[loop1][0] + inputs_shuffle[loop1][1]) > (inputs_nr[0] + 1)){
// printf("(p + c) must be less than (%d + 1)\n", inputs_nr[0]);
loop1--; // (p + c) must be less than (n + 1).
}
else if((inputs_shuffle[loop1][0] == 0) && (inputs_shuffle[loop1][1] == 0)){
break; // if ((p == 0) && (c == 0)), escape this loop.
}
}
loop1--;
if((inputs_shuffle[loop1][0] == 0) && (inputs_shuffle[loop1][1] == 0)){
break; // if ((p == 0) && (c == 0)), escape this loop.
}
for(loop1 = 0; loop1 < 52; loop1++){ // make the stack
if(inputs_nr[0] != 0){
stack[loop1] = inputs_nr[0];
inputs_nr[0]--;
}
else stack[loop1] = '\0';
}
// stack[0], stack[1], stack[2], .......
// n , n-1, n-2, .......
loop1 = 0;
while(((inputs_shuffle[loop1][0] != 0) && (inputs_shuffle[loop1][1] != 0)) && loop1 != 51){
for(loop2 = 0; loop2 < (inputs_shuffle[loop1][0] - 1); loop2++){ //
tmp[loop2] = stack[loop2];
}
for(loop3 = 0; loop3 < inputs_shuffle[loop1][1]; loop3++, loop2++){
stack[loop3] = stack[loop2];
}
for(loop2 = 0; loop2 < (inputs_shuffle[loop1][0] - 1); loop2++, loop3++){
stack[loop3] = tmp[loop2];
}
for(loop2 = 0; loop2 < 52; loop2++){
tmp[loop2] = '\0';
}
loop1++;
}
printf("%d\n", stack[0]);
}
return 0;
} | main.c: In function 'main':
main.c:46:52: error: break statement not within loop or switch
46 | if((inputs_nr[0] == 0) && (inputs_nr[1] == 0)) break;
| ^~~~~
main.c:68:7: error: break statement not within loop or switch
68 | break; // if ((p == 0) && (c == 0)), escape this loop.
| ^~~~~
main.c: At top level:
main.c:107:3: error: expected identifier or '(' before 'return'
107 | return 0;
| ^~~~~~
main.c:109:1: error: expected identifier or '(' before '}' token
109 | }
| ^
|
s768840844 | p00710 | C | File Edit Options Buffers Tools C Help
#include<stdio.h>
int main(void){
int i, n, r, p, c;
scanf("%d%d", &n, &r);
int yama[n];
for(i=0;i<n;i++){
yama[i]=n-i;
}
while(1){
scanf("%d%d", &p, &c);
if(p==0 && c==0){
break;
}
int down[p-1], cut[c];
for(i=0;i<p-1;i++){
down[i]=yama[i];
}
for(i=0;p-1+i<p-1+c;i++){
cut[i]=yama[p-1+i];
}
for(i=0;i<p+c-1;i++){
yama[i]=cut[i];
yama[p-1+i]=down[i];
}
}
printf("%d\n%d", yama[0], yama[0]);
return 0;
} | main.c:1:1: error: unknown type name 'File'
1 | File Edit Options Buffers Tools C Help
| ^~~~
main.c:1:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Options'
1 | File Edit Options Buffers Tools C Help
| ^~~~~~~
main.c:1:11: error: unknown type name 'Options'
In file included from /usr/include/stdio.h:47,
from main.c:2:
/usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h:28:43: error: unknown type name 'size_t'
28 | size_t __nbytes);
| ^~~~~~
/usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h:1:1: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
+++ |+#include <stddef.h>
1 | /* Copyright (C) 1991-2025 Free Software Foundation, Inc.
/usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h:37:44: error: unknown type name 'size_t'
37 | size_t __nbytes);
| ^~~~~~
/usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h:37:44: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h:57:3: error: unknown type name 'cookie_read_function_t'; did you mean 'cookie_seek_function_t'?
57 | cookie_read_function_t *read; /* Read bytes. */
| ^~~~~~~~~~~~~~~~~~~~~~
| cookie_seek_function_t
/usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h:58:3: error: unknown type name 'cookie_write_function_t'; did you mean 'cookie_close_function_t'?
58 | cookie_write_function_t *write; /* Write bytes. */
| ^~~~~~~~~~~~~~~~~~~~~~~
| cookie_close_function_t
/usr/include/stdio.h:314:35: error: unknown type name 'size_t'
314 | extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
| ^~~~~~
/usr/include/stdio.h:130:1: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
129 | #include <bits/stdio_lim.h>
+++ |+#include <stddef.h>
130 |
/usr/include/stdio.h:320:47: error: unknown type name 'size_t'
320 | extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW
| ^~~~~~
/usr/include/stdio.h:320:47: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:340:34: error: unknown type name 'size_t'
340 | int __modes, size_t __n) __THROW __nonnull ((1));
| ^~~~~~
/usr/include/stdio.h:340:34: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:346:24: error: unknown type name 'size_t'
346 | size_t __size) __THROW __nonnull ((1));
| ^~~~~~
/usr/include/stdio.h:346:24: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:385:44: error: unknown type name 'size_t'
385 | extern int snprintf (char *__restrict __s, size_t __maxlen,
| ^~~~~~
/usr/include/stdio.h:385:44: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:389:45: error: unknown type name 'size_t'
389 | extern int vsnprintf (char *__restrict __s, size_t __maxlen,
| ^~~~~~
/usr/include/stdio.h:389:45: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:690:30: error: unknown type name 'size_t'
690 | size_t *__restrict __n, int __delimiter,
| ^~~~~~
/usr/include/stdio.h:690:30: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:693:28: error: unknown type name 'size_t'
693 | size_t *__restrict __n, int __delimiter,
| ^~~~~~
/usr/include/stdio.h:693:28: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:698:27: error: unknown type name 'size_t'
698 | size_t *__restrict __n,
| ^~~~~~
/usr/include/stdio.h:698:27: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:728:8: error: unknown type name 'size_t'
728 | extern size_t fread (void *__restrict __ptr, size_t __size,
| ^~~~~~
/usr/include/stdio.h:728:8: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:728:46: error: unknown type name 'size_t'
728 | extern size_t fread (void *__restrict __ptr, size_t __size,
| ^~~~~~
/usr/include/stdio.h:728:46: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:729:22: error: unknown type name 'size_t'
729 | size_t __n, FILE *__restrict __stream) __wur
| ^~~~~~
/usr/include/stdio.h:729:22: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:735:8: error: unknown type name 'size_t'
735 | extern size_t fwrite (const void *__restrict __ptr, size_t __size,
| ^~~~~~
/usr/include/stdio.h:735:8: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:735:53: error: unknown type name 'size_t'
735 | extern size_t fwrite (const void *__restrict __ptr, size_t __size,
| ^~~~~~
/usr/include/stdio.h:735:53: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:736:23: error: unknown type name 'size_t'
736 | size_t __n, FILE *__restrict __s) __nonnull((4));
| ^~~~~~
/usr/include/stdio.h:736:23: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:756:8: error: unknown type name 'size_t'
756 | extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
| ^~~~~~
/usr/include/stdio.h:756:8: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:756:55: error: unknown type name 'size_t'
756 | extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
| ^~~~~~
/usr/include/stdio.h:756:55: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:757:31: error: unknown type name 'size_t'
757 | size_t __n, FILE *__restrict __stream) __wur
| ^~~~~~
/usr/include/stdio.h:757:31: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:759:8: error: unknown type name 'size_t'
759 | extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
| ^~~~~~
/usr/include/stdio.h:759:8: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:759:62: error: unknown type name 'size_t'
759 | extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
| ^~~~~~
/usr/include/stdio.h:759:62: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
/usr/include/stdio.h:760:32: error: unknown type name 'size_t'
760 | size_t __n, FILE *__restrict __stream)
| ^~~~~~
/usr/include/stdio.h:760:32: note: 'size_t' is defined in header '<stddef.h>'; this is probably fixable by adding '#include <stddef.h>'
|
s292138449 | p00710 | C | #include<stdio.h>
int main(void){
int p, c, count, n, r, huda[100] = {0}, i, j,an[50],a=0;
while (1) {
scanf_s("%d %d", &n, &r);
for (i = 0;i < n;i++) {
huda[i] = i + 1;
}
if (n == 0 && r == 0) {
break;
}
for (i = 0;i < r;i++) {
scanf_s("%d %d", &p, &c);
for (j = 0;j < c;j++) {
huda[n + j] = huda[n - p];
huda[n - p] = -1;
}
count = 0;
for (j = 0;j < n;j++) {
if (count > n)
break;
huda[j] = huda[count];
if (huda[count] == -1) {
j--;
}
count++;
}
/* for (j = 0;j < n;j++) {
printf("%d ", huda[j]);
}*/
}
an[a] = huda[n - 1];
a++;
}
for (i = 0;i < a;i++) {
printf("%d\n", an[i]);
}
return 0;
} | main.c: In function 'main':
main.c:5:17: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
5 | scanf_s("%d %d", &n, &r);
| ^~~~~~~
| scanf
|
s242031161 | p00710 | C | #include<stdio.h>
int main(void){
int p, c, count, n, r, huda[100] = {0}, i, j,an[50],a=0;
while (1) {
scanf("%d %d", &n, &r);
for (i = 0;i < n;i++) {
huda[i] = i + 1;
}
if (n == 0 && r == 0) {
break;
}
for (i = 0;i < r;i++) {
scanf("%d %d", &p, &c);
for (j = 0;j < c;j++) {
huda[n + j] = huda[n - p];
huda[n - p] = -1;
}
count = 0;
for (j = 0;j < n;j++) {
if (count > n)
break;
huda[j] = huda[count];
if (huda[count] == -1) {
j--;
}
count++;
}
/* for (j = 0;j < n;j++) {
printf("%d ", huda[j]);
}*/
}
an[a] = huda[n - 1];
a++;
}
for (i = 0;i < a-1;i++) {
printf("%d\n", an[i]);
}
print("%d",an[a-1]);
return 0;
} | main.c: In function 'main':
main.c:42:9: error: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
42 | print("%d",an[a-1]);
| ^~~~~
| printf
|
s839358452 | p00710 | C | #include<stdio.h>
int main(void){
int p, c, count, n, r, huda[100] = {0}, i, j,an[50],a=0;
while (1) {
scanf("%d %d", &n, &r);
for (i = 0;i < n;i++) {
huda[i] = i + 1;
}
if (n == 0 && r == 0) {
break;
}
for (i = 0;i < r;i++) {
scanf("%d %d", &p, &c);
for (j = 0;j < c;j++) {
huda[n + j] = huda[n - p];
huda[n - p] = -1;
}
count = 0;
for (j = 0;j < n;j++) {
if (count > n)
break;
huda[j] = huda[count];
if (huda[count] == -1) {
j--;
}
count++;
}
/* for (j = 0;j < n;j++) {
printf("%d ", huda[j]);
}*/
}
an[a] = huda[n - 1];
a++;
}
for (i = 0;i < a-1;i++) {
printf("%d\n", an[i]);
}
print("%d",an[a-1]);
return 0;
} | main.c: In function 'main':
main.c:42:9: error: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
42 | print("%d",an[a-1]);
| ^~~~~
| printf
|
s600858466 | p00710 | C | #include<stdio.h>
int main(void)
{
int i,j,n,r,p,c,a[51],b[51],d;
while(1){
scanf(fp"%d %d",&n,&r);
//printf("%d %d\n",n,r);
if(n==0&&r==0) break;
for(i=1;i<=n;i++){
a[n+1-i]=i;
}
for(i=1;i<=r;i++){
scanf("%d %d",&p,&c);
d=1;
for(j=p;j<p+c;j++){
b[d]=a[j];
d++;
}
for(j=p-1;j>0;j--){
a[j+c]=a[j];
}
for(j=1;j<=c;j++){
a[j]=b[j];
}
}
printf("%d\n",a[1]);
}
} | main.c: In function 'main':
main.c:7:23: error: 'fp' undeclared (first use in this function); did you mean 'p'?
7 | scanf(fp"%d %d",&n,&r);
| ^~
| p
main.c:7:23: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:25: error: expected ')' before string constant
7 | scanf(fp"%d %d",&n,&r);
| ~ ^~~~~~~
| )
|
s806846999 | p00710 | C | clude<stdio.h>
int main(){
int n, r, i, p, c, q, j;
int card[50], t[50];
while(1){
scanf("%d %d", &n, &r);
if((n == 0)&&(r == 0))
break;
else{
for(i=0; i<n; i++)
card[i]=n-i;
for(j=0; j<r; j++){
scanf("%d %d", &p, &c);
q = p;
for(i=0; i<(p-1);i++){
t[i] = card[i];
}
for(i=0; i<c; i++){
card[i] = card[q-1];
q++;
}
for(i=0; i<(p-1); i++){
card[c]=t[i];
c++;
}
}
}
printf("%d\n", card[0]);
}
return 0;
} | main.c:1:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
1 | clude<stdio.h>
| ^
|
s421448137 | p00710 | C | #include <stdio.h>
??
int main() {
??
????int r,d,n,i,j,k,l;
????int p,c;
????int a[60] = {0};
????int b[60] = {0};
??
??
????while(1) {
??
????????scanf("%d %d", &n, &r);
??
????????if(n == 0 && r == 0) {
????????????break;
????????}
??
??
????????for(i =0 ; i<=n ; i++) {
????????????a[n-1-i] = i+1;
????????????b[n-1-i] = i+1;
????????}
??
??
??
????????for(i = 0; i < r; i++) {
????????????scanf("%d %d",&p,&c);
??
????????????for(j = 0; j<c;j++) {
????????a[j] = b[p+j-1];
????????//printf("a[%d] = %d\n",j,a[j]);
????????????}
????????????for(j = 0;j<p-1;j++) {
????????a[c+j] = b[j];
????????//printf("a[%d] = %d\n" ,c+j ,a[c+j]);
????????????}
??
????????????for(j = 0;j<p+c-1;j++) {
????????b[j] = a[j];
????????????}
????????}
??
??
????????printf("%d\n",a[0]);
??
????}
??
????return 0;
} | main.c:2:1: error: expected identifier or '(' before '?' token
2 | ??
| ^
main.c:32:7: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
32 | ????????//printf("a[%d] = %d\n",j,a[j]);
main.c:36:7: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
36 | ????????//printf("a[%d] = %d\n" ,c+j ,a[c+j]);
|
s374603810 | p00710 | C | #include <stdio.h>
#include <string.h>
int main(void)
{
int n, r;
int tmp[64];
int p, c;
while(1){
(scanf("%d %d", &n, &r);
if(!n && !r)
break;
int card[64];
int i;
for (i = 0; i < n; i++){
card[i] = n-i;
}
while (r-- > 0){
//int p, c;
//int tmp[64];
scanf("%d %d", &p, &c);
for (i = p - 1; i < p + c - 1; i++){
tmp[i - p + 1] = card[i];
}
for (i = p - 1 + c - 1; i-c+1 > 0 ; i--){
card[i] = card[i - c];
}
int j = 0;
for (i = 0; i < c; i++){
card[i] = tmp[j];
j++;
}
}
printf("%d\n", card[0]);
}
return 0;
} | main.c: In function 'main':
main.c:10:31: error: expected ')' before ';' token
10 | (scanf("%d %d", &n, &r);
| ~ ^
| )
main.c:38:33: error: expected ';' before '}' token
38 | printf("%d\n", card[0]);
| ^
| ;
39 |
40 | }
| ~
|
s812269509 | p00710 | C | #include <stdio.h>
int main()
{
????int i, j, n, r, q, N, R;
????int d[51], sd[51];
????while(1)
????????{
????????????for ( i = 0; i < 51; i++)
????????{
????????????d[i] = 0;
????????????sd[i] = 0;
????????}
????????????scanf("%d %d", &N, &R);
????????????if ( N == 0 && R == 0 ) return 0;
????????????for ( i = 1; i <= N; i++)
????????{
????????????d[i] = N - i + 1;
????????}
????????????for ( i = 1; i <= R; i++)
????????{
????????????scanf("%d %d", &n, &r);
????????????q = n;
????????????for( j = 1; j <= r; j++, n++)
????????????????{
????????????????????sd[j] = d[n];
????????????????}
????????????for ( j = 0; j < n - 1; j++)
????????????????{
????????????????????d[q+r-1] = d[q-1];
????????????????????q--;
????????????????}
????????????for( j = 1; j <= r; j++)
????????????????{
????????????????????d[j] = sd[j];
????????????????}
????????}
????????????printf("%d\n", d[1]);
????????}
????return 0;
} | main.c: In function 'main':
main.c:4:1: error: expected expression before '?' token
4 | ????int i, j, n, r, q, N, R;
| ^
main.c:5:1: error: expected expression before '?' token
5 | ????int d[51], sd[51];
| ^
main.c:6:1: error: expected expression before '?' token
6 | ????while(1)
| ^
|
s254988062 | p00710 | C | #include<stdio.h>
int main(void)
{
int n,r;
int p = 0;
int c = 0;
int a[50] = {0};
int b[50] = {0};
int i,j;
while(1){
scanf("%d %d",&n,&r);
if(n == 0 &&r == 0)
break;
for(i = 0;i < n;i++){
a[i] = n - i;
}
for(i = 0;i < r;i++){
scanf("%d %d",&p,&c);
for(j = 0;j < c;j++){
b[j] = a[p-1+j];
}
for(j = 0;j < p-1;k++){
b[c+j] = a[j];
}
for(j = 0;j < n-p-c+1;j++){
b[p+c+j-1]= a[p+c+j-1];
}
for(j = 0;j < n;j++){
a[j] = b[j];
}
}
printf("%d\n",a[0]);
}
return 0;
}
| main.c: In function 'main':
main.c:28:25: error: 'k' undeclared (first use in this function)
28 | for(j = 0;j < p-1;k++){
| ^
main.c:28:25: note: each undeclared identifier is reported only once for each function it appears in
|
s628510972 | p00710 | C | #include <stdio.h>
int main(){
int n, r, p, c, i;
while( true ){
int N[50];
scanf("%d %d", &n, &r);
if( n == 0 && r == 0) break;
//1からnまで順に積み上げる
for( i = 0; i < n; i++){
N[i] = n-i;
}
//カット操作
for( ; r > 0; r--){
scanf("%d %d", &p, &c);
int copy[50];
for( i = 0; i < p-1+c; i++){
copy[i] = N[i];
}
for( i = 0; i < p-1+c; i++){
if( i < c){
N[i] = copy[p-1+i];
}else{
N[i] = copy[i-c];
}
}
}
printf("%d\n", N[0]);
}
return 0;
} | main.c: In function 'main':
main.c:6:16: error: 'true' undeclared (first use in this function)
6 | while( true ){
| ^~~~
main.c:2:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
1 | #include <stdio.h>
+++ |+#include <stdbool.h>
2 |
main.c:6:16: note: each undeclared identifier is reported only once for each function it appears in
6 | while( true ){
| ^~~~
|
s177395801 | p00710 | C | include<stdio.h>
int n,m;
int p,c;
int s[50],dist[50];
int main(){
int i,j;
while(1){
scanf("%d%d",&n,&m);
if(n==0&&m==0)
break;
for(i=0;i<n;i++){
s[i]=i+1;
}
for(i=0;i<m;i++){
scanf("%d%d",&p,&c);
p--;
for(j=0;j<c;j++){
dist[j] = s[j+p];
}
for(j=0;j<p;j++){
s[j+c] = s[j];
}
for(j=0;j<c;j++){
s[j] = dist[j];
}
}
}
printf("%d\n",s[0]);
return 0;
} | main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
1 | include<stdio.h>
| ^
main.c: In function 'main':
main.c:10:1: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
10 | scanf("%d%d",&n,&m);
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | include<stdio.h>
main.c:10:1: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
10 | scanf("%d%d",&n,&m);
| ^~~~~
main.c:10:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:10:15: error: 'n' undeclared (first use in this function)
10 | scanf("%d%d",&n,&m);
| ^
main.c:10:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:10:18: error: 'm' undeclared (first use in this function)
10 | scanf("%d%d",&n,&m);
| ^
main.c:32:1: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
32 | printf("%d\n",s[0]);
| ^~~~~~
main.c:32:1: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:32:1: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:32:1: note: include '<stdio.h>' or provide a declaration of 'printf'
|
s349920053 | p00710 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main()
{
int n, r, p, c;
while (true) {
cin >> n >> r;
if (n == 0 && r == 0) break;
vector<int> cards;
for (int i = 1; i <= n; i++) {
cards.push_back(i);
}
for (; r > 0; r--) {
cin >> p >> c;
p = n - p - c + 1;
for (; c > 0; c--) {
cards.push_back(cards[p]);
cards.erase(cards.begin() + p);
}
}
cout << cards.back() << '\n';
}
return 0; | a.cc: In function 'int main()':
a.cc:28:18: error: expected '}' at end of input
28 | return 0;
| ^
a.cc:6:1: note: to match this '{'
6 | {
| ^
|
s859112018 | p00710 | C++ | #include <stdio.h>
#include <stdlib.h>
void shuffle(int *card,int p,int c);
int main(void){
int i,j,n,r,p,c;
int *card;
while(1){
x = scanf("%d %d",&n,&r);
if((n == 0) && (r == 0)){
break;
}
card = (int *)calloc(n,sizeof(int));
if(card == NULL){
printf("メモリが確保できません\n");
return -1;
}
for(i = 0;i < n; i++){
card[i] = n - i;
}
for(i = 0;i < r; i++){
scanf("%d %d",&p,&c);
shuffle(card,p,c);
}
printf("%d\n",card[0]);
free(card);
}
return 0;
}
void shuffle(int *card,int p,int c){
int box[50],i;
for(i = 0; i < c; i++){
box[i] = card[p + i - 1];
}
for(i = 0; i < p; i++){
card[p - 2 + c - i] = card[p - 2 - i];
}
for(i = 0; i < c; i++){
card[i] = box[i];
}
} | a.cc: In function 'int main()':
a.cc:11:17: error: 'x' was not declared in this scope
11 | x = scanf("%d %d",&n,&r);
| ^
|
s825692247 | p00710 | C++ | #include<vector>
#include<algorithm>
using namespace std;
vector<int>card;
void cut(int p,int c){
vector<int>res;
for(int i=p;i<p+c;i++)res.push_back(card[i]);
for(int i=0;i<p;i++)res.push_back(card[i]);
for(int i=p+c;i<card.size();i++)res.push_back(card[i]);
card=res;
}
int main(void){
int n,r;
while(cin >> n >> r, n|r){
card.resize(n);
for(int i=0;i<n;i++)card[i]=n-i;
int p,c;
for(int i=0;i<r;i++){
cin >> p >> c;
cut(p-1,c);
}
cout << card[0] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:19:9: error: 'cin' was not declared in this scope
19 | while(cin >> n >> r, n|r){
| ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
2 | #include<algorithm>
+++ |+#include <iostream>
3 |
a.cc:28:5: error: 'cout' was not declared in this scope
28 | cout << card[0] << endl;
| ^~~~
a.cc:28:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:28:24: error: 'endl' was not declared in this scope
28 | cout << card[0] << endl;
| ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
2 | #include<algorithm>
+++ |+#include <ostream>
3 |
|
s127683750 | p00710 | C++ | #include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#define pi 3.14159
using namespace std;
int main() {
int n, r;
while(cin >> n >> r) {
if(n == 0 && r == 0) break;
int a[50], b[50];
for(int i = 0; i < n; i++) {
a[i] = n - i;
}
for(int i = 0; i < n; i++) {
b[i] = n - i;
}
for (int i = 0; i < r; i++) {
int p, c;
cin >> p >> c;
for(int j = 0; j < c; j++) {
b[j] = a[p + j - 1];
}
for(int j = 0; j < p - 1; j++) {
b[c + j] = a[j];
}
for(int j = 0; j < n; j++) {
a[j] = b[j];
}
cout << b[0] <<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:39:2: error: expected '}' at end of input
39 | }
| ^
a.cc:10:12: note: to match this '{'
10 | int main() {
| ^
|
s216249560 | p00710 | C++ | #include <stdio.h>
#include <string.h>
void shuffle(int card[50],int p,int c){
int d[50],i;
memcpy(d,card.50 * sizeof(int));
for(i = 0;i < c;i++){
d[i] = card[p - 1 + i];
}
for(i = 0; i < p - 1;i++){
d[c + i] = card[i];
}
memcpy(card,d,50 * sizeof(int));
}
int main(void){
int n,r,p,c,i,card[50];
while(1){
scanf("%d %d",&n,&r);
if(n == 0 && r == 0) break;
for(i = 0; i < n;i++){
card[i] = i;
}
for(i = 0;i < n; i++){
scanf("%d %d",&p,&c);
shuffle(card,p,c);
}
printf("%d\n",(n + 1 - card[0]));
}
return 0;
}
| a.cc: In function 'void shuffle(int*, int, int)':
a.cc:6:22: error: expected ')' before numeric constant
6 | memcpy(d,card.50 * sizeof(int));
| ~ ^~~
| )
a.cc:6:15: error: too few arguments to function 'void* memcpy(void*, const void*, size_t)'
6 | memcpy(d,card.50 * sizeof(int));
| ~~~~~~^~~~~~~~~~
In file included from a.cc:2:
/usr/include/string.h:43:14: note: declared here
43 | extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
| ^~~~~~
|
s154730128 | p00710 | C++ | #include <iostream>
#include <vector>
using namespace std;
int N, R, p, c;
int main() {
while (cin >> N >> R && N) {
vector <int> A(N,0);
for (int i = 0; i < N; ++i) A[i] = N - i;
for (int i = 0; i < R; ++i) {
cin >> p >> c;
rotate(A.begin(), A.begin()+p-1,A.begin()+c+p-1);
}
cout << A[0] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:11:13: error: 'rotate' was not declared in this scope
11 | rotate(A.begin(), A.begin()+p-1,A.begin()+c+p-1);
| ^~~~~~
|
s227495392 | p00710 | C++ | #include <iostream>
#include <vector>
using namespace std;
int N, R, p, c;
int main() {
while (cin >> N >> R && N) {
vector <int> A(N,0);
for (int i = 0; i < N; ++i) A[i] = N - i;
for (int i = 0; i < R; ++i) {
cin >> p >> c;
rotate(A.begin(), A.begin()+p-1,A.begin()+c+p-1);
}
cout << A[0] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:11:13: error: 'rotate' was not declared in this scope
11 | rotate(A.begin(), A.begin()+p-1,A.begin()+c+p-1);
| ^~~~~~
|
s990391436 | p00710 | C++ | int main(){
int n,k;
while(1){
cin >> n >> k;
if(n==0&&k==0) break;
vector<int> card(n+1,0);
for(int i=1;i<n+1;++i) card[i]=n-i+1;
//for(int i=1;i<n+1;++i){
//cout << card[i] << endl;
//}
for(int i=0;i<k;++i){
int p,c;
cin >> p >> c;
rotate(card.begin()+1,card.begin()+p,card.begin()+p+c);
for(int j=1;j<n+1;++j){
//cout << card[j] << endl;
}
}
cout << card[1] << endl;
}
} | a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
4 | cin >> n >> k;
| ^~~
a.cc:6:5: error: 'vector' was not declared in this scope
6 | vector<int> card(n+1,0);
| ^~~~~~
a.cc:6:12: error: expected primary-expression before 'int'
6 | vector<int> card(n+1,0);
| ^~~
a.cc:7:28: error: 'card' was not declared in this scope
7 | for(int i=1;i<n+1;++i) card[i]=n-i+1;
| ^~~~
a.cc:16:14: error: 'card' was not declared in this scope
16 | rotate(card.begin()+1,card.begin()+p,card.begin()+p+c);
| ^~~~
a.cc:16:7: error: 'rotate' was not declared in this scope
16 | rotate(card.begin()+1,card.begin()+p,card.begin()+p+c);
| ^~~~~~
a.cc:21:5: error: 'cout' was not declared in this scope
21 | cout << card[1] << endl;
| ^~~~
a.cc:21:13: error: 'card' was not declared in this scope
21 | cout << card[1] << endl;
| ^~~~
a.cc:21:24: error: 'endl' was not declared in this scope
21 | cout << card[1] << endl;
| ^~~~
|
s286889631 | p00710 | C++ | #include <iostream>
using namespace std;
int n,r;
int main(){
while(1){
cin >> n >> r;
if ((n == 0)&&(r == 0)){
break;
}
int A[n];
for (int i = 0; i <= n-1; i++){
A[i] = n-i;
//cout << A[i] << endl;
}
int p,c;
for (int i = r; i >=1; i--){
cin >> p >> c;
int M[p-1];
int N[c];
for (int i = 0; i <= p-2; i++){
M[i] = A[i];
}
for (int i = 0; i <= c-1; i++){
N[i] = A[p-1+i];
}
//??????
???????????????for (int i = 0; i <= c-1; i++){
A[i] = N[i];
}
for (int i = 0; i <= p-2; i++){
A[c+i] = M[i];
}
if(i == 1){
cout << A[0] << endl;
}
}
}
} | a.cc: In function 'int main()':
a.cc:34:1: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:2: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:3: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:4: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:5: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:6: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:7: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:8: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:9: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:10: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:11: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:12: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:13: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:14: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:15: error: expected primary-expression before '?' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:16: error: expected ':' before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
| :
a.cc:34:16: error: expected primary-expression before 'for'
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^~~
a.cc:34:45: error: expected ';' before ')' token
34 | ???????????????for (int i = 0; i <= c-1; i++){
| ^
| ;
|
s791047430 | p00710 | C++ | #include <iostream>
#include <deque>
#include <vector>
using namespace std;
int main( void ){
vector< int > result;
deque< int > card;
while( true ){
int n, r;
cin >> n >> r;
if( n == 0 && r == 0 )
break;
for( int i = 1; i < n + 1; i++ ){
card.push_front( i );
}
for( int i = 0; i < r; i++ ){
int p, c;
cin >> p >> c;
for( auto itr = card.begin(); itr != card.end(); ++itr ){
if( ( *itr ) =< p ){
int temp = ( *itr );
card.erase( itr );
card.push_front( temp );
}
}
}
result.push_back( card.front() );
}
for( auto itr = result.begin(); itr != result.end(); ++itr ){
cout << ( *itr ) << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:22:47: error: expected primary-expression before '<' token
22 | if( ( *itr ) =< p ){
| ^
|
s768289590 | p00710 | C++ | #include <iostream>
#include <deque>
#include <vector>
using namespace std;
int main( void ){
vector< int > result;
deque< int > card;
while( true ){
int n, r;
cin >> n >> r;
if( n == 0 && r == 0 )
break;
for( int i = 1; i < n + 1; i++ ){
card.push_front( i );
}
for( int i = 0; i < r; i++ ){
int p, c;
cin >> p >> c;
for( auto itr = card.begin(); itr != card.end(); ++itr ){
if( ( *itr ) =< p ){
int temp = ( *itr );
card.erase( itr );
card.push_front( temp );
}
}
}
result.push_back( card.front() );
}
for( auto itr = result.begin(); itr != result.end(); ++itr ){
cout << ( *itr ) << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:22:47: error: expected primary-expression before '<' token
22 | if( ( *itr ) =< p ){
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.