Submission #67876

#TimeUsernameProblemLanguageResultExecution timeMemory
67876tempytemptempXOR Sum (info1cup17_xorsum)C++14
7 / 100
1680 ms4592 KiB
/* We found Despacito 5 during contest (not clickbait) */ #include <iostream> #include <cstdio> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <algorithm> #include <cstring> #include <cfloat> #include <cmath> #include <cassert> #include <locale> #include <string> #include <bitset> #include <functional> #include <climits> #include <iomanip> using namespace std; #define read(x) freopen(x,"r",stdin) #define write(x) freopen(x,"w",stdout) #define cl(a,b) memset(a,b,sizeof(a)) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define ll long long #define ld long double #define vec vector #define vi vec<int> #define heap priority_queue #define res reserve #define pb push_back #define f(x,y,z) for(int x=(y); x<(z); x++) #define fd(x,y,z) for(int x=(y); x>=(z); x--) #define fit(x,y) for(auto x: y) #define srt(x) sort(all(x)) #define rsrt(x) sort(rall(x)) #define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin()) #define pii pair<int,ll> #define ppi pair<pii,int> #define pip pair<int,pii> #define mp make_pair #define f1 first #define s2 second #define cdbg(x) cerr<<#x<<" = "<<x<<",\t"; #define cdbl cerr<<"\n----------\n"; #define pow2(x) ((x)*(x)) #define edist(x1, y1, x2, y2) (sqrt((pow2(x1-x2)+pow2(y1-y2)))) #define mdist(x1, y1, x2, y2) (abs((x1)-(x2))+abs((y1)-(y2))) #define y1 FullSensei #define mid ((ss+se)>>1) #define left (si<<1) #define right ((si<<1)+1) #define pi 3.141592653589793 #define popcount __builtin_popcount #define spc ' ' #define endl '\n' #define lb lower_bound bool checkbit(int x,int y){return (x&(1<<y));} int setbit(int x,int y){return (x^(1<<y));} const int dirs[4][2]={{1,0},{0,1},{-1,0},{0,-1}}; const int mod=1e9+7; const int p1=805306457; const int p2=1610612741; const int INF=1e9; const int N=1e6; const int V=4e3; vi buff, v; int n; int main(){ scanf("%d",&n); v.res(N+3); buff.res(V+3); f(i,1,n+1){ int temp; scanf("%d",&temp); //assert(n<=4e3 || temp<=V); buff.pb(temp); } srt(buff); ll factor=0; int cnt=1; for(int i=0; i<buff.size(); i++){ if(i+1<buff.size()){ if(buff[i]!=buff[i+1]){ if(cnt==1){ v.pb(buff[i]); continue; } if(cnt%2==1){ v.pb(buff[i]); } ll temp=cnt; temp=temp*(cnt-1)/2+temp; if(temp%2==1){ factor^=((ll) buff[i]*2); } cnt=1; } else{ cnt++; } } else{ if(cnt==1){ v.pb(buff[i]); continue; } if(cnt%2==1){ v.pb(buff[i]); } ll temp=cnt; temp=temp*(cnt-1)/2+temp; if(temp%2==1){ factor^=((ll) buff[i]*2); } cnt=1; } } ll ans=factor; f(i,0,v.size()){ f(j,i,v.size()){ ll temp = (ll) v[i] + v[j]; // cerr<<v[i]<<spc<<v[j]<<spc<<temp<<spc<<ans<<endl; ans ^= temp; } } cout<<ans<<endl; return 0; }

Compilation message (stderr)

xorsum.cpp: In function 'int main()':
xorsum.cpp:87:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<buff.size(); i++){
               ~^~~~~~~~~~~~
xorsum.cpp:88:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i+1<buff.size()){
      ~~~^~~~~~~~~~~~
xorsum.cpp:36:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define f(x,y,z)    for(int x=(y); x<(z); x++)
                                     ^
xorsum.cpp:125:2: note: in expansion of macro 'f'
  f(i,0,v.size()){
  ^
xorsum.cpp:36:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define f(x,y,z)    for(int x=(y); x<(z); x++)
                                     ^
xorsum.cpp:126:3: note: in expansion of macro 'f'
   f(j,i,v.size()){
   ^
xorsum.cpp:75:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
xorsum.cpp:80:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&temp);
   ~~~~~^~~~~~~~~~~~
#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...