QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#59500#3433. Xor MaximizationyahocoAC ✓612ms103364kbJava111.0kb2022-10-29 19:27:052022-10-29 19:27:09

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-29 19:27:09]
  • 评测
  • 测评结果:AC
  • 用时:612ms
  • 内存:103364kb
  • [2022-10-29 19:27:05]
  • 提交

answer

import java.io.*;
import java.util.*;
import java.lang.Math;

public class Xormax {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        Vector<Long> a = new Vector<Long> ();
        String s[] = in.readLine().split(" ");
        for (int i = 0; i < n; ++i)
            a.add(Long.parseLong(s[i]));

        long res = 0;
        for (int b = 60; b >= 0; --b)
        {
            for (int i = 0; i < a.size(); i++)
                if (a.get(i) >= 1L<<b)
            {
                Long cur = a.get(i);
                if ((res & 1L<<b) == 0)
                    res ^= cur;
                for (int j = 0; j < a.size(); j++)
                    if (a.get(j) >= 1L<<b)
                        a.set(j, a.elementAt(j) ^ cur);
                a.remove(i);
                break;
            }
        }
        System.out.println(res);
    }
}

详细

Test #1:

score: 100
Accepted
time: 134ms
memory: 35080kb

input:

4
9 12 6 3

output:

15

result:

ok single line: '15'

Test #2:

score: 0
Accepted
time: 131ms
memory: 34968kb

input:

2
5 5

output:

5

result:

ok single line: '5'

Test #3:

score: 0
Accepted
time: 106ms
memory: 34948kb

input:

14
727656223459865191 46734384439509901 352731051433687991 872737646419514461 6394223127373478 122226718859492962 991650508481700423 68404068934835268 181523155840050401 513266597294984183 377142102015718971 258937141002888370 228103993964680576 857125736352310010

output:

1152884976327387407

result:

ok single line: '1152884976327387407'

Test #4:

score: 0
Accepted
time: 120ms
memory: 35064kb

input:

11
733786329171582042 103629652512066028 872666982654708386 744174176071588678 468068652858644860 91682974870255741 20498920835104039 689440785841585755 798745762089054811 806771608966370029 259838268344063002

output:

1152584652250311431

result:

ok single line: '1152584652250311431'

Test #5:

score: 0
Accepted
time: 146ms
memory: 34980kb

input:

24
959012475231154386 539414450391485757 11328061950879205 716865129227948885 944038185582960548 442071198381030454 867284673285745810 527762046221995131 472826510901121950 146395135767629264 190379473184806507 806943900961289018 95447753527417363 335280245764008035 747810116191957466 83863930074439...

output:

1152921423206646539

result:

ok single line: '1152921423206646539'

Test #6:

score: 0
Accepted
time: 152ms
memory: 34932kb

input:

43
649550373872406733 469213177240140942 970424048966598837 140354423648517557 412097155778238053 336442500190447119 902221757519472508 381040589624464029 937274573539726968 377614419613188989 735337568430103671 608019970936342808 739071341172751885 972337839285045880 449178724331479829 893113936186...

output:

1152921504606842111

result:

ok single line: '1152921504606842111'

Test #7:

score: 0
Accepted
time: 110ms
memory: 34740kb

input:

59
849048759349277294 388396784758380200 803346769291138431 172901561486008020 707327354206372729 598279862144206712 386591440990771152 638424529049690655 380168759520097761 176874438049206817 556493738402010119 741550479370950965 316565533502046480 255234203398584204 944958756613069674 926091377308...

output:

1152921504606846975

result:

ok single line: '1152921504606846975'

Test #8:

score: 0
Accepted
time: 125ms
memory: 34672kb

input:

50
964795927480393866 230185044715761239 763101510672454922 388161128644484848 101452120776585297 888915637253030264 496133753887092229 522684356146479693 619963995783618156 204243252890150827 594126756767256805 261367289896116473 214205729876218732 290379767301298968 969663931381649174 669140149974...

output:

1152921504606846411

result:

ok single line: '1152921504606846411'

Test #9:

score: 0
Accepted
time: 388ms
memory: 45868kb

input:

9650
606820689117695293 575080092666354640 401860424840754904 866966950991434609 794308369501123115 507297646764260667 690597046070994621 652441047978616659 764521047147069647 345976413698460573 354223869099277616 818213849855356882 39599933479294393 641303196100755765 846809611236934090 18903129636...

output:

1152921504606846975

result:

ok single line: '1152921504606846975'

Test #10:

score: 0
Accepted
time: 612ms
memory: 103364kb

input:

100000
411201050377970238 632033856935985100 278118343965985522 616323158240729564 434523013929725014 728053038605060634 450808570135495970 645661326094415184 654507008810474313 81232693413706255 291022297738494175 462615801297105951 321333219572294285 955310960304146965 112685332516233870 153357680...

output:

1152921504606846975

result:

ok single line: '1152921504606846975'

Test #11:

score: 0
Accepted
time: 540ms
memory: 59404kb

input:

99990
259838268344063002 20498920835104039 91682974870255741 103629652512066028 806771608966370029 91682974870255741 103629652512066028 733786329171582042 103629652512066028 468068652858644860 103629652512066028 798745762089054811 872666982654708386 733786329171582042 872666982654708386 744174176071...

output:

1152584652250311431

result:

ok single line: '1152584652250311431'

Test #12:

score: 0
Accepted
time: 561ms
memory: 59732kb

input:

99984
432757016933967469 651689254605223607 959012475231154386 190379473184806507 959012475231154386 587430751049199816 716865129227948885 747810116191957466 832431124939231927 747810116191957466 806943900961289018 653497804185148572 472826510901121950 959012475231154386 95447753527417363 7478101161...

output:

1152921423206646539

result:

ok single line: '1152921423206646539'

Test #13:

score: 0
Accepted
time: 597ms
memory: 76676kb

input:

99946
749959279063472693 635421554808965846 400381486077924791 60612833800006612 626396688348128154 842444025523394056 166558205678238358 140108187114583899 783294487671630815 749142967960745100 255234203398584204 981608932098437924 987737618935510345 359544425050587549 380168759520097761 1530284547...

output:

1152921504606846975

result:

ok single line: '1152921504606846975'