답안 #43490

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43490 2018-03-16T16:33:36 Z Fated001 Palembang Bridges (APIO15_bridge) C++14
0 / 100
3 ms 696 KB
#include<bits/stdc++.h>
using namespace std;
pair<long long,long long> P[5005];
long long pos[100005];
int main()
{
   int k,n;
   scanf("%d %d",&k,&n);
   if(k==2) assert(0);
   long long out=0;
   int cnt=0,c=0;
   for(int i=1;i<=n;i++)
   {
      long long a,b;
      char s1[2],s2[2];
      scanf("%s %lld %s %lld",s1,&a,s2,&b);
      if(s1[0]==s2[0]) out+=abs(b-a);
      else
      {
         pos[++cnt]=a;
         pos[++cnt]=b;
         P[++c]={a,b};
      }
   }
   long long mn=LLONG_MAX;
   for(int i=1;i<=cnt;i++)
   {
      long long tmp=0;
      for(int j=1;j<=c;j++)
         tmp+=abs(pos[i]-P[j].first)+1+abs(pos[i]-P[j].second);
      mn=min(mn,tmp);
   }
   printf("%lld\n",out+mn);
}

Compilation message

bridge.cpp: In function 'int main()':
bridge.cpp:8:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d",&k,&n);
                        ^
bridge.cpp:16:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%s %lld %s %lld",s1,&a,s2,&b);
                                           ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 532 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 648 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 696 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -