Submission #43426

#TimeUsernameProblemLanguageResultExecution timeMemory
43426duicemanPalembang Bridges (APIO15_bridge)C++14
0 / 100
5 ms3696 KiB
#include <bits/stdc++.h> using namespace std; #define x first #define y second #define umap unordered_map #define pqueue priority_queue #define mset multiset #define mp make_pair #define mt make_tuple #define all(x) x.begin(),x.end() #define long long long #define MOD 1000000007 #define MAX (int)(1e9+5) #define MIN (int)(-1e9-5) #define FILEIN_ freopen("__in.txt","r",stdin) #define FILEOUT_ freopen("__out.txt","w",stdout) #define FILEIO_ freopen("__in.txt","r",stdin),freopen("__out.txt","w",stdout) #define FILEIN(text) freopen(text,"r",stdin) #define FILEOUT(text) freopen(text,"w",stdout) #define FILEIO(text) freopen(text".in","r",stdin),freopen(text".out","w",stdout) char c1[5],c2[5]; umap<int,int> in,out; main(){ int t,i,j,k,n,m,x,y,res=0,l=0,r=0,mn=MAX; set<int> pos; in.reserve(200005); out.reserve(200005); scanf("%d %d",&m,&n); if(m != 1) return 136; for(i = 1; i <= n; i++){ scanf("%s %d %s %d",c1,&x,c2,&y); x++; y++; res += y-x; if(c1[0] == c2[0]){ n--; i--; continue; } res += m; if(x > y) swap(x,y); in[x]++; out[y]++; pos.emplace(x); pos.emplace(y); } l = r = 0; for(int x : pos){ res += x*2*in[x]; r += in[x]; } y = 0; for(int x : pos){ res -= (x-y)*r*2; res += (x-y)*l*2; r -= in[x]; l += out[x]; mn = min(mn,res); y = x; } printf("%d\n",mn); return 0; }

Compilation message (stderr)

bridge.cpp:27:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
bridge.cpp: In function 'int main()':
bridge.cpp:28:6: warning: unused variable 't' [-Wunused-variable]
  int t,i,j,k,n,m,x,y,res=0,l=0,r=0,mn=MAX;
      ^
bridge.cpp:28:10: warning: unused variable 'j' [-Wunused-variable]
  int t,i,j,k,n,m,x,y,res=0,l=0,r=0,mn=MAX;
          ^
bridge.cpp:28:12: warning: unused variable 'k' [-Wunused-variable]
  int t,i,j,k,n,m,x,y,res=0,l=0,r=0,mn=MAX;
            ^
bridge.cpp:33:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&m,&n);
                      ^
bridge.cpp:36:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s %d %s %d",c1,&x,c2,&y);
                                   ^
#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...