code
stringlengths
1
983k
submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
user_id
stringlengths
10
10
date
stringlengths
10
10
language
class label
13 classes
original_language
stringlengths
1
39
filename_ext
stringlengths
1
8
status
class label
1 class
cpu_time
int32
0
40k
memory
int32
0
2.59M
code_size
int32
1
983k
accuracy
stringlengths
3
7
#include <bits/stdc++.h> #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)(n);++i) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i) #define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i) #define each(a,b) for(auto& (a): (b)) #define all(v) (v).begin(),(v).end() #define len(v) (int)(v).size() #define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) #define cmx(x,y) x=max(x,y) #define cmn(x,y) x=min(x,y) #define fi first #define se second #define pb push_back #define show(x) cout<<#x<<" = "<<(x)<<endl #define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl #define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl #define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl #define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl #define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl #define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl using namespace std; typedef pair<int,int> P; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<double> vd; typedef vector<P> vp; typedef vector<string> vs; const int MAX_N = 100005; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vi x(n),y(n),h(n); rep(i,n){ cin >> x[i] >> y[i] >> h[i]; } rep(i,101){ rep(j,101){ bool flag = true; ll hh = -1; rep(k,n){ if(h[k] == 0) continue; if(hh < 0){ hh = abs(x[k]-i)+abs(y[k]-j)+h[k]; }else if(hh != abs(x[k]-i)+abs(y[k]-j)+h[k]){ flag = false; break; } } if(flag){ rep(k,n){ if(h[k] > 0) continue; if(hh-abs(x[k]-i)-abs(y[k]-j) > 0){ flag = false; break; } } if(flag){ cout << i << " " << j << " " << hh << "\n"; return 0; } } } } return 0; }
s647832254
p03240
u509674552
1538875027
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
2
256
2,358
null
#include <stdio.h> #include <stdlib.h> int ABS(int a){ return a >= 0 ? a : -a; } int max(int a, int b){ return a >= b ? a : b; } int main(){ int N, i, Cx, Cy, H, f; scanf("%d", &N); int *x = (int *)malloc(sizeof(int) * N); int *y = (int *)malloc(sizeof(int) * N); int *h = (int *)malloc(sizeof(int) * N); for(i = 0; i < N; i++){ scanf("%d%d%d", &x[i], &y[i], &h[i]); } for(Cx = 0; Cx <= 100; Cx++){ for(Cy = 0; Cy <= 100; Cy++){ for(i = 0; h[i] == 0; i++); H = h[i] + ABS(x[i] - Cx) + ABS(y[i] - Cy); for(i = 0, f = 1; i < N; i++){ if(h[i] != max(H - ABS(x[i] - Cx) - ABS(y[i] - Cy), 0)){ f = 0; break; } } if(f == 1){ printf("%d %d %d\n", Cx, Cy, H); return 0; } } } }
s033584845
p03240
u208608367
1538875025
1C
C (GCC 5.4.1)
c
0Accepted
1
128
733
null
// in the name of Allah #include <bits/stdc++.h> #define endl '\n' #define ll long long #define pb push_back #define ld long double #define sz(x) ((int) (x.size())) #define max_n 123456 #define mod 1000000007 // #define mod 998244353 #define myPrime 97654321 #define inf 1e9 #define eps 1e-9 #define fr first #define se second using namespace std; ll add(ll a, ll b) { a += b; if(a >= mod) return a - mod; return a; } ll mul(ll a, ll b) { a *= b; if(a >= mod) return a % mod; return a; } ll power(ll x, ll y) { if(y == 0) return 1; ll foo = power(x, y/2); foo = mul(foo, foo); if(y&1) return mul(x, foo); return foo; } int n; ll x[123]; ll y[123]; ll h[123]; int main() { // ll start_time = clock(); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // cout << fixed << setprecision(12); cin >> n; for(int i=0; i<n; i++) cin >> x[i] >> y[i] >> h[i]; for(ll X=0; X<=100; X++) { for(ll Y=0; Y<=100; Y++) { bool f = 1; ll H = 1e18; set <ll> Hst; for(int i=0; i<n; i++) { ll len = abs(X - x[i]) + abs(Y - y[i]); if(h[i] > 0) Hst.insert(h[i] + len); else H = min(H, len); if(sz(Hst) > 1) { f = 0; break; } } if(f) { if(sz(Hst) == 0) { if(H > 0) { cout << X << " " << Y << " " << *Hst.begin() << endl; return 0; } } else if(H >= *Hst.begin()) { cout << X << " " << Y << " " << *Hst.begin() << endl; return 0; } } } } return 0; } // sorted or not // mutiset vs set // clear when it's multi-testcase
s421884361
p03240
u812771098
1538875025
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
5
256
1,524
null
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <random> using namespace std; typedef long long int ll; typedef pair<int, int> P; int main() { int n; cin>>n; int x[100], y[100], h[100]; int i0; for(int i=0; i<n; i++){ cin>>x[i]>>y[i]>>h[i]; if(h[i]>0) i0=i; } for(int cx=0; cx<=100; cx++){ for(int cy=0; cy<=100; cy++){ int H=h[i0]+abs(x[i0]-cx)+abs(y[i0]-cy); bool nuee=0; for(int i=0; i<n; i++){ if(max(0, H-abs(x[i]-cx)-abs(y[i]-cy))!=h[i]){ nuee=1; break; } } if(!nuee){ cout<<cx<<" "<<cy<<" "<<H<<endl; return 0; } } } return 0; }
s025026122
p03240
u930898631
1538875016
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
1
256
815
null
#include<bits/stdc++.h> #include<random> using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; #define MOD 1000000007LL #define INF 1000000000LL #define EPS 1e-10 #define FOR(i,n,m) for(ll i=n;i<(ll)m;i++) #define REP(i,n) FOR(i,0,n) #define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;} #define ALL(v) v.begin(),v.end() #define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end()); #define pb push_back int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; cin>>N; vector<ll> x(N); vector<ll> y(N); vector<ll> h(N); REP(i,N) cin>>x[i]>>y[i]>>h[i]; FOR(cx,0,101) FOR(cy,0,101) { set<ll> s; ll mini=INF*INF; REP(i,N) { ll dist=abs(x[i]-cx)+abs(y[i]-cy); if(h[i]==0) { mini=min(dist,mini); continue; } s.insert(dist+h[i]); } if(s.size()==1&&*s.begin()<=mini) { cout<<cx<<" "<<cy<<" "<<*s.begin()<<endl; return 0; } else if(s.size()==0) { if(mini>0) { cout<<cx<<" "<<cy<<" "<<mini<<endl; return 0; } } } return 0; }
s866417992
p03240
u607034173
1538875010
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
47
256
1,050
null
#include <bits/stdc++.h> using namespace std; #define int long long #define stoi stoll using ll=long long; using vi=vector<int>; using pii=pair<int,int>; #define ALL(c) begin(c),end(c) #define RALL(c) rbegin(c),rend(c) #define ITR(i,b,e) for(auto i=(b);i!=(e);++i) #define FORE(x,c) for(auto &x:c) #define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i) #define REP(i,n) REPF(i,0,n) #define REPR(i,n) for(int i=(int)(n);i>=0;--i) #define SZ(c) ((int)c.size()) #define CONTAIN(c,x) (c.find(x)!=end(c)) #define INSEG(l,x,r) ((l)<=(x)&&(x)<(r)) #define dump(...) #define pb push_back #define _ 0 const signed INF_=1001001001; const long long INF=1001001001001001001LL; const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0}; template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":"\n");return os;} template<class T> istream& operator>>(istream &is,vector<T> &v) { ITR(i,begin(v),end(v)) is>>*i;return is;} template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) { is>>p.first>>p.second;return is;} template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;} template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;} template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));} template<class T> using heap=priority_queue<T,vector<T>,greater<T>>; struct before_main_function { before_main_function() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(15) << fixed; // #define endl "\n" } } before_main_function; //------------------8<------------------------------------8<-------------------- signed main() { int N; cin >> N; vector<vi> a(N); REP(i, N) { int x, y, h; cin >> x >> y >> h; a[i] = {h, x, y}; } sort(RALL(a)); auto dist = [](int x1, int y1, int x2, int y2) { return abs(x1 - x2) + abs(y1 - y2); }; REP(x, 101) { REP(y, 101) { int h = -1; bool ok = true; REP(k, N) { int d = dist(a[k][1], a[k][2], x, y); if (h == -1) { h = d + a[k][0]; } if (max(h - d, 0LL) != a[k][0]) { ok = false; continue; } } if (ok) { cout << x << " " << y << " " << h << endl; return 0; } } } return (0^_^0); }
s951848566
p03240
u133129810
1538875003
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
256
2,545
null
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int,int> ii; const int N = 1e5 + 5; int n,x[N],y[N],h[N]; int geth(int cx,int cy) { int res = -1,mx = -1; for (int i = 1 ; i <= n ; i++) { int a = abs(cx - x[i]); int b = abs(cy - y[i]); if (res == -1) { if (h[i] == 0) { mx = max(mx,a + b); } else { res = a + b + h[i]; } } else { if (max(res - a - b,0) != h[i]) return -1; } } if (mx != -1 && res > mx) return -1; return res; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1 ; i <= n ; i++) cin >> x[i] >> y[i] >> h[i]; for (int cx = 0 ; cx <= 100 ; cx++) for (int cy = 0 ; cy <= 100 ; cy++) { int temp = geth(cx,cy); if (temp != -1) { cout << cx << " " << cy << " " << temp << endl; return 0; } } }
s977629154
p03240
u445860050
1538875002
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
256
924
null
#include <bits/stdc++.h> #define rep(i, a, n) for(int i = a; i < n; i++) #define repr(i, a, b) for(int i = a; i >= b; i--) #define int long long #define all(a) a.begin(), a.end() #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) using namespace std; typedef pair<int, int> P; const int mod = 1000000007; const int INF = 1e15; signed main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> x(n), y(n), h(n); rep(i, 0, n){ cin >> x[i] >> y[i] >> h[i]; } rep(i, 0, 101){ rep(j, 0, 101){ int H = INF; rep(k, 0, n){ int tmp = abs(x[k] - i) + abs(y[k] - j); int tmph = h[k] + tmp; chmin(H, tmph); } bool f = true; rep(k, 0, n){ int tmp = abs(x[k] - i) + abs(y[k] - j); int tmph = max(H - tmp, 0LL); if(tmph != h[k]){ f = false; break; } } if(f){ cout << i << ' ' << j << ' ' << H << endl; return 0; } } } }
s366665670
p03240
u984730891
1538874993
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
6
256
1,164
null
#include <bits/stdc++.h> #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define llong long long #define pb(a) push_back(a) #define INF 999999999 #define MOD 1000000007 using namespace std; typedef pair<int, int> P; typedef pair<llong, llong> LP; typedef pair<int, P> PP; typedef pair<llong, LP> LPP; int iy[]={0, 0, 1, -1}; int ix[]={1, -1, 0, 0}; long long int n, x[101], y[101], h[101], cx, cy, ch, hh, hm; int main(){ cin >> n; for(int i=0;i<n;i++){ cin >> x[i] >> y[i] >> h[i]; } for(int i=0;i<=100;i++){ for(int j=0;j<=100;j++){ hh = 0; hm = 1e+9 + 2000; for(int k=0;k<n;k++){ if(h[k]==0){ hm = min(hm, abs(x[k]-i) + abs(y[k]-j)); }else{ if(hh==0) hh = h[k] + abs(x[k]-i) + abs(y[k]-j); if(hh!=0&&hh!=h[k] + abs(x[k]-i) + abs(y[k]-j)) break; } if(k==n-1&&hh<=hm){ cx = i; cy = j; ch = hh; } } } } cout << cx << " " << cy << " " << ch << endl; return 0; }
s582048874
p03240
u420071596
1538874991
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
256
969
null
#include <iostream> using namespace std; int main(void){ int n; cin >> n; int x[100], y[100], h[100]; int not_zero; int i; for(i = 0; i < n; i++){ cin >> x[i] >> y[i] >> h[i]; if(h[i] != 0){ not_zero = i; } } bool flag; int cx, cy, ans_h; for(cx = 0; cx <= 100; cx++){ for(cy = 0; cy <= 100; cy++){ ans_h = h[not_zero] + abs(x[not_zero] - cx) + abs(y[not_zero] - cy); flag = true; for(i = 0; i < n; i++){ if(h[i] != max(ans_h - (abs(x[i] - cx) + abs(y[i] - cy)), 0)){ flag = false; } } if(flag == true){ printf("%d %d %d\n", cx, cy, ans_h); return 0; } } } return 0; }
s746334951
p03240
u178152729
1538874991
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
256
854
null
#include<bits/stdc++.h> using namespace std; int main() { int n,ans; cin >> n; int x[n],y[n],h[n]; for (int i = 0;i < n;++i) cin >> x[i] >> y[i] >> h[i]; for (int i = 0;i <= 100;++i) { for (int j = 0;j <= 100;++j) { bool f = true; for (int k = 0;k < n;++k) { if (h[k]) { ans = h[k]+abs(x[k]-i)+abs(y[k]-j); break; } } for (int k = 0;k < n;++k) { if (max(0,ans-abs(x[k]-i)-abs(y[k]-j)) != h[k]) { f = false; break; } } if (f) { cout << i << " " << j << " " << ans << endl; exit(0); } } } return 0; }
s212577635
p03240
u506255180
1538874987
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
2
256
576
null
#include<iostream> #include <vector> #include <list> #include<stack> #include<queue> #include<array> #include <set> #include<map> #include<string> #include<stdlib.h> #include<algorithm> #include <functional> #include<math.h> #include<fstream> #include<iomanip> using namespace std; using ll = long long; using ld = long double; using pii = pair<int,int>; #define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++) #define REP(i,n) FOR((i),0,(n)) #define WAITING(str) int str;std::cin>>str; #define DEBUGING(str) cout<<str<<endl constexpr int INF = (1 << 30); constexpr ll INFL = (1ll << 60); constexpr ll MOD = 1000000007;// 10^9+7 constexpr ll nil = -1; //変数 int N; vector<ll> xs, ys, hs; //サブ関数 //入力 void input() { cin >> N; xs.resize(N); ys.resize(N); hs.resize(N); REP(i, N) { cin >> xs[i] >> ys[i] >> hs[i]; } } bool judge(ll cx, ll cy, ll h) { REP(i, N) { if (max(h - abs(xs[i] - cx) - abs(ys[i]- cy), 0ll) != hs[i]) { return false; } } return true; } //計算 void calc() { ll minh = *max_element(hs.begin(), hs.end()); while (true) { REP(x, 101)REP(y, 101) { if (judge(x, y, minh)) { cout << x << " " << y << " " << minh << endl; return; } } minh++; } } //出力 void output() { } //デバッグ void debug() { int N; cin>>N; } //メイン関数 int main() { input(); calc(); output(); debug(); return 0; }
s103105889
p03240
u692632484
1538874983
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
6
256
1,396
null
#include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<complex> #include<bitset> #include<stack> #include<unordered_map> using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; const ll INF = (ll)1000000007 * 1000000007; typedef pair<int, int> P; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef long double ld; typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<ll, ll> LP; typedef pair<ld, ld> LDP; struct high { int x, y, h; }; high t[100]; int main() { int n; cin >> n; ll mi = INF; rep(i, n) { int x, y;ll h; cin >> x >> y >> h; t[i] = { x,y,h }; mi = min(mi, h); } for (int i = 0; i <= 100; i++) { for (int j = 0; j <= 100; j++) { for (ll k = mi; k <= mi + 200; k++) { bool f = true; rep(l, n) { int z = t[l].h + abs(t[l].x - i) + abs(t[l].y - j); if (t[l].h + abs(t[l].x - i) + abs(t[l].y - j) != k) { if (t[l].h != 0 || z < k) { f = false; break; } } } if (f) { cout << i << " " << j << " " << k << endl; } } } } return 0; }
s604277863
p03240
u294531924
1538874977
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
202
256
1,509
null
#include <bits/stdc++.h> #include <boost/multiprecision/cpp_int.hpp> using namespace std; using namespace boost::multiprecision; // Define using ll = long long; using ull = unsigned long long; using ld = long double; using int128 = __int128; using cint = cpp_int; const ll MOD = 1e9 + 7; const ll INF = LONG_MAX; const ull MAX = ULONG_MAX; #define endl '\n' #define space ' ' #define def inline auto #define func inline constexpr ll #define run __attribute__((constructor)) def _ #define all(v) begin(v), end(v) // Debug #define debug(...) \ { \ cerr << __LINE__ << ": " << #__VA_ARGS__ << " = "; \ for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] "; \ cerr << endl; \ } // Loop #define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i) #define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i) #define each(i, a) for (auto &&i : a) #define rep(i, n) inc(i, 0, n - 1) // Stream #define input(a) scanf("%lld", &(a)) #define output(a) printf("%lld\n", (a)) #define fout(n) cout << fixed << setprecision(n) #define fasten cin.tie(0), ios::sync_with_stdio(0) // Speed run() { fasten, fout(10); } #pragma GCC optimize("-O3") #pragma GCC target("avx") // Math func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } func lcm(ll a, ll b) { return a * b / gcd(a, b); } signed main() { ll N; cin >> N; vector<ll> X, Y, H; rep(i, N) { ll A, B, C; cin >> A >> B >> C; X.push_back(A), Y.push_back(B), H.push_back(C); } rep(CX, 101) rep(CY, 101) { ll H1; bool check = 1; rep(i, N) { if (H[i]) { H1 = H[i] + abs(X[i] - CX) + abs(Y[i] - CY); break; } } rep(i, N) { if (max(H1 - abs(X[i] - CX) - abs(Y[i] - CY), 0LL) != H[i]) { check = 0; } } if (check) { cout << CX << space << CY << space << H1 << endl; return 0; } } } // for compilation: g++ -O3 -o _ _.cpp -std=c++17
s459641960
p03240
u398942100
1538874975
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
256
2,276
null
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author prakharjain */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); TaskC solver = new TaskC(); solver.solve(1, in, out); out.close(); } static class TaskC { public void solve(int testNumber, InputReader in, OutputWriter out) { int n = in.nextInt(); int[] x = new int[n]; int[] y = new int[n]; int[] h = new int[n]; int minh = 0; for (int i = 0; i < n; i++) { x[i] = in.nextInt(); y[i] = in.nextInt(); h[i] = in.nextInt(); minh = Math.max(minh, h[i]); } for (int cx = 0; cx <= 100; cx++) { for (int cy = 0; cy <= 100; cy++) { for (int ch = minh; ch <= minh + 400; ch++) { boolean poss = true; for (int i = 0; i < n; i++) { int ah = Math.max(ch - abs(x[i] - cx) - abs(y[i] - cy), 0); if (ah != h[i]) { poss = false; break; } } if (poss) { out.println(cx + " " + cy + " " + ch); return; } } } } } int abs(int a) { if (a < 0) return -a; return a; } } static class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void print(Object... objects) { for (int i = 0; i < objects.length; i++) { if (i != 0) { writer.print(' '); } writer.print(objects[i]); } } public void println(Object... objects) { print(objects); writer.println(); } public void close() { writer.close(); } } static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private InputReader.SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public static boolean isWhitespace(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public int read() { if (numChars == -1) { throw new InputMismatchException(); } if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) { return -1; } } return buf[curChar++]; } public int nextInt() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public boolean isSpaceChar(int c) { if (filter != null) { return filter.isSpaceChar(c); } return isWhitespace(c); } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }
s476737795
p03240
u485601469
1538874974
2Java
Java8 (OpenJDK 1.8.0)
java
0Accepted
111
23,124
4,832
null
N = gets.to_i xs, ys, hs = [], [], [] N.times do |i| xs[i], ys[i], hs[i] = gets.split.map(&:to_i) end (0..100).each do |x| (0..100).each do |y| h = nil hmax = 10**10 success = true N.times do |i| dist = (xs[i]-x).abs + (ys[i]-y).abs if hs[i] == 0 hmax = dist if hmax > dist else hc = hs[i] + dist if h && h != hc success = false break else h = hc end end end if success && h <= hmax puts [x, y, h].join(' ') exit end end end
s792957867
p03240
u314396879
1538874972
5Ruby
Ruby (2.3.3)
rb
0Accepted
198
1,788
705
null
#include<bits/stdc++.h> using namespace std; #define ll long long ll x[10005],y[10005],h[10005],n; int check(ll cx,ll cy){ int H=-1; for (int i=0;i<n;i++){ if (h[i]>0){ H=h[i]+abs(cx-x[i])+abs(cy-y[i]); if (H>=1) break; else H=-1; } } for (int i=0;i<n;i++){ ll _h=max(H-abs(cx-x[i])-abs(cy-y[i]),(ll)0); if (_h!=h[i]){ return -1; } } return H; } int main(){ cin>>n; for (int i=0;i<n;i++){ cin>>x[i]>>y[i]>>h[i]; } int ans=-1; for (int i=0;i<=100;i++){ for (int j=0;j<=100;j++){ if ((ans=check(i,j))!=-1){ cout<<i<<" "<<j<<" "<<ans<<endl; return 0; } } } }
s616437676
p03240
u897380063
1538874958
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
2
256
631
null
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define de(x) cout<<#x<<"="<<x<<endl #define rff freopen("input.txt","r",stdin) #else #define de(x) #define rff #endif #define itr(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++) #define For(i,n) for (int i=1;i<=(int)(n);i++) #define rep(i,n) for (int i=0;i<(int)(n);i++) #define all(x) (x).begin(),(x).end() #define PQ priority_queue #define pii pair<int,int> #define vi vector <int> #define ll long long #define pb push_back #define mp make_pair #define re return #define se second #define fi first const int INF=0x7fffffff; const int MAXN=+3; int n; int X[103],Y[103],H[103],mn=INF; int absi(int x){ if (x<0) re -x; re x; } bool check(int x,int y,int h){ rep(i,n){ if (max(h-absi(x-X[i])-absi(y-Y[i]),-mn)!=H[i]) re 0; } re 1; } int main(){ cin>>n; rep(i,n){ cin>>X[i]>>Y[i]>>H[i]; mn=min(mn,H[i]); } rep(i,n){ H[i]-=mn; } rep(i,101){ rep(j,101){ rep(k,202){ if (check(i,j,k)){ cout<<i<<" "<<j<<" "<<k+mn; } } } } re 0; }
s763913293
p03240
u233782106
1538874938
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
246
256
1,053
null
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> #include <algorithm> #include <set> #include <map> #include <vector> #include <math.h> #include <queue> #include <stack> #include <list> #include <functional> #include <numeric> #include <iostream> #include <string> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (n); ++i) int main() { int N, x[123], y[123], h[123], mh = 0; scanf("%d", &N); rep(i, N) { scanf("%d%d%d", &x[i], &y[i], &h[i]); mh = max(h[i], mh); } rep(Cx, 101) { rep(Cy, 101) { rep(H, 300) { bool f = true; rep(i, N) { if (max(H + mh - abs(x[i] - Cx) - abs(y[i] - Cy), 0ll) != h[i]) { f = false; break; } } if (f) { printf("%lld %lld %lld\n", Cx, Cy, mh + H); return 0; } } } } return 0; }
s200245355
p03240
u810616694
1538874924
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
5
256
840
null
#include <bits/stdc++.h> using namespace std; #define llong long long /*{{{*/ #define ii pair<int, int> #define xx first #define yy second #define len(x) ((int)x.size()) #define rep(i,n) for (int i = -1; ++ i < n; ) #define rep1(i,n) for (int i = 0; i ++ < n; ) template<typename a> ostream& operator<<(ostream& cout, const vector<a>& b) { cout << "["; if (len(b)) cout << b[0]; rep1(i, len(b) - 1) cout << ", " << b[i]; return cout << "]"; } template<typename u, typename v> ostream& operator<<(ostream& cout, const pair<u, v> a) { return cout << "(" << a.xx <<", " << a.yy << ")"; }/*}}}*/ #define maxn 111 int n; int x[maxn], y[maxn], h[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; int n0 = -1; rep(i, n) { cin >> x[i] >> y[i] >> h[i]; if (h[i]) n0 = i; } if (n0 == -1) { cout << "0 0 1"; return 0; } rep(u, 101) rep(v, 101) { int ch = h[n0] + abs(u - x[n0]) + abs(v - y[n0]); bool ok = true; rep(i, n) { if (max(ch - abs(u - x[i]) - abs(v - y[i]), 0) != h[i]) { ok = false; break; } } if (ok) { cout << u << ' ' << v << ' ' << ch; return 0; } } return 0; }
s113291572
p03240
u402685795
1538874922
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
1
256
1,219
null
import algorithm import strutils import sequtils proc gs() : seq[int] = stdin.readLine.split.map(parseInt) var N = gs()[0] var x,y,h : array[101,int] for i in 0..<N: var t = gs() x[i] = t[0] y[i] = t[1] h[i] = t[2] var j = 0 for i in 0..<N: if h[i] > 0: j = i break for X in 0..100: for Y in 0..100: var H = abs(X - x[j]) + abs(Y - y[j]) + h[j] var OK = true for i in 0..<N: if max(H - abs(X - x[i]) - abs(Y - y[i]),0) != h[i]: OK = false if OK: echo X , " " , Y , " " , H
s141989827
p03240
u852585808
1538874912
12Other
Nim (0.13.0)
nim
0Accepted
3
256
592
null
#include<cstdio> #include<algorithm> using namespace std; int x[105],y[105],h[105]; int main(){ int n,i,j,k,t,p=0; bool ok; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&h[i]); if(!p&&h[i])p=i; } for(i=0;i<=100;i++) for(j=0;j<=100;j++){ ok=1; t=h[p]+abs(i-x[p])+abs(j-y[p]); for(k=0;k<n;k++)if(max(t-abs(i-x[k])-abs(j-y[k]),0)!=h[k])ok=0; if(ok){ printf("%d %d %d\n",i,j,t); return 0; } } }
s856388406
p03240
u070422134
1538874911
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
3
128
443
null
#include <bits/stdc++.h> #ifdef NON_SUBMIT #define TEST(n) (n) #else #define TEST(n) ((void)0) #endif using namespace std; vector<tuple<int, int, int>> P; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); TEST(freopen("input.txt", "r", stdin)); TEST(freopen("output.txt", "w", stdout)); int N, x, y, h; cin >> N; P.resize(N); for (int i = 0; i < N; i++) { cin >> x >> y >> h; P[i] = tie(x, y, h); } for (int i = 0; i <= 100; i++) { for (int j = 0; j <= 100; j++) { int H = 0x7fffffff; bool valid = true; for (auto p : P) { tie(x, y, h) = p; H = min(H, h + abs(x - i) + abs(y - j)); } for (auto p : P) { tie(x, y, h) = p; if (h != max(H - abs(x - i) - abs(y - j), 0)) { valid = false; break; } } if (valid) { cout << i << ' ' << j << ' ' << H << '\n'; return 0; } } } return 0; }
s923366966
p03240
u548859367
1538874907
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
5
256
892
null
// need #include <iostream> #include <algorithm> // data structure #include <bitset> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #include <complex> //#include <deque> #include <valarray> #include <unordered_map> #include <array> // stream //#include <istream> //#include <sstream> //#include <ostream> #include <fstream> // etc #include <cassert> #include <cmath> #include <functional> #include <iomanip> //#include <chrono> #include <random> #include <numeric> // input #define INIT std::ios::sync_with_stdio(false);std::cin.tie(0); #define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); template<typename T> void MACRO_VAR_Scan(T& t) { std::cin >> t; } template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { std::cin >> first; MACRO_VAR_Scan(rest...); } #define VEC_ROW(type, n, ...)std::vector<type> __VA_ARGS__;MACRO_VEC_ROW_Init(n, __VA_ARGS__); for(int w=0; w<n; ++w){MACRO_VEC_ROW_Scan(w, __VA_ARGS__);} template<typename T> void MACRO_VEC_ROW_Init(int n, T& t) { t.resize(n); } template<typename First, typename...Rest>void MACRO_VEC_ROW_Init(int n, First& first, Rest&...rest) { first.resize(n); MACRO_VEC_ROW_Init(n, rest...); } template<typename T> void MACRO_VEC_ROW_Scan(int p, T& t) { std::cin >> t[p]; } template<typename First, typename...Rest>void MACRO_VEC_ROW_Scan(int p, First& first, Rest&...rest) { std::cin >> first[p]; MACRO_VEC_ROW_Scan(p, rest...); } #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i; #define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& R:c)for(auto& w:R)std::cin>>w; // output #define OUT(dist) std::cout<<(dist); #define FOUT(n, dist) std::cout<<std::fixed<<std::setprecision(n)<<(dist); #define SOUT(n, c, dist) std::cout<<std::setw(n)<<std::setfill(c)<<(dist); #define SP std::cout<<" "; #define TAB std::cout<<"\t"; #define BR std::cout<<"\n"; #define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' '); #define ENDL std::cout<<std::endl; #define FLUSH std::cout<<std::flush; #define SHOW(dist) {std::cerr << #dist << "\t:" << (dist) << "\n";} #define SHOWVECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";} #define SHOWVECTOR2(v) {std::cerr << #v << "\t:\n";for(const auto& xxx : v){for(const auto& yyy : xxx){std::cerr << yyy << " ";}std::cerr << "\n";}} #define SHOWQUEUE(a) {auto tmp(a);std::cerr << #a << "\t:";while(!tmp.empty()){std::cerr << tmp.front() << " ";tmp.pop();}std::cerr << "\n";} // utility #define ALL(a) (a).begin(),(a).end() #define FOR(w, a, n) for(int w=(a);w<(n);++w) #define RFOR(w, a, n) for(int w=(n)-1;w>=(a);--w) #define REP(w, n) for(int w=0;w<int(n);++w) #define RREP(w, n) for(int w=int(n)-1;w>=0;--w) #define FORLL(w, a, n) for(ll w=ll(a);w<ll(n);++w) #define RFORLL(w, a, n) for(ll w=ll(n)-1;w>=ll(a);--w) #define REPLL(w, n) for(ll w=0;w<ll(n);++w) #define RREPLL(w, n) for(ll w=ll(n)-1;w>=0;--w) #define IN(a, x, b) (a<=x && x<b) template<class T> inline T CHMAX(T& a, const T b) { return a = (a < b) ? b : a; } template<class T> inline T CHMIN(T& a, const T b) { return a = (a > b) ? b : a; } #define EXCEPTION(msg) throw std::string("Exception : " msg " [ in ") + __func__ + " : " + std::to_string(__LINE__) + " lines ]" #define TRY(cond, msg) try {if (cond) EXCEPTION(msg);}catch (std::string s) {std::cerr << s << std::endl;} //void CHECKTIME(std::function<void()> f) { auto start = std::chrono::system_clock::now(); f(); auto end = std::chrono::system_clock::now(); auto res = std::chrono::duration_cast<std::chrono::nanoseconds>((end - start)).count(); std::cerr << "[Time:" << res << "ns (" << res / (1.0e9) << "s)]\n"; } // test template<class T> std::vector<std::vector<T>> VV(int n, int m, T init = T()) { return std::vector<std::vector<T>>(n, std::vector<T>(m, init)); } template<typename S, typename T> std::ostream& operator<<(std::ostream& os, std::pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; } // type/const #define int ll using ll = long long; using ull = unsigned long long; using ld = long double; using PAIR = std::pair<int, int>; using PAIRLL = std::pair<ll, ll>; constexpr int INFINT = 1 << 30; // 1.07x10^ 9 constexpr int INFINT_LIM = (1LL << 31) - 1; // 2.15x10^ 9 constexpr ll INFLL = 1LL << 60; // 1.15x10^18 constexpr ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62); // 9.22x10^18 constexpr double EPS = 1e-10; constexpr int MOD = 1000000007; constexpr double PI = 3.141592653589793238462643383279; template<class T, size_t N> void FILL(T(&a)[N], const T& val) { for (auto& x : a) x = val; } template<class ARY, size_t N, size_t M, class T> void FILL(ARY(&a)[N][M], const T& val) { for (auto& b : a) FILL(b, val); } template<class T> void FILL(std::vector<T>& a, const T& val) { for (auto& x : a) x = val; } template<class ARY, class T> void FILL(std::vector<std::vector<ARY>>& a, const T& val) { for (auto& b : a) FILL(b, val); } // ------------>8------------------------------------->8------------ signed main() { INIT; VAR(int, n); VEC_ROW(int, n, x, y, h); FOR(i, 1, n) { if (h[i] != 0) { std::swap(x[0], x[i]); std::swap(y[0], y[i]); std::swap(h[0], h[i]); break; } } REP(cx, 101) REP(cy, 101) { int ch = -1; REP(i, n) { if (h[i] == 0) { if (ch > std::abs(x[i] - cx) + std::abs(y[i] - cy)) { ch = -1; break; } continue; } if (ch == -1) { ch = h[i] + std::abs(x[i] - cx) + std::abs(y[i] - cy); } else { if (ch != h[i] + std::abs(x[i] - cx) + std::abs(y[i] - cy)) { ch = -1; break; } } } if (ch <= 0) continue; OUT(cx)SP OUT(cy)SP OUT(ch)BR; return 0; } return 0; }
s355608974
p03240
u591343832
1538874894
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
1
256
5,832
null
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} //INSERT ABOVE HERE signed 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]; for(Int cx=0;cx<=100;cx++){ for(Int cy=0;cy<=100;cy++){ Int z=1e15; for(Int i=0;i<n;i++) chmin(z,h[i]+abs(cx-x[i])+abs(cy-y[i])); Int flg=z>0; for(Int i=0;i<n;i++) flg&=max<Int>(z-abs(cx-x[i])-abs(cy-y[i]),0LL)==h[i]; if(flg){ cout<<cx<<" "<<cy<<" "<<z<<endl; return 0; } } } assert(0); return 0; }
s722259467
p03240
u687214625
1538874894
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
6
256
725
null
#pragma GCC optimize("O2") #include <iostream> #include <cmath> using namespace std; #define ll long long ll x[105],y[105],h[105]; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; for (ll i=0;i<n;i++) { cin >> x[i] >> y[i] >> h[i]; } for (ll i=0;i<=100;i++) { for (ll j=0;j<=100;j++) { ll H; for (ll k=0;k<n;k++) { if (h[k]!=0) { H = h[k] + abs(x[k]-i) + abs(y[k]-j); break; } } bool check = true; for (ll k=0;k<n;k++) { if (max(H-abs(x[k]-i)-abs(y[k]-j),(ll)0)!=h[k]) {check=false;break;} } if (check) { cout << i << ' ' << j << ' ' << H << endl; return 0; } } } return 0; }
s878997759
p03240
u574576596
1538874891
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
2
384
872
null
#include<bits/stdc++.h> using namespace std; const int M = 1000000007; int main() { int n; cin >> n; vector<vector<int>> x(n, vector<int>(3)); int a = -1; for (int i = 0; i < n; ++i) { cin >> x[i][0] >> x[i][1] >> x[i][2]; if (x[i][2] > 0) { a = i; } } for (int i = 0; i <= 100; ++i) { for (int j = 0; j <= 100; ++j) { int h = x[a][2] + abs(i - x[a][0]) + abs(j - x[a][1]); bool ok = true; for (int k = 0; k < n; ++k) { int hh = max(h - abs(i - x[k][0]) - abs(j - x[k][1]), 0); if (hh != x[k][2]) { ok = false; break; } } if (ok) { cout << i << " " << j << " " << h << "\n"; return 0; } } } return 0; }
s001746430
p03240
u778204640
1538874887
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
3
384
884
null
#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 ans_x, ans_y, ans_h; for(int cx = 0; cx <= 100; ++cx) { for(int cy = 0; cy <= 100; ++cy) { set<int> hs; for(int i = 0; i < n; ++i) { if(h[i] == 0) continue; hs.insert(h[i] + abs(cx - x[i]) + abs(cy - y[i])); } if(hs.size() == 1u && *hs.begin() > 0) { bool ok = true; for(int i = 0; i < n; ++i) { ok &= max(0, *hs.begin() - abs(x[i] - cx) - abs(y[i] - cy)) == h[i]; } if(!ok) continue; ans_x = cx, ans_y = cy; ans_h = *hs.begin(); } } } cout << ans_x << ' ' << ans_y << ' ' << ans_h << endl; }
s791861412
p03240
u733618878
1538874887
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
49
256
928
null
#include "iostream" #include "algorithm" #include "string" #include "vector" #include "cmath" #include "bitset" #include "queue" #include "functional" #include "map" #include "unordered_map" #include "set" #include "stack" #include "tuple" #define rep(n) for (int i = 0; i < n; ++i) #define REP(n,i) for (int i = 0; i < n; ++i) #define mod 1000000007 #define sp ' ' #define intmax 2147483647 #define intinf 1000000000 #define llmax 9223372036854775807 #define nyan "(=^・ω・^=)" #define mkp make_pair #define mkt make_tuple #define P pair<ll, ll> #define iP pair<int,int> typedef long long ll; using namespace std; int n, x[100], y[100], h[100],H; bool b,f; int main() { cin >> n; rep(n) cin >> x[i] >> y[i] >> h[i]; for (int cx = 0; cx <= 100; ++cx) { for (int cy = 0; cy <= 100; ++cy) { f = true; rep(n) { if (h[i] != 0) { H = h[i] + abs(x[i] - cx) + abs(y[i] - cy); break; } } rep(n) { if (h[i]>0) { if (h[i] != H - abs(x[i] - cx) - abs(y[i] - cy)) { f = false; break; } } else { if (H - abs(x[i] - cx) - abs(y[i] - cy) > 0) { f = false; break; } } } if (f) { cout << cx << sp << cy << sp << H << endl; return 0; } } } return 0; }
s063243930
p03240
u015514760
1538874882
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
2
256
1,257
null
#define _CRT_SECURE_NO_WARNINGS #pragma GCC optimize("O3") #include <iostream> #include <cstring> #include <thread> #include <ctime> #include <string> #include <cassert> #include <random> #include <cmath> #include <algorithm> #include <map> #include <unordered_map> #include <queue> #include <set> using namespace std; namespace fastinput { /** Interface */ template <class T = int> inline T readInt(); inline long double readDouble(); inline int readUInt(); inline int readChar(); inline void readWord(char *s); inline bool readLine(char *s); // do not save '\n' inline bool isEof(); inline int peekChar(); inline bool seekEof(); template <class T> inline void writeInt(T x); template <class T> inline void writeUInt(T x, int len = -1); inline void writeChar(int x); inline void writeWord(const char *s); inline void writeDouble(long double x, int len = 0); inline void flush(); /** Read */ static const int buf_size = 4096; static char buf[buf_size]; static int buf_len = 0, buf_pos = 0; inline bool isEof() { if (buf_pos == buf_len) { buf_pos = 0, buf_len = fread(buf, 1, buf_size, stdin); if (buf_pos == buf_len) return 1; } return 0; } inline int getChar() { return isEof() ? -1 : buf[buf_pos++]; } inline int peekChar() { return isEof() ? -1 : buf[buf_pos]; } inline bool seekEof() { int c; while ((c = peekChar()) != -1 && c <= 32) buf_pos++; return c == -1; } inline int readChar() { int c = getChar(); while (c != -1 && c <= 32) c = getChar(); return c; } inline int readUInt() { int c = readChar(), x = 0; while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar(); return x; } template <class T> inline T readInt() { int s = 1, c = readChar(); T x = 0; if (c == '-') s = -1, c = getChar(); while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar(); return s == 1 ? x : -x; } inline long double readDouble() { int s = 1, c = readChar(); long double x = 0; if (c == '-') s = -1, c = getChar(); while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar(); if (c == '.') { c = getChar(); long double coef = 1; while ('0' <= c && c <= '9') x += (c - '0') * (coef *= 0.1), c = getChar(); } return s == 1 ? x : -x; } inline void readWord(char *s) { int c = readChar(); while (c > 32) *s++ = (char)c, c = getChar(); *s = 0; } inline string readString() { string s; int c = readChar(); while (c > 32) { s.push_back(c); c = getChar(); } return s; } inline bool readLine(char *s) { int c = getChar(); while (c != '\n' && c != -1) *s++ = (char)c, c = getChar(); *s = 0; return c != -1; } /** Write */ static int write_buf_pos = 0; static char write_buf[buf_size]; inline void writeChar(int x) { if (write_buf_pos == buf_size) fwrite(write_buf, 1, buf_size, stdout), write_buf_pos = 0; write_buf[write_buf_pos++] = (char)x; } inline void flush() { if (write_buf_pos) fwrite(write_buf, 1, write_buf_pos, stdout), write_buf_pos = 0; } template <class T> inline void writeInt(T x) { if (x < 0) writeChar('-'), x = -x; char s[24]; int n = 0; while (x || !n) s[n++] = '0' + x % 10, x /= 10; while (n--) writeChar(s[n]); } template <class T> inline void writeUInt(T x, int output_len) { char s[24]; int n = 0; while (x || !n) s[n++] = (char)('0' + (char)(x % 10)), x /= 10; while (n < output_len) s[n++] = '0'; while (n--) writeChar(s[n]); } inline void writeWord(const char *s) { while (*s) writeChar(*s++); } inline void writeDouble(long double x, int output_len) { if (x < 0) writeChar('-'), x = -x; int t = (int)x; writeUInt(t), x -= t; writeChar('.'); for (int i = output_len - 1; i > 0; i--) { x *= 10; t = std::min(9, (int)x); writeChar('0' + t), x -= t; } x *= 10; t = std::min(9, (int)(x + 0.5)); writeChar('0' + t); } } using namespace fastinput; using namespace std; /** Begin fast allocation */ const int MAX_MEM = 2e8; int mpos = 0; char mem[MAX_MEM]; inline void * operator new (size_t n) { mpos += n; return (void *)(mem + mpos - n); } inline void operator delete (void *) noexcept { } // must have! /** End fast allocation */ const int N = 1e5; int x[N]; int y[N]; int h[N]; int main() { int n = readInt(); for (int i = 0; i < n; ++i) { x[i] = readInt(); y[i] = readInt(); h[i] = readInt(); } if (n == 1) { cout << x[0] << " " << y[0] << " " << h[0] << endl; return 0; } for (int cx = 0; cx <= 100; ++cx) { for (int cy = 0; cy <= 100; ++cy) { int H = -1; bool bad = false; for (int i = 0; i < n; ++i) { if (h[i] == 0) continue; int diff = abs(cx - x[i]) + abs(cy - y[i]); H = diff + h[i]; } if (H != -1) { for (int i = 0; !bad && i < n; ++i) { int diff = abs(cx - x[i]) + abs(cy - y[i]); if (h[i] != max(H - diff, 0)) bad = true; } } if (!bad) { cout << cx << " " << cy << " " << H << endl; return 0; } } } return 0; }
s213812684
p03240
u217145434
1538874873
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
3
256
5,063
null
import strutils import sequtils import algorithm import math import queues import tables import sets import logging import future const INF* = int(1e18 + 373) proc readSeq*(): seq[string] = stdin.readLine().strip().split() proc readSeq*(n: Natural): seq[string] = result = newSeq[string](n) for i in 0..<n: result[i] = stdin.readLine().strip() proc readInt1*(): int = readSeq().map(parseInt)[0] proc readInt2*(): (int, int) = let a = readSeq().map(parseInt) return (a[0], a[1]) proc readInt3*(): (int, int, int) = let a = readSeq().map(parseInt) return (a[0], a[1], a[2]) proc readInt4*(): (int, int, int, int) = let a = readSeq().map(parseInt) return (a[0], a[1], a[2], a[3]) type seq2*[T] = seq[seq[T]] proc newSeq2*[T](n1, n2: Natural): seq2[T] = newSeqWith(n1, newSeq[T](n2)) #------------------------------------------------------------------------------# type P = tuple [ x, y, h: int ] proc subr(y, x, h: int; ps: seq[P]): bool = for i in 0..<ps.len(): if ps[i].h != max(h - abs(ps[i].y - y) - abs(ps[i].x - x), 0): return false return true proc main() = let n = readInt1() var ps = newSeq[P](n) for i in 0..<n: ps[i] = readInt3() for y in 0..100: for x in 0..100: var h = -1 for i in 0..<ps.len(): if ps[i].h != 0: h = ps[i].h + abs(ps[i].y - y) + abs(ps[i].x - x) break if subr(y, x, h, ps): echo x, " ", y, " ", h return main()
s730615420
p03240
u643405868
1538874840
12Other
Nim (0.13.0)
nim
0Accepted
1
256
1,462
null
/* ЗАПУСКАЕМ ░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░ ▄███▀░◐░░░▌░░░░░░░ ░░░░▌░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░▄▀▒▒▀▀▀▀▄ ░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄ ░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░▄▄▌▌▄▌▌░░░░░ */ #include <iostream> #include <complex> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <numeric> #include <cstring> #include <ctime> #include <cstdlib> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <list> #include <cmath> #include <bitset> #include <cassert> #include <queue> #include <stack> #include <deque> #include <random> using namespace std; template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; } template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; } template<typename T, typename U> inline ostream &operator<< (ostream &_out, const pair<T, U> &_p) { _out << _p.first << ' ' << _p.second; return _out; } template<typename T, typename U> inline istream &operator>> (istream &_in, pair<T, U> &_p) { _in >> _p.first >> _p.second; return _in; } template<typename T> inline ostream &operator<< (ostream &_out, const vector<T> &_v) { if (_v.empty()) { return _out; } _out << _v.front(); for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) { _out << ' ' << *_it; } return _out; } template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; } template<typename T> inline ostream &operator<< (ostream &_out, const set<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; } template<typename T> inline ostream &operator<< (ostream &_out, const multiset<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; } template<typename T> inline ostream &operator<< (ostream &_out, const unordered_set<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; } template<typename T> inline ostream &operator<< (ostream &_out, const unordered_multiset<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; } template<typename T, typename U> inline ostream &operator<< (ostream &_out, const map<T, U> &_m) { if (_m.empty()) { return _out; } _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')'; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) { _out << ", (" << _it->first << ": " << _it->second << ')'; } return _out; } template<typename T, typename U> inline ostream &operator<< (ostream &_out, const unordered_map<T, U> &_m) { if (_m.empty()) { return _out; } _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')'; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) { _out << ", (" << _it->first << ": " << _it->second << ')'; } return _out; } #define sz(c) (int)(c).size() #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() #define left left228 #define right right228 #define next next228 #define rank rank228 #define prev prev228 #define y1 y1228 #define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin) #define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout) #define files(FILENAME) read(FILENAME), write(FILENAME) #define pb push_back #define x first #define y second const string FILENAME = "input"; int n; int x[105], y[105], h[105]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); //read(FILENAME); cin >> n; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> h[i]; } for (int cx = 0; cx <= 100; cx++) { for (int cy = 0; cy <= 100; cy++) { int gr = 2e9 + 2; int resh = -1; bool bad = false; for (int i = 0; i < n; i++) { int k = abs(x[i] - cx) + abs(y[i] - cy); if (h[i] == 0) { chkmin(gr, k); } else { if (resh != -1 && resh != h[i] + k) { bad = true; } resh = h[i] + k; } } if (resh > gr) { bad = true; } if (!bad && resh >= 1 && gr >= 1) { cout << cx << ' ' << cy << ' ' << resh << endl; } } } return 0; }
s591128916
p03240
u139147798
1538874831
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
256
5,335
null
#include <bits/stdc++.h> using namespace std; #define li long long int #define rep(i,to) for(li i=0;i<((li)(to));i++) #define repp(i,start,to) for(li i=(li)(start);i<((li)(to));i++) #define pb push_back #define sz(v) ((li)(v).size()) #define bgn(v) ((v).begin()) #define eend(v) ((v).end()) #define allof(v) (v).begin(), (v).end() #define dodp(v,n) memset(v,(li)n,sizeof(v)) #define bit(n) (1ll<<(li)(n)) #define mp(a,b) make_pair(a,b) #define rin rep(i,n) #define EPS 1e-12 #define ETOL 1e-8 #define MOD 1000000007 typedef pair<li, li> PI; #define INF bit(60) #define DBGP 1 #define idp if(DBGP) #define F first #define S second #define p2(a,b) idp cout<<a<<"\t"<<b<<endl #define p3(a,b,c) idp cout<<a<<"\t"<<b<<"\t"<<c<<endl #define p4(a,b,c,d) idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl #define p5(a,b,c,d,e) idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl #define p6(a,b,c,d,e,f) idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl #define p7(a,b,c,d,e,f,g) idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl #define p8(a,b,c,d,e,f,g,h) idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl #define p9(a,b,c,d,e,f,g,h,i) idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl #define p10(a,b,c,d,e,f,g,h,i,j) idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl #define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it) #define p2p(x) idp p2((x).F, (x).S) #define dump(x,n) idp{rep(i,n){cout<<x[i]<<" ";}puts("");} #define dump2(x,n) idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");} #define dumpi(x) idp{foreach(it, x){cout<<(*it)<<" ";}puts("");} #define dumpi2(x) idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");} #define read2d(a,w,h) rep(i,h)rep(j,w)cin>>a[i][j] #define dump2d(a,w,h) rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");} typedef pair<li, li> PI; PI p[111]; li h[111]; li n; inline li d(li y, li x, li i) { return abs(y - p[i].F) + abs(x - p[i].S); } inline li ok(li y, li x) { li res = 0; rin{ if (h[i] > 0) { res = h[i] + d(y, x, i); break; } } rin { if (max(res - d(y, x, i), 0ll) != h[i]) { return 0; } } return res; } int main() { cin >> n; rin{ cin >> p[i].S >> p[i].F; cin >> h[i]; } rep(y, 101) { rep(x, 101) { if (ok(y, x) > 0) { cout << x << " " << y << " " << ok(y, x) << endl; return 0; } } } return 0; }
s648798386
p03240
u213143275
1538874826
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
2
256
2,792
null
#if 0 cat <<EOF >mistaken-paste #endif // thanks for @rsk0315_h4x #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" #define _USE_MATH_DEFINES #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <math.h> #include <time.h> #define BIG 2000000007 #define VERYBIG 2000000000000007LL #define MOD 1000000007 #define FOD 998244353 typedef uint64_t ull; typedef int64_t sll; #define N_MAX 1000000 #ifdef __cplusplus #include <queue> #include <stack> #include <tuple> #include <set> #include <map> #include <string> #include <algorithm> #include <functional> #include <array> using std::queue; using std::priority_queue; using std::stack; using std::tuple; using std::set; using std::map; using std::vector; using std::greater; using std::pair; using std::string; #endif typedef struct { int32_t a; int32_t b; } hw; typedef struct { sll a; sll b; } hwll; typedef struct { sll a; sll b; sll c; } hwllc; typedef struct { hwll a; hwll b; } linell; ull n, m; ull h, w; ull k; ull q; sll va, vb, vc, vd, ve, vf; ull ua, ub, uc, ud, ue, uf; long double vra, vrb, vrc; double vda, vdb, vdc; char ch, dh; ull umin (ull x, ull y) { return (x < y) ? x : y; } ull umax (ull x, ull y) { return (x > y) ? x : y; } sll smin (sll x, sll y) { return (x < y) ? x : y; } sll smax (sll x, sll y) { return (x > y) ? x : y; } ull gcd (ull x, ull y) { if (x < y) { return gcd(y, x); } else if (y == 0) { return x; } else { return gcd(y, x % y); } } ull bitpow (ull a, ull x, ull modulo) { ull result = 1; while (x) { if (x & 1) { result *= a; result %= modulo; } x /= 2; a = (a * a) % modulo; } return result; } ull divide (ull a, ull b, ull modulo) { return (a * bitpow(b, modulo - 2, modulo)) % modulo; } ull udiff (ull a, ull b) { if (a >= b) { return a - b; } else { return b - a; } } sll sdiff (sll a, sll b) { if (a >= b) { return a - b; } else { return b - a; } } int bitcount (ull n) { int result = 0; while (n) { if (n & 1) result++; n /= 2; } return result; } // double distance (sll x1, sll y1, sll x2, sll y2) { // double xdist2, ydist2, origindist, dist; // xdist2 = (x1 - x2) * (x1 - x2); // ydist2 = (y1 - y2) * (y1 - y2); // return sqrt(xdist2 + ydist2); // } int32_t pullcomp (const void *left, const void *right) { ull l = *(ull*)left; ull r = *(ull*)right; if (l < r) { return -1; } if (l > r) { return +1; } return 0; } int32_t psllcomp (const void *left, const void *right) { sll l = *(sll*)left; sll r = *(sll*)right; if (l < r) { return -1; } if (l > r) { return +1; } return 0; } int32_t pcharcomp (const void *left, const void *right) { char l = *(char*)left; char r = *(char*)right; if (l < r) { return -1; } if (l > r) { return +1; } return 0; } int32_t pdoublecomp (const void *left, const void *right) { double l = *(double*)left; double r = *(double*)right; if (l < r) { return -1; } if (l > r) { return +1; } return 0; } int32_t pstrcomp (const void *left, const void *right) { char* l = *(char**)left; char* r = *(char**)right; return strcmp(l, r); } int32_t phwllABcomp (const void *left, const void *right) { hwll l = *(hwll*)left; hwll r = *(hwll*)right; if (l.a < r.a) { return -1; } if (l.a > r.a) { return +1; } if (l.b < r.b) { return -1; } if (l.b > r.b) { return +1; } return 0; } int32_t phwllREVcomp (const void *left, const void *right) { hwll l = *(hwll*)left; hwll r = *(hwll*)right; if (l.b < r.b) { return -1; } if (l.b > r.b) { return +1; } if (l.a < r.a) { return -1; } if (l.a > r.a) { return +1; } return 0; } int32_t ptriplecomp (const void *left, const void *right) { hwllc l = *(hwllc*)left; hwllc r = *(hwllc*)right; if (l.a < r.a) { return -1; } if (l.a > r.a) { return +1; } if (l.b < r.b) { return -1; } if (l.b > r.b) { return +1; } if (l.c < r.c) { return -1; } if (l.c > r.c) { return +1; } return 0; } int32_t ptripleREVcomp (const void *left, const void *right) { hwllc l = *(hwllc*)left; hwllc r = *(hwllc*)right; if (l.b < r.b) { return -1; } if (l.b > r.b) { return +1; } if (l.a < r.a) { return -1; } if (l.a > r.a) { return +1; } if (l.c < r.c) { return -1; } if (l.c > r.c) { return +1; } return 0; } int32_t pquadcomp (const void *left, const void *right) { linell l = *(linell*)left; linell r = *(linell*)right; sll ac = phwllABcomp(&(l.a), &(r.a)); if (ac) return ac; sll bc = phwllABcomp(&(l.b), &(r.b)); if (bc) return bc; return 0; } bool isinrange (sll left, sll x, sll right) { return (left <= x && x <= right); } bool isinrange_soft (sll left, sll x, sll right) { return (left <= x && x <= right) || (left >= x && x >= right); } sll a[N_MAX]; // ull a[N_MAX]; // sll a[3001][3001]; sll b[N_MAX]; // sll b[3001][3001]; sll c[N_MAX]; // sll d[N_MAX]; // sll e[N_MAX]; char s[N_MAX + 1]; // char s[3010][3010]; char t[N_MAX + 1]; // char t[3010][3010]; hwll xy[N_MAX]; hwllc tup[N_MAX]; // sll table[1000][1000]; ull solve () { sll i, j, ki, li; // ull result = 0; sll result = 0; double dresult = 0; // ull maybe = 0; sll maybe = 0; // ull sum = 0; sll sum = 0; sll item; ull *dpcell; for (i = 0; i <= 100; i++) { for (j = 0; j <= 100; j++) { ull ul = 0, uh = VERYBIG; for (ki = 0; ki < n; ki++) { ull mh = sdiff(i, a[ki]) + sdiff(j, b[ki]); if (!c[ki]) { uh = smin(uh, mh); } else { if (ul && ul != c[ki] + mh) break; if (!ul) ul = c[ki] + mh; } } if (ki == n && ul <= uh) { printf("%llu %llu %llu\n", i, j, ul); return 0; } } } // printf("%lld\n", result); // printf("%.15lf\n", dresult); // puts(s); return 0; success: // puts("YES"); puts("Yes"); // printf("%llu\n", result); // puts("0"); // puts("Yay!"); return 0; fail: // puts("NO"); puts("No"); // puts("0"); // puts("-1"); // puts("-1 -1 -1"); // puts("Impossible"); return 1; } int32_t main (void) { int32_t i, j; int32_t x, y; // scanf("%llu%llu", &h, &w); scanf("%llu", &n, &m); // scanf("%llu", &k, &n, &m); // scanf("%llu%llu", &h, &w); // scanf("%lld%lld", &va, &vb, &vc, &vd); // scanf("%llu%llu", &ua, &ub, &uc, &ud); // scanf("%llu", &q); // scanf("%s", s); // scanf("%s", t); for (i = 0; i < n; i++) { // scanf("%lld%lld", &xy[i].a, &xy[i].b); // scanf("%lld%lld%lld", &tup[i].a, &tup[i].b, &tup[i].c); scanf("%lld", &a[i]); scanf("%lld", &b[i]); scanf("%lld", &c[i]); // scanf("%lld", &d[i]); // a[i]--; // b[i]--; // c[i]--; // tup[i].a--; // tup[i].b--; } // scanf("%llu", &m, &k); // scanf("%llu", &q); // scanf("%s", s); // for (i = 0; i < m; i++) { // scanf("%lld", &b[i]); // // b[i]--; // } // for (i = 0; i < h; i++) { // for (j = 0; j < w; j++) { // scanf("%llu", &table[i][j]); // } // } // for (i = 0; i < h; i++) { // scanf("%s", &s[i]); // } solve(); return 0; }
s847867142
p03240
u238041222
1538874813
1C
C (GCC 5.4.1)
c
0Accepted
5
6,272
6,986
null
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<functional> #include<vector> #include<queue> #include<stack> #include<set> using namespace std; #define MOD 1000000007 #define f(i,n) for(int i=0;i<int(n);i++) #define N 2000 int main(){ int a[N]; int b[N]; int c[N]; f(i, N)a[i] = 0; int n; int x, y, z; int s, ans; bool v = true; ans = 0; scanf("%d", &n); f(i, n){ scanf("%d %d %d", &a[i],&b[i],&c[i]); } f(xx, 101){ f(yy, 101){ ans = 0; z = 0; f(i, n){ if (c[i] > 0){ x = xx - a[i]; y = yy - b[i]; s = c[i] + abs(x) + abs(y); if (z == 0)z = s; if (s == z)ans++; } } f(i, n){ if (c[i] == 0){ x = xx - a[i]; y = yy - b[i]; s = abs(x) + abs(y); if (z <= s)ans++; } } if (ans == n&&z>0){ printf("%d %d %d\n", xx, yy, z); return 0; } } } return 0; }
s933500497
p03240
u510611356
1538874799
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
128
935
null
#include"bits/stdc++.h" using namespace std; using ll = int64_t; int main() { ll N; cin >> N; vector<ll> x(N), y(N), h(N); for (ll i = 0; i < N; i++) { cin >> x[i] >> y[i] >> h[i]; } for (ll cx = 0; cx <= 100; cx++) { for (ll cy = 0; cy <= 100; cy++) { ll H = -1; for (ll i = 0; i < N; i++) { if (h[i] != 0) { H = h[i] + abs(cx - x[i]) + abs(cy - y[i]); break; } } assert(H != -1); bool ok = true; for (ll i = 0; i < N; i++) { if (h[i] != max(H - abs(cx - x[i]) - abs(cy - y[i]), (ll)0)) { ok = false; break; } } if (ok) { cout << cx << " " << cy << " " << H << endl; return 0; } } } }
s506451824
p03240
u456065785
1538874798
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
2
256
924
null
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N; int X[1010],Y[1010],H[1010]; void solve() { int i,j,k,l,r,x,y; string s; cin>>N; FOR(i,N) cin>>X[i]>>Y[i]>>H[i]; for(x=0;x<=100;x++) { for(y=0;y<=100;y++) { ll R; FOR(i,N) if(H[i]>0) { R=H[i]+abs(x-X[i])+abs(y-Y[i]); break; } FOR(i,N) if(H[i]!=max(0LL,R-abs(x-X[i])-abs(y-Y[i]))) break; if(i==N) { cout<<x<<" "<<y<<" "<<R<<endl; return; } } } } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); cout.tie(0); solve(); return 0; }
s135006566
p03240
u452725238
1538874795
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
2
256
1,087
null
#define _USE_MATH_DEFINES #include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <vector> #include <array> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> #include <iterator> #include <memory> #include <regex> 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]; for(int cy=0; ; ++cy){ for(int cx=0; cx<=100; ++cx){ int height = INT_MAX; for(int i=0; i<n; ++i){ int tmp = h[i] + abs(y[i] - cy) + abs(x[i] - cx); height = min(height, tmp); } bool ok = true; for(int i=0; i<n; ++i){ int tmp = max(0, height - abs(y[i] - cy) - abs(x[i] - cx)); if(tmp != h[i]){ ok = false; break; } } if(ok){ cout << cx << ' ' << cy << ' ' << height << endl; return 0; } } } }
s638315079
p03240
u917944707
1538874795
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
6
256
1,307
null
#include <bits/stdc++.h> #define each(i, c) for (auto& i : c) #define unless(cond) if (!(cond)) using namespace std; typedef long long int lli; typedef unsigned long long ull; typedef complex<double> point; template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; } template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; } int main(int argc, char *argv[]) { ios_base::sync_with_stdio(0); cin.tie(0); int n; while (cin >> n) { int x[n]; int y[n]; int h[n]; for (int i = 0; i < n; ++i) { cin >> x[i] >> y[i] >> h[i]; } for (int cx = 0; cx <= 100; ++cx) { for (int cy = 0; cy <= 100; ++cy) { int H = 0; for (int i = 0; i < n; ++i) { if (h[i] == 0) continue; H = h[i] + abs(x[i] - cx) + abs(y[i] - cy); break; } if (H == 0) continue; bool f = true; for (int i = 0; i < n; ++i) { int z = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0); f = f && (h[i] == z); } if (f) { cout << cx << ' ' << cy << ' ' << H << endl; cx = cy = 1000; } } } } return 0; }
s720055241
p03240
u768334187
1538874787
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
3
256
1,327
null
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <cstdio> #include <cstring> #include <string> #include <math.h> using namespace std; typedef long long ll; typedef double D; typedef pair<int,int> P; #define M 1000000007 #define F first #define S second #define PB push_back #define INF 100000000000000000 void YES(bool anser){ if(anser)printf("YES\n"); else printf("NO\n"); } void Yes(bool anser){ if(anser)printf("Yes\n"); else printf("No\n"); } void yes(bool anser){ if(anser)printf("yes\n"); else printf("no\n"); } int n,p=1000000000; int m[105][105],x[1005],y[1005],h[1005]; int main(void){ cin>>n; for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>h[i]; for(int i=0;i<n;i++)p=min(p,h[i]); if(p!=0){ for(int i=0;i<n;i++)h[i]=h[i]-p+1; } if(p==0)p++; for(int i=0;i<=100;i++){ for(int j=0;j<=100;j++){ for(int k=1;k<=200;k++){ bool o=true; for(int l=0;l<n;l++){ if(max(k-abs(y[l]-i)-abs(x[l]-j),0)!=h[l])o=false; } if(o){ cout<<j<<' '<<i<<' '<<k+p-1<<endl; return 0; } } } } }
s334234330
p03240
u743900647
1538874774
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
481
256
1,293
null
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; /***********************************************/ /* Dear online judge: * I've read the problem, and tried to solve it. * Even if you don't accept my solution, you should respect my effort. * I hope my code compiles and gets accepted. * ___ __ _______ _______ * |\ \|\ \ |\ ___ \ |\ ___ \ * \ \ \/ /|_\ \ __/| \ \ __/| * \ \ ___ \\ \ \_|/__\ \ \_|/__ * \ \ \\ \ \\ \ \_|\ \\ \ \_|\ \ * \ \__\\ \__\\ \_______\\ \_______\ * \|__| \|__| \|_______| \|_______| */ const long long mod = 1000000007; int main(int argc, char** argv) { #ifdef ONLINE_JUDGE ios_base::sync_with_stdio(false); cin.tie(nullptr); #endif int N; cin>>N; vector<pair<pair<int,int>,long long> > a(N); for(int i = 0;i < N;i++) cin>>a[i].first.first>>a[i].first.second>>a[i].second; if(a[0].second == 0) for(int i = 1;i < N;i++) if(a[i].second != 0) { swap(a[0],a[i]); break; } for(long long cx = 0;cx <= 100;cx++) { for(long long cy = 0;cy <= 100;cy++) { bool can = true; long long h = -1; for(int i = 0;i < N;i++) { long long cur = a[i].second + abs(a[i].first.first - cx) + abs(a[i].first.second - cy); if(h == -1) { h = cur; } else { if(a[i].second == 0) can &= cur >= h; else can &= cur == h; } } if(can) { cout<<cx<<' '<<cy<<' '<<h<<'\n'; return 0; } } } return 0; }
s630233023
p03240
u461151831
1538874774
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
256
1,752
null
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline().rstrip() # ignore trailing spaces n = ni() xyh = [] bes = -1 for i in range(n): xyh.append(na()) if xyh[-1][2] > 0: bes = len(xyh)-1 bx = -1 by = -1 bh = -1 for x in range(101): for y in range(101): if bh >= 0: continue h = abs(xyh[bes][0] - x) + abs(xyh[bes][1] - y) + xyh[bes][2] ok = True for u in xyh: if max(h-abs(u[0]-x)-abs(u[1]-y), 0) != u[2]: ok = False break if ok: bx, by, bh = x, y, h print(bx, by, bh)
s766998061
p03240
u119714109
1538874761
3Python
Python (3.4.3)
py
0Accepted
29
3,064
674
null
#include <iostream> #include <algorithm> #include <vector> #include <string> 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]; } for (int cx = 0; cx <= 100; cx++) { for (int cy = 0; cy <= 100; cy++) { int ans = 1; for (int i = 0; i < n; i++) { int d = abs(cx - x[i]) + abs(cy - y[i]); if (h[i] > 0) { ans = max(ans, d + h[i]); } } bool ok = true; for (int i = 0; i < n; i++) { int d = abs(cx - x[i]) + abs(cy - y[i]); ok &= max(ans - d, 0) == h[i]; } if (ok) { cout << cx << ' ' << cy << ' ' << ans << endl; return 0; } } } }
s680465476
p03240
u006493569
1538874746
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
6
256
758
null
#include <bits/stdc++.h> typedef long long i64; using std::cout; using std::endl; using std::cin; int main(){ int n; cin >> n; std::vector<int> x(n), y(n), h(n); std::vector<std::vector<std::pair<int, int>>> X(101), Y(101); for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> h[i]; for(int i = 0; i < 101; i++) { for(int j = 0; j < 101; j++) { for(int l = 0; l < n; l++) { int H = std::abs(x[l] - i) + std::abs(y[l] - j) + h[l]; bool f = true; for(int k = 0; k < n; k++) { f &= std::max(0, H - std::abs(x[k] - i) - std::abs(y[k] - j)) == h[k]; } if(f) { cout << i << " " << j << " " << H << endl; return 0; } } } } return 0; }
s407535467
p03240
u424655672
1538874741
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
236
256
694
null
#include <iostream> #include <algorithm> #include <vector> #include <iomanip> using namespace std; template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; } template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; } template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; } template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; } template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; } template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; } long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }} struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); } template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; } template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } } template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; } #define mod long(1e9 + 7) #define all(x) (x).begin(), (x).end() #define bitcount(n) __builtin_popcountl(long(n)) #define fcout cout << fixed << setprecision(10) #define highest(x) (63 - __builtin_clzl(x)) int main(){ int N; cin >> N; long x[N], y[N], h[N]; int able_h = 0; for(int i = 0; i < N; i++){ cin >> x[i] >> y[i] >> h[i]; if(h[i] > 0){ able_h = i; } } for(long i = 0; i <= 100; i++){ for(long j = 0; j <= 100; j++){ long H = abs(x[able_h] - i) + abs(y[able_h] - j) + h[able_h]; bool is_ok = true; for(int k = 0; k < N; k++){ if(max(H - abs(x[k] - i) - abs(y[k] - j), 0l) != h[k]){ is_ok = false; break; } } if(is_ok){ cout << i << " " << j << " " << H << endl; return 0; } } } }
s283457613
p03240
u115888500
1538874740
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
1
256
2,891
null
#include <bits/stdc++.h> using namespace std; typedef long long signed int LL; typedef long long unsigned int LU; #define incID(i, l, r) for(int i = (l) ; i < (r); i++) #define incII(i, l, r) for(int i = (l) ; i <= (r); i++) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--) #define decII(i, l, r) for(int i = (r) ; i >= (l); i--) #define inc(i, n) incID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec(i, n) decID(i, 0, n) #define dec1(i, n) decII(i, 1, n) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define FI first #define SE second #define PQ priority_queue #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #define FOR(it, v) for(auto it = v.begin(); it != v.end(); ++it) #define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it) template<typename T> bool setmin(T & a, T b) { if(b < a) { a = b; return true; } else { return false; } } template<typename T> bool setmax(T & a, T b) { if(b > a) { a = b; return true; } else { return false; } } template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } } template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } } template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } // ---- ---- int n, x[100], y[100], h[100]; bool f(int cx, int cy, int hh) { inc(i, n) { if(max(0, hh - abs(cx - x[i]) - abs(cy - y[i])) != h[i]) { return false; } } return true; } int main() { cin >> n; inc(i, n) { cin >> x[i] >> y[i] >> h[i]; } int ma = 0; inc(i, n) { setmax(ma, h[i]); } incII(cx, 0, 100) { incII(cy, 0, 100) { incII(hh, ma, ma + 300) { if(f(cx, cy, hh)) { cout << cx << " " << cy << " " << hh << endl; return 0; } } } } assert(false); }
s041857365
p03240
u568652083
1538874736
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
12
256
2,006
null
/* URL https:// SCORE 0 AC false WA false TLE false MLE false TASK_TYPE FAILURE_TYPE NOTES */ #include <iostream> #include <cstdint> #include <utility> #include <tuple> #include <vector> #include <stack> #include <queue> #include <unordered_map> #include <unordered_set> #include <map> #include <set> #include <algorithm> #include <limits> #include <numeric> #include <iomanip> #include <type_traits> #include <functional> #include <experimental/optional> /* import STL */ // stream using std::cout; using std::cerr; using std::cin; using std::endl; using std::flush; // basic types using std::nullptr_t; using std::experimental::optional; using std::pair; using std::tuple; using std::string; // function for basic types using std::experimental::make_optional; using std::make_pair; using std::make_tuple; using std::get; /* TODO remove them */ using std::vector; using std::queue; using std::stack; // algorithms using std::upper_bound; using std::lower_bound; using std::min_element; using std::max_element; using std::nth_element; using std::accumulate; /* macros */ // loops #define REP(i, n) for (i64 i = 0; i < static_cast<decltype(i)>(n); ++i) #define REPR(i, n) for (i64 i = (n) - 1; i >= static_cast<decltype(i)>(0); --i) #define FOR(i, n, m) for (i64 i = (n); i < static_cast<decltype(i)>(m); ++i) #define FORR(i, n, m) for (i64 i = (m) - 1; i >= static_cast<decltype(i)>(n); --i) #define EACH(x, xs) for (auto &x: (xs)) #define EACH_V(x, xs) for (auto x: (xs)) // helpers #define CTR(x) (x).begin(), (x).end() /* utils for std::tuple */ namespace internal { namespace tuple_utils { // TODO rename to "internal::tuple" template<size_t...> struct seq {}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template<class Tuple, size_t... Is> void read(std::istream &stream, Tuple &t, seq<Is...>) { static_cast<void>((int[]) {0, (void(stream >> get<Is>(t)), 0)...}); } template<class Tuple, size_t... Is> void print(std::ostream &stream, Tuple const &t, seq<Is...>) { static_cast<void>((int[]) {0, (void(stream << (Is == 0 ? "" : ", ") << get<Is>(t)), 0)...}); } template<size_t I, class F, class A, class... Elems> struct ForEach { void operator()(A &arg, tuple<Elems...> const &t) const { F()(arg, get<I>(t)); ForEach<I - 1, F, A, Elems...>()(arg, t); } void operator()(A &arg, tuple<Elems...> &t) const { F()(arg, get<I>(t)); ForEach<I - 1, F, A, Elems...>()(arg, t); } }; template<class F, class A, class... Elems> struct ForEach<0, F, A, Elems...> { void operator()(A &arg, tuple<Elems...> const &t) const { F()(arg, get<0>(t)); } void operator()(A &arg, tuple<Elems...> &t) const { F()(arg, get<0>(t)); } }; template<class F, class A, class... Elems> void for_each(A &arg, tuple<Elems...> const &t) { ForEach<std::tuple_size<tuple<Elems...>>::value - 1, F, A, Elems...>()(arg, t); } template<class F, class A, class... Elems> void for_each(A &arg, tuple<Elems...> &t) { ForEach<std::tuple_size<tuple<Elems...>>::value - 1, F, A, Elems...>()(arg, t); } }} /* utils for Matrix (definition of Matrix) */ namespace internal { namespace matrix { template <typename V, int N> struct matrix_t { using type = std::vector<typename matrix_t<V, N-1>::type>; }; template <typename V> struct matrix_t<V, 0> { using type = V; }; template <typename V, int N> using Matrix = typename matrix_t<V, N>::type; template <typename V, typename It, int N> struct matrix_helper { static Matrix<V, N> create(const It &begin, const It &end, const V &default_value) { return Matrix<V, N>(*begin, matrix_helper<V, It, N - 1>::create(begin + 1, end, default_value)); } }; template <typename V, typename It> struct matrix_helper<V, It, 0> { static Matrix<V, 0> create(const It &begin __attribute__((unused)), const It &end __attribute__((unused)), const V &default_value) { return default_value; } }; }} /* Primitive types */ using i8 = int8_t; using u8 = uint8_t; using i16 = int16_t; using u16 = uint16_t; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; using usize = size_t; /* Data structure type */ template <typename T> using Vector = std::vector<T>; template <typename V> using OrderedSet = std::set<V>; template <typename V> using HashSet = std::unordered_set<V>; template <typename K, typename V> using OrderedMap = std::map<K, V>; template <typename K, typename V> using HashMap = std::unordered_map<K, V>; template <typename T, int N> using Matrix = internal::matrix::Matrix<T, N>; template <typename T, typename Compare = std::less<T>, typename Container = std::vector<T>> using PriorityQueue = std::priority_queue<T, Container, Compare>; /* utils for Vector */ template <typename V> Vector<V> make_pre_allocated_vector(size_t N) { Vector<V> retval; retval.reserve(N); return retval; } /* utils for Matrix */ template <class V, int N> Matrix<V, N> make_matrix(const std::array<size_t, N> &shape, V default_value = V()) { return internal::matrix::matrix_helper<V, decltype(shape.begin()), N>::create(shape.begin(), shape.end(), default_value); } /* utils for STL iterators */ namespace internal { template <typename Iterator, typename F> struct MappedIterator { MappedIterator(const Iterator &it, const F &function) : it(it), function(function) {} auto operator *() const { return this->function(this->it); } void operator++() { ++this->it; } void operator+=(size_t n) { this->it += n; } auto operator+(size_t n) const { return MappedIterator<Iterator, F>(this->it + n, this->function); } bool operator==(const MappedIterator<Iterator, F> &rhs) const { return this->it == rhs.it; } bool operator!=(const MappedIterator<Iterator, F> &rhs) const { return !(*this == rhs); } private: Iterator it; F function; }; template <typename Iterator, typename P> struct FilteredIterator { FilteredIterator(const Iterator &it, const Iterator &end, const P &predicate) : it(it), end(end), predicate(predicate) { if (this->it != end) { if (!predicate(this->it)) { this->increment(); } } } decltype(auto) operator *() const { return *this->it; } auto operator ->() const { return this->it; } void operator++() { this->increment(); } void operator+=(size_t n) { REP (i, n) { this->increment(); } } auto operator+(size_t n) const { auto retval = *this; retval += n; return retval; } bool operator==(const FilteredIterator<Iterator, P> &rhs) const { return this->it == rhs.it; } bool operator!=(const FilteredIterator<Iterator, P> &rhs) const { return !(*this == rhs); } private: void increment() { if (this->it == this->end) { return ; } ++this->it; while (this->it != this->end && !this->predicate(this->it)) { ++this->it; } } Iterator it; Iterator end; P predicate; }; template <typename Iterator, typename ElementIterator> struct FlattenedIterator { FlattenedIterator(const Iterator &it, const Iterator &end) : it(make_pair(it, ElementIterator())), end(end) { if (this->it.first != this->end) { this->it.second = it->begin(); } this->find_valid(); } decltype(auto) operator *() const { return this->it; } const pair<Iterator, ElementIterator> *operator ->() const { return &this->it; } void operator++() { this->increment(); } void operator+=(size_t n) { REP (i, n) { this->increment(); } } auto operator+(size_t n) const { auto retval = *this; retval += n; return retval; } bool operator==(const FlattenedIterator<Iterator, ElementIterator> &rhs) const { if (this->it.first != rhs.it.first) { return false; } if (this->it.first == this->end || rhs.it.first == rhs.end) { if (this->end == rhs.end) { return true; } else { return false; } } else { return this->it.second == rhs.it.second; } } bool operator!=(const FlattenedIterator<Iterator, ElementIterator> &rhs) const { return !(*this == rhs); } private: bool is_end() const { return this->it.first == this->end; } bool is_valid() const { if (this->is_end()) return false; if (this->it.second == this->it.first->end()) return false; return true; } void _increment() { if (this->it.second == this->it.first->end()) { ++this->it.first; if (this->it.first != this->end) { this->it.second = this->it.first->begin(); } } else { ++this->it.second; } } void find_valid() { while (!this->is_end() && !this->is_valid()) { this->_increment(); } } void increment() { this->_increment(); while (!this->is_end() && !this->is_valid()) { this->_increment(); } } pair<Iterator, ElementIterator> it; Iterator end; }; } template <class Iterator> struct Container { Container(const Iterator &begin, const Iterator &end) : m_begin(begin), m_end(end) {} const Iterator& begin() const { return this->m_begin; } const Iterator& end() const { return this->m_end; } Iterator m_begin; Iterator m_end; }; template <typename C, typename F> auto iterator_map(const C &c, F function) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; return Container<internal::MappedIterator<Iterator, F>>( internal::MappedIterator<Iterator, F>(c.begin(), function), internal::MappedIterator<Iterator, F>(c.end(), function)); } template <typename C, typename P> auto iterator_filter(const C &c, P predicate) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; return Container<internal::FilteredIterator<Iterator, P>>( internal::FilteredIterator<Iterator, P>(c.begin(), c.end(), predicate), internal::FilteredIterator<Iterator, P>(c.end(), c.end(), predicate)); } template <typename C> auto iterator_flatten(const C &c) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; using ElementIterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin()->begin())>>; return Container<internal::FlattenedIterator<Iterator, ElementIterator>>( internal::FlattenedIterator<Iterator, ElementIterator>(c.begin(), c.end()), internal::FlattenedIterator<Iterator, ElementIterator>(c.end(), c.end())); } /* input */ template <class F, class S> std::istream &operator>>(std::istream &stream, pair<F, S> &pair) { stream >> pair.first; stream >> pair.second; return stream; } template <class ...Args> std::istream &operator>>(std::istream &stream, tuple<Args...> &tuple) { internal::tuple_utils::read(stream, tuple, internal::tuple_utils::gen_seq<sizeof...(Args)>()); return stream; } template <class T> T read() { T t; cin >> t; return t; } template <class F, class S> pair<F, S> read() { pair<F, S> p; cin >> p; return p; } template <class T1, class T2, class T3, class ...Args> tuple<T1, T2, T3, Args...> read() { tuple<T1, T2, T3, Args...> t; cin >> t; return t; } template <typename T, typename F = std::function<T()>> Vector<T> read(const usize length, F r) { auto retval = make_pre_allocated_vector<T>(length); REP (i, length) { retval.emplace_back(r()); } return retval; } template <class T> Vector<T> read(const usize length) { return read<T>(length, [] { return read<T>(); }); } template <class F, class S> Vector<pair<F, S>> read(const usize length) { return read<pair<F, S>>(length); } template <class T1, class T2, class T3, class ...Args> Vector<tuple<T1, T2, T3, Args...>> read(const usize length) { return read<tuple<T1, T2, T3, Args...>>(length); } namespace internal { template <typename T> struct oneline { std::string operator()(const T &t) const { std::ostringstream oss; oss << t; return oss.str(); } }; template <typename F, typename S> struct oneline<pair<F, S>> { std::string operator()(const pair<F, S> &p) const { std::ostringstream oss; oss << "{" << oneline<F>()(p.first) << ", " << oneline<S>()(p.second) << "}"; return oss.str(); } }; template <typename ...Args> struct oneline<tuple<Args...>> { struct oneline_tuple { template<class V> void operator()(Vector<std::string> &strs, const V &v) const { strs.emplace_back(oneline<V>()(v)); } }; std::string operator()(const tuple<Args...> &t) const { std::ostringstream oss; Vector<std::string> strs; internal::tuple_utils::for_each<oneline_tuple, Vector<std::string>, Args...>(strs, t); oss << "{"; REPR (i, strs.size()) { oss << strs[i]; if (i != 0) { oss << ", "; } } oss << "}"; return oss.str(); } }; template <> struct oneline<bool> { std::string operator()(const bool b) const { return b ? "true" : "false"; } }; template <typename X> struct oneline<Vector<X>> { std::string operator()(const Vector<X> &vec) const { std::string retval = "["; auto f = oneline<X>(); REP (i, vec.size()) { retval += f(vec[i]); if (i != static_cast<i64>(vec.size() - 1)) { retval += ", "; } } retval += "]"; return retval; } }; template <typename X> struct oneline<OrderedSet<X>> { std::string operator()(const OrderedSet<X> &s) const { std::string retval = "{"; auto f = oneline<X>(); size_t ctr = 0; EACH (x, s) { retval += f(x); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename X> struct oneline<HashSet<X>> { std::string operator()(const HashSet<X> &s) const { std::string retval = "{"; auto f = oneline<X>(); size_t ctr = 0; EACH (x, s) { retval += f(x); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename K, typename V> struct oneline<OrderedMap<K, V>> { std::string operator()(const OrderedMap<K, V> &s) const { std::string retval = "{"; auto f1 = oneline<K>(); auto f2 = oneline<V>(); size_t ctr = 0; EACH (x, s) { retval += f1(x.first); retval += ": "; retval += f2(x.second); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename K, typename V> struct oneline<HashMap<K, V>> { std::string operator()(const HashMap<K,V> &s) const { std::string retval = "{"; auto f1 = oneline<K>(); auto f2 = oneline<V>(); size_t ctr = 0; EACH (x, s) { retval += f1(x.first); retval += ": "; retval += f2(x.second); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename V> struct keys { /* no implementation */ }; template <typename X> struct keys<std::vector<X>> { Vector<size_t> operator()(const Vector<X> &v) const { Vector<size_t> keys; REP (i, v.size()) { keys.emplace_back(i); } return keys; } }; template <typename K, typename V> struct keys<OrderedMap<K, V>> { Vector<K> operator()(const OrderedMap<K, V> &c) const { Vector<K> keys; EACH (elem, c) { keys.emplace_back(elem.first); } return keys; } }; template <typename K, typename V> struct keys<HashMap<K, V>> { Vector<K> operator()(const HashMap<K, V> &c) const { Vector<K> keys; EACH (elem, c) { keys.emplace_back(elem.first); } return keys; } }; } template <typename T> void dump(const T& t) { using namespace internal; std::cerr << oneline<T>()(t) << std::endl; } template <typename V1, typename V2, typename ...Args> void dump(const V1 &v1, const V2 &v2, const Args&... args) { using namespace internal; using F = typename oneline<tuple<V1, V2, Args...>>::oneline_tuple; auto x = std::make_tuple(v1, v2, args...); Vector<std::string> strs; internal::tuple_utils::for_each<F, Vector<std::string>, V1, V2, Args...>(strs, x); REPR (i, strs.size()) { std::cerr << strs[i]; if (i != 0) { std::cerr << ", "; } } std::cerr << std::endl; } template <typename C> std::string as_set(const C& ctr) { Vector<std::string> values; using namespace internal; EACH (x, ctr) { values.emplace_back(oneline<decltype(x)>()(x)); } std::string retval = "---\n"; REP (i, values.size()) { retval += values[i]; retval += "\n"; } retval += "---"; return retval; } template <typename C> std::string as_map(const C& ctr) { using namespace internal; auto ks = keys<C>()(ctr); Vector<std::string> keys; Vector<std::string> values; EACH (key, ks) { keys.emplace_back(oneline<decltype(key)>()(key)); values.emplace_back(oneline<decltype(ctr.at(key))>()(ctr.at(key))); } size_t l = 0; EACH (key, keys) { l = std::max(l, key.size()); } std::string retval = "---\n"; REP (i, values.size()) { retval += keys[i]; REP (j, l - keys[i].size()) { retval += " "; } retval += ": "; retval += values[i]; retval += "\n"; } retval += "---"; return retval; } template <typename C> std::string as_table(const C &ctr) { using namespace internal; auto rkeys = keys<C>()(ctr); auto ckeys = OrderedSet<std::string>(); auto values = Vector<pair<std::string, OrderedMap<std::string, std::string>>>(); /* Stringify all data */ EACH (rkey, rkeys) { auto rkey_str = oneline<decltype(rkey)>()(rkey); values.emplace_back(rkey_str, OrderedMap<std::string, std::string>()); auto row = ctr.at(rkey); auto ks = keys<decltype(row)>()(row); EACH (ckey, ks) { auto ckey_str = oneline<decltype(ckey)>()(ckey); ckeys.emplace(ckey_str); values.back().second.emplace(ckey_str, oneline<decltype(row.at(ckey))>()(row.at(ckey))); } } /* Calculate string length */ size_t max_row_key_length = 0; EACH (value, values) { max_row_key_length = std::max(max_row_key_length, value.first.size()); } OrderedMap<std::string, size_t> max_col_length; EACH (ckey, ckeys) { max_col_length.emplace(ckey, ckey.size()); } EACH (value, values) { EACH (elem, value.second) { auto ckey = elem.first; auto value = elem.second; max_col_length[ckey] = std::max(max_col_length[ckey], value.size()); } } std::string retval = "---\n"; /* Header */ REP(i, max_row_key_length) { retval += " "; } retval += " "; size_t cnt = 0; EACH (ckey, ckeys) { retval += ckey; REP (j, max_col_length[ckey] - ckey.size()) { retval += " "; } cnt += 1; if (cnt != ckeys.size()) { retval += ", "; } } retval += "\n------\n"; /* Values */ EACH (value, values) { retval += value.first; REP(i, max_row_key_length - value.first.size()) { retval += " "; } retval += "| "; size_t cnt = 0; EACH (ckey, ckeys) { auto v = std::string(""); if (value.second.find(ckey) != value.second.end()) { v = value.second.at(ckey); } retval += v; REP (j, max_col_length[ckey] - v.size()) { retval += " "; } cnt += 1; if (cnt != ckeys.size()) { retval += ", "; } } retval += "\n"; } retval += "---"; return retval; } // Hash namespace std { template <class F, class S> struct hash<pair<F, S>> { size_t operator ()(const pair<F, S> &p) const { return hash<F>()(p.first) ^ hash<S>()(p.second); } }; template <class ...Args> struct hash<tuple<Args...>> { struct hash_for_element { template<class V> void operator()(size_t &size, const V &v) const { size ^= std::hash<V>()(v); } }; size_t operator ()(const tuple<Args...> &t) const { size_t retval = 0; internal::tuple_utils::for_each<hash_for_element, size_t, Args...>(retval, t); return retval; } }; } #define MAIN void body(); // main function (DO NOT EDIT) int main (int argc, char **argv) { cin.tie(0); std::ios_base::sync_with_stdio(false); cout << std::fixed; body(); return 0; } void body() { auto N = read<i64>(); auto xyhs = read<i64, i64, i64>(N); REP (Cx, 101) { REP (Cy, 101) { i64 H = -1; bool ans = true; EACH (xyh, xyhs) { auto X = get<0>(xyh); auto Y = get<1>(xyh); auto h = get<2>(xyh); if (H < 0 && h > 0) { // h = max(H - |X-Cx| - |Y-Cy|, 0)???H?????????? H = h + std::abs(X - Cx) + std::abs(Y - Cy); break; } } EACH (xyh, xyhs) { auto X = get<0>(xyh); auto Y = get<1>(xyh); auto h = get<2>(xyh); auto h_ = std::max<i64>(H - std::abs(X - Cx) - std::abs(Y - Cy), 0); if (h != h_) { ans = false; break; } } if (ans) { cout << Cx << " " << Cy << " " << H << endl; return ; } } } }
s942498644
p03240
u071730284
1538874722
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
2
256
24,619
null
#include<stdio.h> #include<stdlib.h> #include<math.h> typedef long long int int64; #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) #define ABS(a) ((a)>(0)?(a):-(a)) void run(void){ int n; scanf("%d",&n); int x[100]; int y[100]; int h[100]; int i; for(i=0;i<n;i++) scanf("%d%d%d",x+i,y+i,h+i); int j; for(i=0;i<=100;i++){ for(j=0;j<=100;j++){ int k; for(k=0;k<n && h[k]==0;k++); int height=h[k]+ABS(x[k]-i)+ABS(y[k]-j); for(k=0;k<n;k++){ if(MAX(height-ABS(x[k]-i)-ABS(y[k]-j),0)!=h[k]) break; } if(k==n){ printf("%d %d %d\n",i,j,height); return; } } } } int main(void){ run(); return 0; }
s803870743
p03240
u425248533
1538874709
1C
C (GCC 5.4.1)
c
0Accepted
2
128
691
null
#include <bits/stdc++.h> using namespace std; const int Maxn = 105; int n; int X[Maxn], Y[Maxn], H[Maxn]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d %d %d", &X[i], &Y[i], &H[i]); for (int cx = 0; cx <= 100; cx++) for (int cy = 0; cy <= 100; cy++) { int st = -1; bool ok = true; int mn = 2000000007; for (int i = 0; i < n && ok; i++) if (H[i] > 0) { int my = H[i] + abs(cx - X[i]) + abs(cy - Y[i]); if (st != -1 && st != my) ok = false; st = my; } else mn = min(mn, H[i] + abs(cx - X[i]) + abs(cy - Y[i])); if (ok) if (st == -1) st = mn; else if (mn < st) ok = false; if (ok) { printf("%d %d %d\n", cx, cy, st); return 0; } } return 0; }
s414864581
p03240
u055221623
1538874709
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
256
945
null
#include <iostream> #include <vector> #include <map> #include <set> #include <queue> #include <string> #include <iomanip> #include <algorithm> #include <cmath> #include <stdio.h> using namespace std; #define int long long int MOD = 1000000007; signed main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> h(N); vector<int> x(N); vector<int> y(N); int res = 0; int t = 0; for (int i = 0; i < N; i++) { cin >> x[i] >> y[i] >> h[i]; if (h[i] != 0) { t = i; } } int resx, resy; for (int X = 0; X <= 100; X++) { for (int Y = 0; Y <= 100; Y++) { int H = h[t] + abs(x[t] - X) + abs(y[t] - Y); bool ok = true; for (int i = 0; i < N; i++) { if (max((int)0, H - abs(x[i] - X) - abs(y[i] - Y)) != h[i]) { ok = false; break; } } if (ok) { resx = X; resy = Y; res = H; } } } cout << resx << " " << resy << " " << res << endl; }
s459592944
p03240
u864888234
1538874695
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
1
256
917
null
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<ll> x(n), y(n), h(n); for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> h[i]; } for (int cx = 0; cx <= 100; cx++) { for (int cy = 0; cy <= 100; cy++) { ll H = 0; for (int i = 0; i < n; i++) { if (h[i] == 0) continue; H = h[i] + abs(x[i] - cx) + abs(y[i] - cy); } if (H == 0) continue; bool f = true; for (int i = 0; i < n; i++) { ll th = max(H - (abs(x[i] - cx) + abs(y[i] - cy)), 0LL); if (th != h[i]) { f = false; break; } } if (!f) continue; cout << cx << " " << cy << " " << H << endl; return 0; } } return 0; }
s455929513
p03240
u553623615
1538874676
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
3
256
974
null
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #include<iostream> #include<unordered_set> using namespace std; #define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);} #define printe(...) fprintf(stderr, __VA_ARGS__); #define PrtExp(_Exp) cerr<< #_Exp <<" = "<< (_Exp) #define PrtExpN(_Exp) cerr<< #_Exp <<" = "<< (_Exp) <<"\n" #define SINT(n) scanf("%d",&n) #define SINT2(n,m) scanf("%d %d",&n,&m) #define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o) #define SINT4(n,m,o,P) scanf("%d %d %d %d",&n,&m,&o,&P) #define SINT5(n,m,o,P,q) scanf("%d %d %d %d %d",&n,&m,&o,&P,&q) #define SLL(n) scanf("%lld",&n) #define SLL2(n,m) scanf("%lld %lld",&n,&m) #define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o) #define SST(s) scanf("%s",s) #define SCH(c) scanf("%c",&c) #define GC() getchar() #define PINT(n) printf("%d",(int)(n)) #define PINT2(n,m) printf("%d %d",(int)(n),(int)(m)) #define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l)) #define PLL(n) printf("%lld",(long long)(n)) #define PST(s) printf("%s",(s)) #define PCH(s) printf("%c",(s)) #define PINTN(n) printf("%d\n",(int)(n)) #define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m)) #define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l)) #define PLLN(n) printf("%lld\n",(long long)(n)) #define PSTN(s) printf("%s\n",(s)) #define PCHN(s) printf("%c\n",(s)) #define PSP() printf(" ") #define PN() printf("\n") #define PC(c) putchar(c) #define CSP (' ') #define SN ("\n") #define rep(i,a) for(int i=0;i<a;i++) #define reP(i,a) for(int i=0;i<=a;i++) #define Rep(i,a) for(int i=a-1;i>=0;i--) #define ReP(i,a) for(int i=a;i>=0;i--) #define rEp(i,a) for(i=0;i<a;i++) #define rEP(i,a) for(i=0;i<=a;i++) #define REp(i,a) for(i=a-1;i>=0;i--) #define REP(i,a) for(i=a;i>=0;i--) #define repft(i,a,b) for(int i=a;i<b;i++) #define repfT(i,a,b) for(int i=a;i<=b;i++) #define Repft(i,a,b) for(int i=a-1;i>=b;i--) #define RepfT(i,a,b) for(int i=a;i>=b;i--) #define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it) #define FILL(a,v) fill(begin(a),end(a), v) #define FILL0(a) memset(a,0,sizeof(a)) #define FILL1(a) memset(a,-1,sizeof(a)) typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> Pi; typedef pair<ll, ll> Pll; const int INF = 1010000000; // 0x3C33'6080 const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863 template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; }; template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); }; template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); }; #define fs first #define sc second int in[102][3]; int main() { int n; cin >> n; int ma = 0; rep(i, n) { cin >> in[i][0]; cin >> in[i][1]; cin >> in[i][2]; ma = max(ma, in[i][2]); } rep(x, 101)rep(y, 101) repfT(h, ma-300,ma+300) { reP(i, n) { if (i == n) { cout << x << " " << y << " " << h << endl; return 0; } int H = max(0, h - abs(x - in[i][0]) - abs(y - in[i][1])); if (H != in[i][2]) break; } } }
s000019323
p03240
u959498604
1538874669
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
480
256
3,273
null
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define rep(i,n) for(int i=0;i<(n);i++) typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1}; 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;} void solve() { int N; cin >> N; vector<ll> X(N), Y(N), H(N); for (ll i = 0; i < N; i++) { cin >> X[i] >> Y[i] >> H[i]; } for (ll x = 0; x <= 100; x++) { for (ll y = 0; y <= 100; y++) { int k; for (int i = 0; i < N; i++) { if (H[i] != 0) { k = i; break; } } ll h = H[k] + abs(x - X[k]) + abs(y - Y[k]); int flag = 1; for (int i = 0; i < N; i++) { ll hh = max(0LL, h - abs(X[i] - x) - abs(Y[i] - y)); if (hh != H[i]) { flag = 0; break; } } if (flag) { cout << x << " " << y << " " << h << endl; return; } } } } int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); solve(); return 0; }
s566394061
p03240
u745250049
1538874648
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
2
256
1,669
null
#include <iostream> #include <vector> #include <string> #include <cmath> #include <algorithm> #include <utility> #include <queue> #include <set> #include <map> #include <deque> #include <iomanip> #include <cstdio> using namespace std; typedef long long ll; typedef pair<int,int> PII; typedef vector<int> VI; typedef vector<VI> VVI; #define MP make_pair #define PB push_back #define inf 1000000007 #define rep(i,n) for(int i=0;i<(int)(n);++i) int main(){ int n; cin >> n; vector<ll>x(n),y(n),h(n); rep(i,n)cin >> x[i] >> y[i] >> h[i]; bool flag =0; for(int i=0;i<=100;i++){ for(int j=0;j<=100;j++){ ll H; for(int k=1;k<=200;k++){ bool pflag = 1; ll p = i; ll q = j; H = k; for(int l=0;l<n;l++){ if(h[l]!=max(H-abs(p-x[l])-abs(q-y[l]),0LL)){ pflag = 0; break; } } if(pflag){ flag = 1; } if(flag)break; } if(flag){ cout << i << " " << j << " " << H << endl; return 0; } } } ll H; rep(i,101){ rep(j,101){ bool pflag = 1; rep(k,n){ if(k==0){ H = h[k] + abs(i-x[k])+abs(j-y[k]); }else{ if(h[k]!=max(H-abs(i-x[k])-abs(j-y[k]),0LL)){ pflag = 0; break; } } } if(pflag){ cout << i << " " << j << " " << H << endl; return 0; } } } return 0; }
s593667507
p03240
u007610006
1538874632
0C++
C++14 (Clang 3.8.0)
cpp
0Accepted
213
256
1,806
null
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N; int X[1010],Y[1010],H[1010]; void solve() { int i,j,k,l,r,x,y; string s; cin>>N; FOR(i,N) cin>>X[i]>>Y[i]>>H[i]; for(x=0;x<=100;x++) { for(y=0;y<=100;y++) { ll R=H[0]+abs(x-X[0])+abs(y-Y[0]); FOR(i,N) { if(H[i]>0) { R=H[i]+abs(x-X[i])+abs(y-Y[i]); break; } } FOR(i,N) { ll R2=max(0LL,R-abs(x-X[i])-abs(y-Y[i])); if(H[i]!=R2) break; } if(i==N) { cout<<x<<" "<<y<<" "<<R<<endl; return; } } } } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); cout.tie(0); solve(); return 0; }
s806344228
p03240
u452725238
1538874626
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
2
256
1,155
null
//Problem C #include<bits/stdc++.h> using namespace std; int n,x[222],y[222],h[222]; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d%d%d",&x[i],&y[i],&h[i]); for(int i=0;i<101;i++)for(int j=0;j<101;j++){ int H=0,f=1; for(int k=1;k<=n;k++)if(h[k])H=h[k]+abs(i-x[k])+abs(j-y[k]); for(int k=1;k<=n;k++)if(max(0,H-abs(i-x[k])-abs(j-y[k]))!=h[k])f=0; if(f){printf("%d %d %d",i,j,H);return 0;} } return 0; }
s591980429
p03240
u939552717
1538874614
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
6
256
466
null
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> #define int long long #define inf 1000000007 #define pa pair<int,int> #define ll long long #define pal pair<double,double> #define ppap pair<pa,int> // #define PI 3.14159265358979323846 #define paa pair<int,char> #define mp make_pair #define pb push_back #define EPS (1e-10) int dx[8]={0,-1,0,1,1,1,-1,-1}; int dy[8]={1,0,-1,0,-1,1,1,-1}; using namespace std; class pa3{ public: int x,y,z; pa3(int x=0,int y=0,int z=0):x(x),y(y),z(z) {} bool operator < (const pa3 &p) const{ if(x!=p.x) return x<p.x; if(y!=p.y) return y<p.y; return z<p.z; //return x != p.x ? x<p.x: y<p.y; } bool operator > (const pa3 &p) const{ if(x!=p.x) return x>p.x; if(y!=p.y) return y>p.y; return z>p.z; //return x != p.x ? x<p.x: y<p.y; } bool operator == (const pa3 &p) const{ return x==p.x && y==p.y && z==p.z; } bool operator != (const pa3 &p) const{ return !( x==p.x && y==p.y && z==p.z); } }; class pa4{ public: double x; int y,z,w; pa4(double x=0,int y=0,int z=0,int w=0):x(x),y(y),z(z),w(w) {} bool operator < (const pa4 &p) const{ if(x!=p.x) return x<p.x; if(y!=p.y) return y<p.y; if(z!=p.z)return z<p.z; return w<p.w; //return x != p.x ? x<p.x: y<p.y; } bool operator > (const pa4 &p) const{ if(x!=p.x) return x>p.x; if(y!=p.y) return y>p.y; if(z!=p.z)return z>p.z; return w>p.w; //return x != p.x ? x<p.x: y<p.y; } bool operator == (const pa4 &p) const{ return x==p.x && y==p.y && z==p.z &&w==p.w; } }; class pa2{ public: int x,y; pa2(int x=0,int y=0):x(x),y(y) {} pa2 operator + (pa2 p) {return pa2(x+p.x,y+p.y);} pa2 operator - (pa2 p) {return pa2(x-p.x,y-p.y);} bool operator < (const pa2 &p) const{ return y != p.y ? y<p.y: x<p.x; } bool operator > (const pa2 &p) const{ return x != p.x ? x<p.x: y<p.y; } bool operator == (const pa2 &p) const{ return abs(x-p.x)==0 && abs(y-p.y)==0; } bool operator != (const pa2 &p) const{ return !(abs(x-p.x)==0 && abs(y-p.y)==0); } }; /* class Point{ public: double x,y; Point(double x=0,double y=0):x(x),y(y) {} Point operator + (Point p) {return Point(x+p.x,y+p.y);} Point operator - (Point p) {return Point(x-p.x,y-p.y);} Point operator * (double a) {return Point(x*a,y*a);} Point operator / (double a) {return Point(x/a,y/a);} double absv() {return sqrt(norm());} double norm() {return x*x+y*y;} bool operator < (const Point &p) const{ return x != p.x ? x<p.x: y<p.y; } bool operator == (const Point &p) const{ return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS; } }; typedef Point Vector; #define pl pair<int,pas> struct Segment{ Point p1,p2; }; double dot(Vector a,Vector b){ return a.x*b.x+a.y*b.y; } double cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; } bool parareru(Point a,Point b,Point c,Point d){ // if(abs(cross(a-b,d-c))<EPS)cout<<"dd "<<cross(a-b,d-c)<<endl; return abs(cross(a-b,d-c))<EPS; } double distance_ls_p(Point a, Point b, Point c) { if ( dot(b-a, c-a) < EPS ) return (c-a).absv(); if ( dot(a-b, c-b) < EPS ) return (c-b).absv(); return abs(cross(b-a, c-a)) / (b-a).absv(); } bool is_intersected_ls(Segment a,Segment b) { if(a.p1==b.p1||a.p2==b.p1||a.p1==b.p2||a.p2==b.p2) return false; if(parareru((a.p2),(a.p1),(a.p1),(b.p2))&&parareru((a.p2),(a.p1),(a.p1),(b.p1))){ // cout<<"sss"<<endl; if(dot(a.p1-b.p1,a.p1-b.p2)<EPS) return true; if(dot(a.p2-b.p1,a.p2-b.p2)<EPS) return true; if(dot(a.p1-b.p1,a.p2-b.p1)<EPS) return true; if(dot(a.p1-b.p2,a.p2-b.p2)<EPS) return true; return false; } else return ( cross(a.p2-a.p1, b.p1-a.p1) * cross(a.p2-a.p1, b.p2-a.p1) < EPS ) && ( cross(b.p2-b.p1, a.p1-b.p1) * cross(b.p2-b.p1, a.p2-b.p1) < EPS ); } double segment_dis(Segment a,Segment b){ if(is_intersected_ls(a,b))return 0; double r=distance_ls_p(a.p1, a.p2, b.p1); r=min(r,distance_ls_p(a.p1, a.p2, b.p2)); r=min(r,distance_ls_p(b.p1, b.p2, a.p2)); r=min(r,distance_ls_p(b.p1, b.p2, a.p1)); return r; } Point intersection_ls(Segment a, Segment b) { Point ba = b.p2-b.p1; double d1 = abs(cross(ba, a.p1-b.p1)); double d2 = abs(cross(ba, a.p2-b.p1)); double t = d1 / (d1 + d2); return a.p1 + (a.p2-a.p1) * t; } */ string itos( int i ) { ostringstream s ; s << i ; return s.str() ; } int gcd(int v,int b){ if(v>b) return gcd(b,v); if(v==b) return b; if(b%v==0) return v; return gcd(v,b%v); } double distans(double x1,double y1,double x2,double y2){ double rr=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2); return sqrt(rr); } int mod; int pr[500010]; int inv[500010]; int beki(int wa,int rr,int warukazu){ if(rr==0) return 1%warukazu; if(rr==1) return wa%warukazu; if(rr%2==1) return (beki(wa,rr-1,warukazu)*wa)%warukazu; int zx=beki(wa,rr/2,warukazu); return (zx*zx)%warukazu; } double bekid(double w,int r){ if(r==0) return 1.0; if(r==1) return w; if(r%2) return bekid(w,r-1)*w; double f=bekid(w,r/2); return f*f; } int comb(int nn,int rr){ int r=pr[nn]*inv[rr]; r%=mod; r*=inv[nn-rr]; r%=mod; return r; } void gya(int ert){ pr[0]=1; for(int i=1;i<ert;i++){ pr[i]=(pr[i-1]*i)%mod; } for(int i=0;i<ert;i++) inv[i]=beki(pr[i],mod-2,mod); } // cin.tie(0); // ios::sync_with_stdio(false); //priority_queue<pa3,vector<pa3>,greater<pa3>> pq; //sort(ve.begin(),ve.end(),greater<int>()); //----------------kokomade tenpure------------ //vector<double> ans(100000000),ans2(100000000) int x[110],y[119],h[110]; int kyo[110]; void ch(int xx,int yy,int n){ int ans=-1; for(int i=0;i<n;i++){ kyo[i]=abs(x[i]-xx)+abs(yy-y[i]); if(h[i]>0){ ans=h[i]+kyo[i]; } // if(xx==0 && yy==0)cout<<ans<<endl; } for(int i=0;i<n;i++){ if(h[i]!=max(0ll,ans-kyo[i])) return; } cout<<xx<<" "<<yy<<" "<<ans<<endl; exit(0); } signed main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin>>n; for(int i=0;i<n;i++){ cin>>x[i]>>y[i]>>h[i]; } for(int i=0;i<=100;i++)for(int j=0;j<=100;j++)ch(i,j,n); return 0; }
s043210267
p03240
u834777932
1538874567
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
256
12,286
null
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) //const ll mod = 1000000007; int main() { //cout.precision(10); int n; cin >> n; int x[105], y[105], h[105]; for(int i = 1; i <= n; i++){ cin >> x[i] >> y[i] >> h[i]; if(h[i] > 0){ swap(x[i], x[1]); swap(y[i], y[1]); swap(h[i], h[1]); } } for(int cx = 0; cx <= 100; cx++){ for(int cy = 0; cy <= 100; cy++){ int ch = h[1] + abs(cx - x[1]) + abs(cy - y[1]); bool checker = true; for(int i = 2; i <= n; i++){ if(max(ch - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]){ checker = false; } } if(checker){ cout << cx << " " << cy << " " << ch << endl; return 0; } } } return 0; }
s305222001
p03240
u980655160
1538874560
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
256
969
null
#include <bits/stdc++.h> #define fi first #define se second #define fin(s) freopen( s, "r", stdin ); #define fout(s) freopen( s, "w", stdout ); const long long N = 110; const long long Q = 10001; const long long mod = 1e9 + 7;; const long long block = sqrt(N); using namespace std; int n; int a[N]; int b[N]; int c[N]; void solve() { cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i] >> b[i] >> c[i]; } for(int i = 0; i <= 100; i++){ for(int j = 0; j <= 100; j++){ set < int > s; int big = 2e9; for(int h = 1; h <= n; h++){ int dif = abs(a[h] - i) + abs(b[h] - j); if(c[h]){ s.insert(c[h] + dif); } else{ big = min(big, dif); } } if(s.size() == 1 && *s.begin() <= big){ cout << i << " " << j << " " << *s.begin() << "\n"; return; } } } } bool mtest = false; int main() { //fin("input.txt"); //fout("output.txt"); //fin("substr3.in"); //fout("substr3.out"); ios_base::sync_with_stdio(0); int TE = 1; if(mtest) cin >> TE; while(TE--) solve(); return 0; }
s325504624
p03240
u941977569
1538874542
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
47
256
1,601
null
#include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <bitset> #include <algorithm> #include <complex> using namespace std; #define REP(i,n) for(int i=0; i<n; ++i) #define FOR(i,a,b) for(int i=a; i<=b; ++i) #define FORR(i,a,b) for (int i=a; i>=b; --i) #define ALL(c) (c).begin(), (c).end() typedef long long ll; typedef vector<int> VI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef vector<VI> VVI; typedef pair<int,int> P; typedef pair<ll,ll> PL; int in() { int x; scanf("%d", &x); return x; } ll lin() { ll x; scanf("%lld", &x); return x; } int main() { int n; cin >> n; VI x(n), y(n), h(n); REP(i,n){ cin >> x[i] >> y[i] >> h[i]; } int s = 0; REP(i,n) if (h[i] != 0) s = i; FOR(a,0,100) FOR(b,0,100){ int p = h[s] + abs(x[s] - a) + abs(y[s] - b); bool ok = true; REP(i,n){ if (h[i] != max(0, p - abs(x[i] - a) - abs(y[i] - b))) ok = false; } if (ok){ cout << a << " " << b << " " << p << endl; return 0; } } return 0; }
s240663580
p03240
u016572066
1538874499
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
256
1,237
null
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0;i<(int)(n);i++) #define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--) #define CHMAX(a,b) (a)=max((a),(b)) #define CHMIN(a,b) (a)=min((a),(b)) #define ALL(v) (v).begin(), (v).end() #define MOD 1000000007 int n; int x[125],y[125],h[125]; int main(){ cin>>n; REP(i,n)cin>>x[i]>>y[i]>>h[i]; REP(cx,101)REP(cy,101){ int hmax = (1<<30) + (1<<29); int hmin = -1; REP(i,n){ int sa = abs(x[i]-cx)+abs(y[i]-cy); if(h[i]==0){ CHMIN(hmax, sa); }else{ CHMAX(hmin, h[i]+sa); CHMIN(hmax, h[i]+sa); } } if(hmax==hmin){ printf("%d %d %d\n",cx,cy,hmin); return 0; } } return 0; }
s235974613
p03240
u462560753
1538874464
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
256
748
null
#include <bits/stdc++.h> using namespace std; using int64 = long long; int main() { int N, X[101], Y[101], H[101]; cin >> N; for(int i = 0; i < N; i++) cin >> X[i] >> Y[i] >> H[i]; for(int i = 0; i < 101; i++) { for(int j = 0; j < 101; j++) { vector< int > cand; for(int k = 0; k < N; k++) { int dist = abs(i - X[k]) + abs(j - Y[k]); cand.emplace_back(H[k] + dist); } for(auto &HH : cand) { bool ok = true; for(int k = 0; k < N; k++) { int dist = abs(i - X[k]) + abs(j - Y[k]); if(max(HH - dist, 0) != H[k]) ok = false; } if(ok) { cout << i << " " << j << " " << HH << endl; return 0; } } } } }
s300334525
p03240
u524343822
1538874437
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
268
256
744
null
#include <iostream> #include <vector> #include <algorithm> #include <tuple> using namespace std; long long N, X[1009], Y[1009], H[1009]; vector<tuple<long long, long long, long long>>vec; int main() { cin >> N; tuple<long long, long long, long long>G = make_tuple(-1, -1, -1); for (int i = 1; i <= N; i++) { cin >> X[i] >> Y[i] >> H[i]; if (H[i] >= 1) G = make_tuple(X[i], Y[i], H[i]); } for (int i = 0; i <= 100; i++) { for (int j = 0; j <= 100; j++) { long long V = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j); V = max(V, 0LL); bool flag = true; for (int k = 1; k <= N; k++) { long long VV = V - abs(X[k] - i) - abs(Y[k] - j); VV = max(VV, 0LL); if (H[k] != VV) flag = false; } if (flag == true) vec.push_back(make_tuple(i, j, V)); } } if (vec.size() == 1) { cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl; } return 0; }
s533764927
p03240
u504103417
1538863168
0C++
C++14 (GCC 5.4.1)
cpp
0Accepted
4
256
904
null