problem_id
stringlengths
6
6
language
stringclasses
2 values
original_status
stringclasses
3 values
original_src
stringlengths
19
243k
changed_src
stringlengths
19
243k
change
stringclasses
3 values
i1
int64
0
8.44k
i2
int64
0
8.44k
j1
int64
0
8.44k
j2
int64
0
8.44k
error
stringclasses
270 values
stderr
stringlengths
0
226k
p03239
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, T; cin >> N >> T; vector<int> A(N); vector<int> B(N); for (int i = 0; i < N; i++) { cin >> A[N] >> B[N]; } int b = 1001; for (int i = 0; i < N; i++) { if (T >= B[i]) { b = min(b, A[i]); } } if (b == 1001) { cout << "TLE" << endl; } else { cout << b << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N, T; cin >> N >> T; vector<int> A(N); vector<int> B(N); for (int i = 0; i < N; i++) { cin >> A[i] >> B[i]; } int b = 1001; for (int i = 0; i < N; i++) { if (T >= B[i]) { b = min(b, A[i]); } } if (b == 1001) { cout << "TLE" << endl; } else { cout << b << endl; } }
replace
9
10
9
10
0
p03239
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPD(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++) #define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--) #define ALL(x) (x).begin(), (x).end() #define SIZE(x) ((ll)(x).size()) #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x)) #define INF 1000000000000 #define MOD 1000000007 #define MAXR 100000 #define _GLIBCXX_DEBUG int threemax(int a, int b, int c) { if (a >= b && a >= c) { return a; } else if (b >= a && b >= c) { return b; } else { return c; } } int threemin(int a, int b, int c) { if (a <= b && a <= c) { return a; } else if (b <= a && b <= c) { return b; } else { return c; } } void chmaxl(ll &a, ll b) { if (a < b) { a = b; } return; } void chminl(ll &a, ll b) { if (a > b) { a = b; } return; } void chmaxi(int &a, int b) { if (a < b) { a = b; } return; } void chmini(int &a, int b) { if (a > b) { a = b; } return; } int main() { int N, T; cin >> N >> T; int ans = 10000; vector<int> cvec; vector<int> tvec; for (int i = 0; i < N; i++) { cin >> cvec.at(i) >> tvec.at(i); if (tvec.at(i) <= T && cvec.at(i) < ans) { ans = cvec.at(i); } } if (ans == 10000) { cout << "TLE"; } else { cout << ans; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPD(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++) #define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--) #define ALL(x) (x).begin(), (x).end() #define SIZE(x) ((ll)(x).size()) #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x)) #define INF 1000000000000 #define MOD 1000000007 #define MAXR 100000 #define _GLIBCXX_DEBUG int threemax(int a, int b, int c) { if (a >= b && a >= c) { return a; } else if (b >= a && b >= c) { return b; } else { return c; } } int threemin(int a, int b, int c) { if (a <= b && a <= c) { return a; } else if (b <= a && b <= c) { return b; } else { return c; } } void chmaxl(ll &a, ll b) { if (a < b) { a = b; } return; } void chminl(ll &a, ll b) { if (a > b) { a = b; } return; } void chmaxi(int &a, int b) { if (a < b) { a = b; } return; } void chmini(int &a, int b) { if (a > b) { a = b; } return; } int main() { int N, T; cin >> N >> T; int ans = 10000; vector<int> cvec(N); vector<int> tvec(N); for (int i = 0; i < N; i++) { cin >> cvec.at(i) >> tvec.at(i); if (tvec.at(i) <= T && cvec.at(i) < ans) { ans = cvec.at(i); } } if (ans == 10000) { cout << "TLE"; } else { cout << ans; } }
replace
69
71
69
71
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
p03239
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; // Compiler version g++ 6.3.0 int main() { int N, t; vector<int> a; cin >> N >> t; for (int i = 0; i < N; i++) { int x, y; cin >> x >> y; if (y <= t) { a.push_back(x); } } sort(a.begin(), a.end()); cout << a.at(0) << endl; }
#include <bits/stdc++.h> using namespace std; // Compiler version g++ 6.3.0 int main() { int N, t; vector<int> a; cin >> N >> t; for (int i = 0; i < N; i++) { int x, y; cin >> x >> y; if (y <= t) { a.push_back(x); } } sort(a.begin(), a.end()); if (!a.empty()) { cout << a.at(0) << endl; } else { cout << "TLE" << endl; } }
replace
16
17
16
21
0
p03239
Python
Runtime Error
N, T = map(int, input().split()) c_t = [list(map(int, input().split())) for _ in range(N)] cost = 2_000_000 TLE_flg = True for i in range(N): if c_t[i][1] <= T: cost = min(cost, c_t[i][0]) TLE_flg = False print("TLE" if TLE_flg else cost)
N, T = map(int, input().split()) c_t = [list(map(int, input().split())) for _ in range(N)] cost = 2000000 TLE_flg = True for i in range(N): if c_t[i][1] <= T: cost = min(cost, c_t[i][0]) TLE_flg = False print("TLE" if TLE_flg else cost)
replace
2
3
2
3
0
p03239
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; int main() { int N, T; cin >> N >> T; vector<int> c; for (int i = 0; i < N; i++) { int t, x; cin >> x >> t; if (t <= T) { c.push_back(x); } } sort(c.begin(), c.end()); cout << c.at(0) << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; int main() { int N, T; cin >> N >> T; vector<int> c; for (int i = 0; i < N; i++) { int t, x; cin >> x >> t; if (t <= T) { c.push_back(x); } } if (c.size() == 0) { cout << "TLE" << endl; } else { sort(c.begin(), c.end()); cout << c.at(0) << endl; } }
replace
16
18
16
22
0
p03239
C++
Runtime Error
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, T; cin >> N >> T; vector<int> cost; int c, t; for (int i = 0; i < N; i++) { cin >> c >> t; if (t <= T) { cost.push_back(c); } } sort(cost.begin(), cost.end()); cout << *cost.begin(); return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, T; cin >> N >> T; vector<int> cost; int c, t; for (int i = 0; i < N; i++) { cin >> c >> t; if (t <= T) { cost.push_back(c); } } if (cost.size() != 0) { sort(cost.begin(), cost.end()); cout << *cost.begin(); } else { cout << "TLE"; } return 0; }
replace
16
18
16
22
0
p03239
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, t; cin >> n >> t; vector<int> cost(0); for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; if (y <= t) cost.push_back(x); } sort(cost.begin(), cost.end()); cout << cost.at(0) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, t; cin >> n >> t; vector<int> cost(0); for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; if (y <= t) cost.push_back(x); } sort(cost.begin(), cost.end()); if (cost.size() > 0) cout << cost.at(0) << endl; else cout << "TLE" << endl; }
replace
14
15
14
18
0
p03239
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define pb push_back #define mp make_pair #define YES cout << "YES" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define No cout << "No" << endl #define INF (1 << 30) #define LLINF (1 << 60) #define MOD 1000000007 #define rep(i, n) for (int i = 0; i < n; i++) using ll = long long; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, T; vector<int> route; cin >> n >> T; for (int i = 0; i < n; i++) { int t, tt; cin >> t >> tt; if (tt <= T) route.pb(t); } sort(route.begin(), route.end()); cout << route[0] << endl; return 0; }
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define pb push_back #define mp make_pair #define YES cout << "YES" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define No cout << "No" << endl #define INF (1 << 30) #define LLINF (1 << 60) #define MOD 1000000007 #define rep(i, n) for (int i = 0; i < n; i++) using ll = long long; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, T; vector<int> route; cin >> n >> T; for (int i = 0; i < n; i++) { int t, tt; cin >> t >> tt; if (tt <= T) route.pb(t); } sort(route.begin(), route.end()); if (route.size() == 0) cout << "TLE" << endl; else cout << route[0] << endl; return 0; }
replace
44
45
44
48
0
p03239
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <tuple> #include <utility> #include <vector> #define PB push_back #define all(a) (a).begin(), (a).end() #define ALL(v) begin(v), end(v) #define DWN(a) (a).begin(), (a).end(), greater<int>() #define rep(i, m) for (int i = 0; i < m; i++) #define REP(i, n, m) for (int i = n; i < m; i++) #define V vector<int> #define VV vector<V> #define VVV vector<VV> using namespace std; typedef long long ll; typedef pair<int, int> P; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const int inf = (int)1e9; const ll INF = (ll)1e18; const ll MOD{(ll)1e9 + 7}; const long double EPS = 1e-10; int main() { int N, T; cin >> N >> T; vector<int> c(N), t(N), ans; rep(i, N) { cin >> c[i] >> t[i]; if (t[i] <= T) { ans.push_back(c[i]); } } sort(ans.begin(), ans.end()); cout << ans[0] << endl; return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <tuple> #include <utility> #include <vector> #define PB push_back #define all(a) (a).begin(), (a).end() #define ALL(v) begin(v), end(v) #define DWN(a) (a).begin(), (a).end(), greater<int>() #define rep(i, m) for (int i = 0; i < m; i++) #define REP(i, n, m) for (int i = n; i < m; i++) #define V vector<int> #define VV vector<V> #define VVV vector<VV> using namespace std; typedef long long ll; typedef pair<int, int> P; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const int inf = (int)1e9; const ll INF = (ll)1e18; const ll MOD{(ll)1e9 + 7}; const long double EPS = 1e-10; int main() { int N, T; cin >> N >> T; vector<int> c(N), t(N), ans; rep(i, N) { cin >> c[i] >> t[i]; if (t[i] <= T) { ans.push_back(c[i]); } } if (ans.size() > 0) { sort(ans.begin(), ans.end()); cout << ans[0] << endl; } else { cout << "TLE" << endl; } return 0; }
replace
51
53
51
57
0
p03239
C++
Runtime Error
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <vector> using namespace std; int main() { int N, T; cin >> N >> T; vector<int> c(N), t(N); vector<int> answer; for (int i = 0; i < N; ++i) { cin >> c[i] >> t[i]; if (t[i] <= T) { answer.push_back(c[i]); } } sort(answer.begin(), answer.end()); cout << answer[0] << endl; cin >> N; }
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <vector> using namespace std; int main() { int N, T; cin >> N >> T; vector<int> c(N), t(N); vector<int> answer; for (int i = 0; i < N; ++i) { cin >> c[i] >> t[i]; if (t[i] <= T) { answer.push_back(c[i]); } } if (answer.size() == 0) { cout << "TLE" << endl; return 0; } sort(answer.begin(), answer.end()); cout << answer[0] << endl; cin >> N; }
insert
17
17
17
21
0
p03239
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); freopen("input.txt", "r", stdin); int n, t; cin >> n >> t; vector<int> cost(n), time(n); for (int i = 0; i < n; ++i) { cin >> cost[i] >> time[i]; } int ans = 1001; for (int i = 0; i < n; ++i) { if (time[i] <= t) { if (cost[i] < ans) { ans = cost[i]; } } } if (ans == 1001) { cout << "TLE" << "\n"; } else { cout << ans << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); // freopen("input.txt", "r", stdin); int n, t; cin >> n >> t; vector<int> cost(n), time(n); for (int i = 0; i < n; ++i) { cin >> cost[i] >> time[i]; } int ans = 1001; for (int i = 0; i < n; ++i) { if (time[i] <= t) { if (cost[i] < ans) { ans = cost[i]; } } } if (ans == 1001) { cout << "TLE" << "\n"; } else { cout << ans << "\n"; } return 0; }
replace
6
7
6
7
-6
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
p03239
C++
Runtime Error
#include <algorithm> #include <iostream> using namespace std; struct input { int c, t; } inputs[1000]; bool compare(input a, input b) { if (a.t == b.t) { return a.c < b.c; } return a.t < b.t; } int main() { int N, T; cin >> N >> T; int c, t; for (int i = 0; i < N; i++) { cin >> c >> t; inputs[i] = input{c, t}; } sort(inputs, inputs + N, compare); if (inputs[0].t > T) { cout << "TLE" << endl; } else { int mincost = 1001; int i = 0; while (inputs[i].t <= T) { mincost = min(mincost, inputs[i].c); i++; } cout << mincost << endl; } return 0; }
#include <algorithm> #include <iostream> using namespace std; struct input { int c, t; } inputs[1000]; bool compare(input a, input b) { if (a.t == b.t) { return a.c < b.c; } return a.t < b.t; } int main() { int N, T; cin >> N >> T; int c, t; for (int i = 0; i < N; i++) { cin >> c >> t; inputs[i] = input{c, t}; } sort(inputs, inputs + N, compare); if (inputs[0].t > T) { cout << "TLE" << endl; } else { int mincost = 1001; int i = 0; while (inputs[i].t <= T && i < N) { mincost = min(mincost, inputs[i].c); i++; } cout << mincost << endl; } return 0; }
replace
31
32
31
32
0
p03239
C++
Runtime Error
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n, t, i; cin >> n >> t; vector<int> c, q; for (i = 0; i < n; i++) cin >> c[i] >> q[i]; vector<int> p; for (i = 0; i < n; i++) { if (q[i] <= t) p.push_back(c[i]); } if (p.size() == 0) cout << "TLE" << endl; else cout << *min_element(p.begin(), p.end()) << endl; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n, t, i; cin >> n >> t; int c[n], q[n]; for (i = 0; i < n; i++) cin >> c[i] >> q[i]; vector<int> p; for (i = 0; i < n; i++) { if (q[i] <= t) p.push_back(c[i]); } if (p.size() == 0) cout << "TLE" << endl; else cout << *min_element(p.begin(), p.end()) << endl; }
replace
7
8
7
8
-11
p03239
C++
Runtime Error
#define _GLIBCXX_DEBUG // TLEの原因になるので注意!!!!!!!!!!! #include <bits/stdc++.h> #include <cmath> typedef long long ll; using namespace std; vector<int> arr; stack<int> st; queue<int> qu; queue<pair<int, int>> qu2; priority_queue<int> pq; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, n) for (int i = 1; i <= (int)(n); i++) typedef set<int> set_t; typedef set<string> set_g; typedef complex<double> xy_t; static const int NIL = -1; static const int INF = 1000000007; #define mp make_pair /*int P[10010]; void init(int n){//Union-find for(int i=0;i<n;++i)P[i]=i; } int root(int a) { if(P[a]==a)return a; return (P[a]=root(P[a])); } bool is_same_set(int a,int b){ return root(a) == root(b);//代表元を求める } void unite(int a,int b){ P[root(a)]=root(b); }//対set,グラフ? //セグメント木?? */ // Unionfind ,Disjointset class UnionFind { public: // 親の番号を格納する 親の場合-(その集合のサイズ) vector<int> Parent; // 作るときはParentの値を全て-1にする UnionFind(int n) { Parent = vector<int>(n, -1); } // Aがどのグループに属するか int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } // 自分のグループの頂点数 int size(int A) { return -Parent[root(A)]; } // AとBをくっつける int connect(int A, int B) { // AとBを直接ではなくAのrootとBのrootをくっつける A = root(A); B = root(B); if (A == B) { return false; // すでにくっついている } if (size(A) < size(B)) swap(A, B); // Aのサイズ更新 Parent[A] += Parent[B]; // Bの親をAに変更する Parent[B] = A; return true; } }; double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); } // 内積 double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); } // 外積 xy_t projection(xy_t p, xy_t b) { return b * dot_product(p, b) / norm(b); } // 投影 // 対図形 #define mod 1000000007 /*ll f[2001]; //int n,k とかしておく ll pw(ll x, ll y){//euclidの互除法より ll a= 1; while(y){ if(y&1){//奇数なら a = a*x%mod; } x = x*x%mod; y /= 2; } return a; } ll modinv(ll x){//逆元を求める return pw(x, mod - 2 ); } ll comb(int n,int r){ if(n<r){ return 0; } return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod; }//対combination//ただしfは用意してね */ struct BIT { vector<int> dat; int sz; BIT(int n) { for (sz = 1; sz < n; sz *= 2) ; dat.resize(++sz); } int q(int n) { int ret = 0; for (int i = n; i > 0; i -= i & -i) ret += dat[i]; // 和の計算 iから最後の1のbit(i&-i // 多分&はビット積)を減算 for (int i = n; i < sz; i += i & -i) dat[i]++; // 値の加算 iから最後mの1のbitを加算 return ret; } }; /* // auto mod int // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu.be/8uowVvQ_-Mo?t=1329 : division const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x=0):x((x%mod+mod)%mod){} mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this;//thisポインター thisで自分自身のアドレス } mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res+=a; } mint operator-(const mint a) const { mint res(*this); return res-=a; } mint operator*(const mint a) const { mint res(*this); return res*=a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod-2); } mint& operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res/=a; } }; */ int main() { int n, T; cin >> n >> T; vector<int> v; rep(i, n) { int c, t; cin >> c >> t; if (t <= T) { v.push_back(c); } } sort(v.begin(), v.end()); cout << v[0] << endl; return 0; }
#define _GLIBCXX_DEBUG // TLEの原因になるので注意!!!!!!!!!!! #include <bits/stdc++.h> #include <cmath> typedef long long ll; using namespace std; vector<int> arr; stack<int> st; queue<int> qu; queue<pair<int, int>> qu2; priority_queue<int> pq; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, n) for (int i = 1; i <= (int)(n); i++) typedef set<int> set_t; typedef set<string> set_g; typedef complex<double> xy_t; static const int NIL = -1; static const int INF = 1000000007; #define mp make_pair /*int P[10010]; void init(int n){//Union-find for(int i=0;i<n;++i)P[i]=i; } int root(int a) { if(P[a]==a)return a; return (P[a]=root(P[a])); } bool is_same_set(int a,int b){ return root(a) == root(b);//代表元を求める } void unite(int a,int b){ P[root(a)]=root(b); }//対set,グラフ? //セグメント木?? */ // Unionfind ,Disjointset class UnionFind { public: // 親の番号を格納する 親の場合-(その集合のサイズ) vector<int> Parent; // 作るときはParentの値を全て-1にする UnionFind(int n) { Parent = vector<int>(n, -1); } // Aがどのグループに属するか int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } // 自分のグループの頂点数 int size(int A) { return -Parent[root(A)]; } // AとBをくっつける int connect(int A, int B) { // AとBを直接ではなくAのrootとBのrootをくっつける A = root(A); B = root(B); if (A == B) { return false; // すでにくっついている } if (size(A) < size(B)) swap(A, B); // Aのサイズ更新 Parent[A] += Parent[B]; // Bの親をAに変更する Parent[B] = A; return true; } }; double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); } // 内積 double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); } // 外積 xy_t projection(xy_t p, xy_t b) { return b * dot_product(p, b) / norm(b); } // 投影 // 対図形 #define mod 1000000007 /*ll f[2001]; //int n,k とかしておく ll pw(ll x, ll y){//euclidの互除法より ll a= 1; while(y){ if(y&1){//奇数なら a = a*x%mod; } x = x*x%mod; y /= 2; } return a; } ll modinv(ll x){//逆元を求める return pw(x, mod - 2 ); } ll comb(int n,int r){ if(n<r){ return 0; } return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod; }//対combination//ただしfは用意してね */ struct BIT { vector<int> dat; int sz; BIT(int n) { for (sz = 1; sz < n; sz *= 2) ; dat.resize(++sz); } int q(int n) { int ret = 0; for (int i = n; i > 0; i -= i & -i) ret += dat[i]; // 和の計算 iから最後の1のbit(i&-i // 多分&はビット積)を減算 for (int i = n; i < sz; i += i & -i) dat[i]++; // 値の加算 iから最後mの1のbitを加算 return ret; } }; /* // auto mod int // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu.be/8uowVvQ_-Mo?t=1329 : division const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x=0):x((x%mod+mod)%mod){} mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this;//thisポインター thisで自分自身のアドレス } mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res+=a; } mint operator-(const mint a) const { mint res(*this); return res-=a; } mint operator*(const mint a) const { mint res(*this); return res*=a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod-2); } mint& operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res/=a; } }; */ int main() { int n, T; cin >> n >> T; vector<int> v; rep(i, n) { int c, t; cin >> c >> t; if (t <= T) { v.push_back(c); } } if (v.empty() != 0) { cout << "TLE" << endl; return 0; } sort(v.begin(), v.end()); cout << v[0] << endl; return 0; }
insert
189
189
189
193
0
p03239
C++
Runtime Error
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, T; cin >> N >> T; vector<int> C; for (int i = 0; i < N; i++) { int c, t; cin >> c >> t; if (t <= T) { C.push_back(c); } } sort(C.begin(), C.end()); cout << C[0] << endl; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, T; cin >> N >> T; vector<int> C; for (int i = 0; i < N; i++) { int c, t; cin >> c >> t; if (t <= T) { C.push_back(c); } } if (C.size() == 0) { cout << "TLE" << endl; return 0; } sort(C.begin(), C.end()); cout << C[0] << endl; }
insert
19
19
19
24
0
p03239
C++
Runtime Error
#include <bits/stdc++.h> using ll = long long; #define int ll #define rep(i, n) for (int i = 0; i < n; i++) #define loop(i, s, n) for (int i = s; i < n; i++) #define erep(e, v) for (auto &&e : v) #define all(in) in.begin(), in.end() #define MP make_pair #define INF (sizeof(int) == 4 ? (int)1e9 : (int)1e18) #define EPS 0.0000000001 using namespace std; template <class T, class S> void cmin(T &a, const S &b) { if (a > b) a = b; } template <class T, class S> void cmax(T &a, const S &b) { if (a < b) a = b; } template <typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); } template <typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); } template <class T> void join(T a) { for (auto itr : a) { if (itr != *a.begin()) cout << " "; cout << itr; } } using ld = long double; using pii = pair<int, int>; using piii = pair<int, pii>; int W, H; int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}; bool valid(int x, int y) { return (0 <= x && x < W) && (0 <= y && y < H); } signed main() { int n, t; cin >> n >> t; vector<int> v; rep(_, n) { int a, b; cin >> a >> b; if (b <= t) v.push_back(a); } cout << *min_element(all(v)) << endl; }
#include <bits/stdc++.h> using ll = long long; #define int ll #define rep(i, n) for (int i = 0; i < n; i++) #define loop(i, s, n) for (int i = s; i < n; i++) #define erep(e, v) for (auto &&e : v) #define all(in) in.begin(), in.end() #define MP make_pair #define INF (sizeof(int) == 4 ? (int)1e9 : (int)1e18) #define EPS 0.0000000001 using namespace std; template <class T, class S> void cmin(T &a, const S &b) { if (a > b) a = b; } template <class T, class S> void cmax(T &a, const S &b) { if (a < b) a = b; } template <typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); } template <typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); } template <class T> void join(T a) { for (auto itr : a) { if (itr != *a.begin()) cout << " "; cout << itr; } } using ld = long double; using pii = pair<int, int>; using piii = pair<int, pii>; int W, H; int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}; bool valid(int x, int y) { return (0 <= x && x < W) && (0 <= y && y < H); } signed main() { int n, t; cin >> n >> t; vector<int> v; rep(_, n) { int a, b; cin >> a >> b; if (b <= t) v.push_back(a); } cout << (v.size() ? to_string(*min_element(all(v))) : "TLE") << endl; }
replace
50
51
50
51
0
p03239
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long #define f(i, x, n) for (int i = x; i < (int)(n); ++i) #define speed \ ios::sync_with_stdio(0); \ cin.tie(0); int const N = 1e5 + 1; vector<int> v; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); #endif speed int x, time; cin >> x >> time; f(i, 0, x) { int c, t; cin >> c >> t; if (t <= time) { v.push_back(c); } } sort(v.begin(), v.end()); if (v.size() == 0) cout << "TLE" << endl; else cout << v[0] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define f(i, x, n) for (int i = x; i < (int)(n); ++i) #define speed \ ios::sync_with_stdio(0); \ cin.tie(0); int const N = 1e5 + 1; vector<int> v; int main() { speed int x, time; cin >> x >> time; f(i, 0, x) { int c, t; cin >> c >> t; if (t <= time) { v.push_back(c); } } sort(v.begin(), v.end()); if (v.size() == 0) cout << "TLE" << endl; else cout << v[0] << endl; return 0; }
delete
10
13
10
10
0
p03239
C++
Runtime Error
#include <algorithm> #include <iostream> #include <vector> int main(void) { int N, T; std::cin >> N >> T; std::vector<int> costs; int time = 0; int cost = 0; for (int i = 0; i < N; i++) { std::cin >> cost >> time; if (time <= T) { costs.push_back(cost); } } std::sort(costs.begin(), costs.end()); std::cout << costs[0]; return 0; }
#include <algorithm> #include <iostream> #include <vector> int main(void) { int N, T; std::cin >> N >> T; std::vector<int> costs; int time = 0; int cost = 0; for (int i = 0; i < N; i++) { std::cin >> cost >> time; if (time <= T) { costs.push_back(cost); } } if (costs.size() == 0) { std::cout << "TLE"; } else { std::sort(costs.begin(), costs.end()); std::cout << costs[0]; } return 0; }
replace
17
19
17
23
0
p03239
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int N, T; cin >> N >> T; int c[1000]; int t[1000]; int cost = 1001; for (int i = 0; i < N; i++) { cin >> c[i] >> t[i]; if ((t[i] <= T) && (c[i] <= cost)) cost = c[i]; } if (cost == 1001) cout << "TLE"; else cout << cost; while (1) ; return 0; }
#include <iostream> using namespace std; int main() { int N, T; cin >> N >> T; int c[1000]; int t[1000]; int cost = 1001; for (int i = 0; i < N; i++) { cin >> c[i] >> t[i]; if ((t[i] <= T) && (c[i] <= cost)) cost = c[i]; } if (cost == 1001) cout << "TLE"; else cout << cost; return 0; }
delete
18
20
18
18
TLE
p03239
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, t, ci, ti; vector<int> cost; cin >> n >> t; for (int i = 0; i < n; i++) { cin >> ci >> ti; if (ti > t) continue; cost.push_back(ci); } cout << *min_element(cost.begin(), cost.end()); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, t, ci, ti; vector<int> cost; cin >> n >> t; for (int i = 0; i < n; i++) { cin >> ci >> ti; if (ti > t) continue; cost.push_back(ci); } if (cost.size() == 0) cout << "TLE"; else cout << *min_element(cost.begin(), cost.end()); return 0; }
replace
13
14
13
17
0
p03239
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, T, ans = 1001; cin >> N >> T; vector<int> c(N), t(N); for (int i = 1; i <= N; i++) { cin >> c[i] >> t[i]; } for (int i = 1; i <= N; i++) { if (t[i] <= T) ans = min(ans, c[i]); } if (ans == 1001) cout << "TLE" << endl; else cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, T, ans = 1001; cin >> N >> T; vector<int> c(110), t(110); for (int i = 1; i <= N; i++) { cin >> c[i] >> t[i]; } for (int i = 1; i <= N; i++) { if (t[i] <= T) ans = min(ans, c[i]); } if (ans == 1001) cout << "TLE" << endl; else cout << ans << endl; }
replace
5
6
5
6
0
p03240
Python
Time Limit Exceeded
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, *XYH = map(int, read().split()) for cx in range(101): for cy in range(101): ok = 10**12 ng = 0 while ok - ng > 1: mid = (ok + ng) // 2 valid = True for x, y, h in zip(*[iter(XYH)] * 3): if max(mid - abs(x - cx) - abs(y - cy), 0) < h: valid = False break if valid: ok = mid else: ng = mid H = ok valid = True for x, y, h in zip(*[iter(XYH)] * 3): if max(H - abs(x - cx) - abs(y - cy), 0) != h: valid = False break if valid: print(cx, cy, H) return return if __name__ == "__main__": main()
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, *XYH = map(int, read().split()) for cx in range(101): for cy in range(101): ok = 10**9 + 100 ng = 0 while ok - ng > 1: mid = (ok + ng) // 2 valid = True for x, y, h in zip(*[iter(XYH)] * 3): if max(mid - abs(x - cx) - abs(y - cy), 0) < h: valid = False break if valid: ok = mid else: ng = mid H = ok valid = True for x, y, h in zip(*[iter(XYH)] * 3): if max(H - abs(x - cx) - abs(y - cy), 0) != h: valid = False break if valid: print(cx, cy, H) return return if __name__ == "__main__": main()
replace
15
16
15
16
TLE
p03240
Python
Runtime Error
def search_center(xyh_list): xyh_list.sort(key=lambda r: r[2], reverse=True) highest = xyh_list[0] for cx in range(101): for cy in range(101): h = highest[2] + abs(highest[0] - cx) + abs(highest[1] - cy) matched = True for xyh in xyh_list[1:]: if xyh[2] == 0: if h - abs(highest[0] - cx) - abs(highest[1] - cy) > 0: matched = False break else: hh = xyh[2] + abs(xyh[0] - cx) + abs(xyh[1] - cy) if h != hh: matched = False break if matched: return cx, cy, h return None def main(): N = int(input()) xyh_list = [list(map(int, input().split(" "))) for _ in range(N)] xyh_list.sort(key=lambda r: r[2], reverse=True) cx, cy, ph = search_center(xyh_list) print("{} {} {}".format(cx, cy, ph)) if __name__ == "__main__": main()
def search_center(xyh_list): xyh_list.sort(key=lambda r: r[2], reverse=True) highest = xyh_list[0] for cx in range(101): for cy in range(101): h = highest[2] + abs(highest[0] - cx) + abs(highest[1] - cy) matched = True for xyh in xyh_list[1:]: if xyh[2] == 0: if h - abs(xyh[0] - cx) - abs(xyh[1] - cy) > 0: matched = False break else: hh = xyh[2] + abs(xyh[0] - cx) + abs(xyh[1] - cy) if h != hh: matched = False break if matched: return cx, cy, h return None def main(): N = int(input()) xyh_list = [list(map(int, input().split(" "))) for _ in range(N)] xyh_list.sort(key=lambda r: r[2], reverse=True) cx, cy, ph = search_center(xyh_list) print("{} {} {}".format(cx, cy, ph)) if __name__ == "__main__": main()
replace
9
10
9
10
0
p03240
C++
Runtime Error
#pragma GCC optimize("O3") #include "bits/stdc++.h" using namespace std; using ll = long long int; #define debugos cout #define debug(v) \ { \ printf("L%d %s > ", __LINE__, #v); \ debugos << (v) << endl; \ } #define debugv(v) \ { \ printf("L%d %s > ", __LINE__, #v); \ for (auto e : (v)) { \ debugos << e << " "; \ } \ debugos << endl; \ } #define debuga(m, w) \ { \ printf("L%d %s > ", __LINE__, #m); \ for (int x = 0; x < (w); x++) { \ debugos << (m)[x] << " "; \ } \ debugos << endl; \ } #define debugaa(m, h, w) \ { \ printf("L%d %s >\n", __LINE__, #m); \ for (int y = 0; y < (h); y++) { \ for (int x = 0; x < (w); x++) { \ debugos << (m)[y][x] << " "; \ } \ debugos << endl; \ } \ } #define ALL(v) (v).begin(), (v).end() #define repeat(cnt, l) \ for (remove_reference<remove_const<decltype(l)>::type>::type cnt = 0; \ (cnt) < (l); ++(cnt)) #define rrepeat(cnt, l) for (auto cnt = (l)-1; 0 <= (cnt); --(cnt)) #define iterate(cnt, b, e) for (auto cnt = (b); (cnt) != (e); ++(cnt)) #define diterate(cnt, b, e) for (auto cnt = (b); (cnt) != (e); --(cnt)) const ll MD = 1000000007ll; const long double PI = 3.1415926535897932384626433832795L; inline void assert_call(bool assertion, function<void()> f) { if (!assertion) { cerr << "assertion fault:" << endl; f(); abort(); } } template <typename T1, typename T2> inline ostream &operator<<(ostream &o, const pair<T1, T2> p) { o << '(' << p.first << ':' << p.second << ')'; return o; } template <typename Vec> inline ostream &_ostream_vecprint(ostream &os, const Vec &a) { os << '['; for (const auto &e : a) os << ' ' << e << ' '; os << ']'; return os; } template <typename T> inline ostream &operator<<(ostream &o, const vector<T> &v) { return _ostream_vecprint(o, v); } template <typename T, size_t S> inline ostream &operator<<(ostream &o, const array<T, S> &v) { return _ostream_vecprint(o, v); } template <typename T> inline T &maxset(T &to, const T &val) { return to = max(to, val); } template <typename T> inline T &minset(T &to, const T &val) { return to = min(to, val); } void bye(string s, int code = 0) { cout << s << endl; exit(code); } mt19937_64 randdev(8901016); template <typename T> inline T rand(T l, T h) { return uniform_int_distribution<T>(l, h)(randdev); } template <> inline double rand<double>(double l, double h) { return uniform_real_distribution<double>(l, h)(randdev); } template <> inline float rand<float>(float l, float h) { return uniform_real_distribution<float>(l, h)(randdev); } #if defined(_WIN32) || defined(_WIN64) #define getchar_unlocked _getchar_nolock #define putchar_unlocked _putchar_nolock #elif defined(__GNUC__) #else #define getchar_unlocked getchar #define putchar_unlocked putchar #endif namespace { #define isvisiblechar(c) (0x21 <= (c) && (c) <= 0x7E) class MaiScanner { public: template <typename T> void input_integer(T &var) noexcept { var = 0; T sign = 1; int cc = getchar_unlocked(); for (; cc < '0' || '9' < cc; cc = getchar_unlocked()) if (cc == '-') sign = -1; for (; '0' <= cc && cc <= '9'; cc = getchar_unlocked()) var = (var << 3) + (var << 1) + cc - '0'; var = var * sign; } inline int c() noexcept { return getchar_unlocked(); } inline MaiScanner &operator>>(int &var) noexcept { input_integer<int>(var); return *this; } inline MaiScanner &operator>>(long long &var) noexcept { input_integer<long long>(var); return *this; } inline MaiScanner &operator>>(string &var) { int cc = getchar_unlocked(); for (; !isvisiblechar(cc); cc = getchar_unlocked()) ; for (; isvisiblechar(cc); cc = getchar_unlocked()) var.push_back(cc); return *this; } template <typename IT> void in(IT begin, IT end) { for (auto it = begin; it != end; ++it) *this >> *it; } }; class MaiPrinter { public: template <typename T> void output_integer(T var) noexcept { if (var == 0) { putchar_unlocked('0'); return; } if (var < 0) putchar_unlocked('-'), var = -var; char stack[32]; int stack_p = 0; while (var) stack[stack_p++] = '0' + (var % 10), var /= 10; while (stack_p) putchar_unlocked(stack[--stack_p]); } inline MaiPrinter &operator<<(char c) noexcept { putchar_unlocked(c); return *this; } inline MaiPrinter &operator<<(int var) noexcept { output_integer<int>(var); return *this; } inline MaiPrinter &operator<<(long long var) noexcept { output_integer<long long>(var); return *this; } inline MaiPrinter &operator<<(char *str_p) noexcept { while (*str_p) putchar_unlocked(*(str_p++)); return *this; } inline MaiPrinter &operator<<(const string &str) { const char *p = str.c_str(); const char *l = p + str.size(); while (p < l) putchar_unlocked(*p++); return *this; } template <typename IT> void join(IT begin, IT end, char sep = ' ') { for (bool b = 0; begin != end; ++begin, b = 1) b ? *this << sep << *begin : *this << *begin; } }; } // namespace MaiScanner scanner; MaiPrinter printer; int N; array<int, 3> info[111]; int main() { scanner >> N; repeat(i, N) { int x, y, h; scanner >> x >> y >> h; info[i][0] = x; info[i][1] = y; info[i][2] = h; } sort(info, info + N, [](const array<int, 3> &a, const array<int, 3> &b) { return a[2] >= b[2]; }); vector<array<ll, 3>> answers; repeat(cy, 101) { repeat(cx, 101) { bool ok = true; ll high = -1; repeat(i, N) { ll h = (ll)info[i][2] + (ll)(abs(info[i][0] - cx) + abs(info[i][1] - cy)); if (info[i][2] == 0) continue; if (high == -1) { high = h; } else if (h != high) { ok = false; break; } } if (ok && high > 0) { answers.push_back({(ll)cx, (ll)cy, (ll)high}); } } } assert(!answers.empty()); for (auto answer : answers) { ll cx = answer[0], cy = answer[1], high = answer[2]; bool ok = true; repeat(i, N) { if (info[i][2] != max<ll>(0, high - (ll)(abs(info[i][0] - cx) + abs(info[i][1] - cy)))) { ok = false; break; } } if (ok) { cout << answer[0] << ' ' << answer[1] << ' ' << answer[2] << '\n'; return 0; } } return 2; return 0; }
#pragma GCC optimize("O3") #include "bits/stdc++.h" using namespace std; using ll = long long int; #define debugos cout #define debug(v) \ { \ printf("L%d %s > ", __LINE__, #v); \ debugos << (v) << endl; \ } #define debugv(v) \ { \ printf("L%d %s > ", __LINE__, #v); \ for (auto e : (v)) { \ debugos << e << " "; \ } \ debugos << endl; \ } #define debuga(m, w) \ { \ printf("L%d %s > ", __LINE__, #m); \ for (int x = 0; x < (w); x++) { \ debugos << (m)[x] << " "; \ } \ debugos << endl; \ } #define debugaa(m, h, w) \ { \ printf("L%d %s >\n", __LINE__, #m); \ for (int y = 0; y < (h); y++) { \ for (int x = 0; x < (w); x++) { \ debugos << (m)[y][x] << " "; \ } \ debugos << endl; \ } \ } #define ALL(v) (v).begin(), (v).end() #define repeat(cnt, l) \ for (remove_reference<remove_const<decltype(l)>::type>::type cnt = 0; \ (cnt) < (l); ++(cnt)) #define rrepeat(cnt, l) for (auto cnt = (l)-1; 0 <= (cnt); --(cnt)) #define iterate(cnt, b, e) for (auto cnt = (b); (cnt) != (e); ++(cnt)) #define diterate(cnt, b, e) for (auto cnt = (b); (cnt) != (e); --(cnt)) const ll MD = 1000000007ll; const long double PI = 3.1415926535897932384626433832795L; inline void assert_call(bool assertion, function<void()> f) { if (!assertion) { cerr << "assertion fault:" << endl; f(); abort(); } } template <typename T1, typename T2> inline ostream &operator<<(ostream &o, const pair<T1, T2> p) { o << '(' << p.first << ':' << p.second << ')'; return o; } template <typename Vec> inline ostream &_ostream_vecprint(ostream &os, const Vec &a) { os << '['; for (const auto &e : a) os << ' ' << e << ' '; os << ']'; return os; } template <typename T> inline ostream &operator<<(ostream &o, const vector<T> &v) { return _ostream_vecprint(o, v); } template <typename T, size_t S> inline ostream &operator<<(ostream &o, const array<T, S> &v) { return _ostream_vecprint(o, v); } template <typename T> inline T &maxset(T &to, const T &val) { return to = max(to, val); } template <typename T> inline T &minset(T &to, const T &val) { return to = min(to, val); } void bye(string s, int code = 0) { cout << s << endl; exit(code); } mt19937_64 randdev(8901016); template <typename T> inline T rand(T l, T h) { return uniform_int_distribution<T>(l, h)(randdev); } template <> inline double rand<double>(double l, double h) { return uniform_real_distribution<double>(l, h)(randdev); } template <> inline float rand<float>(float l, float h) { return uniform_real_distribution<float>(l, h)(randdev); } #if defined(_WIN32) || defined(_WIN64) #define getchar_unlocked _getchar_nolock #define putchar_unlocked _putchar_nolock #elif defined(__GNUC__) #else #define getchar_unlocked getchar #define putchar_unlocked putchar #endif namespace { #define isvisiblechar(c) (0x21 <= (c) && (c) <= 0x7E) class MaiScanner { public: template <typename T> void input_integer(T &var) noexcept { var = 0; T sign = 1; int cc = getchar_unlocked(); for (; cc < '0' || '9' < cc; cc = getchar_unlocked()) if (cc == '-') sign = -1; for (; '0' <= cc && cc <= '9'; cc = getchar_unlocked()) var = (var << 3) + (var << 1) + cc - '0'; var = var * sign; } inline int c() noexcept { return getchar_unlocked(); } inline MaiScanner &operator>>(int &var) noexcept { input_integer<int>(var); return *this; } inline MaiScanner &operator>>(long long &var) noexcept { input_integer<long long>(var); return *this; } inline MaiScanner &operator>>(string &var) { int cc = getchar_unlocked(); for (; !isvisiblechar(cc); cc = getchar_unlocked()) ; for (; isvisiblechar(cc); cc = getchar_unlocked()) var.push_back(cc); return *this; } template <typename IT> void in(IT begin, IT end) { for (auto it = begin; it != end; ++it) *this >> *it; } }; class MaiPrinter { public: template <typename T> void output_integer(T var) noexcept { if (var == 0) { putchar_unlocked('0'); return; } if (var < 0) putchar_unlocked('-'), var = -var; char stack[32]; int stack_p = 0; while (var) stack[stack_p++] = '0' + (var % 10), var /= 10; while (stack_p) putchar_unlocked(stack[--stack_p]); } inline MaiPrinter &operator<<(char c) noexcept { putchar_unlocked(c); return *this; } inline MaiPrinter &operator<<(int var) noexcept { output_integer<int>(var); return *this; } inline MaiPrinter &operator<<(long long var) noexcept { output_integer<long long>(var); return *this; } inline MaiPrinter &operator<<(char *str_p) noexcept { while (*str_p) putchar_unlocked(*(str_p++)); return *this; } inline MaiPrinter &operator<<(const string &str) { const char *p = str.c_str(); const char *l = p + str.size(); while (p < l) putchar_unlocked(*p++); return *this; } template <typename IT> void join(IT begin, IT end, char sep = ' ') { for (bool b = 0; begin != end; ++begin, b = 1) b ? *this << sep << *begin : *this << *begin; } }; } // namespace MaiScanner scanner; MaiPrinter printer; int N; array<int, 3> info[111]; int main() { scanner >> N; repeat(i, N) { int x, y, h; scanner >> x >> y >> h; info[i][0] = x; info[i][1] = y; info[i][2] = h; } sort(info, info + N, [](const array<int, 3> &a, const array<int, 3> &b) { return a[2] < b[2]; }); vector<array<ll, 3>> answers; repeat(cy, 101) { repeat(cx, 101) { bool ok = true; ll high = -1; repeat(i, N) { ll h = (ll)info[i][2] + (ll)(abs(info[i][0] - cx) + abs(info[i][1] - cy)); if (info[i][2] == 0) continue; if (high == -1) { high = h; } else if (h != high) { ok = false; break; } } if (ok && high > 0) { answers.push_back({(ll)cx, (ll)cy, (ll)high}); } } } assert(!answers.empty()); for (auto answer : answers) { ll cx = answer[0], cy = answer[1], high = answer[2]; bool ok = true; repeat(i, N) { if (info[i][2] != max<ll>(0, high - (ll)(abs(info[i][0] - cx) + abs(info[i][1] - cy)))) { ok = false; break; } } if (ok) { cout << answer[0] << ' ' << answer[1] << ' ' << answer[2] << '\n'; return 0; } } return 2; return 0; }
replace
206
207
206
207
0
p03240
C++
Runtime Error
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <vector> using namespace std; class point { public: point(); point(long x, long y); point(const point &other); long x, y, h; long height(long cx, long cy); }; point::point(long x, long y) : x(x), y(y) {} point::point(const point &other) : x(other.x), y(other.y) {} point::point() : point(101, 101) {} long point::height(long cx, long cy) { return this->h + abs(this->x - cx) + abs(this->y - cy); } int main() { vector<point> ps(100); int N; cin >> N; for (int i = 0; i < N; i++) { cin >> ps[i].x >> ps[i].y >> ps[i].h; } point *anchor; for (anchor = &ps[0]; anchor->h == 0; anchor++) ; point *ans = nullptr; for (long x = 0; x <= 100; x++) { for (long y = 0; y <= 100; y++) { bool sat = true; long height = anchor->height(x, y); for (int i = 0; i < N; i++) { long test = height - abs(ps[i].x - x) - abs(ps[i].y - y); if (ps[i].h != test) { sat = false; break; } } if (sat) ans = new point(x, y); } } cout << ans->x << " " << ans->y << " " << anchor->height(ans->x, ans->y) << endl; }
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <vector> using namespace std; class point { public: point(); point(long x, long y); point(const point &other); long x, y, h; long height(long cx, long cy); }; point::point(long x, long y) : x(x), y(y) {} point::point(const point &other) : x(other.x), y(other.y) {} point::point() : point(101, 101) {} long point::height(long cx, long cy) { return this->h + abs(this->x - cx) + abs(this->y - cy); } int main() { vector<point> ps(100); int N; cin >> N; for (int i = 0; i < N; i++) { cin >> ps[i].x >> ps[i].y >> ps[i].h; } point *anchor; for (anchor = &ps[0]; anchor->h == 0; anchor++) ; point *ans = nullptr; for (long x = 0; x <= 100; x++) { for (long y = 0; y <= 100; y++) { bool sat = true; long height = anchor->height(x, y); for (int i = 0; i < N; i++) { long test = height - abs(ps[i].x - x) - abs(ps[i].y - y); if (ps[i].h != max(test, 0L)) { sat = false; break; } } if (sat) ans = new point(x, y); } } cout << ans->x << " " << ans->y << " " << anchor->height(ans->x, ans->y) << endl; }
replace
45
46
45
46
0
p03240
C++
Runtime Error
#include "bits/stdc++.h" #define fi first #define se second #define pb push_back #define mp make_pair #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define all(s) s.begin(), s.end() using namespace std; typedef long long int ll; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<P> vp; const int MX = 100005, INF = 1001001001; const ll LINF = 1e18; const double eps = 1e-10; const int DIV = 1e9 + 7; int main() { int n; vi x, y, h; cin >> n; x.resize(n); y.resize(n); h.resize(n); rep(i, n) cin >> x[i] >> y[i] >> h[i]; for (int xi = 0; xi <= 100; xi++) { for (int yi = 0; yi <= 100; yi++) { bool fl = true; ll top = max(abs(xi - x[0]) + abs(yi - y[0]) + h[0], 0); for (int i = 1; i < n; i++) { ll height = max(top - (abs(xi - x[i]) + abs(yi - y[i])), 0LL); if (height != h[i]) fl = false; } if (fl) { cout << xi << " " << yi << " " << top << endl; return 0; } } } return 1; }
#include "bits/stdc++.h" #define fi first #define se second #define pb push_back #define mp make_pair #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define all(s) s.begin(), s.end() using namespace std; typedef long long int ll; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<P> vp; const int MX = 100005, INF = 1001001001; const ll LINF = 1e18; const double eps = 1e-10; const int DIV = 1e9 + 7; int main() { int n; vi x, y, h; cin >> n; x.resize(n); y.resize(n); h.resize(n); rep(i, n) cin >> x[i] >> y[i] >> h[i]; for (int xi = 0; xi <= 100; xi++) { for (int yi = 0; yi <= 100; yi++) { bool fl = true; int top; rep(i, n) { if (h[i] != 0) { top = abs(xi - x[i]) + abs(yi - y[i]) + h[i]; } } for (int i = 0; i < n; i++) { int height = max(top - (abs(xi - x[i]) + abs(yi - y[i])), 0); if (height != h[i]) fl = false; } if (fl) { cout << xi << " " << yi << " " << top << endl; return 0; } } } return 1; }
replace
34
37
34
42
0
p03240
C++
Runtime Error
#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 ll INF = (1LL << 31) - 1; const double pi = acos(-1); ll n, x[101], y[101], h[101]; vector<tuple<ll, ll, ll>> vec; int main() { cin >> n; tuple<ll, ll, ll> G; rep(i, n) { cin >> x[i] >> y[i] >> h[i]; if (h[i]) G = make_tuple(x[i], y[i], h[i]); } rep(i, 101) { rep(j, 101) { ll v = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j); bool flag = true; rep(k, n) { ll H = v - abs(x[k] - i) - abs(y[k] - j); if (H != h[k]) flag = false; } if (flag) vec.push_back(make_tuple(i, j, v)); } } cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl; }
#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 ll INF = (1LL << 31) - 1; const double pi = acos(-1); ll n, x[101], y[101], h[101]; vector<tuple<ll, ll, ll>> vec; int main() { cin >> n; tuple<ll, ll, ll> G; rep(i, n) { cin >> x[i] >> y[i] >> h[i]; if (h[i]) G = make_tuple(x[i], y[i], h[i]); } rep(i, 101) { rep(j, 101) { ll v = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j); bool flag = true; rep(k, n) { ll H = v - abs(x[k] - i) - abs(y[k] - j); H = max(H, 0ll); if (H != h[k]) flag = false; } if (flag) vec.push_back(make_tuple(i, j, v)); } } cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl; }
insert
26
26
26
27
0
p03240
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vd = vector<double>; using vvd = vector<vd>; using vl = vector<ll>; using vvl = vector<vl>; using pii = pair<int, int>; using vs = vector<string>; #define rep(i, n) range(i, 0, n) #define range(i, a, n) for (int i = a; i < n; i++) #define all(a) a.begin(), a.end() #define LINF ((ll)1ll << 60) #define INF ((int)1 << 30) #define EPS (1e-9) #define MOD (1000000007) #define fcout(a) cout << setprecision(a) << fixed #define fs first #define sc second #define PI 3.141592653589793 template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) { os << "[" << p.first << ", " << p.second << "]"; return os; }; template <class S> auto &operator<<(ostream &os, vector<S> t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vvi ans(101, vi(101, INF)); vvi data; rep(i, n) { int x, y, h; cin >> x >> y >> h; data.push_back(vi{x, y, h}); } sort(all(data), [](vi a, vi b) { return a[2] > b[2]; }); for (auto &d : data) { rep(cx, 101) rep(cy, 101) { int H = abs(d[0] - cx) + abs(d[1] - cy) + d[2]; if (ans[cy][cx] == INF) ans[cy][cx] = H; if (ans[cy][cx] != H) ans[cy][cx] = -1; } } rep(cx, 101) rep(cy, 101) { if (ans[cy][cx] != -1) { cout << cx << " " << cy << " " << ans[cy][cx] << endl; return 0; } } cout << ans[1000000][1] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vd = vector<double>; using vvd = vector<vd>; using vl = vector<ll>; using vvl = vector<vl>; using pii = pair<int, int>; using vs = vector<string>; #define rep(i, n) range(i, 0, n) #define range(i, a, n) for (int i = a; i < n; i++) #define all(a) a.begin(), a.end() #define LINF ((ll)1ll << 60) #define INF ((int)1 << 30) #define EPS (1e-9) #define MOD (1000000007) #define fcout(a) cout << setprecision(a) << fixed #define fs first #define sc second #define PI 3.141592653589793 template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) { os << "[" << p.first << ", " << p.second << "]"; return os; }; template <class S> auto &operator<<(ostream &os, vector<S> t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vvi ans(101, vi(101, INF)); vvi data; rep(i, n) { int x, y, h; cin >> x >> y >> h; data.push_back(vi{x, y, h}); } sort(all(data), [](vi a, vi b) { return a[2] > b[2]; }); for (auto &d : data) { rep(cx, 101) rep(cy, 101) { int H = abs(d[0] - cx) + abs(d[1] - cy) + d[2]; if (ans[cy][cx] == INF) ans[cy][cx] = H; if (d[2] == 0) { if (ans[cy][cx] > H) ans[cy][cx] = -1; } else { if (ans[cy][cx] != H) ans[cy][cx] = -1; } } } rep(cx, 101) rep(cy, 101) { if (ans[cy][cx] != -1) { cout << cx << " " << cy << " " << ans[cy][cx] << endl; return 0; } } cout << ans[1000000][1] << endl; return 0; }
replace
55
57
55
62
0
p03240
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x[111], y[111], h[111], z; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> h[i]; if (h[i]) z = i; } for (int i = 0; i < 101; i++) { for (int j = 0; j < 101; j++) { int a = 1, b = 2e9; while (a + 1 < b) { int c = (a + b) / 2; if (c - abs(x[z] - i) - abs(y[z] - j) > h[z]) b = c; else a = c; } for (int k = 0; k < n; k++) if (max(a - abs(x[k] - i) - abs(y[k] - j), 0) != h[k]) goto q; cout << i << ' ' << j << ' ' << a << endl; return 0; q:; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x[111], y[111], h[111], z; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> h[i]; if (h[i]) z = i; } for (int i = 0; i < 101; i++) { for (int j = 0; j < 101; j++) { int a = 1, b = 1e9 + 1000; while (a + 1 < b) { int c = (a + b) / 2; if (c - abs(x[z] - i) - abs(y[z] - j) > h[z]) b = c; else a = c; } for (int k = 0; k < n; k++) if (max(a - abs(x[k] - i) - abs(y[k] - j), 0) != h[k]) goto q; cout << i << ' ' << j << ' ' << a << endl; return 0; q:; } } return 0; }
replace
15
16
15
16
TLE
p03240
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int i, j, k; ll N, H, hight, count = 0; bool judge; cin >> N; vector<ll> x(N); vector<ll> y(N); vector<ll> h(N); rep(i, N) cin >> x[i] >> y[i] >> h[i]; rep(i, 101) { rep(j, 101) { judge = true; rep(k, N) { if (h[k] != 0) { H = llabs(x[k] - i) + llabs(y[k] - j) + h[k]; break; } cout << "something error" << endl; return -1; } rep(k, N) { hight = H - llabs(i - x[k]) - llabs(j - y[k]); if (h[k] != max((ll)0, hight)) { judge = false; break; } } if (judge == true) { cout << i << " " << j << " " << H; return 0; } } } }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int i, j, k; ll N, H, hight, count = 0; bool judge; cin >> N; vector<ll> x(N); vector<ll> y(N); vector<ll> h(N); rep(i, N) cin >> x[i] >> y[i] >> h[i]; rep(i, 101) { rep(j, 101) { judge = true; rep(k, N) { if (h[k] != 0) { H = llabs(x[k] - i) + llabs(y[k] - j) + h[k]; break; } } rep(k, N) { hight = H - llabs(i - x[k]) - llabs(j - y[k]); if (h[k] != max((ll)0, hight)) { judge = false; break; } } if (judge == true) { cout << i << " " << j << " " << H; return 0; } } } }
delete
27
29
27
27
0
p03240
C++
Runtime Error
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <functional> #include <iostream> #include <map> #include <numeric> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; template <typename T> inline T get() { T x; cin >> x; return x; } int main() { int n = get<int>(); vector<int> x(n), y(n), h(n); int k = -1; for (int i = 0; i < n; i++) { x[i] = get<int>(), y[i] = get<int>(), h[i] = get<int>(); if (h[i] > 0) k = i; } assert(k != -1); int xx, yy, hh; for (xx = 0; xx <= 100; xx++) { for (yy = 0; yy <= 100; yy++) { hh = h[k] + abs(xx - x[k]) + abs(yy - y[k]); for (int i = 0; i < n; i++) { if (hh != h[i] + abs(xx - x[i]) + abs(yy - y[i])) goto NextCandidate; } goto Found; NextCandidate:; } } cerr << "Error"; exit(1); Found:; cout << xx << " " << yy << " " << hh << endl; return 0; }
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <functional> #include <iostream> #include <map> #include <numeric> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; template <typename T> inline T get() { T x; cin >> x; return x; } int main() { int n = get<int>(); vector<int> x(n), y(n), h(n); int k = -1; for (int i = 0; i < n; i++) { x[i] = get<int>(), y[i] = get<int>(), h[i] = get<int>(); if (h[i] > 0) k = i; } assert(k != -1); int xx, yy, hh; for (xx = 0; xx <= 100; xx++) { for (yy = 0; yy <= 100; yy++) { hh = h[k] + abs(xx - x[k]) + abs(yy - y[k]); for (int i = 0; i < n; i++) { if (h[i] != max(0, hh - abs(xx - x[i]) - abs(yy - y[i]))) goto NextCandidate; } goto Found; NextCandidate:; } } cerr << "Error"; exit(1); Found:; cout << xx << " " << yy << " " << hh << endl; return 0; }
replace
37
38
37
38
0
p03240
C++
Time Limit Exceeded
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <cstdarg> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <sys/time.h> #include <vector> // #include "cout.h" using namespace std; #define SZ(x) ((int)x.size()) #define MSET(x, a) memset(x, a, (int)sizeof(x)) #define PB push_back #define VI vector<int> #define PII pair<int, int> #define LL long long #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(v) (v).begin(), (v).end() #define FIT(it, v) \ for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++) #define OUT(A) cout << #A << " = " << (A) << endl #define OUT2(A, B) \ cout << "(" << #A << ", " << #B << ") = (" << (A) << ", " << (B) << ")" \ << endl template <class T> void chmin(T &t, T f) { if (t > f) t = f; } template <class T> void chmax(T &t, T f) { if (t < f) t = f; } #define present(c, e) ((c).find((e)) != (c).end()) #define cpresent(c, e) (find(ALL(c), (e)) != (c).end()) void init() {} void input() {} void solve() { int n; int x[110], y[110], h[110]; cin >> n; REP(i, n) cin >> x[i] >> y[i] >> h[i]; while (1) { REP(X, 101) REP(Y, 101) { bool ok = true; LL H = -1; REP(i, n) { int tmph = h[i] + abs(X - x[i]) + abs(Y - y[i]); if (H == -1) { H = tmph; } else if (h[i] == 0) { if (H > tmph) ok = false; } else { if (H != tmph) ok = false; } } if (ok) { cout << X << " " << Y << " " << H << endl; return; } } } } int main() { init(); input(); solve(); return 0; }
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <cstdarg> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <sys/time.h> #include <vector> // #include "cout.h" using namespace std; #define SZ(x) ((int)x.size()) #define MSET(x, a) memset(x, a, (int)sizeof(x)) #define PB push_back #define VI vector<int> #define PII pair<int, int> #define LL long long #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(v) (v).begin(), (v).end() #define FIT(it, v) \ for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++) #define OUT(A) cout << #A << " = " << (A) << endl #define OUT2(A, B) \ cout << "(" << #A << ", " << #B << ") = (" << (A) << ", " << (B) << ")" \ << endl template <class T> void chmin(T &t, T f) { if (t > f) t = f; } template <class T> void chmax(T &t, T f) { if (t < f) t = f; } #define present(c, e) ((c).find((e)) != (c).end()) #define cpresent(c, e) (find(ALL(c), (e)) != (c).end()) void init() {} void input() {} void solve() { int n; int x[110], y[110], h[110]; cin >> n; REP(i, n) cin >> x[i] >> y[i] >> h[i]; while (1) { REP(X, 101) REP(Y, 101) { bool ok = true; LL H = -1; REP(i, n) { int tmph = h[i] + abs(X - x[i]) + abs(Y - y[i]); if (H == -1 && h[i] > 0) { H = tmph; } else if (h[i] == 0) { if (H > tmph) ok = false; } else { if (H != tmph) ok = false; } } for (int i = n - 1; i >= 0; i--) { int tmph = h[i] + abs(X - x[i]) + abs(Y - y[i]); if (H == -1 && h[i] > 0) { H = tmph; } else if (h[i] == 0) { if (H > tmph) ok = false; } else { if (H != tmph) ok = false; } } if (ok) { cout << X << " " << Y << " " << H << endl; return; } } } } int main() { init(); input(); solve(); return 0; }
replace
65
66
65
78
TLE
p03240
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; i++) #define all(c) (c).begin(), (c).end() #define pb push_back #define dbg(...) \ do { \ cerr << __LINE__ << ": "; \ dbgprint(#__VA_ARGS__, __VA_ARGS__); \ } while (0); using namespace std; namespace std { template <class S, class T> struct hash<pair<S, T>> { size_t operator()(const pair<S, T> &p) const { return ((size_t)1e9 + 7) * hash<S>()(p.first) + hash<T>()(p.second); } }; template <class T> struct hash<vector<T>> { size_t operator()(const vector<T> &v) const { size_t h = 0; for (auto i : v) h = h * ((size_t)1e9 + 7) + hash<T>()(i) + 1; return h; } }; } // namespace std template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "[ "; rep(i, v.size()) os << v[i] << (i == v.size() - 1 ? " ]" : ", "); return os; } template <class T> ostream &operator<<(ostream &os, const set<T> &v) { os << "{ "; for (const auto &i : v) os << i << ", "; return os << "}"; } template <class T, class U> ostream &operator<<(ostream &os, const map<T, U> &v) { os << "{"; for (const auto &i : v) os << " " << i.first << ": " << i.second << ","; return os << "}"; } template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << "(" << p.first << ", " << p.second << ")"; } void dbgprint(const string &fmt) { cerr << endl; } template <class H, class... T> void dbgprint(const string &fmt, const H &h, const T &...r) { cerr << fmt.substr(0, fmt.find(",")) << "= " << h << " "; dbgprint(fmt.substr(fmt.find(",") + 1), r...); } typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; const int inf = (int)1e9; const double INF = 1e12, EPS = 1e-9; int main() { cin.tie(0); cin.sync_with_stdio(0); int n, minH = inf; cin >> n; vector<vi> in(n); rep(i, n) { rep(j, 3) cin >> in[i][j]; minH = min(minH, in[i][2]); } for (int h = minH; h <= minH + 200; h++) { rep(x, 101) rep(y, 101) { bool ok = 1; rep(i, n) { int tmpH = h - abs(in[i][0] - x) - abs(in[i][1] - y); tmpH = max(tmpH, 0); if (tmpH != in[i][2]) { ok = 0; break; } } if (ok) { cout << x << " " << y << " " << h << endl; return 0; } } } assert(0); return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)n; i++) #define all(c) (c).begin(), (c).end() #define pb push_back #define dbg(...) \ do { \ cerr << __LINE__ << ": "; \ dbgprint(#__VA_ARGS__, __VA_ARGS__); \ } while (0); using namespace std; namespace std { template <class S, class T> struct hash<pair<S, T>> { size_t operator()(const pair<S, T> &p) const { return ((size_t)1e9 + 7) * hash<S>()(p.first) + hash<T>()(p.second); } }; template <class T> struct hash<vector<T>> { size_t operator()(const vector<T> &v) const { size_t h = 0; for (auto i : v) h = h * ((size_t)1e9 + 7) + hash<T>()(i) + 1; return h; } }; } // namespace std template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "[ "; rep(i, v.size()) os << v[i] << (i == v.size() - 1 ? " ]" : ", "); return os; } template <class T> ostream &operator<<(ostream &os, const set<T> &v) { os << "{ "; for (const auto &i : v) os << i << ", "; return os << "}"; } template <class T, class U> ostream &operator<<(ostream &os, const map<T, U> &v) { os << "{"; for (const auto &i : v) os << " " << i.first << ": " << i.second << ","; return os << "}"; } template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << "(" << p.first << ", " << p.second << ")"; } void dbgprint(const string &fmt) { cerr << endl; } template <class H, class... T> void dbgprint(const string &fmt, const H &h, const T &...r) { cerr << fmt.substr(0, fmt.find(",")) << "= " << h << " "; dbgprint(fmt.substr(fmt.find(",") + 1), r...); } typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; const int inf = (int)1e9; const double INF = 1e12, EPS = 1e-9; int main() { cin.tie(0); cin.sync_with_stdio(0); int n, minH = inf; cin >> n; vector<vi> in(n); rep(i, n) { in[i] = vi(3); rep(j, 3) cin >> in[i][j]; minH = min(minH, in[i][2]); } for (int h = minH; h <= minH + 200; h++) { rep(x, 101) rep(y, 101) { bool ok = 1; rep(i, n) { int tmpH = h - abs(in[i][0] - x) - abs(in[i][1] - y); tmpH = max(tmpH, 0); if (tmpH != in[i][2]) { ok = 0; break; } } if (ok) { cout << x << " " << y << " " << h << endl; return 0; } } } assert(0); return 0; }
insert
68
68
68
69
-11
p03240
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <stack> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) vector<int> x, y, h; int is_ok(int Cx, int Cy, int X_base, int Y_base, int h_base, int X, int Y, int h) { if (h > 0 && abs(X_base - Cx) + abs(Y_base - Cy) + h_base == abs(X - Cx) + abs(Y - Cy) + h) { return 1; } else if (h == 0 && abs(X_base - Cx) + abs(Y_base - Cy) + h_base <= abs(X - Cx) + abs(Y - Cy) + h) { return 1; } else { return 0; } } int main() { int N; int s, t, u; int X, Y; int H; int ansx = 0, ansy = 0, ansh = 0; cin >> N; rep(i, N) { cin >> s >> t >> u; x.push_back(s); y.push_back(t); h.push_back(u); } rep(i, N) { if (h[i] > 0) { X = x[i]; Y = y[i]; H = h[i]; break; } } bool ok = true; rep(i, 101) { rep(j, 101) { rep(k, N) { if (is_ok(i, j, X, Y, H, x[k], y[k], h[k]) != 1) { ok = false; break; } } if (ok == true) { ansx = i; ansy = j; ansh = abs(X - ansx) + abs(Y - ansy) + H; cout << ansx << " " << ansy << " " << ansh << endl; while (1) { } return 0; } ok = true; } } return 0; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <stack> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) vector<int> x, y, h; int is_ok(int Cx, int Cy, int X_base, int Y_base, int h_base, int X, int Y, int h) { if (h > 0 && abs(X_base - Cx) + abs(Y_base - Cy) + h_base == abs(X - Cx) + abs(Y - Cy) + h) { return 1; } else if (h == 0 && abs(X_base - Cx) + abs(Y_base - Cy) + h_base <= abs(X - Cx) + abs(Y - Cy) + h) { return 1; } else { return 0; } } int main() { int N; int s, t, u; int X, Y; int H; int ansx = 0, ansy = 0, ansh = 0; cin >> N; rep(i, N) { cin >> s >> t >> u; x.push_back(s); y.push_back(t); h.push_back(u); } rep(i, N) { if (h[i] > 0) { X = x[i]; Y = y[i]; H = h[i]; break; } } bool ok = true; rep(i, 101) { rep(j, 101) { rep(k, N) { if (is_ok(i, j, X, Y, H, x[k], y[k], h[k]) != 1) { ok = false; break; } } if (ok == true) { ansx = i; ansy = j; ansh = abs(X - ansx) + abs(Y - ansy) + H; cout << ansx << " " << ansy << " " << ansh << endl; return 0; } ok = true; } } return 0; }
delete
75
78
75
75
TLE
p03240
C++
Time Limit Exceeded
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <stdio.h> #include <string> #include <vector> using namespace std; int main(void) { int n; cin >> n; int cx, cy, ch; vector<int> x(n), y(n), h(n); for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> h[i]; } for (ch = 1; ch <= 100001000; ch++) { for (cx = 0; cx <= 100; cx++) { for (cy = 0; cy <= 100; cy++) { for (int i = 0; i < n; i++) { if (h[i] != max(ch - abs(x[i] - cx) - abs(y[i] - cy), 0)) break; if (i == n - 1) { cout << cx << " " << cy << " " << ch << endl; return 0; } } } } } return 0; }
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <stdio.h> #include <string> #include <vector> using namespace std; int main(void) { int n; cin >> n; int cx, cy, ch; vector<int> x(n), y(n), h(n); for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> h[i]; } for (cx = 0; cx <= 100; cx++) { for (cy = 0; cy <= 100; cy++) { ch = 0; for (int i = 0; i < n; i++) { if (h[i] > 0 && ch <= 0) ch = h[i] + abs(x[i] - cx) + abs(y[i] - cy); else continue; } for (int i = 0; i < n; i++) { if (h[i] != max(ch - abs(x[i] - cx) - abs(y[i] - cy), 0)) break; if (i == n - 1) { cout << cx << " " << cy << " " << ch << endl; return 0; } } } } return 0; }
replace
17
27
17
32
TLE
p03240
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using vs = vector<string>; using pll = pair<ll, ll>; using vp = vector<pll>; #define rep(i, n) for (ll i = 0; i < (n); i++) #define repr(i, a, b) for (ll i = (a); i < (b); i++) #define ALL(a) (a).begin(), (a).end() #define SZ(x) ((ll)(x).size()) const ll MOD = 1000000007; const ll INF = 100000000000000000LL; inline ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; } inline ll LCM(ll a, ll b) { return a / GCD(a, b) * b; } inline ll powint(unsigned long long x, ll y) { ll r = 1; while (y) { if (y & 1) r *= x; x *= x; y >>= 1; } return r; } inline ll powmod(ll x, ll y, ll m = MOD) { ll r = 1; while (y) { if (y & 1) r *= x; x *= x; r %= m; x %= m; y >>= 1; } return r; } 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; } #ifdef OJ_LOCAL #include "dump.hpp" #else #define dump(...) ((void)0) #endif int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); ll n; cin >> n; vll x(n), y(n), h(n); ll c = 0; rep(i, n) { cin >> x[i] >> y[i] >> h[i]; if (h[i]) c++; } vvvll ans(101, vvll(101, vll(c))); vvvll ans2(101, vvll(101, vll(n - c))); ll p = 0; ll p2 = 0; rep(i, n) { if (h[i]) { rep(j, 101) rep(k, 101) { ans[j][k][p] = abs(j - x[i]) + abs(k - y[i]) + h[i]; } p++; } else { rep(j, 101) rep(k, 101) { ans[j][k][p2] = abs(j - x[i]) + abs(k - y[i]); } p2++; } } if (n - c > 0) { rep(i, 101) rep(j, 101) { sort(ALL(ans[i][j])); sort(ALL(ans2[i][j])); if (ans[i][j][0] == ans[i][j][c - 1] && ans2[i][j][0] >= ans[i][j][0]) { cout << i << " " << j << " " << ans[i][j][0] << endl; return 0; } } } else { rep(i, 101) rep(j, 101) { sort(ALL(ans[i][j])); if (ans[i][j][0] == ans[i][j][c - 1]) { cout << i << " " << j << " " << ans[i][j][0] << endl; return 0; } } } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using vs = vector<string>; using pll = pair<ll, ll>; using vp = vector<pll>; #define rep(i, n) for (ll i = 0; i < (n); i++) #define repr(i, a, b) for (ll i = (a); i < (b); i++) #define ALL(a) (a).begin(), (a).end() #define SZ(x) ((ll)(x).size()) const ll MOD = 1000000007; const ll INF = 100000000000000000LL; inline ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; } inline ll LCM(ll a, ll b) { return a / GCD(a, b) * b; } inline ll powint(unsigned long long x, ll y) { ll r = 1; while (y) { if (y & 1) r *= x; x *= x; y >>= 1; } return r; } inline ll powmod(ll x, ll y, ll m = MOD) { ll r = 1; while (y) { if (y & 1) r *= x; x *= x; r %= m; x %= m; y >>= 1; } return r; } 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; } #ifdef OJ_LOCAL #include "dump.hpp" #else #define dump(...) ((void)0) #endif int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); ll n; cin >> n; vll x(n), y(n), h(n); ll c = 0; rep(i, n) { cin >> x[i] >> y[i] >> h[i]; if (h[i]) c++; } vvvll ans(101, vvll(101, vll(c))); vvvll ans2(101, vvll(101, vll(n - c))); ll p = 0; ll p2 = 0; rep(i, n) { if (h[i]) { rep(j, 101) rep(k, 101) { ans[j][k][p] = abs(j - x[i]) + abs(k - y[i]) + h[i]; } p++; } else { rep(j, 101) rep(k, 101) { ans2[j][k][p2] = abs(j - x[i]) + abs(k - y[i]); } p2++; } } if (n - c > 0) { rep(i, 101) rep(j, 101) { sort(ALL(ans[i][j])); sort(ALL(ans2[i][j])); if (ans[i][j][0] == ans[i][j][c - 1] && ans2[i][j][0] >= ans[i][j][0]) { cout << i << " " << j << " " << ans[i][j][0] << endl; return 0; } } } else { rep(i, 101) rep(j, 101) { sort(ALL(ans[i][j])); if (ans[i][j][0] == ans[i][j][c - 1]) { cout << i << " " << j << " " << ans[i][j][0] << endl; return 0; } } } return 0; }
replace
87
88
87
90
0
p03240
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int CalHeight(int Cx, int Cy, int H, int h, int x, int y) { if (h != 0) return abs(x - Cx) + abs(y - Cy) + h; else if (H <= abs(x - Cx) + abs(y - Cy)) return H; else return -1; } int main() { int N, cnt = 0, hs, xs, ys; cin >> N; int *x = new int[N]; int *y = new int[N]; int *h = new int[N]; for (int i = 0; i < N; i++) { cin >> x[i] >> y[i] >> h[i]; if (h[i] != 0) { hs = h[i]; xs = x[i]; ys = y[i]; } } for (int Cx = 0; Cx <= 100; Cx++) { for (int Cy = 0; Cy <= 100; Cy++) { int H = abs(xs - Cx) + abs(ys - Cy) + hs; for (int i = 0; i < N; i++) { if (H != CalHeight(Cx, Cy, H, h[i], x[i], y[i])) break; if (i == N - 1) { cout << Cx << " " << Cy << " " << H << " " << endl; return 1; } } } } }
#include <bits/stdc++.h> using namespace std; int CalHeight(int Cx, int Cy, int H, int h, int x, int y) { if (h != 0) return abs(x - Cx) + abs(y - Cy) + h; else if (H <= abs(x - Cx) + abs(y - Cy)) return H; else return -1; } int main() { int N, cnt = 0, hs, xs, ys; cin >> N; int *x = new int[N]; int *y = new int[N]; int *h = new int[N]; for (int i = 0; i < N; i++) { cin >> x[i] >> y[i] >> h[i]; if (h[i] != 0) { hs = h[i]; xs = x[i]; ys = y[i]; } } for (int Cx = 0; Cx <= 100; Cx++) { for (int Cy = 0; Cy <= 100; Cy++) { int H = abs(xs - Cx) + abs(ys - Cy) + hs; for (int i = 0; i < N; i++) { if (H != CalHeight(Cx, Cy, H, h[i], x[i], y[i])) break; if (i == N - 1) { cout << Cx << " " << Cy << " " << H << " " << endl; } } } } }
delete
34
35
34
34
1
p03240
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define GET_REP(_1, _2, _3, NAME, ...) NAME #define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__) #define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__) #define _rep(i, n) irep(i, 0, n) #define _rep1(i, n) irep1(i, 1, n) #define irep(i, a, n) for (int i = a; i < (int)(n); ++i) #define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i) #define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define rrep1(i, n) for (int i = (int)(n); i >= 1; --i) #define allrep(X, x) for (auto &&X : x) #define all(x) begin(x), end(x) #define debug(x) cout << #x " => " << (x) << endl #ifdef LOCAL #include "../../Lib/cout_container.hpp" #endif using lint = long long; constexpr int MOD = (int)1e9 + 7; constexpr double EPS = 1e-9; using namespace std; namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; } // namespace int main(void) { int n; cin >> n; struct XYH { lint x, y, h; }; vector<XYH> xyh(n); rep(i, n) cin >> xyh[i].x >> xyh[i].y >> xyh[i].h; auto comp = [](XYH &a, XYH &b) { return a.h != 0; }; sort(all(xyh), comp); rep(CX, 101) { rep(CY, 101) { lint H = xyh[0].h != 0 ? xyh[0].h + abs(xyh[0].x - CX) + abs(xyh[0].y - CY) : 1; bool ok = true; rep(i, 1, n) { lint Htmp = xyh[i].h + abs(xyh[i].x - CX) + abs(xyh[i].y - CY); if (xyh[i].h != 0) { if (H != Htmp) { ok = false; break; } } else { if (H > Htmp) { ok = false; break; } } } if (ok) { cout << CX << " " << CY << " " << H << endl; return 0; } } } return 0; }
#include <bits/stdc++.h> #define GET_REP(_1, _2, _3, NAME, ...) NAME #define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__) #define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__) #define _rep(i, n) irep(i, 0, n) #define _rep1(i, n) irep1(i, 1, n) #define irep(i, a, n) for (int i = a; i < (int)(n); ++i) #define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i) #define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define rrep1(i, n) for (int i = (int)(n); i >= 1; --i) #define allrep(X, x) for (auto &&X : x) #define all(x) begin(x), end(x) #define debug(x) cout << #x " => " << (x) << endl #ifdef LOCAL #include "../../Lib/cout_container.hpp" #endif using lint = long long; constexpr int MOD = (int)1e9 + 7; constexpr double EPS = 1e-9; using namespace std; namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; } // namespace int main(void) { int n; cin >> n; struct XYH { lint x, y, h; }; vector<XYH> xyh(n); rep(i, n) cin >> xyh[i].x >> xyh[i].y >> xyh[i].h; sort(all(xyh), [](XYH &a, XYH &b) { return a.h > b.h; }); rep(CX, 101) { rep(CY, 101) { lint H = xyh[0].h != 0 ? xyh[0].h + abs(xyh[0].x - CX) + abs(xyh[0].y - CY) : 1; bool ok = true; rep(i, 1, n) { lint Htmp = xyh[i].h + abs(xyh[i].x - CX) + abs(xyh[i].y - CY); if (xyh[i].h != 0) { if (H != Htmp) { ok = false; break; } } else { if (H > Htmp) { ok = false; break; } } } if (ok) { cout << CX << " " << CY << " " << H << endl; return 0; } } } return 0; }
replace
38
40
38
39
TLE
p03240
Python
Time Limit Exceeded
N = int(input()) P = [list(map(int, input().split())) for i in range(N)] i = 0 while 1: if P[0][2] > 0: break i += 1 x0, y0, h0 = P[i] for cy in range(101): for cx in range(101): h = h0 + abs(cx - x0) + abs(cy - y0) for x, y, h1 in P: if h1 != max(h - abs(cx - x) - abs(cy - y), 0): break else: print(cx, cy, h) exit(0) exit(1)
N = int(input()) P = [list(map(int, input().split())) for i in range(N)] i = 0 while 1: if P[i][2] > 0: break i += 1 x0, y0, h0 = P[i] for cy in range(101): for cx in range(101): h = h0 + abs(cx - x0) + abs(cy - y0) for x, y, h1 in P: if h1 != max(h - abs(cx - x) - abs(cy - y), 0): break else: print(cx, cy, h) exit(0) exit(1)
replace
5
6
5
6
TLE
p03240
Python
Runtime Error
# -*- coding: utf-8 -*- N = int(input()) X, Y, H = [], [], [] for _ in range(N): x, y, h = map(int, input().split()) X.append(x) Y.append(y) H.append(h) for x in range(101): for y in range(101): hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0} h0 = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] == 0} if len(hc) == 1 and max(h0) <= max(hc): print(x, y, list(hc)[0]) break
# -*- coding: utf-8 -*- N = int(input()) X, Y, H = [], [], [] for _ in range(N): x, y, h = map(int, input().split()) X.append(x) Y.append(y) H.append(h) for x in range(101): for y in range(101): hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0} h0 = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] == 0} if len(hc) == 1: if (len(h0) > 0 and min(h0) >= list(hc)[0]) or len(h0) == 0: print(x, y, list(hc)[0]) break
replace
14
17
14
18
ValueError: max() arg is an empty sequence
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03240/Python/s122970234.py", line 15, in <module> if len(hc) == 1 and max(h0) <= max(hc): ValueError: max() arg is an empty sequence
p03240
Python
Runtime Error
N = int(input()) data = [tuple(map(int, input().split())) for _ in range(N)] data.sort(key=lambda x: x[2]) for cx in range(101): for cy in range(101): h0 = None for x, y, h in data: if h: h_tmp = h + abs(cx - x) + abs(cy - y) if h_tmp != h0 and h0 is not None: break h0 = h_tmp else: if abs(cx - x) + abs(cy - y) < h0: break else: print(cx, cy, h0) exit()
N = int(input()) data = [tuple(map(int, input().split())) for _ in range(N)] data.sort(key=lambda x: -x[2]) for cx in range(101): for cy in range(101): h0 = None for x, y, h in data: if h: h_tmp = h + abs(cx - x) + abs(cy - y) if h_tmp != h0 and h0 is not None: break h0 = h_tmp else: if abs(cx - x) + abs(cy - y) < h0: break else: print(cx, cy, h0) exit()
replace
2
3
2
3
0
p03240
C++
Time Limit Exceeded
#include <cmath> #include <iostream> using namespace std; int x[102], y[102], h[102]; int c_x, c_y, c_h; int max_h; int main() { int n; scanf("%d", &n); max_h = -1; for (int i = 1; i <= n; i++) { scanf("%d%d%d", x + i, y + i, h + i); max_h = max(max_h, h[i]); } int sign = 1; for (c_h = max_h; sign; c_h++) for (c_x = 0; sign && c_x <= 100; c_x++) for (c_y = 0; sign && c_y <= 100; c_y++) { int i = 1; for (; i <= n; i++) if (h[i] != (c_h - abs(c_x - x[i]) - abs(c_y - y[i]))) break; if (i > n) sign = 0; } printf("%d %d %d\n", c_x - 1, c_y - 1, c_h - 1); return 0; }
#include <cmath> #include <iostream> using namespace std; int x[102], y[102], h[102]; int c_x, c_y, c_h; int max_h; int main() { int n; scanf("%d", &n); max_h = -1; for (int i = 1; i <= n; i++) { scanf("%d%d%d", x + i, y + i, h + i); max_h = max(max_h, h[i]); } int sign = 1; for (c_h = max_h; sign; c_h++) for (c_x = 0; sign && c_x <= 100; c_x++) for (c_y = 0; sign && c_y <= 100; c_y++) { int i = 1; for (; i <= n; i++) if (h[i] != max(0, (c_h - abs(c_x - x[i]) - abs(c_y - y[i])))) break; if (i > n) sign = 0; } printf("%d %d %d\n", c_x - 1, c_y - 1, c_h - 1); return 0; }
replace
20
21
20
21
TLE
p03240
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; using ll = long long; using P = pair<ll, ll>; const int INF = 1001001001; const int MOD = 1000000007; template <typename T> void print(const T &v); int main() { int n; cin >> n; vector<int> xs(n), ys(n), hs(n); for (int i = 0; i < n; i++) { cin >> xs[i] >> ys[i] >> hs[i]; } if (n == 5) { map<int, int> mp; for (int i = 0; i < 5; i) { mp[hs[i]]++; } if (mp[0] == 4 && mp[1] == 1) { int xabs = 0, yabs = 0; for (int i = 0; i < 5; i++) { xabs += xs[i]; yabs += ys[i]; } cout << xabs / 5 << ' ' << yabs / 5 << ' ' << 1 << endl; return 0; } } for (int x = 0; x <= 100; x++) { for (int y = 0; y <= 100; y++) { bool flag = true; int before = -1; for (int i = 0; i < n; i++) { if (hs[i] == 0) { continue; } int h = abs(x - xs[i]) + abs(y - ys[i]) + hs[i]; if (before != -1 && before != h) { flag = false; break; } before = h; } if (flag) { cout << x << ' ' << y << ' ' << before << endl; return 0; } } } } // Use For Debug template <typename T> void print(T const &v) { for (int i = 0; i < v.size(); i++) { if (i) cout << " "; cout << v[i]; } cout << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; using ll = long long; using P = pair<ll, ll>; const int INF = 1001001001; const int MOD = 1000000007; template <typename T> void print(const T &v); int main() { int n; cin >> n; vector<int> xs(n), ys(n), hs(n); for (int i = 0; i < n; i++) { cin >> xs[i] >> ys[i] >> hs[i]; } if (n == 5) { map<int, int> mp; for (int i = 0; i < 5; i++) { mp[hs[i]]++; } if (mp[0] == 4 && mp[1] == 1) { int xabs = 0, yabs = 0; for (int i = 0; i < 5; i++) { xabs += xs[i]; yabs += ys[i]; } cout << xabs / 5 << ' ' << yabs / 5 << ' ' << 1 << endl; return 0; } } for (int x = 0; x <= 100; x++) { for (int y = 0; y <= 100; y++) { bool flag = true; int before = -1; for (int i = 0; i < n; i++) { if (hs[i] == 0) { continue; } int h = abs(x - xs[i]) + abs(y - ys[i]) + hs[i]; if (before != -1 && before != h) { flag = false; break; } before = h; } if (flag) { cout << x << ' ' << y << ' ' << before << endl; return 0; } } } } // Use For Debug template <typename T> void print(T const &v) { for (int i = 0; i < v.size(); i++) { if (i) cout << " "; cout << v[i]; } cout << endl; }
replace
19
20
19
20
TLE
p03240
C++
Time Limit Exceeded
#include <algorithm> #include <bits/stdc++.h> #include <iostream> using namespace std; int main() { int a; cin >> a; long long int x[110], y[110], h[110]; for (int i = 0; i < a; i++) { cin >> x[i] >> y[i] >> h[i]; } for (int posx = 0; posx <= 100; posx++) { for (int posy = 0; posy <= 100; posy++) { for (int nh = (h[0] - 1000); nh <= h[0] + 1000; nh++) { bool abcd = true; for (int i = 0; i < a; i++) { long long int k = 0; if (h[i] != max(nh - abs(posx - x[i]) - abs(posy - y[i]), k)) abcd = false; } if (abcd == true) cout << posx << " " << posy << " " << nh << endl; } } } }
#include <algorithm> #include <bits/stdc++.h> #include <iostream> using namespace std; int main() { int a; cin >> a; long long int x[110], y[110], h[110]; for (int i = 0; i < a; i++) { cin >> x[i] >> y[i] >> h[i]; } for (int posx = 0; posx <= 100; posx++) { for (int posy = 0; posy <= 100; posy++) { for (int nh = (h[0] - 250); nh <= h[0] + 250; nh++) { bool abcd = true; for (int i = 0; i < a; i++) { long long int k = 0; if (h[i] != max(nh - abs(posx - x[i]) - abs(posy - y[i]), k)) abcd = false; } if (abcd == true) cout << posx << " " << posy << " " << nh << endl; } } } }
replace
19
20
19
20
TLE
p03240
C++
Runtime Error
// 06, 10, 2018, 09:13:45 Rafaelcs cpp #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long double ld; typedef long long ll; typedef unsigned long long ull; const int N = 100; pii p[N + 10]; int h[N + 10]; int n; int can(int i, int j) { int h0 = 1; for (int k = 0; k < n; k++) { if (h[k] != 0) { h0 = abs(p[0].first - i) + abs(p[0].second - j) + h[0]; break; } } for (int k = 0; k < n; k++) { if (h[k] == 0) continue; int hi = abs(p[k].first - i) + abs(p[k].second - j) + h[k]; if (hi != h0) { return -1; } } return h0; } bool ver(int H, int cx, int cy) { for (int i = 0; i < n; i++) { if (max(H - (abs(cx - p[i].first) + abs(cy - p[i].second)), 0) != h[i]) { return false; } } return true; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d %d %d", &p[i].first, &p[i].second, &h[i]); } for (int i = 0; i <= N; i++) { for (int j = 0; j <= N; j++) { int d = can(i, j); if (d != -1 && d > 0 && ver(d, i, j)) { printf("%d %d %d\n", i, j, d); return 0; } } } assert(false); return 0; }
// 06, 10, 2018, 09:13:45 Rafaelcs cpp #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long double ld; typedef long long ll; typedef unsigned long long ull; const int N = 100; pii p[N + 10]; int h[N + 10]; int n; int can(int i, int j) { int h0 = 1; for (int k = 0; k < n; k++) { if (h[k] != 0) { h0 = abs(p[k].first - i) + abs(p[k].second - j) + h[k]; break; } } for (int k = 0; k < n; k++) { if (h[k] == 0) continue; int hi = abs(p[k].first - i) + abs(p[k].second - j) + h[k]; if (hi != h0) { return -1; } } return h0; } bool ver(int H, int cx, int cy) { for (int i = 0; i < n; i++) { if (max(H - (abs(cx - p[i].first) + abs(cy - p[i].second)), 0) != h[i]) { return false; } } return true; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d %d %d", &p[i].first, &p[i].second, &h[i]); } for (int i = 0; i <= N; i++) { for (int j = 0; j <= N; j++) { int d = can(i, j); if (d != -1 && d > 0 && ver(d, i, j)) { printf("%d %d %d\n", i, j, d); return 0; } } } assert(false); return 0; }
replace
19
20
19
20
0
p03240
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> typedef long long ll; #define PI 3.14159265359 #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define mp make_pair #define all(v) v.begin(), v.end() #define decp(n) cout << fixed << setprecision((int)n) #define _GLIBCXX_DEBAC #include <functional> /*map<Keyの型, Valueの型> 変数名; queue<型> 変数名; priority_queue<型> 変数名; priority_queue<型, vector<型>, greater<型>> 変数名;*/ // copy(v1.begin(), v1.end(), back_inserter(v2)); using namespace std; ll gcd(ll a, ll b) { ll c; if (a < b) { c = a; a = b; b = c; } while (b != 0) { c = a % b; a = b; b = c; } return a; } ll lcm(ll a, ll b) { ll c; c = a * b / gcd(a, b); return c; } int sort_greater(int m, int n) { vector<int> a(m); for (int i = 0; i < m; i++) { cin >> a[i]; } sort(a.begin(), a.end(), greater<int>()); for (int i = 0; i < n; i++) { cout << a[i]; } return 0; } int bubblesort(int a[], int n) { int sw = 0; bool flag = 1; for (int i = 0; flag; i++) { flag = 0; for (int j = n - 1; j >= i + 1; j--) { if (a[j] < a[j - 1]) { swap(a[j], a[j - 1]); flag = 1; sw += 1; } } } return sw; } int a_z() { for (int i = 0; i <= ('Z' - 'A'); i++) { cout << (char)('A' + i); } return 0; } int selecttionsort(int a[], int n) { int t, sw = 0, minj; for (int i = 0; i < n - 1; i++) { minj = i; for (int j = 0; j < n - 1; j++) { if (a[j] < a[minj]) { minj = j; } } t = a[i]; a[i] = a[minj]; a[minj] = t; if (i != minj) sw += 1; } return sw; } bool is_prime(int x) { if (x <= 1) return false; for (int i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return true; } const ll mod = 1000000007; map<string, int> memo; using P = pair<int, int>; /*void dfs(int v, int p = -1) { for (int u : to[v]) { if (u == p) continue; ans[u] += ans[v]; dfs(u, v); } }*/ ll findIndex(int value, vector<ll> a) { for (ll i = 0; i < a.size(); i++) { if (a[i] == value) { return i; } } return -1; } ll nCr(ll n, ll r) { ll a = 1; for (ll i = n; i > n - r; --i) { a = a * i; } for (ll i = 1; i < r + 1; ++i) { a = a / i; } return a; } // E869120 void comb(vector<vector<long long int>> &v) { for (int i = 0; i < v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (int k = 1; k < v.size(); k++) { for (int j = 1; j < k; j++) { v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]); } } } int main() { int n; cin >> n; vector<ll> x(n), y(n), h(n); vector<tuple<ll, ll, ll>> a; tuple<ll, ll, ll> b = make_tuple(-1, -1, -1); for (int i = 1; i <= n; i++) { cin >> x[i] >> y[i] >> h[i]; if (h[i] > 0) b = make_tuple(x[i], y[i], h[i]); } rep(i, 101) { rep(j, 101) { ll z = get<2>(b) + abs(get<0>(b) - i) + abs(get<1>(b) - j); z = max(z, 0ll); bool f = true; for (ll k = 1; k <= n; k++) { ll zz = z - abs(x[k] - i) - abs(y[k] - j); zz = max(zz, 0ll); if (zz != h[k]) f = false; } if (f == true) a.push_back(make_tuple(i, j, z)); } } if (a.size() == 1) cout << get<0>(a[0]) << " " << get<1>(a[0]) << " " << get<2>(a[0]) << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> typedef long long ll; #define PI 3.14159265359 #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define mp make_pair #define all(v) v.begin(), v.end() #define decp(n) cout << fixed << setprecision((int)n) #define _GLIBCXX_DEBAC #include <functional> /*map<Keyの型, Valueの型> 変数名; queue<型> 変数名; priority_queue<型> 変数名; priority_queue<型, vector<型>, greater<型>> 変数名;*/ // copy(v1.begin(), v1.end(), back_inserter(v2)); using namespace std; ll gcd(ll a, ll b) { ll c; if (a < b) { c = a; a = b; b = c; } while (b != 0) { c = a % b; a = b; b = c; } return a; } ll lcm(ll a, ll b) { ll c; c = a * b / gcd(a, b); return c; } int sort_greater(int m, int n) { vector<int> a(m); for (int i = 0; i < m; i++) { cin >> a[i]; } sort(a.begin(), a.end(), greater<int>()); for (int i = 0; i < n; i++) { cout << a[i]; } return 0; } int bubblesort(int a[], int n) { int sw = 0; bool flag = 1; for (int i = 0; flag; i++) { flag = 0; for (int j = n - 1; j >= i + 1; j--) { if (a[j] < a[j - 1]) { swap(a[j], a[j - 1]); flag = 1; sw += 1; } } } return sw; } int a_z() { for (int i = 0; i <= ('Z' - 'A'); i++) { cout << (char)('A' + i); } return 0; } int selecttionsort(int a[], int n) { int t, sw = 0, minj; for (int i = 0; i < n - 1; i++) { minj = i; for (int j = 0; j < n - 1; j++) { if (a[j] < a[minj]) { minj = j; } } t = a[i]; a[i] = a[minj]; a[minj] = t; if (i != minj) sw += 1; } return sw; } bool is_prime(int x) { if (x <= 1) return false; for (int i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return true; } const ll mod = 1000000007; map<string, int> memo; using P = pair<int, int>; /*void dfs(int v, int p = -1) { for (int u : to[v]) { if (u == p) continue; ans[u] += ans[v]; dfs(u, v); } }*/ ll findIndex(int value, vector<ll> a) { for (ll i = 0; i < a.size(); i++) { if (a[i] == value) { return i; } } return -1; } ll nCr(ll n, ll r) { ll a = 1; for (ll i = n; i > n - r; --i) { a = a * i; } for (ll i = 1; i < r + 1; ++i) { a = a / i; } return a; } // E869120 void comb(vector<vector<long long int>> &v) { for (int i = 0; i < v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (int k = 1; k < v.size(); k++) { for (int j = 1; j < k; j++) { v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]); } } } int main() { int n; cin >> n; vector<ll> x(n + 1), y(n + 1), h(n + 1); vector<tuple<ll, ll, ll>> a; tuple<ll, ll, ll> b = make_tuple(-1, -1, -1); for (int i = 1; i <= n; i++) { cin >> x[i] >> y[i] >> h[i]; if (h[i] > 0) b = make_tuple(x[i], y[i], h[i]); } rep(i, 101) { rep(j, 101) { ll z = get<2>(b) + abs(get<0>(b) - i) + abs(get<1>(b) - j); z = max(z, 0ll); bool f = true; for (ll k = 1; k <= n; k++) { ll zz = z - abs(x[k] - i) - abs(y[k] - j); zz = max(zz, 0ll); if (zz != h[k]) f = false; } if (f == true) a.push_back(make_tuple(i, j, z)); } } if (a.size() == 1) cout << get<0>(a[0]) << " " << get<1>(a[0]) << " " << get<2>(a[0]) << endl; return 0; }
replace
159
160
159
160
0
p03240
C++
Runtime Error
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <sstream> #include <vector> using namespace std; using lint = long long; constexpr int MOD = 1000000007, INF = 1111111111; constexpr lint LINF = 1LL << 60; template <class T> ostream &operator<<(ostream &os, const vector<T> &vec) { for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " "); return os; } #ifdef _DEBUG template <class T> void dump(const char *str, T &&h) { cerr << str << " = " << h << "\n"; }; template <class Head, class... Tail> void dump(const char *str, Head &&h, Tail &&...t) { while (*str != ',') cerr << *str++; cerr << " = " << h << "\n"; dump(str + (*(str + 1) == ' ' ? 2 : 1), t...); } #define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__) #else #define DMP(...) ((void)0) #endif template <class T> inline bool chmin(T &a, T b) { return a > b && (a = b, true); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N; cin >> N; struct data { lint x, y, h; }; vector<data> d(N); for (int i = 0; i < N; i++) cin >> d[i].x >> d[i].y >> d[i].h; for (int x = 0; x <= 100; x++) { for (int y = 0; y <= 100; y++) { lint ref = LINF; for (const auto &e : d) chmin(ref, e.h + abs(e.x - x) + abs(e.y - y)); if (all_of(d.begin(), d.end(), [&](data d) { return ref == d.h + abs(d.x - x) + abs(d.y - y); })) { cout << x << " " << y << " " << ref << "\n"; return 0; } } } return -1; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <sstream> #include <vector> using namespace std; using lint = long long; constexpr int MOD = 1000000007, INF = 1111111111; constexpr lint LINF = 1LL << 60; template <class T> ostream &operator<<(ostream &os, const vector<T> &vec) { for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " "); return os; } #ifdef _DEBUG template <class T> void dump(const char *str, T &&h) { cerr << str << " = " << h << "\n"; }; template <class Head, class... Tail> void dump(const char *str, Head &&h, Tail &&...t) { while (*str != ',') cerr << *str++; cerr << " = " << h << "\n"; dump(str + (*(str + 1) == ' ' ? 2 : 1), t...); } #define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__) #else #define DMP(...) ((void)0) #endif template <class T> inline bool chmin(T &a, T b) { return a > b && (a = b, true); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N; cin >> N; struct data { lint x, y, h; }; vector<data> d(N); for (int i = 0; i < N; i++) cin >> d[i].x >> d[i].y >> d[i].h; for (int x = 0; x <= 100; x++) { for (int y = 0; y <= 100; y++) { lint ref = LINF; for (const auto &e : d) chmin(ref, e.h + abs(e.x - x) + abs(e.y - y)); if (all_of(d.begin(), d.end(), [&](data d) { return max(ref - abs(d.x - x) - abs(d.y - y), 0LL) == d.h; })) { cout << x << " " << y << " " << ref << "\n"; return 0; } } } return -1; }
replace
66
67
66
67
0
p03240
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vll = vector<ll>; using P = pair<int, int>; const int INF = 1e9; const ll INFLL = 1e18; const int MOD = 1e9 + 7; const int NIL = -1; const ld PI = acosl(-1); #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(n) n.begin(), n.end() 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; } struct Pos { ll x = -1; ll y = -1; ll h = -1; }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); // cout << fixed << setprecision(6); ll n; cin >> n; vector<Pos> p(n); for (int i = 1; i <= n; i++) cin >> p[i].x >> p[i].y >> p[i].h; Pos G; rep(i, n) if (p[i].h >= 1) G = p[i]; Pos ans; for (int cx = 0; cx <= 100; cx++) { for (int cy = 0; cy <= 100; cy++) { ll v1 = G.h + abs(cx - G.x) + abs(cy - G.y); v1 = max(v1, 0LL); bool flg = true; for (int i = 1; i <= n; i++) { ll v2 = v1 - abs(cx - p[i].x) - abs(cy - p[i].y); v2 = max(v2, 0LL); if (p[i].h != v2) flg = false; } if (flg) { ans.x = cx; ans.y = cy; ans.h = v1; } } } printf("%lld %lld %lld\n", ans.x, ans.y, ans.h); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vll = vector<ll>; using P = pair<int, int>; const int INF = 1e9; const ll INFLL = 1e18; const int MOD = 1e9 + 7; const int NIL = -1; const ld PI = acosl(-1); #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(n) n.begin(), n.end() 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; } struct Pos { ll x = -1; ll y = -1; ll h = -1; }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); // cout << fixed << setprecision(6); ll n; cin >> n; vector<Pos> p(n + 1); for (int i = 1; i <= n; i++) cin >> p[i].x >> p[i].y >> p[i].h; Pos G; rep(i, n) if (p[i].h >= 1) G = p[i]; Pos ans; for (int cx = 0; cx <= 100; cx++) { for (int cy = 0; cy <= 100; cy++) { ll v1 = G.h + abs(cx - G.x) + abs(cy - G.y); v1 = max(v1, 0LL); bool flg = true; for (int i = 1; i <= n; i++) { ll v2 = v1 - abs(cx - p[i].x) - abs(cy - p[i].y); v2 = max(v2, 0LL); if (p[i].h != v2) flg = false; } if (flg) { ans.x = cx; ans.y = cy; ans.h = v1; } } } printf("%lld %lld %lld\n", ans.x, ans.y, ans.h); return 0; }
replace
45
46
45
46
-6
Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)
p03240
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define rng(a) a.begin(), a.end() #define maxs(x, y) (x = max(x, y)) #define mins(x, y) (x = min(x, y)) #define limit(x, l, r) max(l, min(x, r)) #define lims(x, l, r) (x = max(l, min(x, r))) #define isin(x, l, r) ((l) <= (x) && (x) < (r)) #define pb push_back #define sz(x) (int)(x).size() #define uni(x) x.erase(unique(rng(x)), x.end()) #define snuke srand((unsigned)clock() + (unsigned)time(NULL)); #define show(x) cout << #x << " = " << x << endl; #define PQ(T) priority_queue<T, v(T), greater<T>> #define dup(x, y) (((x) + (y)-1) / (y)) #define v(T) vector<T> #define vv(T) v(v(T)) typedef long long int ll; typedef unsigned uint; typedef unsigned long long ull; typedef pair<int, int> P; typedef tuple<int, int, int> T; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; typedef vector<T> vt; inline int getInt() { int x; scanf("%d", &x); return x; } template <typename T> inline istream &operator>>(istream &i, v(T) & v) { rep(j, sz(v)) i >> v[j]; return i; } template <typename T> string join(const v(T) & v) { stringstream s; rep(i, sz(v)) s << ' ' << v[i]; return s.str().substr(1); } template <typename T> inline ostream &operator<<(ostream &o, const v(T) & v) { if (sz(v)) o << join(v); return o; } template <typename T1, typename T2> inline istream &operator>>(istream &i, pair<T1, T2> &v) { return i >> v.fi >> v.se; } template <typename T1, typename T2> inline ostream &operator<<(ostream &o, const pair<T1, T2> &v) { return o << v.fi << "," << v.se; } const double eps = 1e-10; const ll LINF = 1001002003004005006ll; const int INF = 1001001001; const int MX = 200005; #define dame \ { \ puts("-1"); \ return 0; \ } #define yn \ { puts("Yes"); } \ else { \ puts("No"); \ } //--------------------------------------------------------------- #define fastio std::ios::sync_with_stdio(false); #define myio \ ifstream iofi; \ if (argc > 1) { \ iofi.open(argv[1]); \ std::cin.rdbuf(iofi.rdbuf()); \ } //-------------------------------------------------------------- void Main() { int n; cin >> n; vi x(n, 0), y(n, 0); vl h(n, 0ll); int cx, cy, sx, sy; ll ch, sh; rep(i, n) { cin >> x[i] >> y[i] >> h[i]; if (h[i] != 0) { sx = x[i]; sy = y[i]; sh = h[i]; } } rep(i, 101) { cx = i; rep(j, 101) { cy = j; ch = sh + (ll)(abs(cx - sx) + abs(cy - sy)); bool f = true; rep(k, n) { ll up = h[k] + (ll)(abs(cx - x[k]) + abs(cy - y[k])); if (h[k] != 0 and ch != up) { f = false; break; } if (h[k] == 0 and ch >= up) { f = false; break; } } if (f) { cout << cx << " " << cy << " " << ch; return; } } } exit(1); } int main(int argc, char **argv) { fastio; myio; Main(); }
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define rng(a) a.begin(), a.end() #define maxs(x, y) (x = max(x, y)) #define mins(x, y) (x = min(x, y)) #define limit(x, l, r) max(l, min(x, r)) #define lims(x, l, r) (x = max(l, min(x, r))) #define isin(x, l, r) ((l) <= (x) && (x) < (r)) #define pb push_back #define sz(x) (int)(x).size() #define uni(x) x.erase(unique(rng(x)), x.end()) #define snuke srand((unsigned)clock() + (unsigned)time(NULL)); #define show(x) cout << #x << " = " << x << endl; #define PQ(T) priority_queue<T, v(T), greater<T>> #define dup(x, y) (((x) + (y)-1) / (y)) #define v(T) vector<T> #define vv(T) v(v(T)) typedef long long int ll; typedef unsigned uint; typedef unsigned long long ull; typedef pair<int, int> P; typedef tuple<int, int, int> T; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; typedef vector<T> vt; inline int getInt() { int x; scanf("%d", &x); return x; } template <typename T> inline istream &operator>>(istream &i, v(T) & v) { rep(j, sz(v)) i >> v[j]; return i; } template <typename T> string join(const v(T) & v) { stringstream s; rep(i, sz(v)) s << ' ' << v[i]; return s.str().substr(1); } template <typename T> inline ostream &operator<<(ostream &o, const v(T) & v) { if (sz(v)) o << join(v); return o; } template <typename T1, typename T2> inline istream &operator>>(istream &i, pair<T1, T2> &v) { return i >> v.fi >> v.se; } template <typename T1, typename T2> inline ostream &operator<<(ostream &o, const pair<T1, T2> &v) { return o << v.fi << "," << v.se; } const double eps = 1e-10; const ll LINF = 1001002003004005006ll; const int INF = 1001001001; const int MX = 200005; #define dame \ { \ puts("-1"); \ return 0; \ } #define yn \ { puts("Yes"); } \ else { \ puts("No"); \ } //--------------------------------------------------------------- #define fastio std::ios::sync_with_stdio(false); #define myio \ ifstream iofi; \ if (argc > 1) { \ iofi.open(argv[1]); \ std::cin.rdbuf(iofi.rdbuf()); \ } //-------------------------------------------------------------- void Main() { int n; cin >> n; vi x(n, 0), y(n, 0); vl h(n, 0ll); int cx, cy, sx, sy; ll ch, sh; rep(i, n) { cin >> x[i] >> y[i] >> h[i]; if (h[i] != 0) { sx = x[i]; sy = y[i]; sh = h[i]; } } rep(i, 101) { cx = i; rep(j, 101) { cy = j; ch = sh + (ll)(abs(cx - sx) + abs(cy - sy)); bool f = true; rep(k, n) { ll up = h[k] + (ll)(abs(cx - x[k]) + abs(cy - y[k])); if (h[k] != 0 and ch != up) { f = false; break; } if (h[k] == 0 and ch > up) { f = false; break; } } if (f) { cout << cx << " " << cy << " " << ch; return; } } } exit(1); } int main(int argc, char **argv) { fastio; myio; Main(); }
replace
111
112
111
112
0
p03240
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <tuple> #include <vector> //  ceil(a/b) (a + (b - 1))/ b using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef pair<int, int> P; const int inf = 1012345678; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; // int gcd(int a, int b){ // if (a%b==0){ // return(b); // } // else{ // return(gcd(b,a%b)); // } // } int x[110]; int y[110]; int h[110]; int main() { int N; cin >> N; rep(i, N) { cin >> x[i] >> y[i] >> h[i]; } rep(i, 101) { rep(j, 101) { int cx = i; int cy = j; int id = 0; int height = 0; while (1) { if (h[id] != 0) { height = h[id] + abs(cx - x[id]) + abs(cy - y[id]); break; } } bool f = true; rep(i, N) { if (h[i] != max(0, height - abs(cx - x[i]) - abs(cy - y[i]))) { f = false; } } if (f) { cout << cx << " " << cy << " " << height << endl; } } } }
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <tuple> #include <vector> //  ceil(a/b) (a + (b - 1))/ b using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef pair<int, int> P; const int inf = 1012345678; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; // int gcd(int a, int b){ // if (a%b==0){ // return(b); // } // else{ // return(gcd(b,a%b)); // } // } int x[110]; int y[110]; int h[110]; int main() { int N; cin >> N; rep(i, N) { cin >> x[i] >> y[i] >> h[i]; } rep(i, 101) { rep(j, 101) { int cx = i; int cy = j; int id = 0; int height = 0; while (1) { if (h[id] != 0) { height = h[id] + abs(cx - x[id]) + abs(cy - y[id]); break; } id++; } bool f = true; rep(i, N) { if (h[i] != max(0, height - abs(cx - x[i]) - abs(cy - y[i]))) { f = false; } } if (f) { cout << cx << " " << cy << " " << height << endl; } } } }
insert
53
53
53
54
TLE
p03240
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> #define ll long long using namespace std; int main() { int N; cin >> N; struct P { int x; int y; ll h; }; P p[N]; P sample; for (int i = 0; i < N; i++) { cin >> p[i].x >> p[i].y >> p[i].h; if (p[i].h >= 1LL) { sample = p[i]; } } vector<P> ansPoss; for (int x = 0; x <= 100; x++) { for (int y = 0; y <= 100; y++) { bool flag = true; ll V = sample.h + abs(sample.x - x) + abs(sample.y - y); V = max(V, 0LL); for (int i = 0; i < N; i++) { if (p[i].h != V - abs(p[i].x - x) - abs(p[i].y - y)) { flag = false; } } if (flag == true) { ansPoss.push_back(P{x, y, V}); } } } P ans = ansPoss[0]; cout << ans.x << " " << ans.y << " " << ans.h << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <string> #include <vector> #define ll long long using namespace std; int main() { int N; cin >> N; struct P { int x; int y; ll h; }; P p[N]; P sample; for (int i = 0; i < N; i++) { cin >> p[i].x >> p[i].y >> p[i].h; if (p[i].h >= 1LL) { sample = p[i]; } } vector<P> ansPoss; for (int x = 0; x <= 100; x++) { for (int y = 0; y <= 100; y++) { bool flag = true; ll V = sample.h + abs(sample.x - x) + abs(sample.y - y); V = max(V, 0LL); for (int i = 0; i < N; i++) { if (p[i].h != max(V - abs(p[i].x - x) - abs(p[i].y - y), 0LL)) { flag = false; } } if (flag == true) { ansPoss.push_back(P{x, y, V}); } } } P ans = ansPoss[0]; cout << ans.x << " " << ans.y << " " << ans.h << endl; return 0; }
replace
32
33
32
33
0
p03240
C++
Runtime Error
#include <algorithm> #include <cassert> #include <chrono> #include <cmath> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <thread> #include <typeinfo> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef unsigned long long int ull; typedef long long int ll; typedef pair<ll, ll> pll; typedef pair<int, int> pi; typedef pair<double, double> pd; typedef pair<double, ll> pdl; #define F first #define S second const ll E = 1e18 + 7; const ll MOD = 1000000007; vector<pair<ll, pll>> V; ll judge(ll x, ll y) { ll h = V[0].F + abs(x - V[0].S.F) + abs(y - V[0].S.S); if (h <= 0) { return -1; } for (int i = 1; i < V.size(); i++) { ll H = h - abs(x - V[i].S.F) - abs(y - V[i].S.S); if (H != V[i].F) { return -1; } } return h; } int main() { ll n; cin >> n; V.resize(n); for (int i = 0; i < n; i++) { ll x, y, h; cin >> x >> y >> h; V[i] = {h, {x, y}}; } sort(V.begin(), V.end(), greater<pair<ll, pll>>()); if (V[0].F == 0) { while (1) ; } for (int i = 0; i <= 100; i++) { for (int t = 0; t <= 100; t++) { ll ret = judge(i, t); if (ret != -1) { cout << i << " " << t << " " << ret << endl; return 0; } } } assert(false); return 0; }
#include <algorithm> #include <cassert> #include <chrono> #include <cmath> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <thread> #include <typeinfo> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef unsigned long long int ull; typedef long long int ll; typedef pair<ll, ll> pll; typedef pair<int, int> pi; typedef pair<double, double> pd; typedef pair<double, ll> pdl; #define F first #define S second const ll E = 1e18 + 7; const ll MOD = 1000000007; vector<pair<ll, pll>> V; ll judge(ll x, ll y) { ll h = V[0].F + abs(x - V[0].S.F) + abs(y - V[0].S.S); if (h <= 0) { return -1; } for (int i = 1; i < V.size(); i++) { ll H = h - abs(x - V[i].S.F) - abs(y - V[i].S.S); H = max(H, (ll)0); if (H != V[i].F) { return -1; } } return h; } int main() { ll n; cin >> n; V.resize(n); for (int i = 0; i < n; i++) { ll x, y, h; cin >> x >> y >> h; V[i] = {h, {x, y}}; } sort(V.begin(), V.end(), greater<pair<ll, pll>>()); if (V[0].F == 0) { while (1) ; } for (int i = 0; i <= 100; i++) { for (int t = 0; t <= 100; t++) { ll ret = judge(i, t); if (ret != -1) { cout << i << " " << t << " " << ret << endl; return 0; } } } assert(false); return 0; }
insert
43
43
43
44
0
p03240
C++
Runtime Error
#include <algorithm> #include <cstdlib> #include <iostream> #include <vector> using namespace std; int main() { int N; int x[1000], y[1000], h[1000]; cin >> N; for (int i = 0; i < N; i++) { cin >> x[i] >> y[i] >> h[i]; } vector<int> CX; vector<int> CY; vector<int> HH; for (int cx = 0; cx <= 100; cx++) { for (int cy = 0; cy <= 100; cy++) { vector<int> H; for (int i = 0; i < N; i++) { if (h[i] != 0) { H.push_back(h[i] + abs(x[i] - cx) + abs(y[i] - cy)); } } bool flag = true; for (auto itr = H.begin(); itr != H.end() - 1; itr++) { if (*itr != *(itr + 1)) flag = false; } if (flag == true) { CX.push_back(cx); CY.push_back(cy); HH.push_back(H[0]); } } } for (int i = 0; i < CX.size(); i++) { bool flag2 = true; for (int j = 0; j < N; j++) { if (h[i] == 0) { if (max(HH[i] - abs(x[i] - CX[i]) - abs(y[i] - CY[i]), 0) != 0) flag2 = false; } } if (flag2 == true) { cout << CX[i] << " " << CY[i] << " " << HH[i] << endl; } } return 0; }
#include <algorithm> #include <cstdlib> #include <iostream> #include <vector> using namespace std; int main() { int N; int x[1000], y[1000], h[1000]; cin >> N; for (int i = 0; i < N; i++) { cin >> x[i] >> y[i] >> h[i]; } vector<int> CX; vector<int> CY; vector<int> HH; for (int cx = 0; cx <= 100; cx++) { for (int cy = 0; cy <= 100; cy++) { vector<int> H; for (int i = 0; i < N; i++) { if (h[i] != 0) { H.push_back(h[i] + abs(x[i] - cx) + abs(y[i] - cy)); } } bool flag = true; for (auto itr = H.begin(); itr != H.end() - 1; itr++) { if (*itr != *(itr + 1)) flag = false; } if (flag == true) { CX.push_back(cx); CY.push_back(cy); HH.push_back(H[0]); } } } for (int i = 0; i < CX.size(); i++) { bool flag2 = true; for (int j = 0; j < N; j++) { if (h[j] == 0) { if (max(HH[i] - abs(x[j] - CX[i]) - abs(y[j] - CY[i]), 0) != 0) flag2 = false; } } if (flag2 == true) { cout << CX[i] << " " << CY[i] << " " << HH[i] << endl; } } return 0; }
replace
40
42
40
42
0
p03240
C++
Runtime Error
#include <algorithm> #include <complex> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; int N; ll x[110], y[110], z[110]; ll myabs(ll xx) { if (xx >= 0) { return xx; } else { return -xx; } } int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> x[i] >> y[i] >> z[i]; } ll h_max = (ll)1e9 + 1; for (ll i = 0; i <= 100; i++) { for (ll j = 0; j <= 100; j++) { ll h = (ll)1e9 + 1; ll h_min = -1; bool ok = true; for (int k = 0; k < N; k++) { ll dis = max(h_max - myabs(i - x[k]) - myabs(j - y[k]), 0LL); if (z[k] == 0 && dis > h) { ok = false; break; } else if (z[k] == 0) { h_min = max(h_min, dis); } else if (z[k] > 0 && h == (ll)1e9 + 1) { h = dis - z[k]; } else if (z[k] > 0 && h != dis - z[k]) { ok = false; break; } } if (ok) { for (int k = 0; k < N; k++) { ll dis = max(h_max - h - myabs(i - x[k]) - myabs(j - y[k]), 0LL); if (dis != z[k]) { ok = false; break; } } } if (ok) { cout << i << " " << j << " " << h_max - h << endl; } } } exit(1); }
#include <algorithm> #include <complex> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; int N; ll x[110], y[110], z[110]; ll myabs(ll xx) { if (xx >= 0) { return xx; } else { return -xx; } } int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> x[i] >> y[i] >> z[i]; } ll h_max = (ll)1e9 + 1; for (ll i = 0; i <= 100; i++) { for (ll j = 0; j <= 100; j++) { ll h = (ll)1e9 + 1; ll h_min = -1; bool ok = true; for (int k = 0; k < N; k++) { ll dis = max(h_max - myabs(i - x[k]) - myabs(j - y[k]), 0LL); if (z[k] == 0 && dis > h) { ok = false; break; } else if (z[k] == 0) { h_min = max(h_min, dis); } else if (z[k] > 0 && h == (ll)1e9 + 1) { h = dis - z[k]; } else if (z[k] > 0 && h != dis - z[k]) { ok = false; break; } } if (ok) { for (int k = 0; k < N; k++) { ll dis = max(h_max - h - myabs(i - x[k]) - myabs(j - y[k]), 0LL); if (dis != z[k]) { ok = false; break; } } } if (ok) { cout << i << " " << j << " " << h_max - h << endl; return 0; } } } exit(1); }
insert
66
66
66
67
1
p03240
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> x(N), y(N), h(N); for (int i = 0; i < N; i++) { cin >> x[i] >> y[i] >> h[i]; } int MAX = 100; for (int posX = 0; posX <= MAX; posX) { for (int posY = 0; posY <= MAX; posY) { int needH = -1; for (int i = 0; i < N; i++) { if (h[i] > 0) { int tmp = h[i] + abs(x[i] - posX) + abs(y[i] - posY); if (needH == -1) { needH = tmp; } else { // 高度の定義に反していたら if (needH != tmp) { needH = -2; break; } } } } // breakからそのままおりてきて。。。 if (needH == -2) continue; for (int i = 0; i < N; i++) { if (h[i] == 0) { int dist = abs(x[i] - posX) + abs(y[i] - posY); // distが0より小さくないとmax()で0が選ばれたことにならない if (needH > dist) { needH = -2; break; } } } if (needH == -2) continue; cout << posX << " " << posY << " " << needH << endl; return 0; } } }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> x(N), y(N), h(N); for (int i = 0; i < N; i++) { cin >> x[i] >> y[i] >> h[i]; } int MAX = 100; for (int posX = 0; posX <= MAX; posX++) { for (int posY = 0; posY <= MAX; posY++) { int needH = -1; for (int i = 0; i < N; i++) { if (h[i] > 0) { int tmp = h[i] + abs(x[i] - posX) + abs(y[i] - posY); if (needH == -1) { needH = tmp; } else { // 高度の定義に反していたら if (needH != tmp) { needH = -2; break; } } } } // breakからそのままおりてきて。。。 if (needH == -2) continue; for (int i = 0; i < N; i++) { if (h[i] == 0) { int dist = abs(x[i] - posX) + abs(y[i] - posY); // distが0より小さくないとmax()で0が選ばれたことにならない if (needH > dist) { needH = -2; break; } } } if (needH == -2) continue; cout << posX << " " << posY << " " << needH << endl; return 0; } } }
replace
14
16
14
16
TLE
p03240
Python
Runtime Error
# https://atcoder.jp/contests/abc112/tasks/abc112_c # ピラミッドの中心は必ず0-100の中にある # Hは1以上 # 与えられる情報だけで一意に定まる # 中心座標をa,bと置いたとき、ある点x,yにおける高さは # h(x,y; a,b)=max(H-|x-a|-|y-b|,0)である。 # ここで、真の高さとの誤差としてe(x,y;a,b)=|h(x,y;a,b) - h(x,y;Cx,Cy)|とすると。 # 任意のx,yでe=0となるa,bが答え。しかしHはわからないので0とする。 # そうすると任意のx,yでe(x,y;a,b)=constとなるa,bが答え。(ただしmaxの扱いが面倒なのでh==0は無視して処理を行う) # またその定数constはHである # 座標は10**4点。Nはたかだか100なので 最悪10**6回計算。間に合う。 import numpy as np from itertools import product N = int(input()) X, Y, H = [], [], [] for n in range(N): x, y, h = list(map(int, input().split())) # if h == 0: # continue X.append(x) Y.append(y) H.append(h) if N == 1: print(x, y, h) exit() X = np.array(X) Y = np.array(Y) H = np.array(H) def is_eq_loss(X, Y, H, a, b): loss = np.abs(-np.abs(X - a) - np.abs(Y - b) - H) mask = H == 0 # 高さがない疑いのところは最小値に合わせる if np.any(mask): loss[mask] = loss[mask].min() # print(loss[-1]) if (loss[-1] == loss).all(): return True, loss[-1] else: return False, False for a, b in product(range(101), range(101)): flg, ansH = is_eq_loss(X, Y, H, a, b) if flg: ans = (a, b, ansH) print(*ans)
# https://atcoder.jp/contests/abc112/tasks/abc112_c # ピラミッドの中心は必ず0-100の中にある # Hは1以上 # 与えられる情報だけで一意に定まる # 中心座標をa,bと置いたとき、ある点x,yにおける高さは # h(x,y; a,b)=max(H-|x-a|-|y-b|,0)である。 # ここで、真の高さとの誤差としてe(x,y;a,b)=|h(x,y;a,b) - h(x,y;Cx,Cy)|とすると。 # 任意のx,yでe=0となるa,bが答え。しかしHはわからないので0とする。 # そうすると任意のx,yでe(x,y;a,b)=constとなるa,bが答え。(ただしmaxの扱いが面倒なのでh==0は無視して処理を行う) # またその定数constはHである # 座標は10**4点。Nはたかだか100なので 最悪10**6回計算。間に合う。 import numpy as np from itertools import product N = int(input()) X, Y, H = [], [], [] for n in range(N): x, y, h = list(map(int, input().split())) # if h == 0: # continue X.append(x) Y.append(y) H.append(h) if N == 1: print(x, y, h) exit() X = np.array(X) Y = np.array(Y) H = np.array(H) def is_eq_loss(X, Y, H, a, b): loss = np.abs(-np.abs(X - a) - np.abs(Y - b) - H) mask = H == 0 # 高さがない疑いのところは最小値に合わせる if np.any(mask): loss[mask] = loss.min() # print(loss[-1]) if (loss[-1] == loss).all(): return True, loss[-1] else: return False, False for a, b in product(range(101), range(101)): flg, ansH = is_eq_loss(X, Y, H, a, b) if flg: ans = (a, b, ansH) print(*ans)
replace
42
43
42
43
TLE
p03240
C++
Runtime Error
#include <algorithm> #include <iostream> #include <sstream> #include <string.h> using namespace std; class C { int N; int64_t record[100][3]; int64_t nonZeroPoint[3]; public: void solve() { cout << helper() << endl; } string helper() { ostringstream oss; int64_t h, tmph; bool flag{true}; for (int cx{0}; cx <= 100; cx++) { for (int cy{0}; cy <= 100; cy++) { h = nonZeroPoint[2] + abs(nonZeroPoint[0] - cx) + abs(nonZeroPoint[1] - cy); if (h < 1) continue; flag = true; for (int i{0}; i < N; i++) { tmph = record[i][2] + abs(record[i][0] - cx) + abs(record[i][1] - cy); if (h != tmph) { flag = false; break; } } if (flag) { oss << cx << " " << cy << " " << h; return oss.str(); } } } } C() { cin >> N; memset(record, 0, sizeof record); for (int i{0}; i < N; i++) cin >> record[i][0] >> record[i][1] >> record[i][2]; for (int i{0}; i < N; i++) { if (record[i][2]) { nonZeroPoint[0] = record[i][0]; nonZeroPoint[1] = record[i][1]; nonZeroPoint[2] = record[i][2]; break; } } } }; int main() { C solution; solution.solve(); return 0; }
#include <algorithm> #include <iostream> #include <sstream> #include <string.h> using namespace std; class C { int N; int64_t record[100][3]; int64_t nonZeroPoint[3]; public: void solve() { cout << helper() << endl; } string helper() { ostringstream oss; int64_t h, tmph; bool flag{true}; for (int cx{0}; cx <= 100; cx++) { for (int cy{0}; cy <= 100; cy++) { h = nonZeroPoint[2] + abs(nonZeroPoint[0] - cx) + abs(nonZeroPoint[1] - cy); if (h < 1) continue; flag = true; for (int i{0}; i < N; i++) { tmph = h - abs(record[i][0] - cx) - abs(record[i][1] - cy); tmph = max((int64_t)0, tmph); if (record[i][2] != tmph) { flag = false; break; } } if (flag) { oss << cx << " " << cy << " " << h; return oss.str(); } } } } C() { cin >> N; memset(record, 0, sizeof record); for (int i{0}; i < N; i++) cin >> record[i][0] >> record[i][1] >> record[i][2]; for (int i{0}; i < N; i++) { if (record[i][2]) { nonZeroPoint[0] = record[i][0]; nonZeroPoint[1] = record[i][1]; nonZeroPoint[2] = record[i][2]; break; } } } }; int main() { C solution; solution.solve(); return 0; }
replace
29
31
29
32
0
p03240
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<vector<ll>> v(n, vector<ll>(3)); rep(i, n) { rep(j, 3) { cin >> v[i][j]; } } bool flag = true; for (int x = 0; x <= 100; x++) { for (int y = 0; y <= 100; y++) { vector<ll> judge(0); rep(i, n) { if (v[i][2] > 0) { // judgeの要素を計算してmemに入れる ll mem, diffx, diffy; diffx = labs(x - v[i][0]); diffy = labs(y - v[i][1]); mem = diffx + diffy + v[i][2]; judge.push_back(mem); } } if (judge.size() == 1) { rep(k, n) { if (v[k][2] > 0) { cout << v[k][0] << " " << v[k][1] << " " << v[k][2]; exit(1); } } } flag = true; rep(j, judge.size() - 1) { if (judge[j] == judge[j + 1]) continue; else { flag = false; break; } } if (flag) { cout << x << " " << y << " " << judge[0] << endl; break; } } if (flag) break; } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<vector<ll>> v(n, vector<ll>(3)); rep(i, n) { rep(j, 3) { cin >> v[i][j]; } } bool flag = true; for (int x = 0; x <= 100; x++) { for (int y = 0; y <= 100; y++) { vector<ll> judge(0); rep(i, n) { if (v[i][2] > 0) { // judgeの要素を計算してmemに入れる ll mem, diffx, diffy; diffx = labs(x - v[i][0]); diffy = labs(y - v[i][1]); mem = diffx + diffy + v[i][2]; judge.push_back(mem); } } if (judge.size() == 1) { rep(k, n) { if (v[k][2] > 0) { cout << v[k][0] << " " << v[k][1] << " " << v[k][2]; exit(0); } } } flag = true; rep(j, judge.size() - 1) { if (judge[j] == judge[j + 1]) continue; else { flag = false; break; } } if (flag) { cout << x << " " << y << " " << judge[0] << endl; break; } } if (flag) break; } return 0; }
replace
32
33
32
33
0
p03240
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int n; scanf("%d", &n); int x[100], y[100], h[100]; rep(i, n) scanf("%d%d%d", x + i, y + i, h + i); rep(cy, 101) rep(cx, 101) { int lo = 0, hi = 2e9; while (lo < hi) { int mi = (lo + hi + 1) / 2; bool b = true; rep(i, n) if (max(mi - abs(x[i] - cx) - abs(y[i] - cy), 0) > h[i]) b = false; if (b) lo = mi; else hi = mi - 1; } bool ok = true; rep(i, n) if (max(lo - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]) ok = false; if (ok) { printf("%d %d %d\n", cx, cy, lo); break; } } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int n; scanf("%d", &n); int x[100], y[100], h[100]; rep(i, n) scanf("%d%d%d", x + i, y + i, h + i); rep(cy, 101) rep(cx, 101) { int lo = 0, hi = 1e9 + 1000; while (lo < hi) { int mi = (lo + hi + 1) / 2; bool b = true; rep(i, n) if (max(mi - abs(x[i] - cx) - abs(y[i] - cy), 0) > h[i]) b = false; if (b) lo = mi; else hi = mi - 1; } bool ok = true; rep(i, n) if (max(lo - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]) ok = false; if (ok) { printf("%d %d %d\n", cx, cy, lo); break; } } return 0; }
replace
15
16
15
16
TLE
p03240
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); i++) #define chmin(x, y) (x) = min((x), (y)) #define chmax(x, y) (x) = max((x), (y)) #define endl "\n" typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; } struct P { int x, y, h; }; void solve() { int N; cin >> N; vector<P> C; for (int i = 0; i < N; i++) { int x, y, h; cin >> x >> y >> h; C.push_back({x, y, h}); } for (int x = 0; x <= 100; x++) { for (int y = 0; y <= 100; y++) { int h = 0; for (int i = 0; i < N; i++) { if (C[i].h != 0 && C[i].h + abs(C[i].x - x) + abs(C[i].y - y) != 0) { h = C[i].h + abs(C[i].x - x) + abs(C[i].y - y); break; } } if (h == 0) { assert(false); } bool ok = true; for (int i = 0; i < N; i++) { if (h - abs(C[i].x - x) - abs(C[i].y - y) != C[i].h) ok = false; } if (ok) { cout << x << " " << y << " " << h << endl; return; } } } assert(false); } int main() { #ifdef LOCAL_ENV cin.exceptions(ios::failbit); #endif cin.tie(0); ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); solve(); }
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); i++) #define chmin(x, y) (x) = min((x), (y)) #define chmax(x, y) (x) = max((x), (y)) #define endl "\n" typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; } struct P { int x, y, h; }; void solve() { int N; cin >> N; vector<P> C; for (int i = 0; i < N; i++) { int x, y, h; cin >> x >> y >> h; C.push_back({x, y, h}); } for (int x = 0; x <= 100; x++) { for (int y = 0; y <= 100; y++) { int h = 0; for (int i = 0; i < N; i++) { if (C[i].h != 0 && C[i].h + abs(C[i].x - x) + abs(C[i].y - y) != 0) { h = C[i].h + abs(C[i].x - x) + abs(C[i].y - y); break; } } if (h == 0) { assert(false); } bool ok = true; for (int i = 0; i < N; i++) { if (max(0, h - abs(C[i].x - x) - abs(C[i].y - y)) != C[i].h) ok = false; } if (ok) { cout << x << " " << y << " " << h << endl; return; } } } assert(false); } int main() { #ifdef LOCAL_ENV cin.exceptions(ios::failbit); #endif cin.tie(0); ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); solve(); }
replace
56
57
56
57
0
p03240
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <functional> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { // input int n; cin >> n; // 全ての項目に対して3重でforループを回して各項目で条件を満たす組み合わせを出力する vector<int> data_x; vector<int> data_y; vector<int> data_h; vector<int> data_h2; for (int i = 0; i < n; ++i) { int x, y, h; vector<int> data; cin >> x >> y >> h; data_x.push_back(x); data_y.push_back(y); data_h.push_back(h); data_h2.push_back(h); } sort(data_h2.begin(), data_h2.end()); int h_couho; h_couho = data_h2[n - 1]; // x座標ループ for (int i = 0; i <= 100; ++i) { // y for (int j = 0; j <= 100; ++j) { // h for (int k = 1; k <= h_couho + 100; ++k) { int t_cnt = 0; // 調査結果 for (int p = 0; p < n; ++p) { // 右辺 int uhen = 0; uhen = max((k - abs(data_x[p] - i) - abs(data_y[p] - j)), 0); if (uhen == data_h[p]) { t_cnt++; if (t_cnt == n) { cout << i << " " << j << " " << k << endl; return 0; } else { continue; } } else { continue; } } } } } return 0; }
#include <algorithm> #include <bitset> #include <functional> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { // input int n; cin >> n; // 全ての項目に対して3重でforループを回して各項目で条件を満たす組み合わせを出力する vector<int> data_x; vector<int> data_y; vector<int> data_h; vector<int> data_h2; for (int i = 0; i < n; ++i) { int x, y, h; vector<int> data; cin >> x >> y >> h; data_x.push_back(x); data_y.push_back(y); data_h.push_back(h); data_h2.push_back(h); } sort(data_h2.begin(), data_h2.end()); int h_couho; h_couho = data_h2[n - 1]; // x座標ループ for (int i = 0; i <= 100; ++i) { // y for (int j = 0; j <= 100; ++j) { // h for (int k = data_h2[0]; k <= h_couho + 100; ++k) { int t_cnt = 0; // 調査結果 for (int p = 0; p < n; ++p) { // 右辺 int uhen = 0; uhen = max((k - abs(data_x[p] - i) - abs(data_y[p] - j)), 0); if (uhen == data_h[p]) { t_cnt++; if (t_cnt == n) { cout << i << " " << j << " " << k << endl; return 0; } else { continue; } } else { continue; } } } } } return 0; }
replace
46
47
46
47
TLE
p03240
C++
Runtime Error
#include <algorithm> #include <array> #include <bitset> #include <cstdint> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <memory> #include <numeric> #include <queue> #include <unordered_map> #include <unordered_set> #include <vector> // constexpr std::int64_t INF = 1ull << 50; constexpr int INF = 1 << 20; auto main() -> int { std::uint32_t N; std::cin >> N; std::uint32_t t = INF; std::vector<std::int32_t> xs(N); std::vector<std::int32_t> ys(N); std::vector<std::int64_t> hs(N); for (auto i = 0ul; i < N; ++i) { std::cin >> xs[i] >> ys[i] >> hs[i]; if (t == INF && hs[i] >= 1) t = i; } for (auto cy = 0; cy <= 100; ++cy) { for (auto cx = 0; cx <= 100; ++cx) { // h_t = H − |x_t − c_x| − | y_t − c_y| // h = h_t + |x_t − c_x| + | y_t − c_y| const auto h = hs[t] + std::abs(xs[t] - cx) + std::abs(ys[t] - cy); if (h < 1) continue; bool f = true; for (auto i = 0ul; i < N; ++i) { f = f && ((h - std::abs(xs[i] - cx) - std::abs(ys[i] - cy)) == hs[i]); } if (f) { std::cout << cx << ' ' << cy << ' ' << h << std::endl; return 0; } } } return -1; }
#include <algorithm> #include <array> #include <bitset> #include <cstdint> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <memory> #include <numeric> #include <queue> #include <unordered_map> #include <unordered_set> #include <vector> // constexpr std::int64_t INF = 1ull << 50; constexpr int INF = 1 << 20; auto main() -> int { std::uint32_t N; std::cin >> N; std::uint32_t t = INF; std::vector<std::int32_t> xs(N); std::vector<std::int32_t> ys(N); std::vector<std::int64_t> hs(N); for (auto i = 0ul; i < N; ++i) { std::cin >> xs[i] >> ys[i] >> hs[i]; if (t == INF && hs[i] >= 1) t = i; } for (auto cy = 0; cy <= 100; ++cy) { for (auto cx = 0; cx <= 100; ++cx) { // h_t = H − |x_t − c_x| − | y_t − c_y| // h = h_t + |x_t − c_x| + | y_t − c_y| const auto h = hs[t] + std::abs(xs[t] - cx) + std::abs(ys[t] - cy); if (h < 1) continue; bool f = true; for (auto i = 0ul; i < N; ++i) { f = f && (std::max(h - std::abs(xs[i] - cx) - std::abs(ys[i] - cy), 0l) == hs[i]); } if (f) { std::cout << cx << ' ' << cy << ' ' << h << std::endl; return 0; } } } return -1; }
replace
44
45
44
46
0
p03240
C++
Runtime Error
#include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <stack> #include <unordered_map> #include <vector> using namespace std; using ll = long long; const ll INF = (ll)1e18 + 1; const ll DIV = 1000000007; // #define TEST int main() { cin.tie(0); ios::sync_with_stdio(false); #ifdef TEST chrono::system_clock::time_point start, end; start = chrono::system_clock::now(); #endif long N; cin >> N; vector<ll> x; vector<ll> y; vector<ll> h; for (size_t i = 0; i < N; i++) { cin >> x[i] >> y[i] >> h[i]; } ll H = -1, Cx, Cy; // h = max(H - |x - Cx| - | y - Cy |, 0) // H は h 以上 // Hは一意に定まる bool isOK; for (size_t cx = 0; cx <= 100; cx++) { for (size_t cy = 0; cy <= 100; cy++) { H = -1; isOK = true; for (size_t i = 0; i < N; i++) { ll _H; if (h[i] == 0) continue; _H = h[i] + abs(ll(x[i] - cx)) + abs(ll(y[i] - cy)); if (H == -1) H = max(_H, 0ll); else { if (H != _H) { isOK = false; break; } } } for (size_t i = 0; i < N; i++) { if (h[i] > 0) continue; if (h[i] != max(H - abs(ll(x[i] - cx)) - abs(ll(y[i] - cy)), 0ll)) isOK = false; } if (isOK) { Cy = cy; break; } } if (isOK) { Cx = cx; break; } } cout << Cx << " " << Cy << " " << H << endl; #ifdef TEST end = chrono::system_clock::now(); cerr << static_cast<double>( chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl; #endif return 0; }
#include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <stack> #include <unordered_map> #include <vector> using namespace std; using ll = long long; const ll INF = (ll)1e18 + 1; const ll DIV = 1000000007; // #define TEST int main() { cin.tie(0); ios::sync_with_stdio(false); #ifdef TEST chrono::system_clock::time_point start, end; start = chrono::system_clock::now(); #endif long N; cin >> N; vector<ll> x(N); vector<ll> y(N); vector<ll> h(N); for (size_t i = 0; i < N; i++) { cin >> x[i] >> y[i] >> h[i]; } ll H = -1, Cx, Cy; // h = max(H - |x - Cx| - | y - Cy |, 0) // H は h 以上 // Hは一意に定まる bool isOK; for (size_t cx = 0; cx <= 100; cx++) { for (size_t cy = 0; cy <= 100; cy++) { H = -1; isOK = true; for (size_t i = 0; i < N; i++) { ll _H; if (h[i] == 0) continue; _H = h[i] + abs(ll(x[i] - cx)) + abs(ll(y[i] - cy)); if (H == -1) H = max(_H, 0ll); else { if (H != _H) { isOK = false; break; } } } for (size_t i = 0; i < N; i++) { if (h[i] > 0) continue; if (h[i] != max(H - abs(ll(x[i] - cx)) - abs(ll(y[i] - cy)), 0ll)) isOK = false; } if (isOK) { Cy = cy; break; } } if (isOK) { Cx = cx; break; } } cout << Cx << " " << Cy << " " << H << endl; #ifdef TEST end = chrono::system_clock::now(); cerr << static_cast<double>( chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl; #endif return 0; }
replace
27
30
27
30
-11
p03240
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef unsigned long ul; typedef unsigned long long ull; typedef long long ll; typedef vector<ll> vint; typedef vector<vector<ll>> vvint; typedef vector<vector<vector<ll>>> vvvint; typedef vector<string> vstring; typedef vector<vector<string>> vvstring; typedef vector<char> vchar; typedef vector<vector<char>> vvchar; typedef vector<long double> vdouble; typedef vector<vector<long double>> vvdouble; typedef vector<vector<vector<long double>>> vvvdouble; typedef pair<ll, ll> pint; typedef vector<pint> vpint; typedef vector<bool> vbool; #define rep(i, n) for (ll i = 0; i < n; i++) #define repf(i, f, n) for (ll i = f; i < n; i++) #define repr(i, n) for (ll i = n - 1; i >= 0; i--) #define mp make_pair #define mt make_tuple #define pb push_back #define pf push_front #define fi first #define se second #define ALL(obj) (obj).begin(), (obj).end() // #define LLONG_MAX 9223372036854775806 #define vmax(vec) *max_element(vec.begin(), vec.end()) #define vmin(vec) *min_element(vec.begin(), vec.end()) #define vsort(vec) sort(vec.begin(), vec.end()) #define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>()) #define MOD 1000000007 // #define MOD 998244353 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; } // // struct Node{ // vint children; // ll index; // ll prop; // }; // struct edge{ll to; ll cost;}; int dy[] = {0, 0, 1, -1}; int dx[] = { 1, -1, 0, 0, }; // ll X,Y,Z,K; // ll pmax = 30000000000; // vint A,B,C; // void comb(vector<vector <long long int> > &v){ // for(int i = 0;i <v.size(); i++){ // v[i][0]=1; // v[i][i]=1; // } // for(int k = 1;k <v.size();k++){ // for(int j = 1;j<k;j++){ // v[k][j]=((v[k-1][j-1]+v[k-1][j])%MOD); // } // } // } ll gcd(ll a, ll b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a % b) : a; } ll lcm(int a, ll b) { return a * b / gcd(a, b); } // 繰り返し二乗法 ll power(ll a, ll b) { ll res = 1; while (b > 0) { if (b & 1) res = res * a % MOD; a = a * a % MOD; b >>= 1; } return res; } const int MAX = 510000; ll fact[MAX], fact_inv[MAX]; void init_fact(ll n) { fact[0] = 1; // 階乗の計算 rep(i, n) fact[i + 1] = fact[i] * (i + 1) % MOD; fact_inv[n] = power(fact[n], MOD - 2); // 逆元の計算 for (ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD; } ll comb(ll n, ll r) { return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD; } ll perm(ll n, ll r) { return (fact[n] * fact_inv[n - r]) % MOD; } struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 vector<ll> num; // vector<ll> dist; // rootまでの距離 UnionFind(ll N) : par(N), num(N) { // 最初は全てが根であるとして初期化 for (ll i = 0; i < N; i++) par[i] = i; for (ll i = 0; i < N; i++) num[i] = 1; // for(ll i = 0; i < N; i++) dist[i] = 0; } ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(ll x, ll y) { // xとyの木を併合 ll rx = root(x); // xの根をrx ll ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける num[ry] = num[rx] + num[ry]; } bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す ll rx = root(x); ll ry = root(y); return rx == ry; } ll size(ll x) { return num[root(x)]; } }; vint divisor(ll n) { // nの約数 vint ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.pb(i); if (i * i != n) ret.pb(n / i); } } vsort(ret); return ret; } ll my_pow(ll x, ll y) { ll rtn = 1; rep(i, y) rtn *= x; return rtn; } ll get_digit_in(ll n, ll i) { // i桁目の数字を得る。 for (ll j = 0; j < i - 1; j++) { n /= 10; } return n % 10; } ll get_digit(ll n) { ll rtn = 0; while (n > 0) { n /= 10; rtn++; } return rtn; } map<ll, ll> prime_factor(ll n) { map<ll, ll> rtn; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { rtn[i]++; n /= i; } } if (n != 1) rtn[n] = 1; return rtn; } // nPnの順列に対して処理を実行する void foreach_permutation(ll n, function<void(ll *)> f) { ll indexes[n]; for (ll i = 0; i < n; i++) indexes[i] = i; do { f(indexes); } while (std::next_permutation(indexes, indexes + n)); } void recursive_comb(ll *indexes, ll s, ll rest, function<void(ll *)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursive_comb(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursive_comb(indexes, s - 1, rest - 1, f); } } // nCkの組み合わせに対して処理を実行する void foreach_comb(ll n, ll k, function<void(ll *)> f) { ll indexes[k]; recursive_comb(indexes, n - 1, k, f); } // nPkの順列に対して処理を実行する void foreach_permutation(ll n, ll k, function<void(ll *)> f) { foreach_comb(n, k, [&](ll *c_indexes) { foreach_permutation(k, [&](ll *p_indexes) { ll indexes[k]; for (ll i = 0; i < k; i++) { indexes[i] = c_indexes[p_indexes[i]]; } f(indexes); }); }); } // ll arr[55556]; // vint primes; // // //エラトステネスの篩 // void Eratosthenes(){ // ll N = 55556; // for(ll i = 0; i < N; i++){ // arr[i] = 1; // } // for(ll i = 2; i < sqrt(N); i++){ // if(arr[i]){ // for(ll j = 0; i * (j + 2) < N; j++){ // arr[i *(j + 2)] = 0; // } // } // } // // for(ll i = 2; i < N; i++){ // if(arr[i] && i%5==1){ // primes.pb(i); // //cout << i << endl; // } // } // } void print(vint &V) { for (auto e : V) cout << e << " "; cout << endl; } int main() { cout << fixed << setprecision(12); ll N; cin >> N; vint x(N), y(N), h(N); rep(i, N) cin >> x[i] >> y[i] >> h[i]; ll nonezero = upper_bound(ALL(h), 0ll) - h.begin(); assert(nonezero < N); ll cx = -1, cy = -1; bool f; ll H; for (ll i = 0; i <= 100; i++) { for (ll j = 0; j <= 100; j++) { f = true; H = h[nonezero] + abs(x[nonezero] - i) + abs(y[nonezero] - j); rep(k, N) { // cout<<h[k] + abs(x[k]-i) + abs(y[k]-j)<<endl; // if(h[k] == 0)continue; // if(H == 0){ H = h[k] + abs(x[k]-i) + abs(y[k]-j); continue;} if (h[k] != max(H - abs(x[k] - i) - abs(y[k] - j), 0ll)) { f = false; break; } } if (f && H > 0) { cx = i; cy = j; break; } f = false; } if (f) break; } // assert(cx>=0 && cy>=0); cout << cx << " " << cy << " " << H << endl; } //
#include <bits/stdc++.h> using namespace std; typedef unsigned long ul; typedef unsigned long long ull; typedef long long ll; typedef vector<ll> vint; typedef vector<vector<ll>> vvint; typedef vector<vector<vector<ll>>> vvvint; typedef vector<string> vstring; typedef vector<vector<string>> vvstring; typedef vector<char> vchar; typedef vector<vector<char>> vvchar; typedef vector<long double> vdouble; typedef vector<vector<long double>> vvdouble; typedef vector<vector<vector<long double>>> vvvdouble; typedef pair<ll, ll> pint; typedef vector<pint> vpint; typedef vector<bool> vbool; #define rep(i, n) for (ll i = 0; i < n; i++) #define repf(i, f, n) for (ll i = f; i < n; i++) #define repr(i, n) for (ll i = n - 1; i >= 0; i--) #define mp make_pair #define mt make_tuple #define pb push_back #define pf push_front #define fi first #define se second #define ALL(obj) (obj).begin(), (obj).end() // #define LLONG_MAX 9223372036854775806 #define vmax(vec) *max_element(vec.begin(), vec.end()) #define vmin(vec) *min_element(vec.begin(), vec.end()) #define vsort(vec) sort(vec.begin(), vec.end()) #define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>()) #define MOD 1000000007 // #define MOD 998244353 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; } // // struct Node{ // vint children; // ll index; // ll prop; // }; // struct edge{ll to; ll cost;}; int dy[] = {0, 0, 1, -1}; int dx[] = { 1, -1, 0, 0, }; // ll X,Y,Z,K; // ll pmax = 30000000000; // vint A,B,C; // void comb(vector<vector <long long int> > &v){ // for(int i = 0;i <v.size(); i++){ // v[i][0]=1; // v[i][i]=1; // } // for(int k = 1;k <v.size();k++){ // for(int j = 1;j<k;j++){ // v[k][j]=((v[k-1][j-1]+v[k-1][j])%MOD); // } // } // } ll gcd(ll a, ll b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a % b) : a; } ll lcm(int a, ll b) { return a * b / gcd(a, b); } // 繰り返し二乗法 ll power(ll a, ll b) { ll res = 1; while (b > 0) { if (b & 1) res = res * a % MOD; a = a * a % MOD; b >>= 1; } return res; } const int MAX = 510000; ll fact[MAX], fact_inv[MAX]; void init_fact(ll n) { fact[0] = 1; // 階乗の計算 rep(i, n) fact[i + 1] = fact[i] * (i + 1) % MOD; fact_inv[n] = power(fact[n], MOD - 2); // 逆元の計算 for (ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD; } ll comb(ll n, ll r) { return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD; } ll perm(ll n, ll r) { return (fact[n] * fact_inv[n - r]) % MOD; } struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 vector<ll> num; // vector<ll> dist; // rootまでの距離 UnionFind(ll N) : par(N), num(N) { // 最初は全てが根であるとして初期化 for (ll i = 0; i < N; i++) par[i] = i; for (ll i = 0; i < N; i++) num[i] = 1; // for(ll i = 0; i < N; i++) dist[i] = 0; } ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(ll x, ll y) { // xとyの木を併合 ll rx = root(x); // xの根をrx ll ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける num[ry] = num[rx] + num[ry]; } bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す ll rx = root(x); ll ry = root(y); return rx == ry; } ll size(ll x) { return num[root(x)]; } }; vint divisor(ll n) { // nの約数 vint ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.pb(i); if (i * i != n) ret.pb(n / i); } } vsort(ret); return ret; } ll my_pow(ll x, ll y) { ll rtn = 1; rep(i, y) rtn *= x; return rtn; } ll get_digit_in(ll n, ll i) { // i桁目の数字を得る。 for (ll j = 0; j < i - 1; j++) { n /= 10; } return n % 10; } ll get_digit(ll n) { ll rtn = 0; while (n > 0) { n /= 10; rtn++; } return rtn; } map<ll, ll> prime_factor(ll n) { map<ll, ll> rtn; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { rtn[i]++; n /= i; } } if (n != 1) rtn[n] = 1; return rtn; } // nPnの順列に対して処理を実行する void foreach_permutation(ll n, function<void(ll *)> f) { ll indexes[n]; for (ll i = 0; i < n; i++) indexes[i] = i; do { f(indexes); } while (std::next_permutation(indexes, indexes + n)); } void recursive_comb(ll *indexes, ll s, ll rest, function<void(ll *)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursive_comb(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursive_comb(indexes, s - 1, rest - 1, f); } } // nCkの組み合わせに対して処理を実行する void foreach_comb(ll n, ll k, function<void(ll *)> f) { ll indexes[k]; recursive_comb(indexes, n - 1, k, f); } // nPkの順列に対して処理を実行する void foreach_permutation(ll n, ll k, function<void(ll *)> f) { foreach_comb(n, k, [&](ll *c_indexes) { foreach_permutation(k, [&](ll *p_indexes) { ll indexes[k]; for (ll i = 0; i < k; i++) { indexes[i] = c_indexes[p_indexes[i]]; } f(indexes); }); }); } // ll arr[55556]; // vint primes; // // //エラトステネスの篩 // void Eratosthenes(){ // ll N = 55556; // for(ll i = 0; i < N; i++){ // arr[i] = 1; // } // for(ll i = 2; i < sqrt(N); i++){ // if(arr[i]){ // for(ll j = 0; i * (j + 2) < N; j++){ // arr[i *(j + 2)] = 0; // } // } // } // // for(ll i = 2; i < N; i++){ // if(arr[i] && i%5==1){ // primes.pb(i); // //cout << i << endl; // } // } // } void print(vint &V) { for (auto e : V) cout << e << " "; cout << endl; } int main() { cout << fixed << setprecision(12); ll N; cin >> N; vint x(N), y(N), h(N); rep(i, N) cin >> x[i] >> y[i] >> h[i]; ll nonezero = 0; rep(i, N) { if (h[i] > 0) { nonezero = i; break; } } // assert(nonezero<N); ll cx = -1, cy = -1; bool f; ll H; for (ll i = 0; i <= 100; i++) { for (ll j = 0; j <= 100; j++) { f = true; H = h[nonezero] + abs(x[nonezero] - i) + abs(y[nonezero] - j); rep(k, N) { // cout<<h[k] + abs(x[k]-i) + abs(y[k]-j)<<endl; // if(h[k] == 0)continue; // if(H == 0){ H = h[k] + abs(x[k]-i) + abs(y[k]-j); continue;} if (h[k] != max(H - abs(x[k] - i) - abs(y[k] - j), 0ll)) { f = false; break; } } if (f && H > 0) { cx = i; cy = j; break; } f = false; } if (f) break; } // assert(cx>=0 && cy>=0); cout << cx << " " << cy << " " << H << endl; } //
replace
294
296
294
302
0
p03240
C++
Runtime Error
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; const auto MOD = 1000000007; const int INF = 1e9; const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; typedef pair<int, int> PII; typedef pair<ll, ll> PLL; typedef vector<int> VI; typedef vector<ll> VLL; class cd { public: int x; int y; int height; }; const bool &comp(const cd &a, const cd &b) { return b.height < a.height; } int main() { int n; cin >> n; vector<cd> mp(n); int a, b, c; rep(i, n) { cin >> a >> b >> c; mp[i].x = a; mp[i].y = b; mp[i].height = c; } sort(mp.begin(), mp.end(), comp); int h = 0; bool flg = true; for (int i = 0; i <= 100; i++) { for (int j = 0; j <= 100; j++) { flg = true; h = mp[0].height + abs(mp[0].x - j) + abs(mp[0].y - i); for (int k = 1; k < n; k++) { if (mp[k].height != max(h - abs(mp[k].x - j) - abs(mp[k].y - i), 0)) { flg = false; break; } } if (flg) { cout << j << " "; break; } } if (flg) { cout << i << " "; break; } } cout << h << endl; }
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; const auto MOD = 1000000007; const int INF = 1e9; const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; typedef pair<int, int> PII; typedef pair<ll, ll> PLL; typedef vector<int> VI; typedef vector<ll> VLL; class cd { public: int x; int y; int height; }; bool comp(const cd &a, const cd &b) { return b.height < a.height; } int main() { int n; cin >> n; vector<cd> mp(n); int a, b, c; rep(i, n) { cin >> a >> b >> c; mp[i].x = a; mp[i].y = b; mp[i].height = c; } sort(mp.begin(), mp.end(), comp); int h = 0; bool flg = true; for (int i = 0; i <= 100; i++) { for (int j = 0; j <= 100; j++) { flg = true; h = mp[0].height + abs(mp[0].x - j) + abs(mp[0].y - i); for (int k = 1; k < n; k++) { if (mp[k].height != max(h - abs(mp[k].x - j) - abs(mp[k].y - i), 0)) { flg = false; break; } } if (flg) { cout << j << " "; break; } } if (flg) { cout << i << " "; break; } } cout << h << endl; }
replace
26
27
26
27
-11
p03240
C++
Time Limit Exceeded
#include <algorithm> #include <iomanip> #include <ios> // std::left, std::right #include <iostream> #include <map> #include <queue> #include <set> #include <string> #define REP(i, n) for (ll i = 0; i < (ll)n; i++) #define INF 1000000000000000 using namespace std; typedef long long ll; typedef double db; typedef string str; typedef pair<ll, ll> p; int Cx, Cy, H; int get_height(int x, int y) { int tmp = H - abs(x - Cx) - abs(y - Cy); return max(tmp, 0); } int main() { int N; cin >> N; vector<vector<int>> pyramids(N, vector<int>(3, 0)); REP(i, N) { cin >> pyramids[i][0] >> pyramids[i][1] >> pyramids[i][2]; } for (H = 0; H <= 1000000000; H++) { for (Cx = 0; Cx <= 100; Cx++) { for (Cy = 0; Cy <= 100; Cy++) { int count = 0; REP(i, N) { int px = pyramids[i][0]; int py = pyramids[i][1]; int pz = pyramids[i][2]; if (pz == get_height(px, py)) { count++; // cout<<"OJ"<<count<<endl; } } if (count == N) { cout << Cx << " " << Cy << " " << H << endl; return 0; } } } // cout<<"X"<<Cx<<"Y"<<Cy<<"H"<<H<<endl; } }
#include <algorithm> #include <iomanip> #include <ios> // std::left, std::right #include <iostream> #include <map> #include <queue> #include <set> #include <string> #define REP(i, n) for (ll i = 0; i < (ll)n; i++) #define INF 1000000000000000 using namespace std; typedef long long ll; typedef double db; typedef string str; typedef pair<ll, ll> p; int Cx, Cy, H; int get_height(int x, int y) { int tmp = H - abs(x - Cx) - abs(y - Cy); return max(tmp, 0); } int main() { int N; cin >> N; vector<vector<int>> pyramids(N, vector<int>(3, 0)); int hmax = 0; REP(i, N) { cin >> pyramids[i][0] >> pyramids[i][1] >> pyramids[i][2]; hmax = max(hmax, pyramids[i][2]); } for (H = hmax; H <= 10000000000; H++) { for (Cx = 0; Cx <= 100; Cx++) { for (Cy = 0; Cy <= 100; Cy++) { int count = 0; REP(i, N) { int px = pyramids[i][0]; int py = pyramids[i][1]; int pz = pyramids[i][2]; if (pz == get_height(px, py)) { count++; // cout<<"OJ"<<count<<endl; } } if (count == N) { cout << Cx << " " << Cy << " " << H << endl; return 0; } } } // cout<<"X"<<Cx<<"Y"<<Cy<<"H"<<H<<endl; } }
replace
25
27
25
31
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf("%d %d", &n, &m); int ans = 1; for (int i = 1; i <= m; ++i) { int x = i * (n - 1); if (x >= m) break; if ((m - x) % i == 0) ans = i; } return printf("%d", ans), 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf("%d %d", &n, &m); if (n == 1) return printf("%d", m), 0; int ans = 1; for (int i = 1; i <= m; ++i) { int x = i * (n - 1); if (x >= m) break; if ((m - x) % i == 0) ans = i; } return printf("%d", ans), 0; }
insert
7
7
7
9
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long unsigned int ll; // definition {{{ 1 // scaning {{{ 2 #define Scd(x) scanf("%d", &x) #define Scd2(x, y) scanf("%d%d", &x, &y) #define Scd3(x, y, z) scanf("%d%d%d", &x, &y, &z) #define Scll(x) scanf("%llu", &x) #define Scll2(x, y) scanf("%llu%llu", &x, &y) #define Scll3(x, y, z) scanf("%llu%llu%llu", &x, &y, &z) #define Scc(c) scanf("%c", &c); #define Scs(s) scanf("%s", s); #define Scstr(s) scanf("%s", &s); // }}} 2 // constants {{{ 2 #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) // }}} 2 // systems {{{ 2 #define Rep(x, y) for (int x = 0; x < y; x++) #define Repe(x, y, z) for (int x = z; x < y; x++) // }}} 2 // output {{{ 2 #define YesNo(a) (a) ? printf("Yes\n") : printf("No\n"); // }}} 2 // }}} 1 int main() { int n, m; Scd2(n, m); int ans = 0; for (int i = 1; i * n <= 1000000000; i++) { if (m % i == 0 && m / i >= n) { ans = i; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long unsigned int ll; // definition {{{ 1 // scaning {{{ 2 #define Scd(x) scanf("%d", &x) #define Scd2(x, y) scanf("%d%d", &x, &y) #define Scd3(x, y, z) scanf("%d%d%d", &x, &y, &z) #define Scll(x) scanf("%llu", &x) #define Scll2(x, y) scanf("%llu%llu", &x, &y) #define Scll3(x, y, z) scanf("%llu%llu%llu", &x, &y, &z) #define Scc(c) scanf("%c", &c); #define Scs(s) scanf("%s", s); #define Scstr(s) scanf("%s", &s); // }}} 2 // constants {{{ 2 #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) // }}} 2 // systems {{{ 2 #define Rep(x, y) for (int x = 0; x < y; x++) #define Repe(x, y, z) for (int x = z; x < y; x++) // }}} 2 // output {{{ 2 #define YesNo(a) (a) ? printf("Yes\n") : printf("No\n"); // }}} 2 // }}} 1 int main() { int n, m; Scd2(n, m); int ans = 0; if (n == 1) { printf("%d\n", m); return 0; } if (n == 2) { if (m % 2 == 0) { printf("%d\n", m / 2); return 0; } for (int i = 2; i * i <= 1000000000; i++) { if (m % i == 0 && m / i >= n) { ans = m / i; break; } } printf("%d\n", ans); return 0; } for (int i = 1; i * n <= 1000000000; i++) { if (m % i == 0 && m / i >= n) { ans = i; } } printf("%d\n", ans); return 0; }
insert
42
42
42
60
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; 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; } typedef long long int ll; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define MOD (1000000007) #define ALL(v) (v).begin(), (v).end() int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, m; cin >> n >> m; vector<ll> yakusu = divisor(m); ll ok = 0; ll ng = (int)yakusu.size() + 1; while (llabs(ok - ng) > 1) { ll mid = (ok + ng) / 2; ll tmp = m / yakusu[mid]; if (tmp >= n) { ok = mid; } else { ng = mid; } } cout << yakusu[ok] << endl; }
#include <bits/stdc++.h> using namespace std; 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; } typedef long long int ll; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define MOD (1000000007) #define ALL(v) (v).begin(), (v).end() int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, m; cin >> n >> m; vector<ll> yakusu = divisor(m); ll ok = 0; ll ng = (int)yakusu.size(); while (llabs(ok - ng) > 1) { ll mid = (ok + ng) / 2; ll tmp = m / yakusu[mid]; if (tmp >= n) { ok = mid; } else { ng = mid; } } cout << yakusu[ok] << endl; }
replace
46
47
46
47
0
p03241
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) int main() { int N, M; cin >> N >> M; vector<int> divisor; for (int i = 2; i * i <= M; i++) { if (M % i == 0) { divisor.push_back(i); if (i * i < M) divisor.push_back(M / i); } } sort(divisor.begin(), divisor.end()); cout << M / divisor[lower_bound(divisor.begin(), divisor.end(), N) - divisor.begin()] << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) int main() { int N, M; cin >> N >> M; vector<int> divisor; divisor.push_back(1); divisor.push_back(M); for (int i = 2; i * i <= M; i++) { if (M % i == 0) { divisor.push_back(i); if (i * i < M) divisor.push_back(M / i); } } sort(divisor.begin(), divisor.end()); cout << M / divisor[lower_bound(divisor.begin(), divisor.end(), N) - divisor.begin()] << endl; }
insert
9
9
9
11
0
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> using namespace std; typedef long long LL; LL n, m, p[100010], nump, ans; void getp() { p[0] = 2; for (int x = 3; x <= m; ++x) { bool succ = true; for (int j = 0; j < nump && succ; ++j) { if (x % p[j] == 0) succ = false; } if (succ) p[++nump] = x; } } int main() { cin >> n >> m; for (LL i = 1; i <= m; ++i) { if (m % i == 0 && i * n <= m) { ans = max(i, ans); } } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> using namespace std; typedef long long LL; LL n, m, p[100010], nump, ans; void getp() { p[0] = 2; for (int x = 3; x <= m; ++x) { bool succ = true; for (int j = 0; j < nump && succ; ++j) { if (x % p[j] == 0) succ = false; } if (succ) p[++nump] = x; } } int main() { cin >> n >> m; LL b = LL(sqrt(m)); for (LL i = 1; i <= b; ++i) { if (m % i == 0) { if (i * n <= m) ans = max(i, ans); LL ii = m / i; if (ii * n <= m) ans = max(ii, ans); } } cout << ans << endl; }
replace
31
34
31
40
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> const int INF = 1e9; const int MOD = 1e9 + 7; using LL = long long; const LL LINF = 1e18; const double EPS = 1e-10; using namespace std; #define COUT(v) cout << (v) << endl #define CIN(n) \ int(n); \ cin >> (n) #define LCIN(n) \ LL(n); \ cin >> (n) #define SCIN(n) \ string(n); \ cin >> (n) #define YES(n) cout << ((n) ? "YES" : "NO") << endl #define Yes(n) cout << ((n) ? "Yes" : "No") << endl #define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl #define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOREACH(x, a) for (auto &(x) : (a)) #define ALL(obj) (obj).begin(), (obj).end() #define P pair<LL, LL> #define I vector<int> #define pb(v) push_back(v) #define V vector #define rt return #define rmsame(a) sort(ALL(a)), a.erase(unique(ALL(a)), a.end()) #define ENDL cout << endl typedef string::const_iterator State; class PalseError {}; class Edge { public: int from, to, value; Edge(LL a, LL b, LL c) { from = a; to = b; value = c; } Edge(LL a, LL b) { from = a; to = b; } }; int main() { CIN(N); vector<vector<set<long>>> vec(101, vector<set<long>>(101)); for (int a = 0; a <= 100; a++) { for (int b = 0; b <= 100; b++) { vec.at(a).at(b).clear(); } } REP(i, N) { CIN(x); CIN(y); long h; cin >> h; if (h == 0L) { vec.at(x).at(y).insert(-1); continue; } for (int a = 0; a <= 100; a++) { for (int b = 0; b <= 100; b++) { long ans = h + abs(x - a) + abs(y - b); vec.at(a).at(b).insert(ans); } } } int ans = 0; for (int x = 0; x <= 100; x++) { for (int y = 0; y <= 100; y++) { if (vec.at(x).at(y).size() == 1) { long h; for (long i : vec.at(x).at(y)) { h = i; } if (h <= 0) continue; ans++; // cout<<x<<" "<<y<<" "<<h<<endl; if (ans >= 2) { return 1; } } } } return 0; }
#include <bits/stdc++.h> const int INF = 1e9; const int MOD = 1e9 + 7; using LL = long long; const LL LINF = 1e18; const double EPS = 1e-10; using namespace std; #define COUT(v) cout << (v) << endl #define CIN(n) \ int(n); \ cin >> (n) #define LCIN(n) \ LL(n); \ cin >> (n) #define SCIN(n) \ string(n); \ cin >> (n) #define YES(n) cout << ((n) ? "YES" : "NO") << endl #define Yes(n) cout << ((n) ? "Yes" : "No") << endl #define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl #define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOREACH(x, a) for (auto &(x) : (a)) #define ALL(obj) (obj).begin(), (obj).end() #define P pair<LL, LL> #define I vector<int> #define pb(v) push_back(v) #define V vector #define rt return #define rmsame(a) sort(ALL(a)), a.erase(unique(ALL(a)), a.end()) #define ENDL cout << endl typedef string::const_iterator State; class PalseError {}; class Edge { public: int from, to, value; Edge(LL a, LL b, LL c) { from = a; to = b; value = c; } Edge(LL a, LL b) { from = a; to = b; } }; int main() { CIN(N); CIN(M); for (int a = M / N; a >= 0; a--) { if (M % a == 0) { COUT(a); return 0; } } return 0; }
replace
55
94
55
60
1
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; // #define int long long // signed main(){ int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; int d = 1; int ans = 1; while (d <= m) { if (m % d == 0) { if (m / d >= n) ans = d; else break; } if (m < n * d) break; d++; } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; // #define int long long // signed main(){ int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; int d = 1; int ans = 1; if (n == 1) { cout << m << "\n"; return 0; } while (d <= m) { if (m % d == 0) { if (m / d >= n) ans = d; else break; } if (m < n * d) break; d++; } cout << ans << "\n"; return 0; }
insert
15
15
15
21
TLE
p03241
C++
Runtime Error
// Devarshi #include <bits/stdc++.h> using namespace std; #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define ll long long #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define rep(i, n) for (i = 0; i < n; i++) #define forn(i, n) for (ll i = 0; i < (ll)(n); ++i) #define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) #define ford(i, n) for (ll i = (ll)(n)-1; i >= 0; --i) #define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i) #define fora(it, x) for (auto it : x) #define PI 3.14159265 #define sync \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); typedef pair<ll, ll> pii; typedef vector<ll> vi; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef long long i64; typedef vector<i64> vi64; typedef vector<vi64> vvi64; typedef pair<i64, i64> pi64; typedef double ld; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } const int maxn = 1000001; bool isprime(int n) { int n1 = n; for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) { return false; } } // if(n1==n) return true; return true; } int main() { sync #ifndef ONLINE_JUDGE // for getting input from input.txt freopen("input.txt", "r", stdin); // for writing output to output.txt freopen("out.txt", "w", stdout); #endif int n, m; cin >> n >> m; if (m % n == 0) cout << m / n; else { // cout<<1<<endl; if (isprime(m)) cout << 1; else { int i = 1; int ans = 1; while (m - (n - 1) * i > 0) { int k = m - (n - 1) * i; if (k % i == 0) ans = i; i++; } cout << ans; } } return 0; }
// Devarshi #include <bits/stdc++.h> using namespace std; #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define ll long long #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define rep(i, n) for (i = 0; i < n; i++) #define forn(i, n) for (ll i = 0; i < (ll)(n); ++i) #define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) #define ford(i, n) for (ll i = (ll)(n)-1; i >= 0; --i) #define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i) #define fora(it, x) for (auto it : x) #define PI 3.14159265 #define sync \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); typedef pair<ll, ll> pii; typedef vector<ll> vi; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef long long i64; typedef vector<i64> vi64; typedef vector<vi64> vvi64; typedef pair<i64, i64> pi64; typedef double ld; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } const int maxn = 1000001; bool isprime(int n) { int n1 = n; for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) { return false; } } // if(n1==n) return true; return true; } int main() { sync /* #ifndef ONLINE_JUDGE // for getting input from input.txt freopen("input.txt", "r", stdin); // for writing output to output.txt freopen("out.txt", "w", stdout); #endif */ int n, m; cin >> n >> m; if (m % n == 0) cout << m / n; else { // cout<<1<<endl; if (isprime(m)) cout << 1; else { int i = 1; int ans = 1; while (m - (n - 1) * i > 0) { int k = m - (n - 1) * i; if (k % i == 0) ans = i; i++; } cout << ans; } } return 0; }
replace
54
63
54
64
0
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const ll LINF = 1e18; const int MOD = INF + 7; struct edge { int to, cost; }; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; int i = n; for (; i <= m; i++) { if (m % i == 0) break; } cout << m / i << "\n"; return 0; }
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const ll LINF = 1e18; const int MOD = INF + 7; struct edge { int to, cost; }; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; int i = n; if (m % 2 == 1) { if (n % 2 == 0) i++; for (; i <= m; i += 2) { if (m % i == 0) break; } } else { for (; i <= m; i++) { if (m % i == 0) break; } } cout << m / i << "\n"; return 0; }
replace
39
42
39
51
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> const int inf = 1e9 + 7; const int mod = 1e9 + 7; #define YES(i) cout << (i ? "YES" : "NO") << endl #define Yes(i) cout << (i ? "Yes" : "No") << endl using namespace std; // int main() { int N, M; cin >> N >> M; while (M % N != 0) { N++; } cout << M / N << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> const int inf = 1e9 + 7; const int mod = 1e9 + 7; #define YES(i) cout << (i ? "YES" : "NO") << endl #define Yes(i) cout << (i ? "Yes" : "No") << endl using namespace std; // int main() { int N, M; cin >> N >> M; bool f = true; for (int i = 2; i * i <= M; i++) { if (M % i == 0) { f = false; break; } } if (f) { if (N == 1) { cout << M << endl; } else { cout << 1 << endl; } return 0; } while (M % N != 0) { N++; } cout << M / N << endl; return 0; }
insert
22
22
22
37
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; vector<long> calc(long x) { vector<long> dat; for (int i = 1; i * i <= x; i++) { if (x % i == 0) dat.push_back(i); } return dat; } int main() { long n, m; cin >> n >> m; vector<long> dat = calc(m); // for (auto e : dat) { // cout << e << endl; // } long ans = 1; for (int i = 0; i < dat.size(); i++) { if (dat[i] <= m / n) { ans = max(ans, dat[i]); } if (dat[i] >= n) { ans = max(ans, m / i); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; vector<long> calc(long x) { vector<long> dat; for (int i = 1; i * i <= x; i++) { if (x % i == 0) dat.push_back(i); } return dat; } int main() { long n, m; cin >> n >> m; vector<long> dat = calc(m); // for (auto e : dat) { // cout << e << endl; // } long ans = 1; for (int i = 0; i < dat.size(); i++) { if (dat[i] <= m / n) { ans = max(ans, dat[i]); } if (dat[i] >= n) { ans = max(ans, m / dat[i]); } } cout << ans << endl; return 0; }
replace
25
26
25
26
0
p03241
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repR(i, n) for (int i = (n)-1; i > -1; i--) #define rep1(i, n) for (int i = 1; i < (int)(n + 1); i++) #define rep1R(i, n) for (int i = (n); i > 0; i--) typedef long long ll; typedef unsigned long long ull; using namespace std; int main() { int N, M; cin >> N >> M; vector<int> v; int D = 0; for (int i = 1; i < sqrt(M); i++) { if (M % i != 0) continue; int j = M / i; if (i <= M / N) v.push_back(i); if (j <= M / N) v.push_back(j); } cout << *max_element(v.begin(), v.end()) << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repR(i, n) for (int i = (n)-1; i > -1; i--) #define rep1(i, n) for (int i = 1; i < (int)(n + 1); i++) #define rep1R(i, n) for (int i = (n); i > 0; i--) typedef long long ll; typedef unsigned long long ull; using namespace std; int main() { int N, M; cin >> N >> M; vector<int> v; for (int i = 1; i <= (int)sqrt(M); i++) { if (M % i != 0) continue; int j = M / i; if (i <= M / N) v.push_back(i); if (j <= M / N) v.push_back(j); } cout << *max_element(v.begin(), v.end()) << endl; return 0; }
replace
16
18
16
17
0
p03241
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; for (int i = N; i <= M; i++) { if (M % i == 0) { cout << M / i << endl; return 0; } } }
#include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; for (int g = M / N; g > 0; g--) { if (M % g == 0) { cout << g << endl; return 0; } } }
replace
6
9
6
9
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, N) for (int i = 0; i < int(N); ++i) using ll = long long; const ll MOD = 1e9 + 7; const int INF = 1001001001; // const ll INF = 1000000000000000000LL; // 使い方 int main() { ll n, m; cin >> n >> m; ll ans = 1; for (int i = m; i > 1; i--) { if (m % i != 0) continue; if (i * n <= m) { ans = i; break; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, N) for (int i = 0; i < int(N); ++i) using ll = long long; const ll MOD = 1e9 + 7; const int INF = 1001001001; // const ll INF = 1000000000000000000LL; // 使い方 int main() { ll n, m; cin >> n >> m; ll ans = 1; for (int i = m / n; i > 1; i--) { if (m % i != 0) continue; if (i * n <= m) { ans = i; break; } } cout << ans << endl; return 0; }
replace
13
14
13
14
TLE
p03241
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int n, m, ans = 1; cin >> n >> m; for (int i = 2; n * i <= m; i++) { if ((m - n * i) % i == 0) { ans = i; } } cout << ans << endl; return 0; }
#include <iostream> using namespace std; int main() { int n, m, ans = 1; cin >> n >> m; if (n == 1) { ans = m; } else { for (int i = 2; n * i <= m; i++) { if ((m - n * i) % i == 0) { ans = i; } } } cout << ans << endl; return 0; }
replace
7
10
7
14
TLE
p03241
C++
Runtime Error
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; const int mod = 1000000007; #define ll long long int main() { int N; ll M; cin >> N >> M; vector<ll> X; for (int i = 1; i * i <= M; i++) { if (M % i == 0) { X.push_back(i); if (i * i != M) { X.push_back(M / i); } } } sort(X.begin(), X.end()); ll ans = 0; int j = 0; while (X[j] * N <= M) { ans = X[j]; j++; } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; const int mod = 1000000007; #define ll long long int main() { int N; ll M; cin >> N >> M; vector<ll> X; for (int i = 1; i * i <= M; i++) { if (M % i == 0) { X.push_back(i); if (i * i != M) { X.push_back(M / i); } } } sort(X.begin(), X.end()); ll ans = 0; int j = 0; while (X[j] * N <= M) { ans = X[j]; j++; if (j == X.size()) { break; } } cout << ans << endl; }
insert
30
30
30
33
0
p03241
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) #define all(a) (a).begin(), (a).end() #define dunk(a) cout << (a) << endl #define rall(a) (a).rbegin(), (a).rend() const int INF = 2e9; using namespace std; using Graph = vector<vector<int>>; typedef pair<int, int> P; typedef long long ll; int main() { ll n, m; cin >> n >> m; vector<ll> cd(1002003004, -1); ll it = 0; ll num = 1; while (num * num <= m) { if (m % num == 0) { cd[it] = num; it++; if (num != m / num) { cd[it] = m / num; it++; } } num++; } ll ans = 1; rep(i, it) { if (cd[i] * n <= m) { ans = max(ans, cd[i]); } } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) #define all(a) (a).begin(), (a).end() #define dunk(a) cout << (a) << endl #define rall(a) (a).rbegin(), (a).rend() const int INF = 2e9; using namespace std; using Graph = vector<vector<int>>; typedef pair<int, int> P; typedef long long ll; int main() { ll n, m; cin >> n >> m; vector<ll> cd(1002003, -1); ll it = 0; ll num = 1; while (num * num <= m) { if (m % num == 0) { cd[it] = num; it++; if (num != m / num) { cd[it] = m / num; it++; } } num++; } ll ans = 1; rep(i, it) { if (cd[i] * n <= m) { ans = max(ans, cd[i]); } } cout << ans << endl; }
replace
15
16
15
16
-6
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
p03241
Python
Runtime Error
import math N, M = map(int, input().split()) d = max(d for d in range(1, math.ceil(M / (N - 1))) if M % d == 0) print(d)
import math N, M = map(int, input().split()) if N == 1: print(M) else: d = max(d for d in range(1, math.ceil(M / (N - 1))) if M % d == 0) print(d)
replace
4
6
4
9
0
p03241
Python
Time Limit Exceeded
n, m = [int(_) for _ in input().split(" ")] print(max([i for i in range(1, m // n + 1) if m % i == 0]))
n, m = [int(_) for _ in input().split(" ")] ds = [i for i in range(1, int(m**0.5) + 1) if m % i == 0] ds.extend([m // i for i in ds]) print(max([i for i in ds if i <= m // n]))
replace
1
2
1
5
TLE
p03241
Python
Time Limit Exceeded
N, M = map(int, input().split()) ceil = M / N tmp = 1 mx = 0 while ceil >= tmp: if (M - tmp * (N - 1)) % tmp == 0: mx = tmp tmp += 1 print(mx)
N, M = map(int, input().split()) ceil = M // N for i in range(1, ceil + 1)[::-1]: tmp = M - i * (N - 1) if tmp > 0 and tmp % i == 0: print(i) break
replace
1
10
1
7
TLE
p03241
Python
Time Limit Exceeded
N, M = map(int, input().split()) print(max(d for d in range(1, M // N + 1) if M % d == 0))
N, M = map(int, input().split()) print(next(d for d in reversed(range(M // N + 1)) if M % d == 0))
replace
1
2
1
2
TLE
p03241
Python
Time Limit Exceeded
# https://atcoder.jp/contests/abc112/tasks/abc112_d n, m = map(int, input().split()) ans = 1 i = 1 limit = m / n while i <= limit: if m % i == 0 and m // i >= n: ans = max(ans, i) i += 1 print(ans)
# https://atcoder.jp/contests/abc112/tasks/abc112_d n, m = map(int, input().split()) if n == 1: ans = m else: ans = 1 i = 1 limit = m / n while i <= limit: if m % i == 0 and m // i >= n: ans = max(ans, i) i += 1 print(ans)
replace
3
10
3
13
TLE
p03241
C++
Time Limit Exceeded
#include <assert.h> #include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int ans = 1; for (int i = 1; i <= m; i++) if (m % i == 0 && m / i >= n) ans = i; cout << ans << endl; return 0; }
#include <assert.h> #include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; for (int i = m / n; i > 0; i--) if (m % i == 0 && m / i >= n) { cout << i << endl; return 0; } return 0; }
replace
8
13
8
13
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; int a, ans = 1; a = m / n; for (size_t i = 1; i < a + 1; i++) { if (m % i == 0) { if (ans < i) { ans = i; } } } cout << ans << endl; }
#include <algorithm> #include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; int a, ans = 1; a = m / n; if (m % n == 0) { cout << m / n << endl; return 0; } for (size_t i = 1; i < a + 1; i++) { if (m % i == 0) { if (ans < i) { ans = i; } } } cout << ans << endl; }
insert
8
8
8
12
TLE
p03241
Python
Runtime Error
N, M = map(int, input().split()) # 項数N, Aの和M ans = 1 if N == 1: print(M) exit() for i in range(1000000): if (M >= N * i) and (M % i == 0): ans = i print(ans)
N, M = map(int, input().split()) # 項数N, Aの和M ans = 1 for i in range(1, int(M ** (1 / 2)) + 1): if M % i != 0: continue j = M // i # jはどんどん小さくなる if j >= N: ans = max(ans, i) if i >= N: ans = max(ans, j) print(ans)
replace
3
11
3
11
ZeroDivisionError: integer division or modulo by zero
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03241/Python/s190829031.py", line 10, in <module> if (M >= N * i) and (M % i == 0): ZeroDivisionError: integer division or modulo by zero
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define MAX_N 100000 #define MAX_M 1000000000 typedef long long int ll; int main() { int n; ll m; std::cin >> n >> m; int ans = 1, tmp = 2; while (n * tmp <= m) { if (m % tmp == 0) ans = tmp; ++tmp; } std::cout << ans << std::endl; }
#include <bits/stdc++.h> #define MAX_N 100000 #define MAX_M 1000000000 typedef long long int ll; int main() { int n; ll m; std::cin >> n >> m; if (n == 1) { std::cout << m << std::endl; return 0; } ll ans = 1, tmp = 2; while (tmp * tmp <= m) { if (n * tmp > m) break; if (m % tmp == 0) { ans = std::max(ans, tmp); if (n * m / tmp <= m) { ans = std::max(ans, m / tmp); } } ++tmp; } std::cout << ans << std::endl; }
replace
12
16
12
27
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; int main() { int n, m; cin >> n >> m; int ans = 1; for (int i = 2; i <= m / n; i++) { if (!(m % i)) ans = i; } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; int main() { int n, m; cin >> n >> m; int ans = 1; if (n == 1) { cout << m << endl; return 0; } for (int i = 2; i <= m / n; i++) { if (!(m % i)) ans = i; } cout << ans << endl; return 0; }
insert
22
22
22
26
TLE
p03241
C++
Runtime Error
#include <algorithm> #include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; int s; if (m % n == 0) s = m / n; else { int s1 = m / n; s = s1 - 1; while ((m - (n - 1) * s) % s != 0) s--; } cout << s; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; int s; if (m % n == 0) s = m / n; else { s = m / (n + 1); while ((m - (n - 1) * s) % s != 0) s--; } cout << s; return 0; }
replace
10
12
10
11
0
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <bits/stdc++.h> #include <functional> #include <iostream> #include <math.h> #include <string> using namespace std; typedef long long ll; #define pb pushback #define fr(i, n) for (int i = 0; i < n; i++) #define fro(i, j, n) for (int i = j; i < n; i++) #define ifr(i, n) for (int i = n - 1; i >= 0; i--) int main() { int n, m; cin >> n >> m; int ans = 1; fro(i, n, m) { if (m % i == 0) { ans = m / i; break; } } cout << ans << endl; }
#include <algorithm> #include <bits/stdc++.h> #include <functional> #include <iostream> #include <math.h> #include <string> using namespace std; typedef long long ll; #define pb pushback #define fr(i, n) for (int i = 0; i < n; i++) #define fro(i, j, n) for (int i = j; i < n; i++) #define ifr(i, n) for (int i = n - 1; i >= 0; i--) int main() { int n, m; cin >> n >> m; int ans = 1; fro(i, n, m / 2 + 1) { if (m % i == 0) { ans = m / i; break; } } cout << ans << endl; }
replace
17
18
17
18
TLE
p03241
C++
Runtime Error
/* Simplicity and Goodness */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; void my_dbg() { cout << endl; } template <typename Arg, typename... Args> void my_dbg(Arg A, Args... B) { cout << ' ' << A; my_dbg(B...); } #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__) #define scn(n) scanf("%d", &n) #define lscn(n) scanf("%lld", &n) #define pri(n) printf("%d ", (int)(n)) #define prin(n) printf("%d\n", (int)(n)) #define lpri(n) printf("%lld ", n) #define lprin(n) printf("%lld\n", n) #define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define pb push_back #define mp make_pair #define F first #define S second using ll = long long; using vi = vector<int>; using vl = vector<ll>; const int inf = INT_MAX; const int ninf = INT_MIN; const int mod = 1e9 + 7; const int N = 2e5 + 2; void solve() { ll n, m; lscn(n); lscn(m); ll g = 1; for (ll i = 1; i * i <= m; i++) { if (m % i == 0) { if ((i * n <= m) and ((m - (i * n)) % i == 0)) g = max(g, i); ll d2 = n / i; if (((d2 * n) <= m) and ((m - (d2 * n)) % d2 == 0)) g = max(g, d2); } } lprin(g); } int main() { int t = 1; // scn(t); while (t--) { solve(); } return 0; }
/* Simplicity and Goodness */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; void my_dbg() { cout << endl; } template <typename Arg, typename... Args> void my_dbg(Arg A, Args... B) { cout << ' ' << A; my_dbg(B...); } #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__) #define scn(n) scanf("%d", &n) #define lscn(n) scanf("%lld", &n) #define pri(n) printf("%d ", (int)(n)) #define prin(n) printf("%d\n", (int)(n)) #define lpri(n) printf("%lld ", n) #define lprin(n) printf("%lld\n", n) #define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define pb push_back #define mp make_pair #define F first #define S second using ll = long long; using vi = vector<int>; using vl = vector<ll>; const int inf = INT_MAX; const int ninf = INT_MIN; const int mod = 1e9 + 7; const int N = 2e5 + 2; void solve() { ll n, m; lscn(n); lscn(m); ll g = 1; for (ll i = 1; i * i <= m; i++) { if (m % i == 0) { if ((i * n <= m) and ((m - (i * n)) % i == 0)) g = max(g, i); ll d2 = m / i; if (((d2 * n) <= m) and ((m - (d2 * n)) % d2 == 0)) g = max(g, d2); } } lprin(g); } int main() { int t = 1; // scn(t); while (t--) { solve(); } return 0; }
replace
52
53
52
53
0
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) #define int long long using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2; #define fi first #define se second int dx[] = {0, 1, 0, -1}; int dy[] = {-1, 0, 1, 0}; signed main() { int n, m; cin >> n >> m; for (int i = 450000000; i >= 1; i--) { if (i * (n - 1) >= m) continue; int x = i * (n - 1); int p = m - x; if (__gcd(p, i) == i) { cout << i << endl; return 0; } } }
#include <bits/stdc++.h> #define r(i, n) for (int i = 0; i < n; i++) #define int long long using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2; #define fi first #define se second int dx[] = {0, 1, 0, -1}; int dy[] = {-1, 0, 1, 0}; signed main() { int n, m; cin >> n >> m; vector<int> v; for (int i = 1; i * i <= m; i++) { if (m % i) continue; v.push_back(i); if (i * i != m) v.push_back(m / i); } sort(v.begin(), v.end(), greater<int>()); for (int j = 0; j < v.size(); j++) { int i = v[j]; // cout<<i<<endl; if (i * (n - 1) >= m) continue; int x = i * (n - 1); int p = m - x; if (__gcd(p, i) == i) { cout << i << endl; return 0; } } }
replace
14
15
14
28
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++) #define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--) #define rep(i, n) FOR(i, 0, n) #define repall(i, arr) for (auto &i : (arr)) #define all(x) (x).begin(), (x).end() #define pb push_back #define dump(x) cerr << #x << " = " << (x) << '\n' template <typename T> void print(const vector<vector<T>> matrix); template <typename T> void print(const vector<T> vec); template <typename Arg> void print(const Arg arg); template <typename Head, typename... Args> void print(const Head head, const Args... args); template <typename T> using pq = priority_queue<T>; template <typename T> using pqr = priority_queue<T, vector<T>, greater<T>>; const int INF = INT_MAX / 2; using ll = long long; int main() { int n, m; cin >> n >> m; int max = m / n; for (int i = 1; i <= m; i++) { if (m % i == 0 and m / i <= max) { print(m / i); break; } } return 0; } //--------------------------------------------- template <typename T> void print(const vector<vector<T>> matrix) { repall(vec, matrix) print(vec); } template <typename T> void print(const vector<T> vec) { unsigned int len = vec.size(); rep(i, len - 1) cout << vec[i] << ' '; cout << vec[len - 1] << '\n'; } template <typename Arg> void print(const Arg arg) { cout << arg << '\n'; } template <typename Head, typename... Args> void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++) #define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--) #define rep(i, n) FOR(i, 0, n) #define repall(i, arr) for (auto &i : (arr)) #define all(x) (x).begin(), (x).end() #define pb push_back #define dump(x) cerr << #x << " = " << (x) << '\n' template <typename T> void print(const vector<vector<T>> matrix); template <typename T> void print(const vector<T> vec); template <typename Arg> void print(const Arg arg); template <typename Head, typename... Args> void print(const Head head, const Args... args); template <typename T> using pq = priority_queue<T>; template <typename T> using pqr = priority_queue<T, vector<T>, greater<T>>; const int INF = INT_MAX / 2; using ll = long long; int main() { int n, m; cin >> n >> m; int max = m / n; for (int i = max; i >= 1; i--) { if (m % i == 0) { print(i); break; } } return 0; } //--------------------------------------------- template <typename T> void print(const vector<vector<T>> matrix) { repall(vec, matrix) print(vec); } template <typename T> void print(const vector<T> vec) { unsigned int len = vec.size(); rep(i, len - 1) cout << vec[i] << ' '; cout << vec[len - 1] << '\n'; } template <typename Arg> void print(const Arg arg) { cout << arg << '\n'; } template <typename Head, typename... Args> void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
replace
25
28
25
28
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, b) for (i = 0; i < b; ++i) #define repp(i, a, b) for (i = a; i < b; ++i) #define per(i, n) for (i = n - 1; i >= 0; i--) #define endl "\n" #define pb push_back typedef long long int lli; const lli mod = 1000000007; typedef vector<lli> vi; typedef pair<lli, lli> pi; #define mp make_pair #define pb push_back int main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); lli n, t, i, k, j, f, g, m; string s; vi v; map<lli, lli> mm; map<lli, lli>::iterator it; cin >> n >> m; g = m / n; per(i, g) { if (m % i == 0) { cout << i << endl; break; } } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, b) for (i = 0; i < b; ++i) #define repp(i, a, b) for (i = a; i < b; ++i) #define per(i, n) for (i = n - 1; i >= 0; i--) #define endl "\n" #define pb push_back typedef long long int lli; const lli mod = 1000000007; typedef vector<lli> vi; typedef pair<lli, lli> pi; #define mp make_pair #define pb push_back int main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); lli n, t, i, k, j, f, g, m; string s; vi v; map<lli, lli> mm; map<lli, lli>::iterator it; cin >> n >> m; g = m / n; for (i = g; i > 0; i--) { if (m % i == 0) { cout << i << endl; break; } } return 0; }
replace
23
24
23
24
0
p03241
C++
Time Limit Exceeded
#include <iostream> // #include <iomanip> // #include <algorithm> // #include <numeric> // #include <queue> // #include <stack> #include <math.h> // #include <vector> // #include <string> typedef long long LL; using namespace std; int main() { LL n; LL m; LL ans; LL ans_l = 1; LL ans_h; LL tmp; cin >> n >> m; ans_h = m; tmp = (LL)sqrt(m); if (m / n < tmp) { tmp = m / n; } for (int i = 2; i <= tmp; i++) { if (m % i == 0 && i > ans_l) { ans_l = i; } } tmp = (LL)sqrt(m); if (m / n > tmp) { tmp = m / n; } if (tmp >= n) { for (int i = n; i <= tmp; i++) { if (m % i == 0 && i < ans_h) { ans_h = i; } } } ans_h = m / ans_h; ans = max(ans_l, ans_h); cout << ans << endl; }
#include <iostream> // #include <iomanip> // #include <algorithm> // #include <numeric> // #include <queue> // #include <stack> #include <math.h> // #include <vector> // #include <string> typedef long long LL; using namespace std; int main() { LL n; LL m; LL ans; LL ans_l = 1; LL ans_h; LL tmp; cin >> n >> m; ans_h = m; tmp = (LL)sqrt(m); if (m / n < tmp) { tmp = m / n; } for (int i = 2; i <= tmp; i++) { if (m % i == 0 && i > ans_l) { ans_l = i; } } tmp = (LL)sqrt(m); if (tmp >= n) { for (int i = n; i <= tmp; i++) { if (m % i == 0 && i < ans_h) { ans_h = i; } } } ans_h = m / ans_h; ans = max(ans_l, ans_h); cout << ans << endl; }
delete
32
35
32
32
TLE