Submission #22788

#TimeUsernameProblemLanguageResultExecution timeMemory
22788Jongwon Party (#40)Window Xor (KRIII5_WX)C++14
Compilation error
0 ms0 KiB
#include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <vector> using namespace std; typedef vector<int> V; int n; V pro(V &a, V &b) { V r, t; for(int &x: a) for(int &y: b) r.push_back((0LL+x+y) % n); sort(r.begin(), r.end()); if(r.size() == 1) return r; bool c = 0; for(int i = 0; i<r.size(); i++) { if(i != 0 && r[i-1] != r[i]) { if(c) t.push_back(r[i-1]); c = 1; } else c = !c; } if(c) t.push_back(r[r.size()-1]); return t; } V exp(V &a, long long t) { if(t == 1) return a; if(t%2) return pro(exp(a, t-1), a); V h = exp(a, t/2); return pro(h, h); } int arr[100000]; int res[100000]; int main() { //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); int k, i, j; long long t; scanf("%d%d%lld", &n, &k, &t); for(i = 0; i<n; i++) scanf("%d", &arr[i]); V a; for(i = 0; i<k; i++) a.push_back(i); a = exp(a, t); //for(int &x: a) // res[0] ^= arr[x]; for(i = 0; i<n; i++) { for(int &x: a) res[i] ^= arr[(x+i)%n]; } for(i = 0; i<n; i++) printf("%d ", res[i]); return 0; }

Compilation message (stderr)

WX.cpp: In function 'V pro(V&, V&)':
WX.cpp:27:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i<r.size(); i++)
                     ^
WX.cpp: In function 'V exp(V&, long long int)':
WX.cpp:50:23: error: invalid initialization of non-const reference of type 'V& {aka std::vector<int>&}' from an rvalue of type 'V {aka std::vector<int>}'
         return pro(exp(a, t-1), a);
                       ^
WX.cpp:13:3: note:   initializing argument 1 of 'V pro(V&, V&)'
 V pro(V &a, V &b)
   ^
WX.cpp: In function 'int main()':
WX.cpp:64:15: warning: unused variable 'j' [-Wunused-variable]
     int k, i, j;
               ^
WX.cpp:66:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%lld", &n, &k, &t);
                                  ^
WX.cpp:68:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &arr[i]);
                             ^