Submission #315021

# Submission time Handle Problem Language Result Execution time Memory
315021 2020-10-22T00:41:00 Z daniel920712 Cat (info1cup19_cat) C++14
25 / 100
678 ms 23528 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;
int all[3000005];
int where[3000005];
vector < pair < int , int > > ans;
int main()
{
    int T,x,y,ok=1,N,i;
    scanf("%d",&T);
    while(T--)
    {
        ok=1;
        ans.clear();
        scanf("%d",&N);
        for(i=1;i<=N;i++)
        {
            scanf("%d",&all[i]);
            where[all[i]]=i;
        }
        for(i=1;i<=N/2;i++)
        {
            if(all[i]!=i)
            {
                x=i;
                y=where[i];
                swap(all[x],all[y]);
                where[all[x]]=x;
                where[all[y]]=y;
                ans.push_back(make_pair(x,y));
                swap(all[N-x+1],all[N-y+1]);
            }
        }
        for(i=1;i<=N;i++) if(all[i]!=i) ok=0;
        if(ok)
        {
            printf("%d %d\n",ans.size(),ans.size());
            for(auto i:ans) printf("%d %d\n",i.first,i.second);

        }
        else printf("-1\n");
    }
    return 0;
}

Compilation message

cat.cpp: In function 'int main()':
cat.cpp:40:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wformat=]
   40 |             printf("%d %d\n",ans.size(),ans.size());
      |                     ~^       ~~~~~~~~~~
      |                      |               |
      |                      int             std::vector<std::pair<int, int> >::size_type {aka long unsigned int}
      |                     %ld
cat.cpp:40:25: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wformat=]
   40 |             printf("%d %d\n",ans.size(),ans.size());
      |                        ~^               ~~~~~~~~~~
      |                         |                       |
      |                         int                     std::vector<std::pair<int, int> >::size_type {aka long unsigned int}
      |                        %ld
cat.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |     scanf("%d",&T);
      |     ~~~~~^~~~~~~~~
cat.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         scanf("%d",&N);
      |         ~~~~~^~~~~~~~~
cat.cpp:21:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |             scanf("%d",&all[i]);
      |             ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 512 KB Wrong answer
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1024 KB Output is correct
2 Correct 28 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 512 KB Wrong answer
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1024 KB Output is correct
2 Correct 28 ms 1016 KB Output is correct
3 Correct 678 ms 21864 KB Output is correct
4 Correct 623 ms 20716 KB Output is correct
5 Correct 670 ms 23528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 512 KB Wrong answer