Submission #908730

#TimeUsernameProblemLanguageResultExecution timeMemory
908730speedcodeXORanges (eJOI19_xoranges)C++17
75 / 100
1045 ms3232 KiB
#include <stdio.h>

int main(){
    int n,q;
    scanf("%d", &n);
    scanf("%d", &q);
    long long values[n+2];
    long long temp;
    values[0] = 0;
    values[1] = 0;
    for(int i = 0; i < n; i++){
        scanf("%I64d", &temp);
        values[i+2] = temp ^ values[i];
    }
    for(int i = 0; i < q; i++){
        int typ; 
        scanf("%d", &typ);
        if(typ==2){
            int a,b;
            scanf("%d", &a);
            scanf("%d", &b);
            if((b-a) % 2 == 0){
                printf("%d\n", values[a-1] ^ values[b+1]);
            } else printf("0\n");
        } else {
            int pos;
            scanf("%d", &pos);
            scanf("%I64d", &temp);
            long long diff = (values[pos+1] ^ values[pos-1]) ^ temp;
            for(int j = pos+1; j < n+2; j+=2){
                values[j] = values[j] ^ diff;
            }
        }
    }
}

Compilation message (stderr)

xoranges.cpp: In function 'int main()':
xoranges.cpp:12:20: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   12 |         scanf("%I64d", &temp);
      |                ~~~~^   ~~~~~
      |                    |   |
      |                    |   long long int*
      |                    int*
      |                %I64lld
xoranges.cpp:23:26: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   23 |                 printf("%d\n", values[a-1] ^ values[b+1]);
      |                         ~^     ~~~~~~~~~~~~~~~~~~~~~~~~~
      |                          |                 |
      |                          int               long long int
      |                         %lld
xoranges.cpp:28:24: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   28 |             scanf("%I64d", &temp);
      |                    ~~~~^   ~~~~~
      |                        |   |
      |                        |   long long int*
      |                        int*
      |                    %I64lld
xoranges.cpp:5:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
xoranges.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
xoranges.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%I64d", &temp);
      |         ~~~~~^~~~~~~~~~~~~~~~
xoranges.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%d", &typ);
      |         ~~~~~^~~~~~~~~~~~
xoranges.cpp:20:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |             scanf("%d", &a);
      |             ~~~~~^~~~~~~~~~
xoranges.cpp:21:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |             scanf("%d", &b);
      |             ~~~~~^~~~~~~~~~
xoranges.cpp:27:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |             scanf("%d", &pos);
      |             ~~~~~^~~~~~~~~~~~
xoranges.cpp:28:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |             scanf("%I64d", &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...