Submission #60775223


Source Code Expand

Copy
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define fr(j, l,n) for(int j = l; j < int(n); j++)
#define fn(j,n,l) for(int j=n-1;j>=l;j--)
#define gets(s) string s; cin>>s;
#define all(v) v.begin(),v.end()
#define getv(v,n) vector<ll> v(n); fr(i,0,n) cin >> v[i];
#define seev(a) for(auto x:a){cout<<x<<" ";}cout<<endl;
#define vl vector<ll>
#define ve vector
#define vvl vector<vector<ll>>
#define vp vector<pair<ll,ll>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pb push_back
#define mp make_pair
#define mse multiset<ll>
#define se set<ll>
#define ma map<ll,ll>
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define fr(j, l,n) for(int j = l; j < int(n); j++)
#define fn(j,n,l) for(int j=n-1;j>=l;j--) 
#define gets(s) string s; cin>>s;
#define all(v) v.begin(),v.end()
#define getv(v,n) vector<ll> v(n); fr(i,0,n) cin >> v[i];
#define seev(a) for(auto x:a){cout<<x<<" ";}cout<<endl;
#define vl vector<ll>
#define ve vector
#define vvl vector<vector<ll>>
#define vp vector<pair<ll,ll>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pb push_back
#define mp make_pair
#define mse multiset<ll>
#define se set<ll>
#define ma map<ll,ll>
#define getmat(v,n,m) vector<vl>v(n,vl(m));fr(i,0,n) {fr (j,0,m) cin>>v[i][j];}
#define seemat(mat) for(auto row:mat){seev(row);}
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
using namespace std;
using namespace __gnu_pbds;

// Define ordered multiset with long long

typedef tree<long long, long long, less<long>, rb_tree_tag, tree_order_statistics_node_update> ordered_multimap;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

vl sieve;
void SieveOfEratosthenes(int n)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
    vl prime(n+1,true);
 
    for (int p = 2; p * p <= n; p++) {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true) {
            // Update all multiples of p greater than or
            // equal to the square of it numbers which are
            // multiple of p and are less than p^2 are
            // already been marked.
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
 
    // Print all prime numbers
    for (int p = 2; p <= n; p++)
        if (prime[p])
            sieve.push_back(p);
}
bool sortbysec(const pair<ll, ll>& a,
               const pair<ll, ll>& b)
{
    return (a.second < b.second);
}
// gives gcd and the other coefficients
ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
// a raised to power b
ll pwr(ll a, ll b, ll mod = 0){
    ll result = 1;
    if(mod == 0){
        while(b){
            if(b & 1) result *= a;
            a *= a;
            b = b >> 1;
        }
    }
    else {
        while(b){
            if(b & 1){
                result *= a;
                result  = result % mod;
            }
            a *= a;
            a = a % mod;
            b = b >> 1;
        }
    }
    return result;
}
ll modularinverse(ll a,ll p)// p is prime
{
    return pwr(a,p-2,p);
}
// to convert string to binary(63 bits)
string tobin(ll a)
{
    string s;
    for (int i = 0; i < 63; i++)
    {
        if(a%2==1)
        {
            s+='1';
        }
        else
        {
            s+='0';
        }
        a>>=1;
    }
    return s;
}

// QUESTION DHANG SE PADHNA
void solve(ll tc){
    ll n=0,m=0,k=0,a=0,b=0,x=0,y=0,z=0;
    ll c=1;
    cin>>n;
    getv(v,n);
    a=0;
    for (int i = 0; i < n; i++)
    {
        x=v[i];
        while (x%2==0)
        {
            x/=2;
        }
        a+=x;
    }
    // cout<<a<<endl;
    while (c<=2e7)
    {
        c*=2;
        vp val(c);
        for (int i = 0; i < n; i++)
        {
            val[v[i]%c].first+=v[i];
            val[v[i]%c].second++;
        }
        // if(c<=16)
        // {
        //     seev(val);
        // }
        for (int i = 0; i < c/2; i++)
        {
            a+=(val[i].first*val[c/2-i].second)/(c/2LL);
        }
        for (int i = c/2+1; i < c; i++)
        {
            a+=(val[i].first*val[c-i+c/2].second)/(c/2LL);
        }
        // cout<<a<<endl;
        

    }
    cout<<a<<endl;
}
int main(){

#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

int t=1;
// cin>>t;
ll tc=0;
while(t--){
    tc++;
    solve(tc);
}

return 0;
}

Submission Info

Submission Time
Task F - Double Sum 2
User DarshJainMe
Language C++ 20 (gcc 12.2)
Score 0
Code Size 4385 Byte
Status WA
Exec Time 627 ms
Memory 528940 KB

Compile Error

Main.cpp: In function ‘void solve(long long int)’:
Main.cpp:125:12: warning: unused variable ‘m’ [-Wunused-variable]
  125 |     ll n=0,m=0,k=0,a=0,b=0,x=0,y=0,z=0;
      |            ^
Main.cpp:125:16: warning: unused variable ‘k’ [-Wunused-variable]
  125 |     ll n=0,m=0,k=0,a=0,b=0,x=0,y=0,z=0;
      |                ^
Main.cpp:125:24: warning: unused variable ‘b’ [-Wunused-variable]
  125 |     ll n=0,m=0,k=0,a=0,b=0,x=0,y=0,z=0;
      |                        ^
Main.cpp:125:32: warning: unused variable ‘y’ [-Wunused-variable]
  125 |     ll n=0,m=0,k=0,a=0,b=0,x=0,y=0,z=0;
      |                                ^
Main.cpp:125:36: warning: unused variable ‘z’ [-Wunused-variable]
  125 |     ll n=0,m=0,k=0,a=0,b=0,x=0,y=0,z=0;
      |                                    ^
Main.cpp:124:15: warning: unused parameter ‘tc’ [-Wunused-parameter]
  124 | void solve(ll tc){
      |               ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
WA × 3
WA × 24
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt
Case Name Status Exec Time Memory
00_sample_00.txt WA 592 ms 527312 KB
00_sample_01.txt WA 588 ms 527368 KB
00_sample_02.txt WA 590 ms 527252 KB
01_handmade_00.txt WA 616 ms 528856 KB
01_handmade_01.txt WA 615 ms 528928 KB
01_handmade_02.txt WA 616 ms 528844 KB
01_handmade_03.txt WA 607 ms 528360 KB
02_random_00.txt WA 625 ms 528756 KB
02_random_01.txt WA 626 ms 528856 KB
02_random_02.txt WA 625 ms 528868 KB
02_random_03.txt WA 627 ms 528860 KB
02_random_04.txt WA 625 ms 528908 KB
02_random_05.txt WA 596 ms 527900 KB
02_random_06.txt WA 623 ms 528816 KB
02_random_07.txt WA 623 ms 528836 KB
02_random_08.txt WA 625 ms 528820 KB
02_random_09.txt WA 624 ms 528932 KB
02_random_10.txt WA 624 ms 528876 KB
02_random_11.txt WA 625 ms 528924 KB
02_random_12.txt WA 626 ms 528788 KB
02_random_13.txt WA 613 ms 528812 KB
02_random_14.txt WA 616 ms 528940 KB
02_random_15.txt WA 618 ms 528912 KB
02_random_16.txt WA 618 ms 528832 KB


2025-03-05 (Wed)
20:49:38 +00:00