submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| language
stringclasses 3
values | code
stringlengths 1
522k
| compiler_output
stringlengths 43
10.2k
|
|---|---|---|---|---|
s861137415
|
p03979
|
C++
|
#include "bits/stdc++.h"
using namespace std;
//諸機能
#pragma region MACRO
#define putans(x) std::cerr << "answer: " ; cout << (x) << endl
#define dputans(x) std::cerr << "answer: "; cout << setprecision(13) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define put ifs >>
#else //ジャッジシステムでいい感じにやる
#define put cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "="; rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;}
#ifndef _DEBUG
#define dbg1 {}
#define dbg2 {}
#define dbg3 {}
#define dbgArray {}
#endif
#pragma endregion
//typedef(書き換える、書き足す可能性ある)
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e9)
#pragma endregion
class Point {//幾何上のべクトル
public:
double x, y;
Point(double x = 0, double y = 0) : x(x), y(y) {}
Point operator + (Point p) { return Point(x + p.x, y + p.y); }
Point operator - (Point p) { return Point(x - p.x, y - p.y); }
Point operator * (double a) { return Point(x * a, y * a); }
double operator * (Point p) { return dot(p); }
Point operator / (double a) { return Point(x / a, y / a); }
double abs() { return sqrt(norm()); }
double norm() { return x*x + y*y; }
bool operator < (const Point &p) const { return x != p.x ? x < p.x : y < p.y; }
bool operator == (const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; }
//内積、外積
double dot(Point p) { return x * p.x + y * p.y; }
double cross(Point p) { return x * p.y - y * p.x; }
};
class Circle {
public:
Point c;
double r;
Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {}
};
struct Segment {//線分
Point p1, p2;
};
typedef Point Vector;
typedef Segment Line;//直線
typedef vector<Point> Polygon;
double v_norm(Point p) { return p.x * p.x + p.y * p.y; }
double abs(Point p) { return v_norm(p); }
double dot(Point p, Point q) { return p.x * q.x + p.y * q.y; }
double cross(Point p, Point q) { return q.x * p.y - p.y * p.x; }
//直行、並行
bool isOrthogonal(Vector a, Vector b) { return equals(a*b, 0.0); }
bool isParallel(Vector a, Vector b) { return equals(cross(a, b), 0.0); }
//線分sに対する点pの射影
Point projection(Segment s, Point p) {
Vector base = s.p2 - s.p1;
double r = dot(( p - s.p1 ), base) / v_norm(base);
return s.p1 + base*r;
}
//線分sに対する点pの反射
Point reflection(Segment s, Point p) { return p + ( projection(s, p) - p ) * 2; }
//double getDistance(Point a, Point b) { return ( a - b ).abs; }
//double getDistanceLP(Line l, Point p) { return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1)); }
//double getDistanceSP(Segment s, Point p) {
// if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return abs(p - s.p1);
// if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return abs(p - s.p2);
//}
//double getDistance(Segment s1, Segment s2) {
// if (intersect(s1, s2)) return 0;
// return min(min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2))
// , min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2));
//}
//p1-p0を基準として p2-p0 の2ベクトルについて
static const int COUNTER_CLOCKWISE = 1;//反時計回り
static const int CLOCKWISE = -1;//時計回り
static const int ONLINE_BACK = 2;//同一直線状p2,p0,p1の順
static const int ONLINE_FRONT = 1;//同一直線上p0,p1,p2の順
static const int ON_SEGMENT = 0;//p2がp0,p1上にある場合
int ccw(Point p0, Point p1, Point p2) {//上記の分類関数
Vector a = p1 - p0;
Vector b = p2 - p0;
if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
if (cross(a, b) < EPS) return CLOCKWISE;
if (dot(a, b) < -EPS) return ONLINE_BACK;
if (v_norm(a) < v_norm(b)) return ONLINE_FRONT;
return ON_SEGMENT;
}
////線分p1p2とp3p4の交差判定
//bool intersect(Point p1, Point p2, Point p3, Point p4) {return ( (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0) && (ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0));}
//bool intersect(Segment s1, Segment s2) {return intersect(s1.p1 , s1.p1, s2.p1, s2.p2);}
//
//Point getCrossPoint(Segment s1, Segment s2) {
// Vector base = s2.p2 - s2.p1;
// double d1 = abs(cross(base , s1.p1 - s2.p1));
// double d2 = abs(cross(base , s1.p2 - s2.p1));
// double t = d1 / ( d1 + d2 );
// return s1.p1 + (s1.p2 - s1.p1 ) * t;
//}
//
////直線と円の交点を調べる
//pair<Point, Point> getCrossPoints(Circle c, Line l) {
// //assert(intersect(c, i)); 交差しない場合についてのはず
// Vector pr = projection(c, l);
// Vector e = ( l.p2 - l.p1 ) / abs(l.p2 - l.p1);
// double base = sqrt(c.r * c.r - norm(pr - c.c));
// return mp(pr + e * base, pr - e * base);
//}
//
////点の内包を調べる
//static const int IN_POLYGON = 2;//多角形の内部
//static const int OUT_POLYGON = 1;//多角形の外部
//static const int ON_POLYGON = 0;//多角形の線分上
//int contains(Polygon g, Point p) {
// int n = g.size();
// bool x = false;
// rep(i, n) {
// Point a = g[i] - p, b = g[( i + 1 ) % n] - p;
// if (abs(cross(a, b)) < EPS && dot(a, b) < EPS) return OUT_POLYGON;
// if (a.y > b.y) swap(a, b);
// if (a.y < EPS && EPS < b.y && cross(a, b)) x = !x;
// }
// return ( x ? IN_POLYGON : ON_POLYGON );
//}
//凸包
Polygon ConvexHull(Polygon s) {
Polygon u, l;
if (s.size() < 3) return s;
sort(all(s));
u.push_back(s[0]);
u.push_back(s[1]);
l.push_back(s[s.size() - 1]);
l.push_back(s[s.size() - 2]);
for (int i = 2; i < s.size(); i++) {
for (int n = u.size(); n >= 2 && ccw(u[n - 2], u[n - 1], s[i]) != CLOCKWISE; n--)u.pop_back();
u.push_back(s[i]);
}
for (int i = s.size()-3; i >= 0; i--) {
for (int n = l.size(); n >= 2 && ccw(l[n - 2], l[n - 1], s[i]) != CLOCKWISE; n--)l.pop_back();
l.push_back(s[i]);
}
reverse(all(l));
for (int i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);
return l;
}
/*
#define i(x) int x; scanf("%d",&x);
#define l(x) ll x; scanf("%lld",&x);
#define d(x) double x; scanf("%lf",&x);
*/
//今度実装がんばる
//https://www23.atwiki.jp/akitaicpc/pages/65.html
int main() {
/*double xp1, yp1, xp2, yp2; put xp1 >> yp1 >> xp2 >> yp2;
Segment s;
s.p1 = Point(xp1, yp1);
s.p2 = Point(xp2, yp2);
int n; put n;
rep(i, n) {
Point p;
put p.x >> p.y;
Point prj =reflection(s, p);
cout << setprecision(13) << prj.x << " " << prj.y << endl;
}*/
//テンプレート化を来世に考える
auto getI = [&]()->auto { int tmp; put tmp; return tmp; };
auto getLL = [&]()->auto { ll tmp; put tmp; return tmp; };
auto getS = [&]()->auto { string tmp; put tmp; return tmp; };
Polygon sheep;
Polygon convex_sheep;
int h, w; put h >> w;
rep(i, h) {
string s; put s;
rep(j, s.size()) {
if (s[j] == 'X') {
if (i == 0 || j == 0) {
putans(-1);
goto END;
}
sheep.push_back(Point(i, j));
}
}
}
convex_sheep = ConvexHull(sheep);
int num = 0;
rep(i, convex_sheep.size()) {
Point s = convex_sheep[i % convex_sheep.size()];
Point g = convex_sheep[(i + 1) % convex_sheep.size()];
int mandist = abs(s.x - g.x) + abs(s.y - g.y);
num += mandist;
}
putans(num);
END:
return 0;
}
//
//int n, a, b; put n >> a >> b;
// vi t;
// rep(i, n) {
// t.push_back(get());
// }
// int count = 0;
// rep(i, n) {
// if (t[i] < a || b <= t[i])count++;
// }
// putans(count);
//
// set<string> list;
// int ans = 0;
// int n; put n;
// int k; put k;
// int numAlphabet[26];
// fill(all(numAlphabet), 0);
// rep(i, n) {
// string s; put s;
// if (exist(list, s))continue;
// list.insert(s);
// numAlphabet[s[0] - 'A']++;
// }
// sort(all(numAlphabet),greater<int>());
// while (true) {
// rep(i, k) {
// if (numAlphabet[i] == 0) goto END;
// else numAlphabet[i]--;
// }
// sort(all(numAlphabet), greater<int>());
// ans++;
// }
//END:
// putans(ans);
//int t; put t;
//rep(i, t) {
// int n, d; put n >> d;
// if (n == 1) {
// putans(d);
// continue;
// }
// putans(n % 2 != 0 ? ( n - 1 ) * 127 + d : ( n - 1 ) * 127 + ( 127 ^ d ));
//}
//
//int n; put n;
//string s1, s2;
//string r;
//string patan1[4] = { ".","#",".","#" };
//string patan2[4] = { ".",".","#","#" };
//bool front = true;
//rep(j, 420 / 4) {
// if (front) {
// rep(i, 4) {
// cout << s1 + patan1[i] + "\n" << s2 + patan2[i] << endl;
// cin >> r;
// if (r == "T") {
// s1 += patan1[i];
// s2 += patan2[i];
// break;
// }
// if (r == "F" && i == 3) {
// front = !front;
// }
// if (r == "end")goto END;
// }
// }
// else {
// rep(i, 4) {
// cout << patan1[i] + s1 + "\n" << patan2[i] + s2 << endl;
// cin >> r;
// if (r == "T") {
// s1 = patan1[i] + s1;
// s2 = patan2[i] + s2;
// break;
// }
// if (r == "F" && i == 3) {
// front = !front;
// }
// if (r == "end")goto END;
// }
// }
//
//}
//END:
//cout << endl;
|
a.cc:32:9: warning: "dbg2" redefined
32 | #define dbg2 {}
| ^~~~
a.cc:27:9: note: this is the location of the previous definition
27 | #define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
| ^~~~
a.cc:33:9: warning: "dbg3" redefined
33 | #define dbg3 {}
| ^~~~
a.cc:28:9: note: this is the location of the previous definition
28 | #define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
| ^~~~
a.cc:34:9: warning: "dbgArray" redefined
34 | #define dbgArray {}
| ^~~~~~~~
a.cc:29:9: note: this is the location of the previous definition
29 | #define dbgArray(a,n) {std::cerr << (#a) << "="; rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;}
| ^~~~~~~~
a.cc: In function 'int main()':
a.cc:252:1: error: jump to label 'END'
252 | END:
| ^~~
a.cc:237:46: note: from here
237 | goto END;
| ^~~
a.cc:244:13: note: crosses initialization of 'int num'
244 | int num = 0;
| ^~~
|
s706869304
|
p03979
|
C++
|
// In the name of God
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)
const int N = (int) 2e5 + 5, mod = (int) 0, oo = 1e9 + 9;
int n, m, mark[N], to[N], head[N], prev[N], cap[N], cnt = 0;
string mat[N];
int f(int i, int j) { return i * m + j; }
bool outer(int i, int j) {
return (i == 0 || j == 0 || i == n - 1 || j == m - 1);
}
void add_edge(int u, int v, int uv) {
to[cnt] = v, cap[cnt] = uv, prev[cnt] = head[u], head[u] = cnt++;
to[cnt] = u, cap[cnt] = +0, prev[cnt] = head[v], head[v] = cnt++;
}
int dfs(int v, int sink, int flow = oo) {
if (mark[v]++) return 0;
if (v == sink) return flow;
for (int e = head[v]; e != -1; e = prev[e]) {
int u = to[e];
if (cap[e]) {
int x = dfs(u, sink, min(flow, cap[e]));
if (x > 0) {
cap[e ^ 0] -= x;
cap[e ^ 1] += x;
return x;
}
}
}
return 0;
}
int max_flow(int source, int sink) {
int res = 0;
while (true) {
memset(mark, 0, sizeof mark);
int x = dfs(source, sink);
if (!x) break;
res += x;
}
return res;
}
int dx[] = {0, -1, 0, 1};
int dy[] = {1, 0, -1, 0};
int32_t main() {
memset(head, -1, sizeof head);
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 0; i < n; ++i)
cin >> mat[i];
int sink = N - 1, source = N - 2;
for (int i = 0; i < n; ++i)
for (int j = 0; j < m; ++j) {
for (int d = 0; d < 4; ++d) {
int x = i + dx[d], y = j + dy[d];
if (x >= 0 && y >= 0 && x < n && y < m) {
add_edge(f(i, j) << 1 | 1, f(x, y) << 1, oo);
}
}
if (mat[i][j] == 'X')
add_edge(source, f(i, j) << 1, oo);
add_edge(f(i, j) << 1, f(i, j) << 1 | 1, 1 + oo * (mat[i][j] == 'X'));
if (outer(i, j)) {
if (mat[i][j] == 'X') {
cout << -1 << endl;
return 0;
}
add_edge(f(i, j) << 1 | 1, sink, oo);
}
}
cout << max_flow(source, sink) << endl;
}
|
a.cc: In function 'void add_edge(int, int, int)':
a.cc:31:33: error: reference to 'prev' is ambiguous
31 | to[cnt] = v, cap[cnt] = uv, prev[cnt] = head[u], head[u] = cnt++;
| ^~~~
In file included from /usr/include/c++/14/string:47,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:3:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:24:36: note: 'int prev [200005]'
24 | int n, m, mark[N], to[N], head[N], prev[N], cap[N], cnt = 0;
| ^~~~
a.cc:32:33: error: reference to 'prev' is ambiguous
32 | to[cnt] = u, cap[cnt] = +0, prev[cnt] = head[v], head[v] = cnt++;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:24:36: note: 'int prev [200005]'
24 | int n, m, mark[N], to[N], head[N], prev[N], cap[N], cnt = 0;
| ^~~~
a.cc: In function 'int dfs(int, int, int)':
a.cc:37:40: error: reference to 'prev' is ambiguous
37 | for (int e = head[v]; e != -1; e = prev[e]) {
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
244 | prev(_BidirectionalIterator __x, typename
| ^~~~
a.cc:24:36: note: 'int prev [200005]'
24 | int n, m, mark[N], to[N], head[N], prev[N], cap[N], cnt = 0;
| ^~~~
|
s930848762
|
p03980
|
C++
|
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <cctype>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;
typedef string::const_iterator State;
int q;
string str;
P expression(State &begin,int l,int r);
P term(State &begin,int l,int r);
P term(State &begin,int l,int r){
if(isdigit(*begin)){
if(*begin=='0'){
begin++;
return P(0,begin-str.begin()-1);
}
P ret=P(-2,0);
if(*begin>r){
ret=P(r+1,begin-str.begin());
}
if((a>(*begin-'0')*10+9)){
ret=P(l-1,begin-str.begin());
}
int v=0;
while(isdigit(*begin)){
v*=10;
v+=*begin-'0';
begin++;
}
if(ret.first==-2){
if(v>=10)ret=P(v,begin-str.begin()-1);
else ret=P(v,begin-str.begin()-1);
}
return ret;
}else{
return expression(begin,l,r);
}
}
P expression(State &begin,int l,int r){
if(isdigit(*begin))return term(begin,l,r);
int z=0;
if(*begin=='^')z=1;
begin+=2;
P tmp=term(a,b);
P ret=P(-2,-2);
if(z==0 && tmp.first==0)ret=tmp;
if(z==1 && tmp.first==99)ret=tmp;
if(tmp.first!=-1 && z==0 && a>tmp.first)ret=tmp;
if(tmp.first!=-1 && z==1 && b<tmp.first)ret=tmp;
begin++;
int L=l;
int R=r;
if(z==0){
if(tmp.first!=-1)R=min(R,tmp.first-1);
}else{
if(tmp.first!=-1)L=max(L,tmp.first+1);
}
P tmp2=term(L,R);
if(tmp.first==-1 && z==0)tmp.first=110;
if(tmp2.first==-1 && z==0)tmp2.first=110;
if(ret.first==-2){
if(z==0)ret.first=min(tmp.first,tmp2.first);
else ret.first=max(tmp.first,tmp2.first);
ret.second=tmp2.second;
}
begin++;
return ret;
}
int main(void){
scanf("%d",&q);
for(int i=0;i<q;i++){
cin >> str;
State begin=str.begin();
P res=expression(begin,0,99);
printf("%d %d\n",res.first,res.second+1);
}
return 0;
}
|
a.cc: In function 'P term(State&, int, int)':
a.cc:36:21: error: 'a' was not declared in this scope
36 | if((a>(*begin-'0')*10+9)){
| ^
a.cc: In function 'P expression(State&, int, int)':
a.cc:60:20: error: 'a' was not declared in this scope
60 | P tmp=term(a,b);
| ^
a.cc:60:22: error: 'b' was not declared in this scope
60 | P tmp=term(a,b);
| ^
a.cc:74:21: error: invalid initialization of reference of type 'State&' {aka 'std::__cxx11::basic_string<char>::const_iterator&'} from expression of type 'int'
74 | P tmp2=term(L,R);
| ^
a.cc:26:15: note: in passing argument 1 of 'P term(State&, int, int)'
26 | P term(State &begin,int l,int r){
| ~~~~~~~^~~~~
|
s713014454
|
p03980
|
Java
|
import java.io.*;
import java.math.*;
import java.util.*;
import static java.util.Arrays.*;
public class F_X {
private static final int mod = (int)1e9+7;
final Random random = new Random(0);
final IOFast io = new IOFast();
/// MAIN CODE
public void run() throws IOException {
int TEST_CASE = Integer.parseInt(new String(io.nextLine()).trim());
// int TEST_CASE = 1;
while(TEST_CASE-- != 0) {
cs = io.next();
tokenize();
root = new Tree(new ArrayDeque<String>(token));
// root.dumpT();
if(Character.isDigit(token.get(0).charAt(0))) {
io.out.println(Integer.parseInt(token.get(0)) + " " + (token.get(0).length() + 1));
} else {
ParseResult r = root.eval();
// dump(r.value, r.len, r.len2);
io.out.println(r.value + " " + r.len);
}
}
}
char[] cs;
List<String> token = new ArrayList<>();
void tokenize() {
token.clear();
for(int i = 0; i < cs.length; ) {
if("^_(),?".indexOf(cs[i]) >= 0) {
token.add(new String(cs, i++, 1));
} else {
String s = "";
for(int j = 0; j < 2; j++) {
if(!Character.isDigit(cs[i])) {
break;
}
s += cs[i++];
}
token.add(s);
}
}
}
static class Tree {
Tree l, r;
String ope;
String val;
boolean isNum;
int len;
void dumpT() {
dump(isNum, ope, val, len);
if(!isNum) {
l.dumpT();
r.dumpT();
}
}
int val() { return Integer.parseInt(val); }
public Tree(Queue<String> token) {
String s = token.poll();
if("^_(),?".indexOf(s) >= 0) {
ope = s;
token.poll();
l = new Tree(token);
token.poll();
r = new Tree(token);
token.poll();
len = 1 + 1 + l.len + 1 + r.len + 1;
isNum = false;
} else {
val = s;
len = val.length();
isNum = true;
}
}
boolean max() {
return ope == null || ope.equals("^");
}
ParseResult eval() {
return eval(0, 99, 0, false);
}
ParseResult eval(int alpha, int beta, int minimize, boolean rhs) {
if(alpha == beta) return new ParseResult(alpha, 0, len);
if(isNum) {
if(minimize == 1) {
if(alpha >= (val.charAt(0)-'0')*10+9) {
// if(val.charAt(0)-'0' >= beta) {
return new ParseResult(alpha, 1, len);
}
if(rhs && val.charAt(0)-'0' >= beta) {
// if(alpha >= (val.charAt(0)-'0')*10+9) {
return new ParseResult(beta, 1, len);
}
return new ParseResult(Math.min(val(), beta), val() == 0 ? 1 : 2, len);
} else {
if(val.charAt(0)-'0' >= beta) {
// if(alpha >= (val.charAt(0)-'0')*10+9) {
return new ParseResult(beta, 1, len);
}
if(rhs && alpha >= (val.charAt(0)-'0')*10+9) {
// if(alpha >= (val.charAt(0)-'0')*10+9) {
return new ParseResult(alpha, 1, len);
}
return new ParseResult(Math.max(val(), alpha), 2, len);
}
}
if(ope.equals("^")) {
// max
ParseResult resL = l.eval(alpha, beta, -1, false);
resL.value = Math.min(resL.value, beta);
if(resL.value >= beta) {
resL.len += "^(".length();
resL.len2 = len;
return resL;
}
ParseResult resR;
resR = r.eval(resL.value, beta, -1, true);
// dump(l, r);
return new ParseResult(resR.value, "^(,".length() + resL.len2 + resR.len, len);
} else {
ParseResult resL = l.eval(alpha, beta, 1, false);
resL.value = Math.max(resL.value, alpha);
if(alpha >= resL.value) {
resL.len += "^(".length();
resL.len2 = len;
return resL;
}
ParseResult resR;
resR = r.eval(alpha, resL.value, 1, true);
// dump(resL, resR);
return new ParseResult(resR.value, "^(,".length() + resL.len2 + resR.len, len);
}
}
}
static
class ParseResult {
int value;
int len;
int len2;
public ParseResult(int v, int l, int l2) {
value = v;
len = l;
len2 = l2;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return String.format("ParseResult: %d %d %d", value, len, len2);
}
}
Tree root;
/*
int ans;
char[] cs;
ParseResult eval(Tree t) {
if(t.ope.equals("^")) {
// max
ParseResult l = max(t.l, 0, false);
ParseResult r = max(t.r, l.value, true);
dump(l, r);
return new ParseResult(r.value, "^(,".length() + l.len2 + r.len, t.len);
} else {
ParseResult l = min(t.l, 0, 99, false);
ParseResult r = min(t.r, 0, l.value, true);
dump(l, r);
return new ParseResult(r.value, "^(,".length() + l.len2 + r.len, t.len);
}
}
ParseResult min(Tree t, int l, int r) {
if(cont && val == 0) return new ParseResult(0, -1, 0);
if(t.isNum) {
if((t.val.charAt(0)-'0')*10+9 <= l) {
return new ParseResult(val, 1, t.len);
} else if(t.val.charAt(0)-'0' >= r) {
return new ParseResult(r, 1, t.len);
} else {
return new ParseResult(Math.min(t.val(), r), 2, t.len);
}
}
if(t.ope.equals("^")) {
// max
ParseResult l = max(t.l, val, cont);
// if(l.value >= val) new ParseResult(val, "^(".length() + l.len, t.len);
ParseResult r = max(t.r, l.value, true);
return new ParseResult(r.value, "^(,".length() + l.len2 + r.len, t.len);
} else {
ParseResult l = min(t.l, val, cont);
ParseResult r = min(t.r, l.value, true);
return new ParseResult(r.value, "^(,".length() + l.len2 + r.len, t.len);
}
}
ParseResult max(Tree t, int val, boolean cont) {
if(cont && val == 99) return new ParseResult(99, -1, 0);
if(t.isNum) {
if(!cont) {
return new ParseResult(t.val(), t.len, t.len);
} else if((t.val.charAt(0)-'0')*10+9 <= val) {
return new ParseResult(val, 1, t.len);
} else {
return new ParseResult(Math.max(t.val(), val), 2, t.len);
}
}
if(t.ope.equals("^")) {
// max
ParseResult l = max(t.l, val, cont);
ParseResult r = max(t.r, l.value, true);
return new ParseResult(r.value, "^(,".length() + l.len2 + r.len, t.len);
} else {
ParseResult l = min(t.l, val, cont);
// if(l.value <= val) new ParseResult(val, "^(".length() + l.len, t.len);
ParseResult r = min(t.r, l.value, true);
return new ParseResult(r.value, "^(,".length() + l.len2 + r.len, t.len);
}
}
static
class ParseResult {
int value;
int len;
int len2;
public ParseResult(int v, int l, int l2) {
value = v;
len = l;
len2 = l2;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return String.format("ParseResult: %d %d %d", value, len, len2);
}
}
*/
/// TEMPLATE
static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n%r); }
static long gcd(long n, long r) { return r == 0 ? n : gcd(r, n%r); }
static <T> void swap(T[] x, int i, int j) { T t = x[i]; x[i] = x[j]; x[j] = t; }
static void swap(int[] x, int i, int j) { int t = x[i]; x[i] = x[j]; x[j] = t; }
void printArrayLn(int[] xs) { for(int i = 0; i < xs.length; i++) io.out.print(xs[i] + (i==xs.length-1?"\n":" ")); }
void printArrayLn(long[] xs) { for(int i = 0; i < xs.length; i++) io.out.print(xs[i] + (i==xs.length-1?"\n":" ")); }
static void dump(Object... o) { System.err.println(Arrays.deepToString(o)); }
void main() throws IOException {
// IOFast.setFileIO("rle-size.in", "rle-size.out");
try { run(); }
catch (EndOfFileRuntimeException e) { }
io.out.flush();
}
public static void main(String[] args) throws IOException { new F_X().main(); }
static class EndOfFileRuntimeException extends RuntimeException {
private static final long serialVersionUID = -8565341110209207657L; }
static
public class IOFast {
private BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
private PrintWriter out = new PrintWriter(System.out);
void setFileIn(String ins) throws IOException { in.close(); in = new BufferedReader(new FileReader(ins)); }
void setFileOut(String outs) throws IOException { out.flush(); out.close(); out = new PrintWriter(new FileWriter(outs)); }
void setFileIO(String ins, String outs) throws IOException { setFileIn(ins); setFileOut(outs); }
private static int pos, readLen;
private static final char[] buffer = new char[1024 * 8];
private static char[] str = new char[500*8*2];
private static boolean[] isDigit = new boolean[256];
private static boolean[] isSpace = new boolean[256];
private static boolean[] isLineSep = new boolean[256];
static { for(int i = 0; i < 10; i++) { isDigit['0' + i] = true; } isDigit['-'] = true; isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true; isLineSep['\r'] = isLineSep['\n'] = true; }
public int read() throws IOException { if(pos >= readLen) { pos = 0; readLen = in.read(buffer); if(readLen <= 0) { throw new EndOfFileRuntimeException(); } } return buffer[pos++]; }
public int nextInt() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; int ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; }
public long nextLong() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; long ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; }
public char nextChar() throws IOException { while(true) { final int c = read(); if(!isSpace[c]) { return (char)c; } } }
int reads(int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } if(str.length == len) { char[] rep = new char[str.length * 3 / 2]; System.arraycopy(str, 0, rep, 0, str.length); str = rep; } str[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; }
int reads(char[] cs, int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } cs[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; }
public char[] nextLine() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isLineSep); try { if(str[len-1] == '\r') { len--; read(); } } catch(EndOfFileRuntimeException e) { ; } return Arrays.copyOf(str, len); }
public String nextString() throws IOException { return new String(next()); }
public char[] next() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); return Arrays.copyOf(str, len); }
// public int next(char[] cs) throws IOException { int len = 0; cs[len++] = nextChar(); len = reads(cs, len, isSpace); return len; }
public double nextDouble() throws IOException { return Double.parseDouble(nextString()); }
public long[] nextLongArray(final int n) throws IOException { final long[] res = new long[n]; for(int i = 0; i < n; i++) { res[i] = nextLong(); } return res; }
public int[] nextIntArray(final int n) throws IOException { final int[] res = new int[n]; for(int i = 0; i < n; i++) { res[i] = nextInt(); } return res; }
public int[][] nextIntArray2D(final int n, final int k) throws IOException { final int[][] res = new int[n][]; for(int i = 0; i < n; i++) { res[i] = nextIntArray(k); } return res; }
public int[][] nextIntArray2DWithIndex(final int n, final int k) throws IOException { final int[][] res = new int[n][k+1]; for(int i = 0; i < n; i++) { for(int j = 0; j < k; j++) { res[i][j] = nextInt(); } res[i][k] = i; } return res; }
public double[] nextDoubleArray(final int n) throws IOException { final double[] res = new double[n]; for(int i = 0; i < n; i++) { res[i] = nextDouble(); } return res; }
}
}
|
Main.java:8: error: class F_X is public, should be declared in a file named F_X.java
public class F_X {
^
1 error
|
s623625458
|
p03980
|
C++
|
// In the name of God
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)
const int N = (int) 1e5 + 5, mod = (int) 0;
int op[N], t, hi[N], f[N], lo[N], flo[N][2], fhi[N][2];
void update() {
for (int i = t - 1; i >= 0; --i) {
if (op[i]) {
lo[i] = max(flo[i][0], flo[i][1]);
hi[i] = max(fhi[i][0], fhi[i][1]);
} else {
lo[i] = min(flo[i][0], flo[i][1]);
hi[i] = min(fhi[i][0], fhi[i][1]);
}
if (i) flo[i - 1][f[i - 1]] = lo[i];
if (i) fhi[i - 1][f[i - 1]] = hi[i];
}
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int q;
cin >> q;
while (q--) { t = 0;
string x;
cin >> x;
int n = (int) x.size();
if (x[0] == '0') {
cout << 0 << ' ' << 1 << endl;
continue;
}
if (n == 3) {
cout << (x[0] - '0') * 10 + (x[1] - '0') << ' ' << 2 << '\n';
continue;
}
if (n == 2) {
cout << (x[0] - '0') << ' ' << 2 << endl;
continue;
}
for (int i = 0; i < n - 1; ++i) {
// cout << endl << i << " I IS STARTING " << endl << x << endl << endl;
if (x[i] == '(') {
f[t] = 0;
op[t] = (x[i - 1] != '_');
lo[t] = 0;
hi[t] = 99;
for (int i = 0; i < 2; ++i)
flo[t][i] = 0, fhi[t][i] = 99;
t++;
update();
}
if (x[i] == ')') {
if ((x[i - 2] < '0' || x[i - 2] > '9') && (x[i - 1] >= '0' && x[i - 1] <= '9')) {
flo[t - 1][f[t - 1]] = x[i - 1] - '0';
fhi[t - 1][f[t - 1]] = x[i - 1] - '0';
}
update()
t--;
}
if (x[i] == ',') {
if ((x[i - 2] < '0' || x[i - 2] > '9') && (x[i - 1] >= '0' && x[i - 1] <= '9')) {
flo[t - 1][f[t - 1]] = x[i - 1] - '0';
fhi[t - 1][f[t - 1]] = x[i - 1] - '0';
}
update()
f[t - 1] = 1;
}
if (x[i] >= '0' && x[i] <= '9') {
int num = x[i] - '0';
if ((x[i - 1] >= '0' && x[i - 1] <= '9') || x[i] == '0') {
if (x[i - 1] >= '0' && x[i - 1] <= '9') num += 10 * (x[i - 1] - '0');
flo[t - 1][f[t - 1]] = num;
fhi[t - 1][f[t - 1]] = num;
} else {
flo[t - 1][f[t - 1]] = num;
fhi[t - 1][f[t - 1]] = num * 10 + 9;
}
update();
}
if (t > 0 && hi[0] == lo[0]) {
cout << lo[0] << ' ' << i + 1 << endl;
break;
}
// for (int j = 0; j < t; ++j) {
// cout << j << ' ' << f[j] << ' ' << flo[j][0] << ' ' << fhi[j][0] << ' ' << flo[j][1] << ' ' << fhi[j][1] << ' ' << lo[j] << ' ' << hi[j] << endl;
// }
//cout << endl << endl << endl << " I IS ENDING " << endl;
}
}
}
|
a.cc: In function 'int32_t main()':
a.cc:76:25: error: expected ';' before 't'
76 | update()
| ^
| ;
77 | t--;
| ~
a.cc:84:25: error: expected ';' before 'f'
84 | update()
| ^
| ;
85 | f[t - 1] = 1;
| ~
|
s211731768
|
p03980
|
C++
|
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
a
#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x) cerr << #x << " = " << (x) << endl
using namespace std;
// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else
const bool test = false;
#endif
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5
string s;
int i;
int ans2 = 0;
bool tanraku = false;
int f0(char op, int val1) {
bool pre_tanraku = tanraku;
if (isdigit(s[i])) {
int val2 = stoi(s.substr(i));
while (isdigit(s[i])) i++;
if (val1 == -1 || tanraku);
else if (op == '^') {
if (val1 >= 10) {
int tmp = val2 / 10;
if (val2 < 10) tmp = val2 % 10;
tmp = (tmp + 1) * 10 - 1;
if (val2 >= tmp) {
ans2 = i - 1;
tanraku = true;
}
}
else if (val1 % 10 == 9 && val1 / 10 == val2 / 10) {
ans2 = i - 1;
assert(false);
}
}
else if (op == '_') {
{
int tmp = val2 / 10;
if (val2 < 10) tmp = val2 % 10;
if (val1 <= tmp) {
ans2 = i - 1;
tanraku = true;
}
}
//if (val1 % 10 == 0 && val1 / 10 == val2 / 10) {
// ans2 = i - 1;
//}
}
else ans2 = i;
if (tanraku == false && val1 == -1) ans2 = i;
return val2;
}
if (s[i] == '_') {
i += 2;
int a = f0('_', -1);
tanraku = pre_tanraku;
if (a == 0) {
ans2 = i;
tanraku = true;
}
//dump(a);
i++;
int b = f0('_', a);
//dump(b);
i++;
tanraku = pre_tanraku;
return min(a, b);
}
if (s[i] == '^') {
i += 2;
int a = f0('^', -1);
tanraku = pre_tanraku;
if (a == 99) {
ans2 = i;
tanraku = true;
}
i++;
int b = f0('^', a);
i++;
tanraku = pre_tanraku;
return max(a, b);
}
}
signed main() {
cout << setprecision(20) << fixed;
dump(stoi("54???"));
int Q;
cin >> Q;
rep(loop, Q) {
cin >> s;
i = 0;
tanraku = false;
ans2 = 0;
cout << f0('\0', -1) << " ";
cerr << endl;
rep(i, 18-1) cerr << " ";
cerr << "^" << endl;
if (isdigit(s[0])) ans2++;
cout << ans2 << endl;
}
}
|
a.cc:3:1: error: 'a' does not name a type
3 | a
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:4:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59,
from /usr/include/c++/14/bits/stl_algo.h:69,
from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/1
|
s648331816
|
p03980
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int Q;
int N;
string S;
int ptr,L;
pair<int,int> hoge() {
if(ptr>=L) return {0,99};
int x=ptr;
if(S[x]=='0') {
ptr++;
return {0,0};
}
else if(S[x]>='1' && S[x]<='9') {
ptr++;
if(x==L-1) {
return {S[x]-'0',(S[x]-'0')*10+9};
}
if(S[ptr]>='0' && S[ptr]<='9') {
ptr++;
return {(S[x]-'0')*10+(S[x+1]-'0'),(S[x]-'0')*10+(S[x+1]-'0')};
}
else {
return {S[x]-'0',S[x]-'0'};
}
}
else if(S[x]=='^' || S[x]=='_') {
ptr++;
ptr++;
if(ptr>=L) return {0,99};
auto lh=hoge(),rh=lh;
ptr++;
if(ptr>=L) {
rh={0,99};
}
else {
rh=hoge();
}
ptr++;
if(S[x]=='^') return {max(lh.first,rh.first),max(lh.second,rh.second)};
else return {min(lh.first,rh.first),min(lh.second,rh.second)};
}
}
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>Q;
while(Q--) {
ZERO(R);
cin>>S;
N=S.size();
ptr=0;
parse();
for(i=1;i<=N;i++) {
ptr=0;
L=i;
auto ret=hoge();
if(ret.first==ret.second) {
cout<<ret.first<<" "<<i<<endl;
break;
}
}
}
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n';
FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
solve(); return 0;
}
|
a.cc: In function 'void solve()':
a.cc:67:22: error: 'R' was not declared in this scope
67 | ZERO(R);
| ^
a.cc:11:24: note: in definition of macro 'ZERO'
11 | #define ZERO(a) memset(a,0,sizeof(a))
| ^
a.cc:71:17: error: 'parse' was not declared in this scope; did you mean 'pause'?
71 | parse();
| ^~~~~
| pause
a.cc: In function 'std::pair<int, int> hoge()':
a.cc:61:1: warning: control reaches end of non-void function [-Wreturn-type]
61 | }
| ^
|
s441179327
|
p03980
|
C++
|
#include<stdio.h>
#include<algorithm>
using namespace std;
char s[1111];
int top;
char oper[1111];int op1[1111],op2[1111],res[1111];
int _top;
int _op1[1111], _op2[1111], _res[1111];
void calc(){
if(res[top] == -1)return;
while(top > 0){
--top;
if(op1[top] == -1){
op1[top] = res[top+1];
top++;
oper[top] = '@';
res[top] = -1;
break;
}else{
op2[top] = res[top+1];
if(oper[top] == '^')
res[top] = max(op1[top], op2[top]);
else
res[top] = min(op1[top], op2[top]);
oper[top] = '#';
}
}
if(top==0){
oper[top] = '#';
}
}
int calc_min(){
_top = top;
memcpy(_op1, op1, sizeof(int)*(_top+1));
memcpy(_op2, op2, sizeof(int)*(_top+1));
memcpy(_res, res, sizeof(int)*(_top+1));
while(_top > 0){
if(_res[_top] == -1)
_res[_top] = 0;
--_top;
if(_op1[_top] == -1){
_op1[_top] = _res[_top+1];
_op2[_top] = 0;
}else{
_op2[_top] = _res[_top+1];
}
if(oper[_top] == '^')
_res[_top] = max(_op1[_top], _op2[_top]);
else
_res[_top] = min(_op1[_top], _op2[_top]);
}
if(oper[0] == '@'){
if(_res[0] == -1)
_res[0] = 0;
}
return _res[0];
}
int calc_max(){
_top = top;
memcpy(_op1, op1, sizeof(int)*(_top+1));
memcpy(_op2, op2, sizeof(int)*(_top+1));
memcpy(_res, res, sizeof(int)*(_top+1));
while(_top > 0){
if(_res[_top] == -1)
_res[_top] = 99;
else
if(oper[_top] == '@' && _res[_top] >= 1 && _res[_top] <= 9)
_res[_top] = _res[_top] * 10 + 9;
--_top;
if(_op1[_top] == -1){
_op1[_top] = _res[_top+1];
_op2[_top] = 99;
}else{
_op2[_top] = _res[_top+1];
}
if(oper[_top] == '^')
_res[_top] = max(_op1[_top], _op2[_top]);
else
_res[_top] = min(_op1[_top], _op2[_top]);
}
if(oper[0] == '@'){
if(_res[_top] == -1)
_res[_top] = 99;
else
if(_res[_top] >= 1 && _res[_top] <= 9)
_res[_top] = _res[_top] * 10 + 9;
}
return _res[0];
}
void process(){
top = 0;
res[0] = -1;
oper[0] = '@';
for(int it = 0; s[it]; ){
if(s[it] == '^' || s[it] == '_'){
oper[top] = s[it];
op1[top] = -1;
op2[top] = -1;
top++;
res[top] = -1;
oper[top] = '@';
it+=2;
}else{
if(s[it] >= '0' && s[it] <= '9'){
if(res[top] == -1){
res[top] = s[it] - '0';
if(res[top] == 0)
calc();
}
else{
res[top] = res[top] * 10 + (s[it] - '0');
calc();
}
}else
calc();
int S = calc_min();
int E = calc_max();
if(S==E){
printf("%d %d\n",S, it+1);
return;
}
it++;
}
}
}
int main(){
int _;
for(scanf("%d",&_); _--;){
scanf("%s",s);
process();
}
return 0;
}
|
a.cc: In function 'int calc_min()':
a.cc:35:9: error: 'memcpy' was not declared in this scope
35 | memcpy(_op1, op1, sizeof(int)*(_top+1));
| ^~~~~~
a.cc:3:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<algorithm>
+++ |+#include <cstring>
3 | using namespace std;
a.cc: In function 'int calc_max()':
a.cc:63:9: error: 'memcpy' was not declared in this scope
63 | memcpy(_op1, op1, sizeof(int)*(_top+1));
| ^~~~~~
a.cc:63:9: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s691826215
|
p03981
|
C++
|
#ifdef Kelly
#include<DEBUG.h>
#else
#define DEBUG(...)
#endif
/*-------------------------------< Kelly >-------------------------------*/
#include<stdio.h>
#include<string.h>
#include<unordered_map>
#include<string>
using namespace std;
typedef long long int LL;
unordered_map<pair<LL, LL>, int> has;
char ar[100005];
int L;
int eval(int x) {
has.clear();
int ret = 0;
for (int i = 0; i < L - x + 1; i++) {
LL tmp = 0;
LL tmp2 = 0;
for (int j = 0; j < x; j++) {
tmp = (tmp * 31 + ar[i + j] - 'a');
tmp2 = (tmp2 * 51 + ar[i + j] - 'a');
}
if (has[pair<LL,LL>(tmp, tmp2)] == 0) {
has[pair<LL,LL>(tmp, tmp2)] = 1;
ret++;
}
}
return ret;
}
int main() {
scanf("%s", ar);
L = strlen(ar);
int l = 1, r = L;
int ans = 0;
auto max = [](int a, int b) {return a > b ? a : b;};
while (l + 10 <= r) {
int m1 = (l*2 + r) / 3;
int m2 = (l + r*2) / 3;
int e1 = eval(m1);
int e2 = eval(m2);
ans = max(ans, max(e1, e2));
if (e1 > e2) {
r = m2 - 1;
} else {
l = m1 + 1;
}
}
for (int i = l; i <= r; i++) {
ans = max(ans, eval(i));
}
printf("%d\n", ans);
return 0;
}
|
a.cc:15:34: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long long int, long long int>; _Tp = int; _Hash = std::hash<std::pair<long long int, long long int> >; _Pred = std::equal_to<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >]'
15 | unordered_map<pair<LL, LL>, int> has;
| ^~~
In file included from /usr/include/c++/14/unordered_map:41,
from a.cc:9:
/usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long long int, long long int>; _Tp = int; _Hash = std::hash<std::pair<long long int, long long int> >; _Pred = std::equal_to<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >]' is implicitly deleted because the default definition would be ill-formed:
148 | unordered_map() = default;
| ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from /usr/include/c++/14/bits/unordered_map.h:33:
/usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
539 | _Hashtable() = default;
| ^~~~~~~~~~
/usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from /usr/include/c++/14/bits/hashtable.h:35:
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
1731 | _Hashtable_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]'
/usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<long long int, long long int> >]':
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here
1328 | _Hash_code_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<long long int, long long int> >::hash()'
1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
| ^~~~~
In file included from /usr/include/c++/14/bits/hashtable_policy.h:35:
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<long long int, long long int> >::hash()' is implicitly deleted because the default definition would be ill-formed:
102 | struct hash : __hash_enum<_Tp>
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<long long int, long long int>, false>::__hash_enum()'
/usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]'
83 | __hash_enum(__hash_enum&&);
| ^~~~~~~~~~~
/usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]' is private within this context
102 | struct hash : __hash_enum<_Tp>
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here
84 | ~__hash_enum();
| ^
/usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates
1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
| ^~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed:
1328 | _Hash_code_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<long long int, long long int> >, true>::~_Hashtable_ebo_helper()'
/usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<long long int, long long int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed:
1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<long long int, long long int> >::~hash()'
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<long long int, long long int> >::~hash()' is implicitly deleted because the default definition would be ill-formed:
102 | struct hash : __hash_enum<_Tp>
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<long long int, long long int>; bool <anonymous> = false]' is private within this context
/usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here
84 | ~__hash_enum();
| ^
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates
1731 | _Hashtable_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<long long int, long long int>, std::pair<const std::pair<long long int, long long int>, int>, std::__detail::_Select1st, std::hash<std::pair<long long int, long long int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
/usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<long long int, long long int>, std::pair<const std::pair<long long int, long long int>, int>, std::__detail::_Select1st, std::hash<std::pair<long long int, long long int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition woul
|
s473466711
|
p03981
|
C++
|
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k;
int rank[200001];
int tmp[200001];
int lcp[200001];
int sa[200001];
bool compare_sa(int i,int j){
if(rank[i]!=rank[j])return rank[i]<rank[j];
else{
int ri=(i+k<=n?rank[i+k]:-1);
int rj=(j+k<=n?rank[j+k]:-1);
return ri<rj;
}
}
void construct_sa(string s){
for(int i=0;i<=n;i++){
sa[i]=i;
rank[i]=i<n?s[i]:-1;
}
for(k=1;k<=n;k*=2){
sort(sa,sa+n+1,compare_sa);
tmp[sa[0]]=0;
for(int i=1;i<=n;i++){
tmp[sa[i]]=tmp[sa[i-1]]+(compare_sa(sa[i-1],sa[i])?1:0);
}
for(int i=0;i<=n;i++){
rank[i]=tmp[i];
}
}
}
void construct_lcp(string s){
for(int i=0;i<=n;i++){
rank[sa[i]]=i;
}
int h=0;
lcp[0]=0;
for(int i=0;i<n;i++){
int j=sa[rank[i]-1];
if(h>0)h--;
for(;j+h<n && i+h<n;h++){
if(s[j+h]!=s[i+h])break;
}
lcp[rank[i]-1]=h;
}
}
int func(string s){
construct_sa(s);
construct_lcp(s);
int res=0;
for(int i=0;i<=n;i++){
res=max(res,lcp[i]);
}
return res;
}
string t;
int main(void){
cin >> t;
n=t.size();
printf("%d\n",n-func(t));
return 0;
}
|
a.cc: In function 'bool compare_sa(int, int)':
a.cc:26:12: error: reference to 'rank' is ambiguous
26 | if(rank[i]!=rank[j])return rank[i]<rank[j];
| ^~~~
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/vector:62,
from a.cc:3:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc:26:21: error: reference to 'rank' is ambiguous
26 | if(rank[i]!=rank[j])return rank[i]<rank[j];
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc:26:36: error: reference to 'rank' is ambiguous
26 | if(rank[i]!=rank[j])return rank[i]<rank[j];
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc:26:44: error: reference to 'rank' is ambiguous
26 | if(rank[i]!=rank[j])return rank[i]<rank[j];
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc:28:32: error: reference to 'rank' is ambiguous
28 | int ri=(i+k<=n?rank[i+k]:-1);
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc:29:32: error: reference to 'rank' is ambiguous
29 | int rj=(j+k<=n?rank[j+k]:-1);
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc: In function 'void construct_sa(std::string)':
a.cc:37:17: error: reference to 'rank' is ambiguous
37 | rank[i]=i<n?s[i]:-1;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc:46:25: error: reference to 'rank' is ambiguous
46 | rank[i]=tmp[i];
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc: In function 'void construct_lcp(std::string)':
a.cc:53:17: error: reference to 'rank' is ambiguous
53 | rank[sa[i]]=i;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc:58:26: error: reference to 'rank' is ambiguous
58 | int j=sa[rank[i]-1];
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc:63:21: error: reference to 'rank' is ambiguous
63 | lcp[rank[i]-1]=h;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
|
s572949760
|
p03981
|
C++
|
// In the name of God
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)
#define int long long
const int N = (int) 1e5 + 5, L = 20, mod = (int) 1e16 + 7, base = 727;
int h[N], pw[N], n;
string t;
int get_hash(int l, int r) {
return (h[r] - (h[l] * 1ll * pw[r - l] % mod) + mod) % mod;
}
int sa[N], rank[N][L], lcp_table[N], ind[N], adr[N];
pair<int, int> value[N];
int a[N], b[N], c[N];
void radix_sort(int n) {
memset(c, 0, sizeof c);
for (int i = 0; i < n; ++i) c[value[a[i]].second]++;
for (int i = 1; i < N; ++i) c[i] += c[i - 1];
for (int i = 0; i < n; ++i) b[--c[value[a[i]].second]] = a[i];
memset(c, 0, sizeof c);
for (int i = 0; i < n; ++i) c[value[b[i]].first]++;
for (int i = 1; i < N; ++i) c[i] += c[i - 1];
for (int i = n - 1; i >= 0; --i) a[--c[value[b[i]].first]] = b[i];
}
void make_suffix_array() {
for (int i = 0; i < n; ++i)
rank[i][0] = t[i];
for (int g = 1; g < L; ++g) {
for (int i = 0; i < n; ++i) {
value[i] = make_pair(rank[i][g - 1], (i + (1 << g - 1)) < n? rank[i + (1 << g - 1)][g - 1]: 0);
a[i] = i;
}
radix_sort(n);
int cnt = 1;
for (int i = 0; i < n; ++i) {
cnt += (i > 0 && value[a[i]] != value[a[i - 1]]);
rank[a[i]][g] = cnt;
sa[i] = a[i];
}
}
}
int lcp(int a, int b) {
int l = 0;
for (int j = L - 1; j >= 0; --j) if (a < n && b < n)
if (rank[a][j] == rank[b][j]) {
a += 1 << j;
b += 1 << j;
l += 1 << j;
}
return l;
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> t; n = (int) t.size();
make_suffix_array();
int mx = 0;
for (int i = 0; i < n - 1; ++i)
mx = max(mx, lcp(sa[i], sa[i + 1]));
cout << n - mx << endl;
}
|
a.cc: In function 'void make_suffix_array()':
a.cc:47:9: error: reference to 'rank' is ambiguous
47 | rank[i][0] = t[i];
| ^~~~
In file included from /usr/include/c++/14/bits/move.h:37,
from /usr/include/c++/14/bits/exception_ptr.h:41,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:3:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:30:12: note: 'long long int rank [100005][20]'
30 | int sa[N], rank[N][L], lcp_table[N], ind[N], adr[N];
| ^~~~
a.cc:50:34: error: reference to 'rank' is ambiguous
50 | value[i] = make_pair(rank[i][g - 1], (i + (1 << g - 1)) < n? rank[i + (1 << g - 1)][g - 1]: 0);
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:30:12: note: 'long long int rank [100005][20]'
30 | int sa[N], rank[N][L], lcp_table[N], ind[N], adr[N];
| ^~~~
a.cc:50:74: error: reference to 'rank' is ambiguous
50 | value[i] = make_pair(rank[i][g - 1], (i + (1 << g - 1)) < n? rank[i + (1 << g - 1)][g - 1]: 0);
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:30:12: note: 'long long int rank [100005][20]'
30 | int sa[N], rank[N][L], lcp_table[N], ind[N], adr[N];
| ^~~~
a.cc:57:13: error: reference to 'rank' is ambiguous
57 | rank[a[i]][g] = cnt;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:30:12: note: 'long long int rank [100005][20]'
30 | int sa[N], rank[N][L], lcp_table[N], ind[N], adr[N];
| ^~~~
a.cc: In function 'long long int lcp(long long int, long long int)':
a.cc:66:13: error: reference to 'rank' is ambiguous
66 | if (rank[a][j] == rank[b][j]) {
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:30:12: note: 'long long int rank [100005][20]'
30 | int sa[N], rank[N][L], lcp_table[N], ind[N], adr[N];
| ^~~~
a.cc:66:27: error: reference to 'rank' is ambiguous
66 | if (rank[a][j] == rank[b][j]) {
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:30:12: note: 'long long int rank [100005][20]'
30 | int sa[N], rank[N][L], lcp_table[N], ind[N], adr[N];
| ^~~~
|
s289903303
|
p03981
|
C++
|
#include <algorithm>
#include <climits>
#include <vector>
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)n;++i)
// Larsson-Sadakane's Suffix array Construction: O(n (log n)^2)
struct SAComp {
const int h, *g;
SAComp(int h, int* g) : h(h), g(g) {}
bool operator() (int a, int b) {
return a == b ? false : g[a] != g[b] ? g[a] < g[b] : g[a+h] < g[b+h];
}
};
int *buildSA(char* t, int n) {
int *g = new int[n+1], *b = new int[n+1], *v = new int[n+1];
REP(i,n+1) v[i] = i, g[i] = t[i];
b[0] = 0; b[n] = 0;
sort(v, v+n+1, SAComp(0, g));
for(int h = 1; b[n] != n ; h *= 2) {
SAComp comp(h, g);
sort(v, v+n+1, comp);
REP(i, n) b[i+1] = b[i] + comp(v[i], v[i+1]);
REP(i, n+1) g[v[i]] = b[i];
}
return v;
}
// Kasai-Lee-Arimura-Arikawa-Park's simple LCP computation: O(n)
int *buildLCP(char *t, int n, int *a) {
int h = 0, *b = new int[n+1], *lcp = new int[n+1];
REP(i, n+1) b[a[i]] = i;
REP(i, n+1) {
if (b[i]){
for (int j = a[b[i]-1]; j+h<n && i+h<n && t[j+h] == t[i+h]; ++h);
lcp[b[i]] = h;
} else lcp[b[i]] = -1;
if (h > 0) --h;
}
return lcp;
}
struct segment_tree_min {
int n; vector<ll> v;
segment_tree_min() {}
segment_tree_min(int _n) {
for (n = 1; n < _n; n *= 2);
v = vector<ll>(n * 2 - 1, LLONG_MAX);
}
void set(int i, ll x) {
int k = i + n - 1;
v[k] = x;
while (k > 0) {
k = (k - 1) / 2;
v[k] = min(v[k * 2 + 1], v[k * 2 + 2]);
}
}
ll _get(int i, int j, int k, int l, int r) {
if (r <= i || j <= l) return LLONG_MAX;
if (i <= l && r <= j) return v[k];
ll vl = _get(i, j, k * 2 + 1, l, (l + r) / 2);
ll vr = _get(i, j, k * 2 + 2, (l + r) / 2, r);
return min(vl, vr);
}
ll get(int i, int j) { return _get(i, j, 0, 0, n); }
};
int N;
char S[100010];
int *sa, *lcp, *rmq, rnk[100010];
int p[100010];
segment_tree_min st;
int f(int i, int j) {
if (i == j) return N - i;
int x = rnk[i], y = rnk[j];
if (x > y) swap(x, y);
return st.get(x + 1, y + 1);
}
bool cmp(int i, int j) {
if (f(i, j) < N - max(i, j)) return rnk[i] < rnk[j];
int k = N - abs(i - j);
if (i < j) j = i, i = k;
else i = j, j = k;
if (f(i, j) < N - max(i, j)) return rnk[i] < rnk[j];
return false;
}
int main() {
scanf("%s", S);
int N = strlen(S);
sa = buildSA(S, N);
lcp = buildLCP(S, N, sa);
vector<int> imos(N + 10);
for (int i = 1; i < N; i++) {
imos[lcp[i + 1]]++;
imos[N - sa[i]]--;
}
int x = 0, ma = 0;
for (int i = 0; i <= N; i++) {
x += imos[i];
ma = max(ma, x);
}
cout << ma + 1 << endl;
}
|
a.cc: In function 'int main()':
a.cc:97:17: error: 'strlen' was not declared in this scope
97 | int N = strlen(S);
| ^~~~~~
a.cc:7:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
6 | #include <cstdio>
+++ |+#include <cstring>
7 | using namespace std;
|
s117622872
|
p03981
|
C++
|
#include <algorithm>
#include <climits>
#include <vector>
#include <iostream>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)n;++i)
// Larsson-Sadakane's Suffix array Construction: O(n (log n)^2)
struct SAComp {
const int h, *g;
SAComp(int h, int* g) : h(h), g(g) {}
bool operator() (int a, int b) {
return a == b ? false : g[a] != g[b] ? g[a] < g[b] : g[a+h] < g[b+h];
}
};
int *buildSA(char* t, int n) {
int *g = new int[n+1], *b = new int[n+1], *v = new int[n+1];
REP(i,n+1) v[i] = i, g[i] = t[i];
b[0] = 0; b[n] = 0;
sort(v, v+n+1, SAComp(0, g));
for(int h = 1; b[n] != n ; h *= 2) {
SAComp comp(h, g);
sort(v, v+n+1, comp);
REP(i, n) b[i+1] = b[i] + comp(v[i], v[i+1]);
REP(i, n+1) g[v[i]] = b[i];
}
return v;
}
// Kasai-Lee-Arimura-Arikawa-Park's simple LCP computation: O(n)
int *buildLCP(char *t, int n, int *a) {
int h = 0, *b = new int[n+1], *lcp = new int[n+1];
REP(i, n+1) b[a[i]] = i;
REP(i, n+1) {
if (b[i]){
for (int j = a[b[i]-1]; j+h<n && i+h<n && t[j+h] == t[i+h]; ++h);
lcp[b[i]] = h;
} else lcp[b[i]] = -1;
if (h > 0) --h;
}
return lcp;
}
struct segment_tree_min {
int n; vector<ll> v;
segment_tree_min() {}
segment_tree_min(int _n) {
for (n = 1; n < _n; n *= 2);
v = vector<ll>(n * 2 - 1, LLONG_MAX);
}
void set(int i, ll x) {
int k = i + n - 1;
v[k] = x;
while (k > 0) {
k = (k - 1) / 2;
v[k] = min(v[k * 2 + 1], v[k * 2 + 2]);
}
}
ll _get(int i, int j, int k, int l, int r) {
if (r <= i || j <= l) return LLONG_MAX;
if (i <= l && r <= j) return v[k];
ll vl = _get(i, j, k * 2 + 1, l, (l + r) / 2);
ll vr = _get(i, j, k * 2 + 2, (l + r) / 2, r);
return min(vl, vr);
}
ll get(int i, int j) { return _get(i, j, 0, 0, n); }
};
int N;
char S[100010];
int *sa, *lcp, *rmq, rnk[100010];
int p[100010];
segment_tree_min st;
int f(int i, int j) {
if (i == j) return N - i;
int x = rnk[i], y = rnk[j];
if (x > y) swap(x, y);
return st.get(x + 1, y + 1);
}
bool cmp(int i, int j) {
if (f(i, j) < N - max(i, j)) return rnk[i] < rnk[j];
int k = N - abs(i - j);
if (i < j) j = i, i = k;
else i = j, j = k;
if (f(i, j) < N - max(i, j)) return rnk[i] < rnk[j];
return false;
}
int main() {
scanf("%s", S);
int N = strlen(S);
sa = buildSA(S, N);
lcp = buildLCP(S, N, sa);
vector<int> imos(N + 10);
for (int i = 1; i < N; i++) {
imos[lcp[i + 1]]++;
imos[N - sa[i]]--;
}
int x = 0, ma = 0;
for (int i = 0; i <= N; i++) {
x += imos[i];
ma = max(ma, x);
}
cout << ma + 1 << endl;
}
|
a.cc: In function 'int main()':
a.cc:95:17: error: 'strlen' was not declared in this scope
95 | int N = strlen(S);
| ^~~~~~
a.cc:5:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <iostream>
+++ |+#include <cstring>
5 | using namespace std;
|
s085232496
|
p03981
|
C++
|
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x) cerr << #x << " = " << (x) << endl
using namespace std;
// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else
const bool test = false;
#endif
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5
string T;
set<string> s;
int ans = 0;
a
bool ok(string s1) {
for (auto s2 : s) {
int id = 0;
rep(i, s2.size()) {
if (s2[i] == s1[id]) id++;
if (id == s1.size()) return false;
}
}
for (auto s2 : s) {
int id = 0;
rep(i, s1.size()) {
if (s2[id] == s1[i]) id++;
if (id == s2.size()) return false;
}
}
return true;
}
int dfs(int id) {
int res = 0;
if (id == T.size()) {
if (test) {
for (auto s2 : s) {
cerr << s2 << " ";
}
cerr << endl;
}
if (s.size() > ans) ans = s.size();
return 1;
}
REP(j, id, T.size()) {
REP(i, 1, T.size() - j + 1) {
string tmp = T.substr(j, i);
if (ok(tmp)) {
s.insert(tmp);
res += dfs(j + 1);
s.erase(tmp);
}
}
}
return res;
}
signed main() {
cout << setprecision(20) << fixed;
s.insert("abc");
dump(ok("ac"));
dump(ok("cab"));
s.erase("abc");
cin >> T;
if (T.size() > 55) return 0;
dfs(0);
cout << ans << endl;
}
|
a.cc:32:1: error: 'a' does not name a type
32 | a
| ^
a.cc: In function 'int dfs(int)':
a.cc:67:29: error: 'ok' was not declared in this scope
67 | if (ok(tmp)) {
| ^~
a.cc: In function 'int main()':
a.cc:81:14: error: 'ok' was not declared in this scope
81 | dump(ok("ac"));
| ^~
a.cc:12:42: note: in definition of macro 'dump'
12 | #define dump(x) cerr << #x << " = " << (x) << endl
| ^
|
s386282771
|
p03981
|
C++
|
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <set>
#include <map>
#define SIZE 100005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
typedef pair <P,int> PP;
char str[SIZE];
int rank[SIZE];
int sa[SIZE];
int lcp[SIZE];
PP tmp[SIZE];
int imos[SIZE];
int main()
{
scanf("%s",&str);
int n=strlen(str);
for(int i=0;i<n;i++) rank[i]=str[i]-'a';
for(int k=1;k<=n;k<<=1)
{
for(int i=0;i<n;i++)
{
tmp[i]=PP(P(rank[i],i+k<n?rank[i+k]:-1),i);
}
sort(tmp,tmp+n);
for(int i=0;i<n;)
{
int f=i;
for(;i<n&&tmp[i].first==tmp[f].first;i++)
{
rank[tmp[i].second]=f;
}
}
}
for(int i=0;i<n;i++) sa[rank[i]]=i;
int H=0;
for(int i=0;i<n;i++)
{
if(H>0) H--;
if(rank[i]==n-1) continue;
int to=sa[rank[i]+1];
while(i+H<n&&to+H<n&&str[i+H]==str[to+H]) H++;
imos[H]++;
}
for(int i=n-1;i>=1;i--) imos[i]+=imos[i+1];
int ret=0;
for(int i=1;i<=n;i++)
{
ret=max(ret,(n-i+1)-imos[i]);
}
printf("%d\n",ret);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:30:30: error: reference to 'rank' is ambiguous
30 | for(int i=0;i<n;i++) rank[i]=str[i]-'a';
| ^~~~
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 a.cc:3:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [100005]'
20 | int rank[SIZE];
| ^~~~
a.cc:35:34: error: expected primary-expression before '(' token
35 | tmp[i]=PP(P(rank[i],i+k<n?rank[i+k]:-1),i);
| ^
a.cc:35:36: error: expected primary-expression before '(' token
35 | tmp[i]=PP(P(rank[i],i+k<n?rank[i+k]:-1),i);
| ^
a.cc:35:37: error: reference to 'rank' is ambiguous
35 | tmp[i]=PP(P(rank[i],i+k<n?rank[i+k]:-1),i);
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [100005]'
20 | int rank[SIZE];
| ^~~~
a.cc:35:51: error: reference to 'rank' is ambiguous
35 | tmp[i]=PP(P(rank[i],i+k<n?rank[i+k]:-1),i);
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [100005]'
20 | int rank[SIZE];
| ^~~~
a.cc:43:33: error: reference to 'rank' is ambiguous
43 | rank[tmp[i].second]=f;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [100005]'
20 | int rank[SIZE];
| ^~~~
a.cc:47:33: error: reference to 'rank' is ambiguous
47 | for(int i=0;i<n;i++) sa[rank[i]]=i;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [100005]'
20 | int rank[SIZE];
| ^~~~
a.cc:52:20: error: reference to 'rank' is ambiguous
52 | if(rank[i]==n-1) continue;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [100005]'
20 | int rank[SIZE];
| ^~~~
a.cc:53:27: error: reference to 'rank' is ambiguous
53 | int to=sa[rank[i]+1];
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [100005]'
20 | int rank[SIZE];
| ^~~~
|
s859917206
|
p03982
|
C++
|
京都大学决定在大学西侧修建一堵直墙,以保护大学不受每晚从西方袭击的大猩猩的影响。另外,由于攻击严重的位置不能仅通过墙壁来防止,因此使用增援来处理。虽然增援的数量有限,但最先进的技术可以计算下一次攻击大猩猩的数量和位置,因此我们每天都会相应地移动增援部队。您被称为信息部门的精英,以提高效率。
沿着直墙以相等的间隔使用加强件 ñ 从左到右有 N个地方 1 1, 2 2,..., ñ 它有一个N数。为最后一次攻击做准备,现在每个位置 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中)是 A_I 一
我
使用单独的增援。移动其中一些增援部队,每个部位 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中) B_i 乙
我
必须使用多个加固件。但是,这个位置 我 从我的位置 Ĵ 加强到 j 1 移动一个是有成本的 | i \ - \ j | | i - j | 需要。重复此移动,并输出满足条件所需的总成本的最小值。此外,我不会考虑下一次攻击后的攻击。
|
a.cc:1:1: error: extended character 。 is not valid in an identifier
1 | 京都大学决定在大学西侧修建一堵直墙,以保护大学不受每晚从西方袭击的大猩猩的影响。另外,由于攻击严重的位置不能仅通过墙壁来防止,因此使用增援来处理。虽然增援的数量有限,但最先进的技术可以计算下一次攻击大猩猩的数量和位置,因此我们每天都会相应地移动增援部队。您被称为信息部门的精英,以提高效率。
| ^
a.cc:1:1: error: extended character 。 is not valid in an identifier
a.cc:1:1: error: extended character 。 is not valid in an identifier
a.cc:1:1: error: extended character 。 is not valid in an identifier
a.cc:3:72: error: extended character 。 is not valid in an identifier
3 | 沿着直墙以相等的间隔使用加强件 ñ 从左到右有 N个地方 1 1, 2 2,..., ñ 它有一个N数。为最后一次攻击做准备,现在每个位置 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中)是 A_I 一
| ^
a.cc:3:130: error: stray '\' in program
3 | 沿着直墙以相等的间隔使用加强件 ñ 从左到右有 N个地方 1 1, 2 2,..., ñ 它有一个N数。为最后一次攻击做准备,现在每个位置 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中)是 A_I 一
| ^
a.cc:3:132: error: stray '\' in program
3 | 沿着直墙以相等的间隔使用加强件 ñ 从左到右有 N个地方 1 1, 2 2,..., ñ 它有一个N数。为最后一次攻击做准备,现在每个位置 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中)是 A_I 一
| ^
a.cc:3:138: error: stray '\' in program
3 | 沿着直墙以相等的间隔使用加强件 ñ 从左到右有 N个地方 1 1, 2 2,..., ñ 它有一个N数。为最后一次攻击做准备,现在每个位置 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中)是 A_I 一
| ^
a.cc:3:142: error: stray '\' in program
3 | 沿着直墙以相等的间隔使用加强件 ñ 从左到右有 N个地方 1 1, 2 2,..., ñ 它有一个N数。为最后一次攻击做准备,现在每个位置 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中)是 A_I 一
| ^
a.cc:3:144: error: stray '\' in program
3 | 沿着直墙以相等的间隔使用加强件 ñ 从左到右有 N个地方 1 1, 2 2,..., ñ 它有一个N数。为最后一次攻击做准备,现在每个位置 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中)是 A_I 一
| ^
a.cc:3:150: error: stray '\' in program
3 | 沿着直墙以相等的间隔使用加强件 ñ 从左到右有 N个地方 1 1, 2 2,..., ñ 它有一个N数。为最后一次攻击做准备,现在每个位置 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中)是 A_I 一
| ^
a.cc:3:157: error: extended character ≤ is not valid in an identifier
3 | 沿着直墙以相等的间隔使用加强件 ñ 从左到右有 N个地方 1 1, 2 2,..., ñ 它有一个N数。为最后一次攻击做准备,现在每个位置 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中)是 A_I 一
| ^
a.cc:3:159: error: extended character ≤ is not valid in an identifier
3 | 沿着直墙以相等的间隔使用加强件 ñ 从左到右有 N个地方 1 1, 2 2,..., ñ 它有一个N数。为最后一次攻击做准备,现在每个位置 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中)是 A_I 一
| ^
a.cc:5:2: error: extended character 。 is not valid in an identifier
5 | 使用单独的增援。移动其中一些增援部队,每个部位 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中) B_i 乙
| ^
a.cc:5:59: error: stray '\' in program
5 | 使用单独的增援。移动其中一些增援部队,每个部位 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中) B_i 乙
| ^
a.cc:5:61: error: stray '\' in program
5 | 使用单独的增援。移动其中一些增援部队,每个部位 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中) B_i 乙
| ^
a.cc:5:67: error: stray '\' in program
5 | 使用单独的增援。移动其中一些增援部队,每个部位 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中) B_i 乙
| ^
a.cc:5:71: error: stray '\' in program
5 | 使用单独的增援。移动其中一些增援部队,每个部位 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中) B_i 乙
| ^
a.cc:5:73: error: stray '\' in program
5 | 使用单独的增援。移动其中一些增援部队,每个部位 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中) B_i 乙
| ^
a.cc:5:79: error: stray '\' in program
5 | 使用单独的增援。移动其中一些增援部队,每个部位 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中) B_i 乙
| ^
a.cc:5:86: error: extended character ≤ is not valid in an identifier
5 | 使用单独的增援。移动其中一些增援部队,每个部位 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中) B_i 乙
| ^
a.cc:5:88: error: extended character ≤ is not valid in an identifier
5 | 使用单独的增援。移动其中一些增援部队,每个部位 我 我( 1 \ \ leq \ i \ \ leq \ N. 1 ≤ 我≤ Ñ 中) B_i 乙
| ^
a.cc:7:2: error: extended character 。 is not valid in an identifier
7 | 必须使用多个加固件。但是,这个位置 我 从我的位置 Ĵ 加强到 j 1 移动一个是有成本的 | i \ - \ j | | i - j | 需要。重复此移动,并输出满足条件所需的总成本的最小值。此外,我不会考虑下一次攻击后的攻击。
| ^
a.cc:7:87: error: stray '\' in program
7 | 必须使用多个加固件。但是,这个位置 我 从我的位置 Ĵ 加强到 j 1 移动一个是有成本的 | i \ - \ j | | i - j | 需要。重复此移动,并输出满足条件所需的总成本的最小值。此外,我不会考虑下一次攻击后的攻击。
| ^
a.cc:7:91: error: stray '\' in program
7 | 必须使用多个加固件。但是,这个位置 我 从我的位置 Ĵ 加强到 j 1 移动一个是有成本的 | i \ - \ j | | i - j | 需要。重复此移动,并输出满足条件所需的总成本的最小值。此外,我不会考虑下一次攻击后的攻击。
| ^
a.cc:7:108: error: extended character 。 is not valid in an identifier
7 | 必须使用多个加固件。但是,这个位置 我 从我的位置 Ĵ 加强到 j 1 移动一个是有成本的 | i \ - \ j | | i - j | 需要。重复此移动,并输出满足条件所需的总成本的最小值。此外,我不会考虑下一次攻击后的攻击。
| ^
a.cc:7:108: error: extended character 。 is not valid in an identifier
a.cc:7:108: error: extended character 。 is not valid in an identifier
a.cc:1:1: error: '\U00004eac\U000090fd\U00005927\U00005b66\U000051b3\U00005b9a\U00005728\U00005927\U00005b66\U0000897f\U00004fa7\U00004fee\U00005efa\U00004e00\U00005835\U000076f4\U00005899\U0000ff0c\U00004ee5\U00004fdd\U000062a4\U00005927\U00005b66\U00004e0d\U000053d7\U00006bcf\U0000665a\U00004ece\U0000897f\U000065b9\U000088ad\U000051fb\U00007684\U00005927\U00007329\U00007329\U00007684\U00005f71\U000054cd\U00003002\U000053e6\U00005916\U0000ff0c\U00007531\U00004e8e\U0000653b\U000051fb\U00004e25\U000091cd\U00007684\U00004f4d\U00007f6e\U00004e0d\U000080fd\U00004ec5\U0000901a\U00008fc7\U00005899\U000058c1\U00006765\U00009632\U00006b62\U0000ff0c\U000056e0\U00006b64\U00004f7f\U00007528\U0000589e\U000063f4\U00006765\U00005904\U00007406\U00003002\U0000867d\U00007136\U0000589e\U000063f4\U00007684\U00006570\U000091cf\U00006709\U00009650\U0000ff0c\U00004f46\U00006700\U00005148\U00008fdb\U00007684\U00006280\U0000672f\U000053ef\U00004ee5\U00008ba1\U00007b97\U00004e0b\U00004e00\U00006b21\U0000653b\U000051fb\U00005927\U00007329\U00007329\U00007684\U00006570\U000091cf\U0000548c\U00004f4d\U00007f6e\U0000ff0c\U000056e0\U00006b64\U00006211\U00004eec\U00006bcf\U00
|
s655733886
|
p03982
|
C++
|
#include<cstdio>
#include<utility>
#include<set>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
long long arr[100002];
int l[100002],r[100002],n;
set<pair<int,int> > se;
inline void del(const int& a)
{
set<pair<int,int> >::iterator it;
int b=l[a],c=r[a];
r[b]=c;
l[c]=b;
if(b>0)
{
it=se.find(make_pair(a-b,b));
if(it!=se.end())
{
se.erase(it);
}
}
if(c<=n)
{
it=se.find(make_pair(c-a,a));
if(it!=se.end())
{
se.erase(it);
}
}
if(b>0 && c<=n && (arr[b]>0)^(arr[c]>0))
{
se.insert(make_pair(c-b,b));
}
return;
}
int main()
{
int i,a,b,dis;
long long x,ans,remain,rein;
scanf("%d",&n);
for(i=1;i<=n;++i)
{
scanf("%lld",&arr[i]);
}
remain=0;
se.clear();
for(i=1;i<=n;++i)
{
scanf("%lld",&x);
arr[i]-=x;
if(arr[i]<0)
{
remain-=arr[i];
}
}
for(i=1;i<=n;++i)
{
l[i]=i-1;
r[i]=i+1;
if( ((arr[i]>0)^(arr[i+1]>0)) && i<n)
{
se.insert(make_pair(1,i));
}
}
ans=0;
while(remain)
{
// printf("%lld %d\n",remain,se.size());
dis=(se.begin())->first;
a=(se.begin())->second;
se.erase(se.begin());
b=r[a];
rein=min(abs(arr[a]),abs(arr[b]),remain);
remain-=rein;
// printf("rein:%lld\n",rein);
ans+=dis*rein;
arr[a]+=(arr[a]>0?-rein:rein);
arr[b]+=(arr[b]>0?-rein:rein);
if(arr[a]==0)
{
del(a);
}
if(arr[b]==0)
{
del(b);
}
}
printf("%lld\n",ans);
return 0;
}
/*
2
1 5
3 1
2
*/
/*
5
1 2 3 4 5
3 3 1 1 1
6
*/
/*
27
46 3 4 2 10 2 5 2 6 7 20 13 9 49 3 8 4 3 19 9 3 5 4 13 9 5 7
10 2 5 6 2 6 3 2 2 5 3 11 13 2 2 7 7 3 9 5 13 4 17 2 2 2 4
48
*/
/*
18
3878348 423911 8031742 1035156 24256 10344593 19379 3867285 4481365 1475384 1959412 1383457 164869 4633165 6674637 9732852 10459147 2810788
1236501 770807 4003004 131688 1965412 266841 3980782 565060 816313 192940 541896 250801 217586 3806049 1220252 1161079 31168 2008961
6302172
*/
/*
2
1 99999999999
1234567891 1
1234567890
*/
|
In file included from /usr/include/c++/14/bits/stl_tree.h:63,
from /usr/include/c++/14/set:62,
from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
a.cc:76:11: required from here
76 | rein=min(abs(arr[a]),abs(arr[b]),remain);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
284 | if (__comp(__b, __a))
| ~~~~~~^~~~~~~~~~
|
s428733933
|
p03982
|
C++
|
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll a[100005],b[100005];
int n;
int main(){
cin >> n;
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
for(int i=0;i<n;i++) scanf("%lld",&b[i]);
ll M = 0,Mval = 0; ll sidelazy = 0;
set<pair<ll,ll>,greater<pair<ll,ll> > >S; ll lazy = 0;
for(int i=0;i<n;i++){
ll newM,newMval;
if(M<=0){
if(M != 0){
S.insert(mp(M-sidelazy,-lazy));
}
sidelazy += b[i]-a[i]; M=b[i]-a[i]; lazy--;
}
else{
ll cand = M,MIN = Mval+M,pre = M,val = Mval+M;
for(set<pair<ll,ll>,greater<pair<ll,ll> > >::iterator it=S.begin();it!=S.end();it++){
if(sidelazy+(*it).fi>0){
if((*it).sc+lazy+1<0){
if(MIN >= val){
MIN = val;
cand = min(cand,pre);
}
}
else{
if(MIN >= val- ((*it).sc+lazy+1) * (pre-(*it).fi-sidelazy)){
MIN = val- ((*it).sc+lazy+1) * (pre-(*it).fi-sidelazy);
cand = min(cand,(*it).fi+sidelazy);
}
}
val -= ((*it).sc+lazy+1) * (pre-(*it).fi-sidelazy);
pre = (*it).fi+sidelazy;
}
else{
if((*it).sc+lazy+1<0){
if(MIN >= val){
MIN = val;
cand = min(cand,pre);
}
}
else{
if(MIN >= val- ((*it).sc+lazy+1) * pre){
MIN = val- ((*it).sc+lazy+1) * (pre);
cand = min(cand,0);
}
}
if((*it).sc+lazy-1<0){
if(MIN >= val- ((*it).sc+lazy+1) * pre){
MIN = val- ((*it).sc+lazy+1) * (pre);
cand = min(cand,0);
}
}
else{
if(MIN >= val- ((*it).sc+lazy+1) * pre - ((*it).sc+lazy-1) * (-(*it).fi-sidelazy)){
MIN = val- ((*it).sc+lazy+1) * pre - ((*it).sc+lazy-1) * (-(*it).fi-sidelazy);
cand = min(cand,(*it).fi+sidelazy);
}
}
break;
}
}
M = cand;
Mval = MIN; lazy--; vector<P>vec;
for(set<pair<ll,ll>,greater<pair<ll,ll> > >::iterator it=S.begin();it!=S.end();){
if(sidelazy+(*it).fi>0){
ll a = (*it).fi, x = (*it).sc;
S.erase(it++);
if(a+sidelazy>=M);
else{
vec.pb(mp(a,x+2));
}
}
else{
ll a = (*it).fi, x = (*it).sc;
S.erase(it);
if(a+sidelazy>=M);
else{
if(0<M) S.insert(mp(-sidelazy,x+2));
if(a+sidelazy<M) S.insert(mp(a,x));
}
break;
}
}
sidelazy += b[i]-a[i]; M += b[i]-a[i]; for(int i=0;i<vec.size();i++) S.insert(vec[i]);
}
}
if(M<=0){
cout << Mval << endl;
}
else{
ll pre = M;
for(set<pair<ll,ll>,greater<pair<ll,ll> > >::iterator it=S.begin();it!=S.end();it++){
if(sidelazy+(*it).fi>0){
Mval -= ((*it).sc+lazy) * (pre-(*it).fi-sidelazy);
pre = (*it).fi+sidelazy;
}
else{
Mval -= ((*it).sc+lazy) * (pre);
break;
}
}
cout << Mval << endl;
}
}
|
a.cc: In function 'int main()':
a.cc:80:67: error: no matching function for call to 'min(ll&, int)'
80 | cand = min(cand,0);
| ~~~^~~~~~~~
In file included from /usr/include/c++/14/bits/specfun.h:43,
from /usr/include/c++/14/cmath:3906,
from a.cc:4:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:80:67: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
80 | cand = min(cand,0);
| ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:8:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:80:67: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
80 | cand = min(cand,0);
| ~~~^~~~~~~~
a.cc:86:67: error: no matching function for call to 'min(ll&, int)'
86 | cand = min(cand,0);
| ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:86:67: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
86 | cand = min(cand,0);
| ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:86:67: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
86 | cand = min(cand,0);
| ~~~^~~~~~~~
|
s148707115
|
p03982
|
C++
|
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <array>
#include <bitset>
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <list>
#include <queue>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <tuple>
#include <utility>//pair
#include <valarray>
#include <vector>
#define PRIME_SHORT 10007
#define PRIME 1000000007
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ull, int> puli;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pllll;
typedef pair<ull, ull> pulul;
typedef pair<double, double> pdd;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;
const bool debug = false;
void rar(int n, int* a);
void rar2(int n, int m, int** a);
int ipow(int base, int exp);
int left(int current, bool swap);
int right(int current, bool swap);
int griddist(int x, int y, int s, int t);
int griddist(pii one, pii two);
double sqeucldist(double x, double y, double s, double t);
double sqeucldist(pii one, pii two);
ull modadd(ull a, ull b, int mod);
ull modmult(ull a, ull b, int mod);
bool check(ull* vals, int length)
{
for (int i = 0; i < length; ++i)
{
if (vals[i] != 0)
{
return false;
}
}
return true;
}
int main(void) {
int n;
cin >> n;
ull* a = new ull[n];
ull* b = new ull[n];
rar(n, a);
rar(n, b);
ull* diff = new ull[n];
for (int i = 0; i < n; ++i)
diff[i] = a[i] - b[i];
if (debug) {
for (int i = 0; i < n; ++i)
cout << diff[i] << '\t';
cout << endl;
}
ull moves = 0UL;
if (diff[0] > 0 && diff[1] < 0)
{
ull handoff = min(diff[0], -diff[1]);
diff[0] -= handoff;
diff[1] += handoff;
moves += handoff;
}
if (diff[0] < 0)
{
ull handoff = -diff[0];
diff[0] += handoff;
diff[1] -= handoff;
moves += handoff;
}
if (diff[n-1] > 0 && diff[n-2] < 0)
{
ull handoff = min(diff[n-1], -diff[n-2]);
diff[n-1] -= handoff;
diff[n-2] += handoff;
moves += handoff;
}
if (diff[n-1] < 0)
{
ull handoff = -diff[n-1];
diff[n-1] += handoff;
diff[n-2] -= handoff;
moves += handoff;
}
while (check(diff, n) == false)
{
int len = 1;
for (int i = len; i < n-len; ++i)
{
if (diff[i] > 0)
{
if (diff[i+len] < 0)
{
ull handoff = min(diff[i], -diff[i+len]);
diff[i] -= handoff;
diff[i+len] += handoff;
moves += len*handoff;
}
if (diff[i-len] < 0)
{
ull handoff = min(diff[i], -diff[i-len]);
diff[i] -= handoff;
diff[i-len] += handoff;
moves += len*handoff;
}
}
else if (diff[i] < 0)
{
if (diff[i+len] > 0)
{
ull handoff = min(-diff[i], diff[i+len]);
diff[i] += handoff;
diff[i+len] -= handoff;
moves += len*handoff;
}
if (diff[i-len] > 0)
{
ull handoff = min(-diff[i], diff[i-len]);
diff[i] += handoff;
diff[i-len] -= handoff;
moves += len*handoff;
}
}
}
}
cout << moves << endl;
return 0;
}
void rar(int n, int* a)
{
for (int i = 0; i < n; ++i)
{
cin >> a[i];
}
return;
}
void rar2(int n, int m, int** a)
{
for (int i = 0; i < n; ++i)
{
a[i] = new int[m];
for (int j = 0; j < m; ++j)
{
cin >> a[i][j];
}
}
return;
}
int ipow(int base, int exp) {
int result = 1;
while (exp)
{
if (exp & 1)
result *= base;
exp >>= 1;
base *= base;
}
return result;
}
int left(int current, bool swap = false) {
if(swap){
return right(current, false);
} else {
return 2*current + 1;
}
}
int right(int current, bool swap = false) {
if(swap){
return left(current, false);
} else {
return 2*(current+1);
}
}
int griddist(int x, int y, int s, int t) {
return abs(x-s) + abs(y-t);
}
int griddist(pii one, pii two) {
return abs(one.first - two.first) + abs(one.second - two.second);
}
double sqeucldist(double x, double y, double s, double t) {
double a = x-s;
double b = y-t;
return a*a+b*b;
}
double sqeucldist(pii one, pii two) {
double a = one.first - two.first;
double b = one.second - two.second;
return a*a+b*b;
}
ull modadd(ull a, ull b, int mod) {
return (a%mod + b%mod)%mod;
}
ull modmult(ull a, ull b, int mod) {
return ((a%mod)*(b%mod))%mod;
}
|
a.cc: In function 'int main()':
a.cc:67:12: error: cannot convert 'ull*' {aka 'long long unsigned int*'} to 'int*'
67 | rar(n, a);
| ^
| |
| ull* {aka long long unsigned int*}
a.cc:38:22: note: initializing argument 2 of 'void rar(int, int*)'
38 | void rar(int n, int* a);
| ~~~~~^
a.cc:68:12: error: cannot convert 'ull*' {aka 'long long unsigned int*'} to 'int*'
68 | rar(n, b);
| ^
| |
| ull* {aka long long unsigned int*}
a.cc:38:22: note: initializing argument 2 of 'void rar(int, int*)'
38 | void rar(int n, int* a);
| ~~~~~^
|
s352805591
|
p03982
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
template<int NV,class V> class MinCostFlow {
public:
struct edge { ll to, capacity; V cost; int reve;};
vector<edge> E[NV]; int prev_v[NV], prev_e[NV]; V dist[NV];
void add_edge(int x,int y, ll cap, V cost,bool undir=false) {
E[x].push_back((edge){y,cap,cost,(int)E[y].size()});
if(undir) E[y].push_back((edge){x,cap, cost,(int)E[x].size()-1}); /* rev edge */
else E[y].push_back((edge){x,0, -cost,(int)E[x].size()-1}); /* rev edge */
}
V mincost(int from, int to, ll flow) {
V res=0; int i,v;
ZERO(prev_v); ZERO(prev_e);
while(flow>0) {
fill(dist, dist+NV, numeric_limits<V>::max()/2);
dist[from]=0;
priority_queue<pair<V,int> > Q;
Q.push(make_pair(0,from));
while(Q.size()) {
V d=-Q.top().first
int cur=Q.top().second;
Q.pop();
if(dist[cur]!=d) continue;
if(d==numeric_limits<V>::max()/2) break;
FOR(i,E[cur].size()) {
edge &e=E[cur][i];
if(e.capacity>0 && dist[e.to]>d+e.cost) {
dist[e.to]=d+e.cost;
prev_v[e.to]=cur;
prev_e[e.to]=i;
Q.push(make_pair(-dist[e.to],e.to));
}
}
}
if(dist[to]==numeric_limits<V>::max()/2) return -1;
ll lc=flow;
for(v=to;v!=from;v=prev_v[v]) lc = min(lc, E[prev_v[v]][prev_e[v]].capacity);
flow -= lc;
res += lc*dist[to];
for(v=to;v!=from;v=prev_v[v]) {
edge &e=E[prev_v[v]][prev_e[v]];
e.capacity -= lc;
E[v][e.reve].capacity += lc;
}
}
return res;
}
};
MinCostFlow<3050,ll> mcf;
int N;
ll A[101010];
ll B[101010];
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N;
if(N>1000) return;
FOR(i,N) {
cin>>A[i];
mcf.add_edge(0,i+2,A[i],0);
if(i<N-1) mcf.add_edge(i+2,i+3,1LL<<40,1,true);
}
ll sum=0;
FOR(i,N) {
cin>>B[i];
sum += B[i];
mcf.add_edge(i+2,1,B[i],0);
}
cout<<mcf.mincost(0,1,sum)<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n';
FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
solve(); return 0;
}
|
a.cc: In member function 'V MinCostFlow<NV, V>::mincost(int, int, ll)':
a.cc:35:33: error: expected ',' or ';' before 'int'
35 | int cur=Q.top().second;
| ^~~
a.cc:37:41: error: 'cur' was not declared in this scope
37 | if(dist[cur]!=d) continue;
| ^~~
a.cc:39:41: error: 'cur' was not declared in this scope
39 | FOR(i,E[cur].size()) {
| ^~~
a.cc:7:30: note: in definition of macro 'FOR'
7 | #define FOR(x,to) for(x=0;x<(to);x++)
| ^~
|
s310818060
|
p03982
|
Java
|
import java.util.Arrays;
import java.util.Scanner;
public class MainH {
MyScanner sc = new MyScanner();
Scanner sc2 = new Scanner(System.in);
long start = System.currentTimeMillis();
long fin = System.currentTimeMillis();
final int MOD = 1000000007;
int[] dx = { 1, 0, 0, -1 };
int[] dy = { 0, 1, -1, 0 };
void run() {
int N = sc.nextInt();
long[] A = sc.nextLongArray(N);
long[] B = sc.nextLongArray(N);
if (N > 1000)
return;
int cost = 0;
for (int i = 0; i < N; i++) {
if (A[i] < B[i]) {
long need = B[i] - A[i];
int go = i + 1;
int ba = i - 1;
while (true) {
if (ba >= 0) {
if (A[ba] > B[ba]) {
long rem = A[ba] - B[ba];
A[ba] -= Math.min(rem, need);
cost += (i - ba) * Math.min(rem, need);
need -= Math.min(rem, need);
}
}
if (need == 0) break;
if (go < N) {
if (A[go] > B[go]) {
long rem = A[go] - B[go];
A[go] -= Math.min(rem, need);
cost += (go - i) * Math.min(rem, need);
need -= Math.min(rem, need);
}
}
if (need == 0) break;
if (go < N) go++;
if (ba >= 0) ba--;
if (go == N && ba == 0) break;
}
}
}
System.out.println(cost);
}
public static void main(String[] args) {
new MainH().run();
}
void debug(Object... o) {
System.out.println(Arrays.deepToString(o));
}
void debug2(char[][] array) {
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
System.out.print(array[i][j]);
}
System.out.println();
}
}
boolean inner(int h, int w, int limH, int limW) {
return 0 <= h && h < limH && 0 <= w && w < limW;
}
void swap(int[] x, int a, int b) {
int tmp = x[a];
x[a] = x[b];
x[b] = tmp;
}
// find minimum i (k <= a[i])
int lower_bound(int a[], int k) {
int l = -1;
int r = a.length;
while (r - l > 1) {
int mid = (l + r) / 2;
if (k <= a[mid])
r = mid;
else
l = mid;
}
// r = l + 1
return r;
}
// find minimum i (k < a[i])
int upper_bound(int a[], int k) {
int l = -1;
int r = a.length;
while (r - l > 1) {
int mid = (l + r) / 2;
if (k < a[mid])
r = mid;
else
l = mid;
}
// r = l + 1
return r;
}
long gcd(long a, long b) {
return a % b == 0 ? b : gcd(b, a % b);
}
long lcm(long a, long b) {
return a * b / gcd(a, b);
}
boolean palindrome(String s) {
for (int i = 0; i < s.length() / 2; i++) {
if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
return false;
}
}
return true;
}
class MyScanner {
int nextInt() {
try {
int c = System.in.read();
while (c != '-' && (c < '0' || '9' < c))
c = System.in.read();
if (c == '-')
return -nextInt();
int res = 0;
do {
res *= 10;
res += c - '0';
c = System.in.read();
} while ('0' <= c && c <= '9');
return res;
} catch (Exception e) {
return -1;
}
}
double nextDouble() {
return Double.parseDouble(next());
}
long nextLong() {
return Long.parseLong(next());
}
String next() {
try {
StringBuilder res = new StringBuilder("");
int c = System.in.read();
while (Character.isWhitespace(c))
c = System.in.read();
do {
res.append((char) c);
} while (!Character.isWhitespace(c = System.in.read()));
return res.toString();
} catch (Exception e) {
return null;
}
}
int[] nextIntArray(int n) {
int[] in = new int[n];
for (int i = 0; i < n; i++) {
in[i] = nextInt();
}
return in;
}
int[][] nextInt2dArray(int n, int m) {
int[][] in = new int[n][m];
for (int i = 0; i < n; i++) {
in[i] = nextIntArray(m);
}
return in;
}
double[] nextDoubleArray(int n) {
double[] in = new double[n];
for (int i = 0; i < n; i++) {
in[i] = nextDouble();
}
return in;
}
long[] nextLongArray(int n) {
long[] in = new long[n];
for (int i = 0; i < n; i++) {
in[i] = nextLong();
}
return in;
}
char[][] nextCharField(int n, int m) {
char[][] in = new char[n][m];
for (int i = 0; i < n; i++) {
String s = sc.next();
for (int j = 0; j < m; j++) {
in[i][j] = s.charAt(j);
}
}
return in;
}
}
}
|
Main.java:4: error: class MainH is public, should be declared in a file named MainH.java
public class MainH {
^
1 error
|
s930553040
|
p03984
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
ost<<"{"<<p.first<<","<<p.second<<"}";
return ost;
}
template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
ost<<"{";
for(int i=0;i<v.size();i++){
if(i)ost<<",";
ost<<v[i];
}
ost<<"}";
return ost;
}
struct ModX{
using ull=uint64_t;
static const ull mod=(1ll<<61)-1;
static const ull MASK30=(1ll<<30)-1;
static const ull MASK31=(1ll<<31)-1;
ull a;
ModX& s(ull vv){
a=vv<mod?vv:vv-mod;
return *this;
}
ModX(ull a=0):a(a%mod){}
ModX& operator+=(const ModX& x){return s(a+x.a);}
ModX& operator-=(const ModX& x){return s(a+mod-x.a);}
ModX& operator*=(const ModX& x){
const ull au=a>>31;
const ull ad=a&MASK31;
const ull bu=x.a>>31;
const ull bd=x.a&MASK31;
const ull mid=ad*bu+au*bd;
const ull midu=mid>>30;
const ull midd=mid&MASK30;
const ull z=au*bu*2+midu+(midd<<31)+ad*bd;
return s((z&mod)+(z>>61));
}
ModX operator+(const ModX &x)const{return ModX(*this)+=x;}
ModX operator-(const ModX &x)const{return ModX(*this)-=x;}
ModX operator*(const ModX &x)const{return ModX(*this)*=x;}
bool operator==(const ModX &x)const{return a==x.a;}
bool operator!=(const ModX &x)const{return a!=x.a;}
bool operator<(const ModX &x)const{return a<x.a;}
ModX operator-()const{return ModX()-*this;}
};
istream& operator>>(istream& in,const ModX& a){
return (in>>a.a);
}
ostream& operator<<(ostream& out,const ModX& a){
return (out<<a.a);
}
using xint=ModX;
const xint base(119);
const int RHSIZE=1111111;
xint basepow[RHSIZE];
struct RHInit{
RHInit(){
basepow[0]=1;
for(int i=1;i<RHSIZE;i++)basepow[i]=basepow[i-1]*base;
}
}RHInitDummy;
template<uint32_t mod>
struct ModInt{
uint32_t a;
ModInt& s(uint32_t vv){
a=vv<mod?vv:vv-mod;
return *this;
}
ModInt(int64_t x=0){s(x%mod+mod);}
ModInt& operator+=(const ModInt &x){return s(a+x.a);}
ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
ModInt& operator*=(const ModInt &x){
a=uint64_t(a)*x.a%mod;
return *this;
}
ModInt& operator/=(const ModInt &x){
*this*=x.inv();
return *this;
}
ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
bool operator==(const ModInt &x)const{return a==x.a;}
bool operator!=(const ModInt &x)const{return a!=x.a;}
bool operator<(const ModInt &x)const{return a<x.a;}
ModInt operator-()const{return ModInt()-*this;}
ModInt pow(int64_t n)const{
ModInt res(1),x(*this);
while(n){
if(n&1)res*=x;
x*=x;
n>>=1;
}
return res;
}
ModInt inv()const{return pow(mod-2);}
};
template<uint32_t mod>
istream& operator>>(istream& in,const ModInt<mod>& a){
return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
return (out<<a.a);
}
using mint=ModInt<1000000007>;
//using mint=ModInt<998244353>;
template<class Mint,int32_t lg>
struct ModIntTable{
int N;
vector<Mint>facts,finvs,invs;
ModIntTable():N(1<<lg),facts(N),finvs(N),invs(N){
const uint32_t mod=Mint(-1).a+1;
invs[1]=1;
for(int i=2;i<N;i++)invs[i]=invs[mod%i]*(mod-mod/i);
facts[0]=1;
finvs[0]=1;
for(int i=1;i<N;i++){
facts[i]=facts[i-1]*i;
finvs[i]=finvs[i-1]*invs[i];
}
}
inline Mint fact(int n)const{return facts[n];}
inline Mint finv(int n)const{return finvs[n];}
inline Mint inv(int n)const{return invs[n];}
inline Mint binom(int n,int k)const{return facts[n]*finvs[k]*finvs[n-k];}
inline Mint perm(int n,int k)const{return facts[n]*finvs[n-k];}
};
ModIntTable<mint,19>mtable;
// ^ library
//---------------------------------------------------------------
// v main
int N,K;
vint G[111111];
int deg[111111];
xint tree_hs[111111];
mint tree_col[111111];
void dfs(int v,int p){
tree_hs[v]=1;
tree_col[v]=K;
map<xint,int>cnt;
map<xint,mint>mem;
for(auto &u:G[v]){
if(u==p||deg[u]==2)continue;
dfs(u,v);
xint h=tree_hs[u];
tree_hs[v]*=base+h;
cnt[h]++;
mem[h]=tree_col[u];
}
for(auto &q:cnt){
mint w=mem[q.fi];
mint tmp=1;
rep(i,q.se)tmp*=w+i;
tmp*=mtable.finv(q.se);
tree_col[v]*=tmp;
}
}
int gcd(int a,int b){
return b?gcd(b,a%b):a;
}
template<class T>
vector<int>zalgorithm(T s){
vector<int>a(s.size());
a[0]=s.size();
int i=1,j=0;
while(i<s.size()){
while(i+j<s.size()&&s[j]==s[i+j])j++;
a[i]=j;
if(j==0){i++;continue;}
int k=1;
while(i+k<s.size()&&k+a[k]<j)a[i+k]=a[k],k++;
i+=k;j-=k;
}
return a;
}
signed main(){
scanf("%lld%lld",&N,&K);
set<int>va;
rep(i,N){
int a;
scanf("%lld",&a);
a--;
G[i].pb(a);G[a].pb(i);
assert(i!=a);
assert(va.find(pint(min(i,a),max(i,a)))==va.end());
va.insert(pint(min(i,a),max(i,a)));
}
return 0;
rep(i,N)for(auto &u:G[i]){
deg[u]++;
}
queue<int>que;
rep(i,N)if(deg[i]==1){
que.push(i);
}
while(que.size()){
int v=que.front();
que.pop();
for(auto &u:G[v]){
if(--deg[u]==1){
que.push(u);
}
}
}
int latte=0;
rep(i,N)if(deg[i]==2)latte++;
assert(latte>=3);
return 0;
vint c;
rep(i,N)if(deg[i]==2){
c.pb(i);
break;
}
for(int t=0;;t++){
assert(t<=N);
bool flag=false;
for(auto u:G[c.back()]){
if(deg[u]!=2)continue;
if(c.size()>1&&c[c.size()-2]==u)continue;
if(u==c[0])flag=true;
else{
c.pb(u);
break;
}
}
if(flag)break;
}
for(auto u:c)dfs(u,-1);
int n=c.size();
vector<xint>hs_cw,hs_ccw;
vector<mint>col_cw;
hs_cw.pb(0);col_cw.pb(1);
rep(i,2*n){
hs_cw.pb(hs_cw.back()*base+tree_hs[c[i%n]]);
col_cw.pb(col_cw.back()*tree_col[c[i%n]]);
}
hs_ccw.pb(0);
for(int i=2*n-1;i>=0;i--){
hs_ccw.pb(hs_ccw.back()*base+tree_hs[c[i%n]]);
}
vint num(n+1);
reps(i,1,n+1)num[gcd(i,n)]++;
vector<xint>uku;
rep(i,n)uku.pb(tree_hs[c[i]]);
auto z=zalgorithm(uku);
int cir=n;
for(int i=n-1;i>0;i--){
if(n%i)continue;
if(z[i]==n-i)cir=i;
}
mint ans;
int denom=0;
for(int i=cir;i<=n;i+=cir){
mint tmp_ans=col_cw[i];
ans+=tmp_ans*num[i];
denom+=num[i];
}
if(n&1){
int len=n/2;
rep(i,n){
xint h=hs_cw[i+1+len]-hs_cw[i+1]*basepow[len];
int k=n-1-(i+n-1)%n;
xint h2=hs_ccw[k+len]-hs_ccw[k]*basepow[len];
if(h!=h2)continue;
mint tmp=col_cw[i+1+len]*col_cw[i].inv();
ans+=tmp;
denom++;
}
}
else{
int len=n/2;
rep(i,n/2){
xint h=hs_cw[i+len]-hs_cw[i]*basepow[len];
int k=n-1-(i+n-1)%n;
xint h2=hs_ccw[k+len]-hs_ccw[k]*basepow[len];
if(h!=h2)continue;
mint tmp=col_cw[i+len]*col_cw[i].inv();
ans+=tmp;
denom++;
}
rep(i,n/2){
xint h=hs_cw[i+len]-hs_cw[i+1]*basepow[len-1];
int k=n-1-(i+n-1)%n;
xint h2=hs_ccw[k+len-1]-hs_ccw[k]*basepow[len-1];
if(h!=h2)continue;
mint tmp=col_cw[i+len+1]*col_cw[i].inv();
ans+=tmp;
denom++;
}
}
ans/=denom;
cout<<ans<<endl;
return 0;
}
|
In file included from /usr/include/c++/14/cassert:44,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:106,
from a.cc:1:
a.cc: In function 'int main()':
a.cc:244:23: error: no matching function for call to 'std::set<long long int>::find(pint)'
244 | assert(va.find(pint(min(i,a),max(i,a)))==va.end());
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/set:63,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158:
/usr/include/c++/14/bits/stl_set.h:806:9: note: candidate: 'template<class _Kt> decltype (std::set<_Key, _Compare, _Alloc>::iterator{((std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_find_tr(__x)}) std::set<_Key, _Compare, _Alloc>::find(const _Kt&) [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>]'
806 | find(const _Kt& __x)
| ^~~~
/usr/include/c++/14/bits/stl_set.h:806:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_set.h: In substitution of 'template<class _Kt> decltype (std::set<long long int>::iterator{((std::set<long long int>*)this)->std::set<long long int>::_M_t.std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::_M_find_tr(__x)}) std::set<long long int>::find(const _Kt&) [with _Kt = std::pair<long long int, long long int>]':
a.cc:244:9: required from here
244 | assert(va.find(pint(min(i,a),max(i,a)))==va.end());
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:807:45: error: no matching function for call to 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::_M_find_tr(const std::pair<long long int, long long int>&)'
807 | -> decltype(iterator{_M_t._M_find_tr(__x)})
| ~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/map:62,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:1291:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) [with _Req = _Kt; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>]'
1291 | _M_find_tr(const _Kt& __k)
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1291: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<long long int>; _SfinaeType = std::pair<long long int, long long int>]':
/usr/include/c++/14/bits/stl_tree.h:1289:9: required by substitution of 'template<class _Kt> decltype (std::set<long long int>::iterator{((std::set<long long int>*)this)->std::set<long long int>::_M_t.std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::_M_find_tr(__x)}) std::set<long long int>::find(const _Kt&) [with _Kt = std::pair<long long int, long long int>]'
1289 | typename _Req = __has_is_transparent_t<_Compare, _Kt>>
| ^~~~~~~~
a.cc:244:9: required from here
244 | assert(va.find(pint(min(i,a),max(i,a)))==va.end());
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:1427:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<long long int>, std::pair<long long int, long long int>, void>'
1427 | using __has_is_transparent_t
| ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h: In substitution of 'template<class _Kt> decltype (std::set<long long int>::iterator{((std::set<long long int>*)this)->std::set<long long int>::_M_t.std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::_M_find_tr(__x)}) std::set<long long int>::find(const _Kt&) [with _Kt = std::pair<long long int, long long int>]':
a.cc:244:9: required from here
244 | assert(va.find(pint(min(i,a),max(i,a)))==va.end());
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1300:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) const [with _Req = _Kt; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>]'
1300 | _M_find_tr(const _Kt& __k) const
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1300:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_set.h:806:9: error: no matching function for call to 'std::_Rb_tree_const_iterator<long long int>::_Rb_tree_const_iterator(<brace-enclosed initializer list>)'
806 | find(const _Kt& __x)
| ^~~~
/usr/include/c++/14/bits/stl_tree.h:346:7: note: candidate: 'std::_Rb_tree_const_iterator<_Tp>::_Rb_tree_const_iterator(const iterator&) [with _Tp = long long int; iterator = std::_Rb_tree_const_iterator<long long int>::iterator]'
346 | _Rb_tree_const_iterator(const iterator& __it) _GLIBCXX_NOEXCEPT
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:346:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/bits/stl_tree.h:343:7: note: candidate: 'std::_Rb_tree_const_iterator<_Tp>::_Rb_tree_const_iterator(_Base_ptr) [with _Tp = long long int; _Base_ptr = const std::_Rb_tree_node_base*]'
343 | _Rb_tree_const_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPT
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:343:7: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/bits/stl_tree.h:339:7: note: candidate: 'std::_Rb_tree_const_iterator<_Tp>::_Rb_tree_const_iterator() [with _Tp = long long int]'
339 | _Rb_tree_const_iterator() _GLIBCXX_NOEXCEPT
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:339:7: note: candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<long long int>::_Rb_tree_const_iterator(const std::_Rb_tree_const_iterator<long long int>&)'
324 | struct _Rb_tree_const_iterator
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:324:12: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<long long int>::_Rb_tree_const_iterator(std::_Rb_tree_const_iterator<long long int>&&)'
/usr/include/c++/14/bits/stl_tree.h:324:12: note: conversion of argument 1 would be ill-formed:
/usr/include/c++/14/bits/stl_set.h:812:9: note: candidate: 'template<class _Kt> decltype (std::set<_Key, _Compare, _Alloc>::const_iterator{((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_find_tr(__x)}) std::set<_Key, _Compare, _Alloc>::find(const _Kt&) const [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>]'
812 | find(const _Kt& __x) const
| ^~~~
/usr/include/c++/14/bits/stl_set.h:812:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_set.h: In substitution of 'template<class _Kt> decltype (std::set<long long int>::const_iterator{((const std::set<long long int>*)this)->std::set<long long int>::_M_t.std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::_M_find_tr(__x)}) std::set<long long int>::find(const _Kt&) const [with _Kt = std::pair<long long int, long long int>]':
a.cc:244:9: required from here
244 | assert(va.find(pint(min(i,a),max(i,a)))==va.end());
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:813:51: error: no matching function for call to 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::_M_find_tr(const std::pair<long long int, long long int>&) const'
813 | -> decltype(const_iterator{_M_t._M_find_tr(__x)})
| ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_tree.h:1291:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) [with _Req = _Kt; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>]'
1291 | _M_find_tr(const _Kt& __k)
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1291:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_tree.h:1300:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) const [with _Req = _Kt; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>]'
1300 | _M_find_tr(const _Kt& _
|
s876589181
|
p03984
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
class SCC_BI {
public:
static const int MV = 210000;
int NV,time;
vector<vector<int> > E;
vector<int> ord,llink,inin;
stack<int> roots,S;
vector<int> M; //point to group
vector<int> ART; // out
vector<vector<int> > SC; // out
vector<pair<int,int> > BR; // out
void init(int NV=MV) { this->NV=NV; E.clear(); E.resize(NV);}
void add_edge(int x,int y) { assert(NV);E[x].push_back(y); E[y].push_back(x); }
void dfs(int cur,int pre) {
int art=0,conn=0,i,se=0;
ord[cur]=llink[cur]=++time;
S.push(cur); inin[cur]=1; roots.push(cur);
FOR(i,E[cur].size()) {
int tar=E[cur][i];
if(ord[tar]==0) {
conn++; dfs(tar,cur);
llink[cur]=min(llink[cur],llink[tar]);
art += (pre!=-1 && ord[cur]<=llink[tar]);
if(ord[cur]<llink[tar]) BR.push_back(make_pair(min(cur,tar),max(cur,tar)));
}
else if(tar!=pre || se) {
llink[cur]=min(llink[cur],ord[tar]);
while(inin[tar]&&ord[roots.top()]>ord[tar]) roots.pop();
}
else se++; // double edge
}
if(cur==roots.top()) {
SC.push_back(vector<int>());
while(1) {
i=S.top(); S.pop(); inin[i]=0;
SC.back().push_back(i);
M[i]=SC.size()-1;
if(i==cur) break;
}
sort(SC.back().begin(),SC.back().end());
roots.pop();
}
if(art || (pre==-1&&conn>1)) ART.push_back(cur);
}
void scc() {
SC.clear(),BR.clear(),ART.clear(),M.resize(NV);
ord.clear(),llink.clear(),inin.clear(),time=0;
ord.resize(NV);llink.resize(NV);inin.resize(NV);
for(int i=0;i<NV;i++) if(!ord[i]) dfs(i,-1);
sort(BR.begin(),BR.end()); sort(ART.begin(),ART.end());
}
};
struct RollingHash {
static const ll mo0=1000000007,mo1=1000000009;
static ll mul0,mul1;
static const ll add0=1000010007, add1=1003333331;
static vector<ll> pmo[2];
int l; vector<ll> hash_[2];
void init(vector<int> s) {
l=s.size(); int i,j;
hash_[0]=hash_[1]=vector<ll>(1,0);
if(!mul0) mul0=10009+(((ll)&mul0)>>5)%259,mul1=10007+(((ll)&mul1)>>5)%257;
if(pmo[0].empty()) pmo[0].push_back(1),pmo[1].push_back(1);
FOR(i,l) hash_[0].push_back((hash_[0].back()*mul0+add0+s[i])%mo0);
FOR(i,l) hash_[1].push_back((hash_[1].back()*mul1+add1+s[i])%mo1);
}
pair<ll,ll> hash(int l,int r) { // s[l..r]
if(l>r) return make_pair(0,0);
while(pmo[0].size()<r+2)
pmo[0].push_back(pmo[0].back()*mul0%mo0), pmo[1].push_back(pmo[1].back()*mul1%mo1);
return make_pair((hash_[0][r+1]+(mo0-hash_[0][l]*pmo[0][r+1-l]%mo0))%mo0,
(hash_[1][r+1]+(mo1-hash_[1][l]*pmo[1][r+1-l]%mo1))%mo1);
}
};
vector<ll> RollingHash::pmo[2]; ll RollingHash::mul0,RollingHash::mul1;
ll mo=1000000007;
int N,K;
vector<int> E[101010];
int inloop[101010];
SCC_BI bi;
vector<int> L;
ll H[101010],D[101010];
int phi[101010];
ll modpow(ll a, ll n) {
ll r=1;
while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
return r;
}
ll comb(int P_,int Q_) {
if(P_<0 || Q_<0 || Q_>P_) return 0;
ll ret=1;
Q_=min(Q_,P_-Q_);
for(int i=1;i<=Q_;i++) ret=ret*(P_+1-i)%mo*modpow(i,mo-2)%mo;
return ret;
}
ll hcomb(int P_,int Q_) { return (P_==0&&Q_==0)?1:comb(P_+Q_-1,Q_);};
void dfs2(int cur,int pre) {
ll momo[2]={1000000007,1000000009};
vector<ll> prim = {100291,100297,100313,100333,100343,100357,100361,100363,100379,100391};
vector<pair<ll,ll>> V;
FORR(r,E[cur]) if(r!=pre) {
dfs2(r,cur);
V.push_back({H[r],D[r]});
}
sort(ALL(V));
int id=0,id2=1;
ll a=1,b=1;
FORR(r,V) {
ll h=r.first>>32, l=r.first-(h<<32);
(a+=h*prim[(id++)%prim.size()])%=momo[0];
(b+=l*prim[(id2++)%prim.size()])%=momo[1];
}
H[cur]=(a<<32)+b;
D[cur]=K;
for(int i=0,num=1;i<V.size();i+=num+1) {
num=1;
while(i+num<V.size() && V[i+num-1]==V[i+num]) num++;
D[cur] = D[cur] * hcomb(V[i].second,num) % mo;
}
return;
}
void dfs(int cur) {
inloop[cur]=2;
L.push_back(cur);
int i;
FOR(i,E[cur].size()) if(inloop[E[cur][i]]) {
if(inloop[E[cur][i]]==1) dfs(E[cur][i]);
E[cur].erase(E[cur].begin()+i);
i--;
}
dfs2(cur,-1);
}
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N>>K;
bi.init(N);
FOR(i,N) {
cin>>x;
E[i].push_back(x-1);
E[x-1].push_back(i);
bi.add_edge(i,x-1);
}
bi.scc();
FOR(i,bi.SC.size()) FORR(r,bi.SC[i]) inloop[r]=bi.SC[i].size()>1;
FOR(i,N) if(inloop[i]) {
dfs(i);
break;
}
int maxper=1;
for(i=2;i<=L.size();i++) if(L.size()%i==0) {
int ng=0;
FOR(j,L.size()-i) if(H[j]!=H[j+i] || D[j]!=D[j+i]) ng=1;
if(ng==0) maxper=max(maxper,L.size()/i);
}
for(i=1;i<=L.size();i++) phi[__gcd(i,maxper)]++;
// symmetric;
vector<int> nor,rev;
FOR(i,2*L.size()) nor.push_back(H[i%L.size()]),rev.push_back(H[L.size()-1-i%L.size()]);
RollingHash rhn,rhr;
rhn.init(nor);
rhr.init(rev);
int found=-1;
FOR(i,L.size()) {
if(L.size()%2==0 && H[i]!=H[i+L.size()/2]) continue;
if(rhn.hash(i,i+L.size()/2)==rhr.hash(L.size()-1+i,L.size()-1+i+L.size()/2)) {
found=i;
break;
}
}
/*
_P("%d\n",found);
FOR(i,L.size()) _P("%d : %lld %lld\n",i,H[i],D[i]);
*/
ll ret=0;
if(found==-1) {
for(i=1;i<=L.size();i++) if(phi[i]) {
ll t=phi[i];
FOR(j,i) t=t*D[j]%mo;
ret += t;
}
ret = ret%mo*modpow(L.size(),mo-2)%mo;
}
else {
assert(0);
}
cout<<ret<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n';
FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
solve(); return 0;
}
|
a.cc: In function 'void solve()':
a.cc:183:37: error: no matching function for call to 'max(int&, std::vector<int>::size_type)'
183 | if(ng==0) maxper=max(maxper,L.size()/i);
| ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:183:37: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
183 | if(ng==0) maxper=max(maxper,L.size()/i);
| ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:183:37: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
183 | if(ng==0) maxper=max(maxper,L.size()/i);
| ~~~^~~~~~~~~~~~~~~~~~~
|
s302748251
|
p03985
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int T;
double XA,YA,RA;
double XB,YB,RB;
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>T;
while(T--) {
cin>>XA>>YA>>RA;
cin>>XB>>YB>>RB;
double D=hypot(XA-XB,YA-YB);
double X=0.5/RA;
double r1=X-1/(RA+D-RB);
double r2=X-1/(RA+D+RB);
double x = sqrt(c);
double r3 = 0.5/x;
double a = 0.5/(x-r1);
double b = 0.5/(x-r2);
double r4 = abs(a-b);
double dif=(r4-r3)/2;
double at = asin(dif/(r3+dif));
_P("%d\n",(int)(atan(1)*4/at));
}
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n';
FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
solve(); return 0;
}
|
a.cc: In function 'void solve()':
a.cc:32:33: error: 'c' was not declared in this scope
32 | double x = sqrt(c);
| ^
|
s869110739
|
p03986
|
Java
|
import java.util.*; import java.io.*; import java.math.*;
public class Main{
//Don't have to see. start------------------------------------------
static class InputIterator{
ArrayList<String> inputLine = new ArrayList<String>(1024);
int index = 0; int max; String read;
InputIterator(){
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try{
while((read = br.readLine()) != null){
inputLine.add(read);
}
}catch(IOException e){}
max = inputLine.size();
}
boolean hasNext(){return (index < max);}
String next(){
if(hasNext()){
return inputLine.get(index++);
}else{
throw new IndexOutOfBoundsException("There is no more input");
}
}
}
static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
static PrintWriter out = new PrintWriter(System.out);
static void flush(){out.flush();}
static void myout(Object t){out.println(t);}
static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
static String next(){return ii.next();}
static boolean hasNext(){return ii.hasNext();}
static int nextInt(){return Integer.parseInt(next());}
static long nextLong(){return Long.parseLong(next());}
static double nextDouble(){return Double.parseDouble(next());}
static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
static ArrayList<Integer> nextIntArray(){
ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
for(int i = 0; i < input.size(); i++){
ret.add(Integer.parseInt(input.get(i)));
}
return ret;
}
static ArrayList<Long> nextLongArray(){
ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
for(int i = 0; i < input.size(); i++){
ret.add(Long.parseLong(input.get(i)));
}
return ret;
}
static String myconv(Object list, int no){//only join
String joinString = CONVSTR.get(no);
if(list instanceof String[]){
return String.join(joinString, (String[])list);
}else if(list instanceof ArrayList){
return String.join(joinString, (ArrayList)list);
}else{
throw new ClassCastException("Don't join");
}
}
static ArrayList<String> myconv(String str, int no){//only split
String splitString = CONVSTR.get(no);
return new ArrayList<String>(Arrays.asList(str.split(splitString)));
}
public static void main(String[] args){
CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
solve();flush();
}
//Don't have to see. end------------------------------------------
static void solve(){//Here is the main function
ArrayList<String> s = nextCharArray();
int c = 0;
int output = s.szie();
for(int i = 0; i < s.size(); i++){
if(s.get(i).equals("S")){
c++;
}else{
if(c > 0){
c--;
output -= 2;
}
}
}
myout(output);
}
//Method addition frame start
//Method addition frame end
}
|
Main.java:74: error: cannot find symbol
int output = s.szie();
^
symbol: method szie()
location: variable s of type ArrayList<String>
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
|
s810584649
|
p03986
|
C++
|
#include<stack>
using namespace std;
int main()
{
stack<char> x;
string a;
char ex='T';
cin >> a;
for(int i=0;i<a.length();i++)
{
x.push(a[i]);
if (ex == 'S' && x.top() == 'T')
{
x.pop();
x.pop();
}
if (x.size() == 0)ex = 'T';
else
ex = x.top();
}
cout << x.size () << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:7:9: error: 'string' was not declared in this scope
7 | string a;
| ^~~~~~
a.cc:2:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
1 | #include<stack>
+++ |+#include <string>
2 | using namespace std;
a.cc:9:9: error: 'cin' was not declared in this scope
9 | cin >> a;
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include<stack>
+++ |+#include <iostream>
2 | using namespace std;
a.cc:9:16: error: 'a' was not declared in this scope
9 | cin >> a;
| ^
a.cc:22:9: error: 'cout' was not declared in this scope
22 | cout << x.size () << endl;
| ^~~~
a.cc:22:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:22:30: error: 'endl' was not declared in this scope
22 | cout << x.size () << endl;
| ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
1 | #include<stack>
+++ |+#include <ostream>
2 | using namespace std;
|
s375675937
|
p03986
|
C++
|
# include <iostream>
# include <vector>
# include <algorithm>
using namespace std;
# define ll long long
int main(){
string S;
cin >> S;
vector<char> stack;
for(int i=0; i<S.size(); i++){
if(S[i] == 'S') stack.push_back(s[i]);
else {
if(stack.empty()) stack.push_back(s[i]);
else stack.pop_back();
}
}
cout << stack.size() << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:15:37: error: 's' was not declared in this scope
15 | if(S[i] == 'S') stack.push_back(s[i]);
| ^
a.cc:17:41: error: 's' was not declared in this scope
17 | if(stack.empty()) stack.push_back(s[i]);
| ^
|
s325307682
|
p03986
|
C++
|
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
string a;
cin>>a;
int tmp=a.find("ST");
while(a.length()>0&&tmp>=0&&tmp!=string::npos)
{
a.erase(tmp,2);
tmp=a.find("ST",x);
if(tmp==string::npos)
tmp=-1;
}
cout<<a.length()<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:13:33: error: 'x' was not declared in this scope
13 | tmp=a.find("ST",x);
| ^
|
s857359740
|
p03986
|
Java
|
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String str = sc.next();
int s = 0;
int t = 0;
for(int i=0;i<str.length();i++){if(s.charAt(i)=='T'){t++;}
else{break;}
}
for(int i=str.length()-1;i>=0;i--){if(s.charAt(i)=='S'){s++;}
else{break;}
}
System.out.println(Math.max(2*s,2*t));
}
}
|
Main.java:8: error: int cannot be dereferenced
for(int i=0;i<str.length();i++){if(s.charAt(i)=='T'){t++;}
^
Main.java:11: error: int cannot be dereferenced
for(int i=str.length()-1;i>=0;i--){if(s.charAt(i)=='S'){s++;}
^
2 errors
|
s342224149
|
p03986
|
Java
|
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String str = sc.next();
int s = 0;
int t = 0;
for(int i=0;i<str.length();i++){if(s.charAt(i)=='T'){t++;}
else{break;}
}
for(int i=str.length()-1;i>=0;i--){if(s.charAt(i)=='S'){s++;}
else{break;}
}
System.out.println(Math.max(2*s,2*t);
}
}
|
Main.java:14: error: ')' or ',' expected
System.out.println(Math.max(2*s,2*t);
^
1 error
|
s157118103
|
p03986
|
C++
|
#include <iostream>
#include <vector>
using namespace std;
int main() {
string s;
cin >> s;
int a=0,b=0;
for(int i=0;i<s.size();i++){
if(s[i] == 'S'){
a++;
}
else{
if(a>0){
a--;
}
b++;
}
cout << a+b << endl;
}
|
a.cc: In function 'int main()':
a.cc:26:4: error: expected '}' at end of input
26 | }
| ^
a.cc:5:12: note: to match this '{'
5 | int main() {
| ^
|
s051354783
|
p03986
|
C++
|
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll fib(ll a){
if (fibl[a]!=0)return fibl[a];
if (a==0){
return 0;
}else if (a==1){
return 1;
}
return fibl[a]=fib(a-1)+fib(a-2);
}
ll eratosthenes(ll n) {
int p = 0;
for (ll i=0; i<=n; ++i) x[i] = true;
x[0] = x[1] = false;
for(int i=2; i<=n; ++i) {
if(x[i]) {
p++;
for(int j=2*i; j<=n; j+=i) x[j] = false;
}
num[i] = p;
}
return p;
}
ll gcd(ll a,ll b){
if (a%b==0)return(b);
else return(gcd(b,a%b));
}
ll keta(ll N){
int tmp{};
while( N > 0 ){
tmp += ( N % 10 );
N /= 10;
}
N = tmp;
return N;
}
void base_num(ll data,ll base){
if(data==0) return;
ll next=abs(data)%abs(base);
if(data<0) next=(abs(base)-next)%abs(base);
base_num((data-next)/base,base);
cout << next;
}
int main(){
string s;
cin >> s;
ll ans=0,c=0;
for (ll i=0;i<s.size();i++){
if (S[i]=='S')
c++;
else{
if(c==0)ans++
else c++;
}
}
ans+=c;
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:92:13: error: 'S' was not declared in this scope
92 | if (S[i]=='S')
| ^
a.cc:95:26: error: expected ';' before 'else'
95 | if(c==0)ans++
| ^
| ;
96 | else c++;
| ~~~~
|
s153493747
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
void solve(std::string X) {
int tmp = 0;
int tmp1 = 0;
for(int i= 0,i<X.size();i++){
if(X[i] == 'T'){
if(tmp1 == 0)tmp++;
else tmp1++;
}
else tmp1--;
}
cout<<tmp-tmp1;;
}
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
std::string X;
std::cin >> X;
solve(X);
return 0;
}
|
a.cc: In function 'void solve(std::string)':
a.cc:7:17: error: expected ';' before '<' token
7 | for(int i= 0,i<X.size();i++){
| ^
| ;
a.cc:7:17: error: expected primary-expression before '<' token
|
s639919569
|
p03986
|
C++
|
x = input()
while True:
n = len(x)
fl = 0
for i in range(n-1):
if x[i] == "S" and x[i+1] == "T":
x = x[:i] + x[i+2:]
fl = 1
break
if fl == 0:
break
print(len(x))
|
a.cc:1:1: error: 'x' does not name a type
1 | x = input()
| ^
|
s578368195
|
p03986
|
C++
|
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stack>
const int maxn=2e5+5;
using namespace std;
int main()
{
string s;
cin>>s;
stack<char> q;
for(int i=0;i<s.size();i++)
{
if(q.size==0)
{
q.push(s[i]);
continue;
}
char temp=q.top();
q.push(s[i]);
if(temp=='S'&& s[i]=='T')
{
q.pop();
q.pop();
}
}
cout<<q.size()<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:14:22: error: invalid use of member function 'std::stack<_Tp, _Sequence>::size_type std::stack<_Tp, _Sequence>::size() const [with _Tp = char; _Sequence = std::deque<char, std::allocator<char> >; size_type = long unsigned int]' (did you forget the '()' ?)
14 | if(q.size==0)
| ~~^~~~
| ()
|
s070843589
|
p03986
|
C++
|
#include<iostream>
#include<stack>
using namespace std;
stack<char>s;
int main()
{
char a;
int res=0;
while(scanf("%c",&a)!=EOF)
{
res++;
if(ch=='S') s.push(a);
else
{
if(!s.empty())
{
s.pop();
res=res-2;
}
}
}
cout<<res<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:13:20: error: 'ch' was not declared in this scope
13 | if(ch=='S') s.push(a);
| ^~
|
s325154310
|
p03986
|
C++
|
#include<stdio.h>
#include<string.h>
char s1[200005];
char s2[3]={"ST"};
char t[200005];
int main ()
{
gets(s1);
char *p;
while((p=strstr(s1,s2))!=NULL)
{
strcpy(t,p+strlen(s2));
*p='\0';
strcat(s1,t);
}
printf("%d",strlen(s1));
return 0;
}
|
a.cc: In function 'int main()':
a.cc:8:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
8 | gets(s1);
| ^~~~
| getw
|
s424636493
|
p03986
|
C++
|
#include <iostream>
#include <string>
using namespace std;
int main(){
string a;
for(int i=0;i)
string b="ST";
string::size_type idx;
idx=a.find(b);
if(idx == string::npos )
cout << "not found\n";
else
cout <<"found\n";
idx=a.find(c);
if(idx == string::npos )
cout << "not found\n";
else
cout <<"found\n";
return 0;
}
|
a.cc: In function 'int main()':
a.cc:7:18: error: expected ';' before ')' token
7 | for(int i=0;i)
| ^
| ;
a.cc:10:16: error: 'b' was not declared in this scope
10 | idx=a.find(b);
| ^
a.cc:15:16: error: 'c' was not declared in this scope
15 | idx=a.find(c);
| ^
|
s503571131
|
p03986
|
C++
|
const long long MAXN= 1e1000;
string str;
int pos1,pos2;
int main()
{
pos1=0,pos2=1;
cin>>str;
int cnt=0;
while(pos2<=str.size() && cnt<MAXN )
{
while (!(str[pos1] == 'S' && str[pos2] == 'T')) {
pos1++, pos2++;
if (pos2 > str.size()) break;
}
if (pos2 > str.size()) break;
str.erase(pos1, 2);
cnt++;
pos1--,pos2--;
if(pos1<0) break;
}
cout<<str.size();
return 0;
}
|
a.cc:1:1: warning: floating constant exceeds range of 'double' [-Woverflow]
1 | const long long MAXN= 1e1000;
| ^~~~~
a.cc:1:23: warning: overflow in conversion from 'double' to 'long long int' changes value from '+Inf' to '9223372036854775807' [-Woverflow]
1 | const long long MAXN= 1e1000;
| ^~~~~~
a.cc:2:1: error: 'string' does not name a type
2 | string str;
| ^~~~~~
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope
7 | cin>>str;
| ^~~
a.cc:7:10: error: 'str' was not declared in this scope; did you mean 'std'?
7 | cin>>str;
| ^~~
| std
a.cc:22:5: error: 'cout' was not declared in this scope
22 | cout<<str.size();
| ^~~~
|
s818945263
|
p03986
|
C++
|
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
using namespace std;
const int N=200500;
char a[N];
int main()
{
int flag=1;
gets(a);
int size;
while(flag==1)
{
size=strlen(a);
for(int i=0;i<size;i++)
{
if(a[i]=='S'&&a[i+1]=='T')
{
flag=1;
for(int j=i;j<size;j++)
a[j]=a[j+2];
//puts(a);
goto mark;
}
else
{
flag=0;
}
}
mark:
size=strlen(a);
if(size==2&&a[0]=='S'&&a[1]=='T')
{
printf("0\n");
return 0;
}
}
printf("%d\n",size);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:14:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
14 | gets(a);
| ^~~~
| getw
|
s791940496
|
p03986
|
C++
|
#include<stdio.h>
#include<string.h>
const int N=2e6+1;
char a[N];
char temp[N];
/*
int main(void)
{
scanf("%s",a);
char b[2]={'S','T'};
char *p;
while((p=strstr(a,b)) != NULL)
{
*p = '\0';
strcpy (temp, p+strlen(b));
strcat (a, temp);
}
long long ans=strlen(a);
printf("%lld\n",ans);
return 0;
}*/
int main ()
{
gets(a);
char b[2]={'S','T'};
int i = 0, j = 0, count = 0;
while (a[i] != NULL)
{
if (b[count]==NULL && count>0)
{
j = i - count;
while (a[i] != NULL)
{
a[j++] = a[i++];
}
a[j] = NULL;
i = 0;
count = 0;
continue;
}
if (a[i] == b[count])
{
count ++;
}
else if (a[i] == b[0])
{
count = 1;
}
else
{
count = 0;
}
i++;//i用来标记a中的位置
}
if (b[count]==NULL && count>0)
{
a[i-count] = NULL;
}
long long ans=strlen(a);
printf("%d",ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:24:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
24 | gets(a);
| ^~~~
| getw
a.cc:27:20: warning: NULL used in arithmetic [-Wpointer-arith]
27 | while (a[i] != NULL)
| ^~~~
a.cc:29:23: warning: NULL used in arithmetic [-Wpointer-arith]
29 | if (b[count]==NULL && count>0)
| ^~~~
a.cc:32:28: warning: NULL used in arithmetic [-Wpointer-arith]
32 | while (a[i] != NULL)
| ^~~~
a.cc:36:20: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
36 | a[j] = NULL;
| ^~~~
a.cc:55:19: warning: NULL used in arithmetic [-Wpointer-arith]
55 | if (b[count]==NULL && count>0)
| ^~~~
a.cc:57:22: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
57 | a[i-count] = NULL;
| ^~~~
|
s851141985
|
p03986
|
C++
|
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;
vector<char> v;
char x;
int main()
{
while (scanf_s("%c", &x))
{
v.push_back(x);
}
int num = 0;
for (vector<char>::iterator it = v.begin() + 1; it != v.end(); it++)
{
if (*(it - 1) == 'S' && *it == 'T')
{
v.erase(it - 1);
v.erase(it);
num++;
it = v.begin() + 1;
}
if (num == 10 ^ 10000)break;
}
cout << v.size();
return 0;
}
|
a.cc: In function 'int main()':
a.cc:9:16: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
9 | while (scanf_s("%c", &x))
| ^~~~~~~
| scanf
|
s377204952
|
p03986
|
C++
|
#include<bits/stdc++.h>
using namespace std;
char c[200000+5];
int main()
{
gets(c);
int len=strlen(c);
stack<char>ans;
for(int i=0;i<len;++i){
if(ans.empty()){
ans.push(c[i]);
continue;
}
if(ans.top()=='S'&&c[i]=='T'){
ans.pop();
}
else{
ans.push(c[i]);
}
}
cout<<ans.size()<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:6:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
6 | gets(c);
| ^~~~
| getw
|
s627297383
|
p03986
|
C++
|
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;
stack<char>q;
int main(){
string s;
cin>>s;
int len=s.size() ;
for(int i=0;i<len;i++){
if(s[i]=='S')q.push('S');
else{
if(q.size()==0)q.push('T');
else{
char c=q.top();
if(c=='S')q.pop();
SSelse q.push('T');
}
}
}
cout<<q.size()<<endl;
}
|
a.cc: In function 'int main()':
a.cc:18:33: error: 'SSelse' was not declared in this scope
18 | SSelse q.push('T');
| ^~~~~~
|
s539247253
|
p03986
|
C
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
cin >> s;
for (int i = 0; i < s.length()-1; i++) {
if (s[i] == 'S'&&s[i+1]=='T') {
s.erase(i, 2);
if (i > 0) {
i = i - 2;
}
else {
i = i - 1;
}
}
if (s.empty()) {
break;
}
}
if (s.empty()) {
cout << 0 << endl;
}
else {
cout << s.size() << endl;
}
}
|
main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s011181989
|
p03986
|
C
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
cin >> s;
for (int i = 0; i < s.length()-1; i++) {
if (s[i] == 'S'&&s[i+1]=='T') {
s.erase(i, 2);
if (i > 0) {
i = i - 2;
}
else {
i = i - 1;
}
}
if (s.empty()) {
break;
}
}
if (s.empty()) {
cout << 0 << endl;
}
else {
cout << s.size() << endl;
}
}
|
main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s778645818
|
p03986
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000
bool solve(int i,int m);
int main(){
int scount = 0;
int tcount = 0;
string s;
cin >> s;
int ss = s.size();
int ans = ss;
rep(i,ss){
if(s[i] == 'T'){
tcount++;
while(tcount > 0 && scount > 0){
ans -= 2;
tcount--;
scount--;
}
}
if(s[i] == 'S'){
scount++;
tcount = 0;
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:38:2: error: expected '}' at end of input
38 | }
| ^
a.cc:17:11: note: to match this '{'
17 | int main(){
| ^
|
s214308018
|
p03986
|
C++
|
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);
int main(){
int n;
string s;
cin >>s;
n=s.size();
int ans=n,sums=0;
rep(i,n){
if(s[i]=='S'){
sums++;
}
else{
if(sums){
sums--;
ans-=2;
}
}
}
cout << st.size() << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:29:11: error: 'st' was not declared in this scope; did you mean 's'?
29 | cout << st.size() << endl;
| ^~
| s
|
s537342118
|
p03986
|
C++
|
#include <cstdio>
#include <cstring>
int main(){
char a[];
int len = strlen(a);
for(int i = 0;i < len;i++){
scanf("%c",&a[i]);
}
for(int i = 0;i < len;i++){
if(a[i]=='S'&&a[i+1]=='T')len-=2;
}
printf("%d",len);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:4:10: error: storage size of 'a' isn't known
4 | char a[];
| ^
|
s872885974
|
p03986
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define outc cout
#define int long long
signed main(){
int b=0,f=0,g=0,c;
string a;
cin>>a;
c=a.size();
for(int i=0;i<a.size();i++){
if(a[i]=='S') b++;
if(b&&a[i]=='T') b--,c-=2;
}
cout<<c<
|
a.cc: In function 'int main()':
a.cc:14:11: error: expected primary-expression at end of input
14 | cout<<c<
| ^
a.cc:14:11: error: expected '}' at end of input
a.cc:5:14: note: to match this '{'
5 | signed main(){
| ^
|
s460856088
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int sloution(int st, int en)
{
int min=a[st];
int minpos=st;
for(int i=st;i<=en;i++){
if(min>a[i]){
min=a[i];
minpos=i;
}
}
int offset=(minpos-st)>(en-minpos)?(en-minpos+1):(minpos-st+1);
int res=min*(1+offset)*offset+(en-st-2*minpos);
return res+sloution(st,minpos-1)+sloution(minpos+1,en)
}
int main(){
int N;
cin>>N;
extern int a[N];
for(int i=0;i<N;i++){
cin>>a[i];
}
return sloution(0, N-1);
}
|
a.cc: In function 'int sloution(int, int)':
a.cc:5:11: error: 'a' was not declared in this scope
5 | int min=a[st];
| ^
a.cc:15:57: error: expected ';' before '}' token
15 | return res+sloution(st,minpos-1)+sloution(minpos+1,en)
| ^
| ;
16 | }
| ~
a.cc: In function 'int main()':
a.cc:21:14: error: storage size of 'a' isn't constant
21 | extern int a[N];
| ^
|
s577458750
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int sloution(int st, int en)
{
int min=a[st];
int minpos=st;
for(int i=st;i<=en;i++){
if(min>a[i]){
min=a[i];
minpos=i;
}
}
int offset=(minpos-st)>(en-minpos)?(en-minpos+1):(minps-st+1);
int res=min*(1+offset)*offset+(en-st-2*minpos);
return res+sloution(st,minpos-1)+sloution(minpos+1,en)
}
int main(){
int N;
cin>>N;
int a[N];
for(int i:N){
cin>>a[i];
}
return sloution(0, N-1);
}
|
a.cc: In function 'int sloution(int, int)':
a.cc:5:11: error: 'a' was not declared in this scope
5 | int min=a[st];
| ^
a.cc:13:53: error: 'minps' was not declared in this scope; did you mean 'minpos'?
13 | int offset=(minpos-st)>(en-minpos)?(en-minpos+1):(minps-st+1);
| ^~~~~
| minpos
a.cc:15:57: error: expected ';' before '}' token
15 | return res+sloution(st,minpos-1)+sloution(minpos+1,en)
| ^
| ;
16 | }
| ~
a.cc: In function 'int main()':
a.cc:22:13: error: 'begin' was not declared in this scope
22 | for(int i:N){
| ^
a.cc:22:13: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note: 'std::begin'
1238 | begin(const valarray<_Tp>& __va) noexcept
| ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note: 'std::filesystem::__cxx11::begin'
608 | begin(recursive_directory_iterator __iter) noexcept
| ^~~~~
a.cc:22:13: error: 'end' was not declared in this scope
22 | for(int i:N){
| ^
a.cc:22:13: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note: 'std::end'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note: 'std::filesystem::__cxx11::end'
613 | end(recursive_directory_iterator) noexcept
| ^~~
|
s200446087
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main(){
int count=0;
int res=0;
char cur='A';
while(cur){
cin.getchar()>>cur;
if(cur=='S')
count++;
else if(cur=='T')
count--;
if(count<0){
res++;
count=0;
}
}
cout<<2*res<<endl;
}
|
a.cc: In function 'int main()':
a.cc:8:5: error: 'std::istream' {aka 'class std::basic_istream<char>'} has no member named 'getchar'
8 | cin.getchar()>>cur;
| ^~~~~~~
|
s136830113
|
p03986
|
C++
|
include<iostream>
using namespace std;
int main(){
int count=0;
int res=0;
char cur='A';
while(cur){
cin.getchar()>>cur;
if(cur=='S')
count++;
else if(cur=='T')
count--;
if(count<0){
res++;
count=0;
}
}
cout<<2*res<<endl;
}
|
a.cc:1:1: error: 'include' does not name a type
1 | include<iostream>
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:8:1: error: 'cin' was not declared in this scope
8 | cin.getchar()>>cur;
| ^~~
a.cc:18:2: error: 'cout' was not declared in this scope; did you mean 'count'?
18 | cout<<2*res<<endl;
| ^~~~
| count
a.cc:18:15: error: 'endl' was not declared in this scope
18 | cout<<2*res<<endl;
| ^~~~
|
s055570072
|
p03986
|
C++
|
include<iostream>
using namespace std;
int count=0;
int res=0;
char cur;
while(cur){
cin.getchar(X)>>cur;
if(cur=='S')
count++;
else if(cur=='T')
count--;
if(count<0){
res++;
count++;
}
}
}
|
a.cc:1:1: error: 'include' does not name a type
1 | include<iostream>
| ^~~~~~~
a.cc:7:1: error: expected unqualified-id before 'while'
7 | while(cur){
| ^~~~~
a.cc:19:1: error: expected declaration before '}' token
19 | }
| ^
|
s540257004
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
void solve()
{
stack<char>s;
char x;
while(cin>>x){
if(x=='T'){if(s.empty()||s.top()=='T')s.push('T');else if(s.top()=='S')s.pop();}
else(x=='S')s.push('S');
}cout<<s.size()<<endl;
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
solve();
return 0;
}
|
a.cc: In function 'void solve()':
a.cc:26:21: error: expected ';' before 's'
26 | else(x=='S')s.push('S');
| ^
| ;
|
s273071292
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
void solve()
{
stack<char>s;
char x;
while(cin>>x){
if(x=='T'){if(s.empty()||s.top()=='T')s.push('T');else if(s.top()=='S')s.pop();
else(x=='S')s.push('S')
}cout<<s.size()<<endl;
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
solve();
return 0;
}
|
a.cc: In function 'void solve()':
a.cc:26:21: error: expected ';' before 's'
26 | else(x=='S')s.push('S')
| ^
| ;
a.cc:31:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
31 | int main()
| ^~
a.cc:31:9: note: remove parentheses to default-initialize a variable
31 | int main()
| ^~
| --
a.cc:31:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:32:1: error: a function-definition is not allowed here before '{' token
32 | {
| ^
a.cc:37:2: error: expected '}' at end of input
37 | }
| ^
a.cc:21:1: note: to match this '{'
21 | {
| ^
|
s994957662
|
p03986
|
C++
|
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少.
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string X; cin >> X;
string x;
rep(i, 0, X.size()){
if (x.back() == 'S' && X[i] == 'T')
x.pop_back();
else
x.push_back(X[min(i, 200000ll)]);
}
cout << x.size() << endl;
}
// 境界,出力文字列 チェック
// 可読性優先.高速化次点.
// まずは全探索,分割統治,次にDP
// 制限を見る.境界に注意.
// 偶奇,逆から,ソート,出現回数,出現位置,DP, 余事象,包除
// データ構造. 問題の特徴量.単調性,二分探索
// 存在判定:構成方法,入力の特徴
// gcd, lcm ,素因数分解.
// 例外を十分に含む一般化.想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい.各場合を確実に対処.
// 自明な例から処理,除外.
// 小数のときは,精度の設定する.doubel 変数に数値を入力するときは 123. とする.
// テストケース作成は数表あり
|
a.cc: In function 'int main()':
a.cc:28:26: error: no matching function for call to 'min(int64_t&, long long int)'
28 | x.push_back(X[min(i, 200000ll)]);
| ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:28:26: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
28 | x.push_back(X[min(i, 200000ll)]);
| ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:28:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
28 | x.push_back(X[min(i, 200000ll)]);
| ~~~^~~~~~~~~~~~~
|
s946468058
|
p03986
|
C++
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
string s;
cin>>s;
ll a=0,b=0,sum=0,n=s.size();
bool flag=false;
for(int i=0;i<n-1;i++){
if(s[i]=='S'&&s[i+1]=='S') a++;
else if(s[i]=='S'&&s[i+1]=='T') a++;
else if(s[i]=='T'&&s[i+1]=='T') b++;
else{
b++;
sum+=min(a,b);
a=max(0,a-b);
b=0;
}
}
sum+=min(a,b);
cout<<n-2*sum;
}
|
a.cc: In function 'int main()':
a.cc:17:12: error: no matching function for call to 'max(int, ll)'
17 | a=max(0,a-b);
| ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:17:12: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
17 | a=max(0,a-b);
| ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:17:12: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
17 | a=max(0,a-b);
| ~~~^~~~~~~
|
s401216845
|
p03986
|
C++
|
S = input()
ans = 0
pos = 0
scount = 0
while pos < len(S):
while pos <len(S) and S[pos] == 'T':
pos += 1
ans += 1
if pos >= len(S):
break
while pos <len(S) and S[pos] == 'S':
pos += 1
scount += 1
if pos >= len(S):
ans += scount
break
tcount = 0
while pos < len(S) and S[pos] == 'T':
pos += 1
tcount += 1
if pos >= len(S):
ans += abs(scount-tcount)
break
if scount >= tcount:
scount = scount -tcount
else: #scount < tcount
ans += tcount-scount
scount = 0
print(ans)
|
a.cc:30:11: error: stray '#' in program
30 | else: #scount < tcount
| ^
a.cc:1:1: error: 'S' does not name a type
1 | S = input()
| ^
|
s390670597
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin >> s;
for(int i = 0;i< s.size()-2 ; i++)
{
if(s[i] == 'S' && s[i+1] == 'T')
{
s.erase(s.begin()+i);
s.erase(s.begin()+i);
i -= 2;
}
}
if(s = "ST")
{
cout << s.size()-2;
return 0;
}
cout << s.size();
return 0;
}
//s.earase(s.beigin()+makan)
|
a.cc: In function 'int main()':
a.cc:18:14: error: could not convert 's.std::__cxx11::basic_string<char>::operator=(((const char*)"ST"))' from 'std::__cxx11::basic_string<char>' to 'bool'
18 | if(s = "ST")
| ~~^~~~~~
| |
| std::__cxx11::basic_string<char>
|
s297139545
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main () {
string s;
cin >> s;
int n = (int)s.size();
stack<char> st;
for (int i = 0; i < n; ++i) {
if (s[i] == "S") st.push(s[i]);
else {
if (st.top() == "S") st.pop();
else st.push(s[i]);
}
}
cout << st.size() << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:12:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
12 | if (s[i] == "S") st.push(s[i]);
a.cc:14:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
14 | if (st.top() == "S") st.pop();
| ~~~~~~~~~^~~~~~
|
s849637768
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main () {
string s;
cin >> s;
int n = (int)s.size();
string t = s;
sort(s.begin(), s.end, greater<char>());
int cnt = 0;
for (int i = 0; i < n; ++i) {
if (s[i] != t[i]) cnt++;
}
cout << n - cnt << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:11:7: error: no matching function for call to 'sort(std::__cxx11::basic_string<char>::iterator, <unresolved overloaded function type>, std::greater<char>)'
11 | sort(s.begin(), s.end, greater<char>());
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
4762 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
| ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate expects 2 arguments, 3 provided
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<char*, __cxx11::basic_string<char> >; _Compare = greater<char>]'
4793 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
| ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:63: note: no known conversion for argument 2 from '<unresolved overloaded function type>' to '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >'
4793 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate expects 4 arguments, 3 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15:
/usr/include/c++/14/pstl/execution_defs.h: In substitution of 'template<class _ExecPolicy, class _Tp> using __pstl::__internal::__enable_if_execution_policy = typename std::enable_if<__pstl::execution::v1::is_execution_policy<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::value, _Tp>::type [with _ExecPolicy = __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >; _Tp = void]':
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: required by substitution of 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator) [with _ExecutionPolicy = __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >; _RandomAccessIterator = std::greater<char>]'
a.cc:11:7: required from here
11 | sort(s.begin(), s.end, greater<char>());
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/pstl/execution_defs.h:82:7: error: no type named 'type' in 'struct std::enable_if<false, void>'
82 | using __enable_if_execution_policy =
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s383223633
|
p03986
|
C++
|
#include<bits/stdc++.h>
int main(){std::string S;std::cin>>S;stack<char> a;
for(int i=0;i<S.size();i++){if(a.size()&&a.top()==S.at(i)-1)a.pop();else a.push(S.at(i));}
std::cout<<a.size();
}
|
a.cc: In function 'int main()':
a.cc:2:38: error: 'stack' was not declared in this scope; did you mean 'std::stack'?
2 | int main(){std::string S;std::cin>>S;stack<char> a;
| ^~~~~
| std::stack
In file included from /usr/include/c++/14/stack:63,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:160,
from a.cc:1:
/usr/include/c++/14/bits/stl_stack.h:99:11: note: 'std::stack' declared here
99 | class stack
| ^~~~~
a.cc:2:44: error: expected primary-expression before 'char'
2 | int main(){std::string S;std::cin>>S;stack<char> a;
| ^~~~
a.cc:3:36: error: 'a' was not declared in this scope
3 | for(int i=0;i<S.size();i++){if(a.size()&&a.top()==S.at(i)-1)a.pop();else a.push(S.at(i));}
| ^
a.cc:4:16: error: 'a' was not declared in this scope
4 | std::cout<<a.size();
| ^
|
s676399895
|
p03986
|
C++
|
#include<bits/stdc++.h>
int main(){string S;std::cin>>S;stack<char> a;
for(int i=0;i<S.size();i++){if(a.size()&&a.top()==S.at(i)-1)a.pop();else a.push(S.at(i));}
std::cout<<a.size();
}
|
a.cc: In function 'int main()':
a.cc:2:12: error: 'string' was not declared in this scope
2 | int main(){string S;std::cin>>S;stack<char> a;
| ^~~~~~
a.cc:2:12: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
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/stringfwd.h:77:33: note: 'std::string'
77 | typedef basic_string<char> string;
| ^~~~~~
/usr/include/c++/14/string:76:11: note: 'std::pmr::string'
76 | using string = basic_string<char>;
| ^~~~~~
a.cc:2:31: error: 'S' was not declared in this scope
2 | int main(){string S;std::cin>>S;stack<char> a;
| ^
a.cc:2:33: error: 'stack' was not declared in this scope; did you mean 'std::stack'?
2 | int main(){string S;std::cin>>S;stack<char> a;
| ^~~~~
| std::stack
In file included from /usr/include/c++/14/stack:63,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:160:
/usr/include/c++/14/bits/stl_stack.h:99:11: note: 'std::stack' declared here
99 | class stack
| ^~~~~
a.cc:2:39: error: expected primary-expression before 'char'
2 | int main(){string S;std::cin>>S;stack<char> a;
| ^~~~
a.cc:3:36: error: 'a' was not declared in this scope
3 | for(int i=0;i<S.size();i++){if(a.size()&&a.top()==S.at(i)-1)a.pop();else a.push(S.at(i));}
| ^
a.cc:4:16: error: 'a' was not declared in this scope
4 | std::cout<<a.size();
| ^
|
s154943080
|
p03986
|
C++
|
#include<string>
int main(){std::string S;std::cin>>S;stack<char> a;
for(int i=0;i<S.size();i++){if(a.size()&&a.top()==S.at(i)-1)a.pop();else a.push(S.at(i));}
std::cout<<a.size();
}
|
a.cc: In function 'int main()':
a.cc:2:31: error: 'cin' is not a member of 'std'
2 | int main(){std::string S;std::cin>>S;stack<char> a;
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include<string>
+++ |+#include <iostream>
2 | int main(){std::string S;std::cin>>S;stack<char> a;
a.cc:2:38: error: 'stack' was not declared in this scope; did you mean 'obstack'?
2 | int main(){std::string S;std::cin>>S;stack<char> a;
| ^~~~~
| obstack
a.cc:2:44: error: expected primary-expression before 'char'
2 | int main(){std::string S;std::cin>>S;stack<char> a;
| ^~~~
a.cc:3:36: error: 'a' was not declared in this scope
3 | for(int i=0;i<S.size();i++){if(a.size()&&a.top()==S.at(i)-1)a.pop();else a.push(S.at(i));}
| ^
a.cc:4:10: error: 'cout' is not a member of 'std'
4 | std::cout<<a.size();
| ^~~~
a.cc:4:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:4:16: error: 'a' was not declared in this scope
4 | std::cout<<a.size();
| ^
|
s435052078
|
p03986
|
C++
|
#include<string>
int main(){string S;std::cin>>S;stack<char> a;
for(int i=0;i<S.size();i++){if(a.size()&&a.top()==S.at(i)-1)a.pop();else a.push(S.at(i));}
std::cout<<a.size();
}
|
a.cc: In function 'int main()':
a.cc:2:12: error: 'string' was not declared in this scope
2 | int main(){string S;std::cin>>S;stack<char> a;
| ^~~~~~
a.cc:2:12: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string'
77 | typedef basic_string<char> string;
| ^~~~~~
/usr/include/c++/14/string:76:11: note: 'std::pmr::string'
76 | using string = basic_string<char>;
| ^~~~~~
a.cc:2:26: error: 'cin' is not a member of 'std'
2 | int main(){string S;std::cin>>S;stack<char> a;
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include<string>
+++ |+#include <iostream>
2 | int main(){string S;std::cin>>S;stack<char> a;
a.cc:2:31: error: 'S' was not declared in this scope
2 | int main(){string S;std::cin>>S;stack<char> a;
| ^
a.cc:2:33: error: 'stack' was not declared in this scope; did you mean 'obstack'?
2 | int main(){string S;std::cin>>S;stack<char> a;
| ^~~~~
| obstack
a.cc:2:39: error: expected primary-expression before 'char'
2 | int main(){string S;std::cin>>S;stack<char> a;
| ^~~~
a.cc:3:36: error: 'a' was not declared in this scope
3 | for(int i=0;i<S.size();i++){if(a.size()&&a.top()==S.at(i)-1)a.pop();else a.push(S.at(i));}
| ^
a.cc:4:10: error: 'cout' is not a member of 'std'
4 | std::cout<<a.size();
| ^~~~
a.cc:4:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:4:16: error: 'a' was not declared in this scope
4 | std::cout<<a.size();
| ^
|
s605113510
|
p03986
|
C++
|
#include<iostream>
int main(){string S;std::cin>>S;stack<char> a;
for(int i=0;i<S.size();i++){if(a.size()&&a.top()==S.at(i)-1)a.pop();else a.push(S.at(i));}
std::cout<<a.size();
}
|
a.cc: In function 'int main()':
a.cc:2:12: error: 'string' was not declared in this scope
2 | int main(){string S;std::cin>>S;stack<char> a;
| ^~~~~~
a.cc:2:12: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string'
77 | typedef basic_string<char> string;
| ^~~~~~
In file included from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/string:76:11: note: 'std::pmr::string'
76 | using string = basic_string<char>;
| ^~~~~~
a.cc:2:31: error: 'S' was not declared in this scope
2 | int main(){string S;std::cin>>S;stack<char> a;
| ^
a.cc:2:33: error: 'stack' was not declared in this scope; did you mean 'obstack'?
2 | int main(){string S;std::cin>>S;stack<char> a;
| ^~~~~
| obstack
a.cc:2:39: error: expected primary-expression before 'char'
2 | int main(){string S;std::cin>>S;stack<char> a;
| ^~~~
a.cc:3:36: error: 'a' was not declared in this scope
3 | for(int i=0;i<S.size();i++){if(a.size()&&a.top()==S.at(i)-1)a.pop();else a.push(S.at(i));}
| ^
a.cc:4:16: error: 'a' was not declared in this scope
4 | std::cout<<a.size();
| ^
|
s147585620
|
p03986
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int int_len(int n) {
int s=0;
while(n!=0) s++, n/=10;
return s;
}
int int_sum(int n) {
int m=0,s=0,a=n;
while(a!=0) s++, a/=10;
for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
return m;
}
int vec_sum(vector<int> v){
int n=0;
for(int i=0;i<v.size();i++) n+=v[i];
return n;
}
int main() {
int i=0;
string s;
cin>>s;
while(i<s.size()-1 && s.size!=0){
if(s[i]=='S' && s[i+1]=='T'){
s.erase(i,2);
i=0;
}else{
i++;
}
}
cout<<s.size()<<endl;
}
|
a.cc: In function 'int main()':
a.cc:28:27: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
28 | while(i<s.size()-1 && s.size!=0){
| ~~^~~~
| ()
|
s996526529
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef map<int,int> MPi; typedef pair<Int,Int> Pl;
const int mod = 1000000007;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
cin.tie(nullptr); ios::sync_with_stdio(false);
string s; cin>>s; int ans=0,key=0;
for (int i = 0; i < s.size(); i++){
if(s[i]=='S')key++;
else{
if(key){
int a=0;
for (int j = 0; j < key; j++){
if(s[i+j]=='T')a++;
else break;
}
ans+=a;
}
key=0;
}
}
cout<<max(0u,s.size()-ans*2)<<'\n';
}
|
a.cc: In function 'int main()':
a.cc:33:18: error: no matching function for call to 'max(unsigned int, std::__cxx11::basic_string<char>::size_type)'
33 | cout<<max(0u,s.size()-ans*2)<<'\n';
| ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:33:18: note: deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
33 | cout<<max(0u,s.size()-ans*2)<<'\n';
| ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:33:18: note: mismatched types 'std::initializer_list<_Tp>' and 'unsigned int'
33 | cout<<max(0u,s.size()-ans*2)<<'\n';
| ~~~^~~~~~~~~~~~~~~~~~~
|
s895220431
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string x;
cin>>x;
int scount=0;
int tcount=0;
int ans=s.size();
for(int i=0;i<x.size();i++){
if(x.at(i)=='S'){
scount++;
}
else{
tcount++;
}
if(tcount>scount){
ans-=2;
tcount--;
}
}
cout<<ans;
}
|
a.cc: In function 'int main()':
a.cc:8:11: error: 's' was not declared in this scope
8 | int ans=s.size();
| ^
|
s027045556
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string x;
cin>>x;
int scount=0;
int tcount=0;
int ans=s.size();
for(int i=0;i<x.size();i++){
if(x.at(i)=='S'){
scount++;
}
else{
tcount++;
}
if(tcount>scount){
ans-=2;
tcount--;
}
}
}
|
a.cc: In function 'int main()':
a.cc:8:11: error: 's' was not declared in this scope
8 | int ans=s.size();
| ^
|
s556150675
|
p03986
|
C++
|
#include <string>
#include <iostream> int main() { std::string X;
std::cin >> X;
int n = X.length();
int ans = n;
int cnt = 0;
for (int i = 0; i < n; ++i) {
if (X[i] == 'S') ++cnt;
else {
if (cnt > 0) {
--cnt;
ans -= 2;
}
}
}
std::cout << ans << std::endl;
}
|
a.cc:2:269: warning: extra tokens at end of #include directive
2 | #include <iostream> int main() { std::string X;
| ^~~
a.cc:3:8: error: 'cin' in namespace 'std' does not name a type
3 | std::cin >> X;
| ^~~
In file included from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:4:11: error: 'X' was not declared in this scope
4 | int n = X.length();
| ^
a.cc:7:3: error: expected unqualified-id before 'for'
7 | for (int i = 0; i < n; ++i) {
| ^~~
a.cc:7:19: error: 'i' does not name a type
7 | for (int i = 0; i < n; ++i) {
| ^
a.cc:7:26: error: expected unqualified-id before '++' token
7 | for (int i = 0; i < n; ++i) {
| ^~
a.cc:16:8: error: 'cout' in namespace 'std' does not name a type
16 | std::cout << ans << std::endl;
| ^~~~
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:17:1: error: expected declaration before '}' token
17 | }
| ^
|
s254313078
|
p03986
|
C++
|
int main() {
string s;
cin >> s;
int k=0,sn;
for (auto c:s) {
if (c=='S') {++sn;}
else {if (sn>0){--sn;k+=2;}}
}
cout << s.length()-k << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:2:5: error: 'string' was not declared in this scope
2 | string s;
| ^~~~~~
a.cc:3:5: error: 'cin' was not declared in this scope
3 | cin >> s;
| ^~~
a.cc:3:12: error: 's' was not declared in this scope
3 | cin >> s;
| ^
a.cc:9:5: error: 'cout' was not declared in this scope
9 | cout << s.length()-k << endl;
| ^~~~
a.cc:9:29: error: 'endl' was not declared in this scope
9 | cout << s.length()-k << endl;
| ^~~~
|
s715976759
|
p03986
|
C++
|
#include<cstdio>
#define itn int
using namespace std;
int main()
{
string s;
int n=s.size();
int s1=0;
itn ans=0;
for(int i=0;i<n;i++)
{
s[i]=getchar();
if(s[i]=='S') s1+=1;
if(s1&&s[i]=='T')
{
s1-=1;
ans+=2;
}
}
printf("%d",n-ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:6:5: error: 'string' was not declared in this scope
6 | string s;
| ^~~~~~
a.cc:2:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
1 | #include<cstdio>
+++ |+#include <string>
2 | #define itn int
a.cc:7:11: error: 's' was not declared in this scope
7 | int n=s.size();
| ^
|
s167497263
|
p03986
|
C++
|
#include<bits/stdc++.h>
using namespace std;
string s;
int sums,sumt;
int main(){
cin>>s;
for(int i=0;i<S.size();i++){
if(S[i]=='S')sums++;//有S,S出现的次数++
if((sums)&&(S[i]=='T')){//在有S的前提下,有T
sums--;sumt+=2;}}//丢出一个S,自加2,因为需要删除S和T
cout<<s.size()-sumt<<endl;//最后输出即可
}
|
a.cc: In function 'int main()':
a.cc:7:19: error: 'S' was not declared in this scope
7 | for(int i=0;i<S.size();i++){
| ^
|
s083696445
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s;
s+='S';
int res=s.length()-1;
int cnt_s=0,cnt_t=0;
if(s[0]=='S') cnt_s++;
else cnt_t++;
for(int i=1;i<s.length();i++){
if(s[i]=='S') { if(s[i-1]=='T') {res-=2*min(cnt_s,cnt_t);
cnt_s=cnt_t=0;
}
cnt_s++;}
else {cnt_t++;
}
}
cout << res << endl;
}_
|
a.cc:30:2: error: '_' does not name a type
30 | }_
| ^
|
s431914571
|
p03986
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main(){
string X;cin >> X;
int cntS = 0;
int ans = N;
int N = X.size();
for(int i = 0; i < N; ++i){
if(X[i] == 'S')cntS++;
else if(cntS > 0){
cntS--;
ans--;
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:6:13: error: 'N' was not declared in this scope
6 | int ans = N;
| ^
|
s345404348
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s; cin >> s;
int size = s.length(), a = 0, b = 0;
for (int i = 0; i < size; i++) {
if (s[i] == 'S')
a++;
else {
if (s>0)
a--;
else
b++;
}
}
cout << a+b << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:11:12: error: no match for 'operator>' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'int')
11 | if (s>0)
| ~^~
| | |
| | int
| std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1176:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator>(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1176 | operator>(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1176:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
11 | if (s>0)
| ^
/usr/include/c++/14/bits/regex.h:1236:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator>(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1236 | operator>(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1236:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
11 | if (s>0)
| ^
/usr/include/c++/14/bits/regex.h:1329:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator>(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1329 | operator>(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1329:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
11 | if (s>0)
| ^
/usr/include/c++/14/bits/regex.h:1403:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1403 | operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1403:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
11 | if (s>0)
| ^
/usr/include/c++/14/bits/regex.h:1497:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1497 | operator>(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1497:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
11 | if (s>0)
| ^
/usr/include/c++/14/bits/regex.h:1573:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1573 | operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1573:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
11 | if (s>0)
| ^
/usr/include/c++/14/bits/regex.h:1673:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1673 | operator>(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1673:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
11 | if (s>0)
| ^
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:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>'
11 | if (s>0)
| ^
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:
a.cc:11:13: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
11 | if (s>0)
| ^
/usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
507 | operator>(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
11 | if (s>0)
| ^
/usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1714 | operator>(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
11 | if (s>0)
| ^
/usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1774 | operator>(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
11 | if (s>0)
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/string_view:695:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
695 | operator> (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:695:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
11 | if (s>0)
| ^
/usr/include/c++/14/string_view:702:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
702 | operator> (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:702:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
11 | if (s>0)
| ^
/usr/include/c++/14/string_view:710:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
710 | operator> (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:710:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
11 | if (s>0)
| ^
/usr/include/c++/14/bits/basic_string.h:3915:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3915 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3915:5: note: template argument deduction/substitution failed:
a.cc:11:13: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
11 | if (s>0)
| ^
/usr/include/c++/14/bits/basic_string.h:3929:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3929 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
|
s328860099
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string x;
int i, a = 0, b = 0;
cin >> x;
for(i = 0; i < x.size(); i++){
if(x.at(i) == 'T'){
a++;
}
else{
break;
}
}
for(i = n - 1; i >= 0; i--){
if(x.at(i) == 'S'){
b++;
}
else{
break;
}
}
cout << max(a, b) << endl;
}
|
a.cc: In function 'int main()':
a.cc:18:11: error: 'n' was not declared in this scope
18 | for(i = n - 1; i >= 0; i--){
| ^
|
s737451177
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string x, i, a = 0, b = 0;
cin >> x;
for(i = 0; i < x.size(); i++){
if(x.at(i) == 'T'){
a++;
}
else{
break;
}
}
for(i = n - 1; i >= 0; i--){
if(x.at(i) == 'S'){
b++;
}
else{
break;
}
}
cout << max(a, b) << endl;
}
|
a.cc: In function 'int main()':
a.cc:8:11: error: ambiguous overload for 'operator=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'int')
8 | for(i = 0; i < x.size(); i++){
| ^
In file included from /usr/include/c++/14/string:54,
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/basic_string.h:817:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
817 | operator=(const basic_string& __str)
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:828:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
828 | operator=(const _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:840:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
840 | operator=(_CharT __c)
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:858:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
858 | operator=(basic_string&& __str)
| ^~~~~~~~
a.cc:8:16: error: no match for 'operator<' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
8 | for(i = 0; i < x.size(); i++){
| ~ ^ ~~~~~~~~
| | |
| | std::__cxx11::basic_string<char>::size_type {aka long unsigned int}
| std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181:
/usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed:
a.cc:8:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
8 | for(i = 0; i < x.size(); i++){
| ^
/usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed:
a.cc:8:25: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
8 | for(i = 0; i < x.size(); i++){
| ^
/usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1317 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed:
a.cc:8:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
8 | for(i = 0; i < x.size(); i++){
| ^
/usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed:
a.cc:8:25: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
8 | for(i = 0; i < x.size(); i++){
| ^
/usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1485 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed:
a.cc:8:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
8 | for(i = 0; i < x.size(); i++){
| ^
/usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed:
a.cc:8:25: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
8 | for(i = 0; i < x.size(); i++){
| ^
/usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1660 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed:
a.cc:8:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
8 | for(i = 0; i < x.size(); i++){
| ^
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:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
a.cc:8:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>'
8 | for(i = 0; i < x.size(); i++){
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
a.cc:8:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
8 | for(i = 0; i < x.size(); i++){
| ^
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
a.cc:8:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
8 | for(i = 0; i < x.size(); i++){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
a.cc:8:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
8 | for(i = 0; i < x.size(); i++){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
a.cc:8:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
8 | for(i = 0; i < x.size(); i++){
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<
|
s905546997
|
p03986
|
Java
|
import java.util.Scanner;
import java.lang.Math;
public class MainA {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String str = scanner.nextLine();
int ans = str.length();
int sequenceS = 0, sequenceT = 0;
for (int i = 0; i < str.length(); ++i) {
if (str.charAt(i) == 'S') {
ans -= (i > 0 && str.charAt(i - 1) == 'T') ? 2 * Integer.min(sequenceS, sequenceT) : 0;
sequenceS = (i > 0 && str.charAt(i - 1) == 'T') ? 1 : sequenceS + 1;
} else {
sequenceT = (i > 0 && str.charAt(i - 1) == 'S') ? 1 : sequenceT + 1;
ans -= (i == str.length() - 1) ? 2 * Integer.min(sequenceS, sequenceT) : 0;
}
}
System.out.println(ans);
}
}
|
Main.java:4: error: class MainA is public, should be declared in a file named MainA.java
public class MainA {
^
1 error
|
s223310123
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int cs = 0;
int cnt =0;
for (int i =0;i<s.length();i++)
{
if (s[i]=='S')
cs++;
else if (s[i]=='T'&&cs>0)
{
cs--;
cnt++;
}
}
cour << s.length()- cnt*2 << endl;
}
|
a.cc: In function 'int main()':
a.cc:21:3: error: 'cour' was not declared in this scope
21 | cour << s.length()- cnt*2 << endl;
| ^~~~
|
s625407567
|
p03986
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main(){
string str;
cin>>str;
int scnt,tcnt,m=0;
scnt=tcnt=0;
bool s=1;
for(int i=0;i<str.length();++i)
{
if(str[i]=='S'){
if(s)
scnt++;
}
else{
if(scnt>tcnt){
scnt-=tcnt;
tcnt=0;
}
else{
m+=tcnt-scnt;
scnt=tcnt=0;
}
s=true;
scnt++;
}
}
else{
s=false;
tcnt++;
}
}
if(scnt>tcnt)m+=(scnt-tcnt);
else m+=(tcnt-scnt);
cout<<m;
}
|
a.cc: In function 'int main()':
a.cc:31:9: error: 'else' without a previous 'if'
31 | else{
| ^~~~
a.cc: At global scope:
a.cc:36:5: error: expected unqualified-id before 'if'
36 | if(scnt>tcnt)m+=(scnt-tcnt);
| ^~
a.cc:37:5: error: expected unqualified-id before 'else'
37 | else m+=(tcnt-scnt);
| ^~~~
a.cc:38:5: error: 'cout' does not name a type
38 | cout<<m;
| ^~~~
a.cc:39:1: error: expected declaration before '}' token
39 | }
| ^
|
s695625136
|
p03986
|
C++
|
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define MOD 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define M_P make_pair
#define PU_B push_back
#define PU_F push_front
#define PO_B pop_back
#define PO_F pop_front
#define U_B upper_bound
#define L_B lower_bound
#define B_S binary_search
#define PR_Q priority_queue
#define FIR first
#define SEC second
#if __cplusplus < 201103L
#define stoi(argument_string) atoi((argument_string).c_str())
#endif
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAND(x) scanf("%d",&(x))
#define SCAND2(x,y) scanf("%d%d",&(x),&(y))
#define SCAND3(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define SCAND4(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define SCANLLD(x) scanf("%lld",&(x))
#define SCANLLD2(x,y) scanf("%lld%lld",&(x),&(y))
#define SCANLLD3(x,y,z) scanf("%lld%lld%lld",&(x),&(y),&(z))
#define SCANLLD4(x,y,z,w) scanf("%lld%lld%lld%lld",&(x),&(y),&(z),&(w))
#define PRINTD(x) printf("%d\n",(x))
#define PRINTLLD(x) printf("%lld\n",(x))
#define DEBUG(argument) cerr<<(#argument)<<" : "<<(argument)<<"\n"
typedef long long int lli;
using namespace std;
bool compare_by_2nd(pair<int,int> a, pair<int,int> b)
{
if( a.second != b.second )
{
return a.second < b.second;
}
else
{
return a.first < b.first;
}
}
int ctoi(char c)
{
if( c >= '0' and c <= '9' )
{
return (int)(c-'0');
}
return -1;
}
int alphabet_pos(char c)
{
if( c >= 'a' and c <= 'z' )
{
return (int)(c-'a');
}
return -1;
}
int alphabet_pos_capital(char c)
{
if( c >= 'A' and c <= 'Z' )
{
return (int)(c-'A');
}
return -1;
}
vector<string> split(string str, char ch)
{
int first = 0;
int last = str.find_first_of(ch);
if(last == string::npos)
{
last = SIZ(str);
}
vector<string> result;
while( first < SIZ(str) )
{
string Ssubstr(str, first, last - first);
result.push_back(Ssubstr);
first = last + 1;
last = str.find_first_of(ch, first);
if(last == string::npos)
{
last = SIZ(str);
}
}
return result;
}
int gcd( int a , int b ) // assuming a,b >= 1
{
if( a < b )
{
return gcd( b , a );
}
if( a % b == 0 )
{
return b;
}
return gcd( b , a % b );
}
int lcm( int a , int b ) // assuming a,b >= 1
{
return a * b / gcd( a , b );
}
lli pow_fast( lli x, lli n_power , lli modulus )
{
if( n_power == 0 )
{
return 1;
}
if( n_power % 2 == 0)
{
return pow_fast( x * x % modulus , n_power / 2 , modulus );
}
return x * pow_fast( x , n_power - 1 , modulus ) % modulus;
}
struct CombinationTable
{
vector<vector<long long> > val;
CombinationTable( int size ) : val( size+1 , vector<long long>( size+1 ) ) //constructor
{
for( int i = 0 ; i <= size ; ++ i ) // note that 0 <= i <= size
{
for( int j = 0 ; j <= i ; ++ j )
{
if( j == 0 or j == i )
{
val[i][j] = 1LL;
}
else
{
val[i][j] = val[i-1][j-1] + val[i-1][j];
}
}
}
}
};
struct UnionFind //size-based
{
vector<int> parent, treesize;
UnionFind( int size ) : parent( size ) , treesize( size , 1 ) //constructor
{
for( int i = 0 ; i < size ; ++ i )
{
parent[i] = i;
}
}
int root( int x )
{
if( parent[x] == x )
{
return x;
}
return parent[x] = root(parent[x]);
}
void unite( int x, int y )
{
x = root(x);
y = root(y);
if( x == y )
{
return;
}
if( treesize[x] < treesize[y] )
{
parent[x] = y;
treesize[y] += treesize[x];
}
else
{
parent[y] = x;
treesize[x] += treesize[y];
}
}
bool sametree( int x, int y )
{
return root(x) == root(y);
}
int gettreesize( int x )
{
return treesize[root(x)];
}
};
/*------------------ the end of the template -----------------------*/
signed main()
{
IOS; /* making cin faster */
int N;
string X;
CIN(X);
N = SIZ(N);
int cnt = 0;
REP_R(i,N)
{
if( X[i] == 'S' )
{
++ cnt;
}
else
{
break;
}
}
PRINTD(2*cnt);
}
|
a.cc: In function 'int main()':
a.cc:114:26: error: request for member 'size' in 'N', which is of non-class type 'int'
114 | #define SIZ(x) ((int)(x).size())
| ^~~~
a.cc:362:7: note: in expansion of macro 'SIZ'
362 | N = SIZ(N);
| ^~~
|
s578436035
|
p03986
|
C++
|
jhkh
|
a.cc:1:1: error: 'jhkh' does not name a type
1 | jhkh
| ^~~~
|
s223232293
|
p03986
|
C++
|
#include <iostream>
#include<string>
using namespace std;
int main()
{
int T;
string p1;
cin>>p1;
while(p1.find("ST")!=-1)
{
n=p1.find("ST");
p1.erase(n,2);
}
cout<<p1.length()<<endl;
}
|
a.cc: In function 'int main()':
a.cc:12:13: error: 'n' was not declared in this scope
12 | n=p1.find("ST");
| ^
|
s287279465
|
p03986
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main(){
int cnt=0,cntmin=0;
string S;
cin >> S;
int ans=S.length();
for(int i=0; i<S.length(); i++){
if(S[i]=='S')cnt++;
else cnt--;
if(cnt<0)cnt=0;
if(cnt>cntmax)cntmax=cnt;
if(cnt==0){
ans-=cntmax*2;
cntmax=0;
}
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:12:12: error: 'cntmax' was not declared in this scope; did you mean 'cntmin'?
12 | if(cnt>cntmax)cntmax=cnt;
| ^~~~~~
| cntmin
a.cc:14:12: error: 'cntmax' was not declared in this scope; did you mean 'cntmin'?
14 | ans-=cntmax*2;
| ^~~~~~
| cntmin
|
s153497795
|
p03986
|
C++
|
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
int main() {
string X;
cin >> X;
int ans = X.size();
stack<char> st;
for (int i = 0; i < X.size(); ++i) {
if (st.empty() || st.top() == X[i] || st.top() == 'T') st.push(s[i]);
else if(st.top() == 'S' && X[i] == 'T') {
ans -= 2;
st.pop();
}
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:27:72: error: 's' was not declared in this scope
27 | if (st.empty() || st.top() == X[i] || st.top() == 'T') st.push(s[i]);
| ^
|
s100344183
|
p03986
|
C++
|
#include <iostream>
int main(void)
{
char x[200001];
int l, ct = 0, cs = 0, ans = 0;
std::cin >> x;
l = std::strlen(x);
while(x[ct] == 'T') ct++;
for(int i = ct; i != l; i++){
if(x[i] == 'S'){
cs++;
}else{
if(cs > 0) cs--;
else ans++;
}
}
std::cout << ct + ans + cs << std::endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:7:18: error: 'strlen' is not a member of 'std'; did you mean 'mbrlen'?
7 | l = std::strlen(x);
| ^~~~~~
| mbrlen
|
s458043424
|
p03986
|
Java
|
import java.util.Scanner;
public class ProblemA {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String X = sc.next();
sc.close();
int l = X.length();
for(int i = 0; i < 50; i++) {
X = X.replaceAll("SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT", "");
}
int idx = 0;
while(true) {
X = X.replaceAll("ST", "");
idx++;
if(X.length() == l) {
break;
}else {
l = X.length();
}
if(idx > 100000000) break;
}
System.out.println(X.length());
}
}
|
Main.java:3: error: class ProblemA is public, should be declared in a file named ProblemA.java
public class ProblemA {
^
1 error
|
s043234873
|
p03986
|
Java
|
import java.util.Scanner;
public class ProblemA {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String X = sc.next();
sc.close();
int l = X.length();
for(int i = 0; i < 50; i++) {
X = X.replaceAll("SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT", "");
}
while(true) {
X = X.replaceAll("ST", "");
if(X.length() == l) {
break;
}else {
l = X.length();
}
}
System.out.println(X.length());
}
}
|
Main.java:3: error: class ProblemA is public, should be declared in a file named ProblemA.java
public class ProblemA {
^
1 error
|
s142385343
|
p03986
|
C++
|
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
int main()
{
int size,ans,cou;
cou = 0;
string X;
cin >> X;
size = X.length();
ans = size;
for (int i = 0; i < size; i++){
if (X[i] == S){
cou++;
}if (X[i] == T){
ans -= cou;
cou = 0;
}
}
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:23:29: error: 'S' was not declared in this scope
23 | if (X[i] == S){
| ^
a.cc:25:30: error: 'T' was not declared in this scope
25 | }if (X[i] == T){
| ^
|
s455986438
|
p03986
|
C++
|
#include <bits/stdc++.h>
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int main()
{
string s;
cin >> s;
vector<int> v;
for(auto x : s)
{
if(x == 'S')
v.PB(x);
else if(x == 'T' && v.size() && v.back() == 'S')
v.pop_back();
else
v.PB(x);
}
cout << v.size() << endl;
}
|
a.cc: In function 'int main()':
a.cc:12:27: error: 'class std::vector<int>' has no member named 'PB'
12 | v.PB(x);
| ^~
a.cc:16:27: error: 'class std::vector<int>' has no member named 'PB'
16 | v.PB(x);
| ^~
|
s621282895
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;
int main() {
string s;
cin >> s;
ll stack=0;ll syokyo=0;
for (int i = 0;i < s.size();i++) {
if (s[i] == "S") {stack++;}
else if (stack > 0) {stack--;syokyo++;}
}
cout << s.size() - syokyo*2 << endl;
}
|
a.cc: In function 'int main()':
a.cc:17:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
17 | if (s[i] == "S") {stack++;}
|
s137481374
|
p03986
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;
int main() {
string s;
cin >> s;
ll stack=0;ll syokyo=0;
for (int i = 0;i < s.size;i++) {
if (s[i] == "S") {stack++;}
else if (stack > 0) {stack--;syokyo++;}
}
cout << s.size - syokyo*2 << endl;
}
|
a.cc: In function 'int main()':
a.cc:16:30: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
16 | for (int i = 0;i < s.size;i++) {
| ~~^~~~
| ()
a.cc:17:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
17 | if (s[i] == "S") {stack++;}
a.cc:20:19: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
20 | cout << s.size - syokyo*2 << endl;
| ~~^~~~
| ()
|
s718978207
|
p03986
|
C++
|
#include<string>
#include<iostream>
using namespace std;
int main()
{
string str;
cin >> str;
while(str.find("ST",0)!=-1)
{
str.erase(str.find("ST", 0), 2);
}
if(str.lenth()==0) return 0;
else cout << str.length();
return 0;
}
|
a.cc: In function 'int main()':
a.cc:13:16: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'lenth'; did you mean 'length'?
13 | if(str.lenth()==0) return 0;
| ^~~~~
| length
|
s094646566
|
p03986
|
C++
|
TSSTTTSS
|
a.cc:1:1: error: 'TSSTTTSS' does not name a type
1 | TSSTTTSS
| ^~~~~~~~
|
s750381546
|
p03986
|
Java
|
import java.util.Scanner;
public class main {
public static void main(String[] args) {
Scanner stdin = new Scanner( System.in);
String x;
int i=0,j=0;
x =stdin.next();
for(int k=1;k<=x.length();k++){
String xx=x.substring(k-1,k);
if(xx.equals("S")){i++;
}else{i--;
}
if(i<0){
j++;
i=0;
}
}
System.out.print(j*2);
}
}
|
Main.java:3: error: class main is public, should be declared in a file named main.java
public class main {
^
1 error
|
s143446320
|
p03986
|
C++
|
#include<bits/stdc++.h>
using namespace std;
string s;
int sum1,sum2,sum;
int main()
{
cin>>s;
int n=s.size();
for(int i=0;i<n;i++)
{
if(s[i]=='S') sum2++;
if(sum2>=sum1)
else if(sum2) sum1++;
{
sum+=min(sum2,sum1)*2;
sum2-=min(sum2,sum1);
sum1=0;
}
}
cout<<n-sum<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:13:9: error: expected primary-expression before 'else'
13 | else if(sum2) sum1++;
| ^~~~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.