제출 #1095414

#제출 시각아이디문제언어결과실행 시간메모리
1095414rahidilbayramliXOR Sum (info1cup17_xorsum)C++17
56 / 100
1671 ms65452 KiB
#pragma GCC optimize("-O3") #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define ll long long #define ld long double #define vl vector<ll> #define vi vector<int> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define pb push_back #define p_b pop_back #define pii pair<int, int> #define pll pair<ll, ll> #define f first #define s second using namespace std; using namespace __gnu_pbds; typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); //random_device rd; //mt19937 gen(rd()); //uniform_int_distribution<> d(0, 1e9); void solve() { ll n, i, j; cin >> n; ll a[n+5]; for(i = 1; i <= n; i++) cin >> a[i]; if(n <= 100000) { ll xorr = 0; for(i = 1; i <= n; i++) { for(j = i; j <= n; j++) xorr ^= (a[i] + a[j]); } cout << xorr << "\n"; } else { map<ll, ll>mp; for(i = 1; i <= n; i++) mp[a[i]]++; vector<pll>vect; for(auto u : mp) vect.pb(u); ll xorr = 0; for(i = 0; i < vect.size(); i++) { ll cnt = (vect[i].s * (vect[i].s + 1)) / 2; if(cnt % 2 == 1) xorr ^= (vect[i].f * 2); for(j = i + 1; j < vect.size(); j++) { ll f = (vect[i].f + vect[j].f); ll cnt = (vect[i].s * vect[j].s); if(cnt % 2) xorr ^= f; } } cout << xorr << "\n"; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll tests = 1; //cin >> tests; while(tests--) { solve(); } }

컴파일 시 표준 에러 (stderr) 메시지

xorsum.cpp: In function 'void solve()':
xorsum.cpp:50:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for(i = 0; i < vect.size(); i++)
      |                    ~~^~~~~~~~~~~~~
xorsum.cpp:55:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             for(j = i + 1; j < vect.size(); j++)
      |                            ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...