제출 #315128

#제출 시각아이디문제언어결과실행 시간메모리
315128daniel920712Cat (info1cup19_cat)C++14
25 / 100
723 ms262148 KiB
#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,j; 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]; //printf("%d %d\n",x,y); if(N-x+1==y) { swap(all[x],all[x+1]); where[all[x]]=x; where[all[x+1]]=x+1; ans.push_back(make_pair(x,x+1)); swap(all[N-x+1],all[N-x]); where[all[N-x+1]]=N-x+1; where[all[N-x]]=N-x; i--; } else { 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]); where[all[N-x+1]]=N-x+1; where[all[N-y+1]]=N-y+1; if(all[N-i+1]!=N-i+1) break; } //printf("%d %d\n",x,y); } /*for(j=1;j<=N;j++) printf("%d %d\n",all[j],where[all[j]]); printf("\n");*/ } 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; }

컴파일 시 표준 에러 (stderr) 메시지

cat.cpp: In function 'int main()':
cat.cpp:66: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=]
   66 |             printf("%d %d\n",ans.size(),ans.size());
      |                     ~^       ~~~~~~~~~~
      |                      |               |
      |                      int             std::vector<std::pair<int, int> >::size_type {aka long unsigned int}
      |                     %ld
cat.cpp:66: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=]
   66 |             printf("%d %d\n",ans.size(),ans.size());
      |                        ~^               ~~~~~~~~~~
      |                         |                       |
      |                         int                     std::vector<std::pair<int, int> >::size_type {aka long unsigned int}
      |                        %ld
cat.cpp:12:24: warning: unused variable 'j' [-Wunused-variable]
   12 |     int T,x,y,ok=1,N,i,j;
      |                        ^
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 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...