Submission #846382

#TimeUsernameProblemLanguageResultExecution timeMemory
846382vjudge1ČVENK (COI15_cvenk)C++17
0 / 100
15 ms2652 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' const int N = 1e6+100, M = 1e5+10, K = 18; struct Line{ ll x, y; void re(){ cin >> x >> y; } }; ll r(ll n){ if(n==0) return MOD; return log2(n& -n); } ll f(ll x, ll y, ll cost, vector<array<ll, 3>> &g){ if(x==y){ g.pb({0, 0, cost}); return 0; } g.pb({x, y, cost}); if(r(x) < r(y)){ return (1<<r(x)) + f(x - (1<<r(x)), y, 1<<min(r(x), r(y)), g); } return (1<<r(y)) + f(x, y - (1<<r(y)), 1<<min(r(x), r(y)), g); } int n; Line a[N]; void solve(){ cin >> n; for(int i = 0; i < n; ++i){ a[i].re(); } vector<array<ll, 3>> X, Y; ll ans = 0; ans += f(a[0].x, a[0].y, 0, X); ans += f(a[1].x, a[1].y, 0, Y); reverse(all(X)); reverse(all(Y)); // for(auto k: X){ // cout << k[0] << ' ' << k[1] << '\n'; // } // en; // for(auto k: Y){ // cout << k[0] << ' ' << k[1] << '\n'; // } // en; for(int i = 0; i < min(Y.size(), X.size()); ++i){ if(Y[i][0] == X[i][0] && Y[i][1] == X[i][1]){ ans -= X[i][2] + Y[i][2]; }else{ ans += abs(X[i][0] - Y[i][0]) + abs(Y[i][1] - X[i][1]); break; } } cout << ans; } int main(){ cin.tie(0); ios::sync_with_stdio(0); int tt = 1, aa; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); // cin >> tt; while(tt--){ solve(); // en; } cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n"; return 0; }

Compilation message (stderr)

cvenk.cpp: In function 'void solve()':
cvenk.cpp:56:20: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   56 |   for(int i = 0; i < min(Y.size(), X.size()); ++i){
      |                  ~~^~~~~~~~~~~~~~~~~~~~~~~~~
cvenk.cpp: In function 'int main()':
cvenk.cpp:70:15: warning: unused variable 'aa' [-Wunused-variable]
   70 |   int tt = 1, aa;
      |               ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...