제출 #612626

#제출 시각아이디문제언어결과실행 시간메모리
612626krit3379Jakarta Skyscrapers (APIO15_skyscraper)C++17
57 / 100
100 ms25452 KiB
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define N 30005 struct A{ unsigned short a,b,c; }; int a[N],p[N],f,b; vector<int> g[N]; bitset<N> vis; gp_hash_table<int,int> s[N]; A arr[8000000]; int main(){ int n,m,i; scanf("%d %d",&n,&m); for(i=0;i<m;i++){ scanf("%d %d",&a[i],&p[i]); g[a[i]].push_back(p[i]); } arr[0]={a[0],p[0],0}; s[a[0]][p[0]]; while(f<=b){ auto [u,i,o]=arr[f++]; int x=u,po=i,w=o; if(x==a[1]){printf("%d",w);return 0;} if(x>=po&&s[x-po].find(po)==s[x-po].end())arr[++b]={x-po,po,w+1},s[x-po][po]; if(x+po<n&&s[x+po].find(po)==s[x+po].end())arr[++b]={x+po,po,w+1},s[x+po][po]; if(vis[x])continue; vis[x]=true; for(auto po:g[x]){ if(x>=po&&s[x-po].find(po)==s[x-po].end())arr[++b]={x-po,po,w+1},s[x-po][po]; if(x+po<n&&s[x+po].find(po)==s[x+po].end())arr[++b]={x+po,po,w+1},s[x+po][po]; } } printf("-1"); return 0; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:26:16: warning: narrowing conversion of 'a[0]' from 'int' to 'short unsigned int' [-Wnarrowing]
   26 |     arr[0]={a[0],p[0],0};
      |             ~~~^
skyscraper.cpp:26:21: warning: narrowing conversion of 'p[0]' from 'int' to 'short unsigned int' [-Wnarrowing]
   26 |     arr[0]={a[0],p[0],0};
      |                  ~~~^
skyscraper.cpp:32:62: warning: narrowing conversion of '(x - po)' from 'int' to 'short unsigned int' [-Wnarrowing]
   32 |         if(x>=po&&s[x-po].find(po)==s[x-po].end())arr[++b]={x-po,po,w+1},s[x-po][po];
      |                                                             ~^~~
skyscraper.cpp:32:66: warning: narrowing conversion of 'po' from 'int' to 'short unsigned int' [-Wnarrowing]
   32 |         if(x>=po&&s[x-po].find(po)==s[x-po].end())arr[++b]={x-po,po,w+1},s[x-po][po];
      |                                                                  ^~
skyscraper.cpp:32:70: warning: narrowing conversion of '(w + 1)' from 'int' to 'short unsigned int' [-Wnarrowing]
   32 |         if(x>=po&&s[x-po].find(po)==s[x-po].end())arr[++b]={x-po,po,w+1},s[x-po][po];
      |                                                                     ~^~
skyscraper.cpp:33:63: warning: narrowing conversion of '(x + po)' from 'int' to 'short unsigned int' [-Wnarrowing]
   33 |         if(x+po<n&&s[x+po].find(po)==s[x+po].end())arr[++b]={x+po,po,w+1},s[x+po][po];
      |                                                              ~^~~
skyscraper.cpp:33:67: warning: narrowing conversion of 'po' from 'int' to 'short unsigned int' [-Wnarrowing]
   33 |         if(x+po<n&&s[x+po].find(po)==s[x+po].end())arr[++b]={x+po,po,w+1},s[x+po][po];
      |                                                                   ^~
skyscraper.cpp:33:71: warning: narrowing conversion of '(w + 1)' from 'int' to 'short unsigned int' [-Wnarrowing]
   33 |         if(x+po<n&&s[x+po].find(po)==s[x+po].end())arr[++b]={x+po,po,w+1},s[x+po][po];
      |                                                                      ~^~
skyscraper.cpp:37:66: warning: narrowing conversion of '(x - po)' from 'int' to 'short unsigned int' [-Wnarrowing]
   37 |             if(x>=po&&s[x-po].find(po)==s[x-po].end())arr[++b]={x-po,po,w+1},s[x-po][po];
      |                                                                 ~^~~
skyscraper.cpp:37:70: warning: narrowing conversion of 'po' from 'int' to 'short unsigned int' [-Wnarrowing]
   37 |             if(x>=po&&s[x-po].find(po)==s[x-po].end())arr[++b]={x-po,po,w+1},s[x-po][po];
      |                                                                      ^~
skyscraper.cpp:37:74: warning: narrowing conversion of '(w + 1)' from 'int' to 'short unsigned int' [-Wnarrowing]
   37 |             if(x>=po&&s[x-po].find(po)==s[x-po].end())arr[++b]={x-po,po,w+1},s[x-po][po];
      |                                                                         ~^~
skyscraper.cpp:38:67: warning: narrowing conversion of '(x + po)' from 'int' to 'short unsigned int' [-Wnarrowing]
   38 |             if(x+po<n&&s[x+po].find(po)==s[x+po].end())arr[++b]={x+po,po,w+1},s[x+po][po];
      |                                                                  ~^~~
skyscraper.cpp:38:71: warning: narrowing conversion of 'po' from 'int' to 'short unsigned int' [-Wnarrowing]
   38 |             if(x+po<n&&s[x+po].find(po)==s[x+po].end())arr[++b]={x+po,po,w+1},s[x+po][po];
      |                                                                       ^~
skyscraper.cpp:38:75: warning: narrowing conversion of '(w + 1)' from 'int' to 'short unsigned int' [-Wnarrowing]
   38 |             if(x+po<n&&s[x+po].find(po)==s[x+po].end())arr[++b]={x+po,po,w+1},s[x+po][po];
      |                                                                          ~^~
skyscraper.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
skyscraper.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         scanf("%d %d",&a[i],&p[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...