제출 #13634

#제출 시각아이디문제언어결과실행 시간메모리
13634gs14004운세 보기 2 (JOI14_fortune_telling2)C++14
컴파일 에러
0 ms0 KiB
#include <cstdio> #include <vector> using namespace std; vector<int> v; int n,k; int a[200005], b[200005], q[200005]; bool flip[200005]; int main(){ scanf("%d %d",&n,&k); for (int i=0; i<n; i++) { scanf("%d %d",&a[i],&b[i]); if(a[i] > b[i]){ swap(a[i],b[i]); flip[i] = 1; } v.push_back(a[i]); v.push_back(b[i]); } sort(v.begin(),v.end()); v.resize(unique(v.begin(),v.end()) - v.begin()); for (int i=0; i<n; i++) { a[i] = (int)(lower_bound(v.begin(),v.end(),a[i]) - v.begin()); b[i] = (int)(lower_bound(v.begin(),v.end(),b[i]) - v.begin()); } for (int i=0; i<k; i++) { scanf("%d",&q[i]); q[i] = (int)(upper_bound(v.begin(),v.end(),q[i]) - v.begin()) - 1; } for (int i=0; i<n; i++) { printf("%d %d\n",a[i],b[i]); } for (int i=0; i<k; i++) { printf("%d\n",q[i]); } for (int i=0; i<k; i++) { for (int j=0; j<n; j++) { if(b[j] >= q[i]){ flip[j] ^= 1; } else if(a[j] >= q[i]){ flip[j] = 1; } } } long long ret = 0; for (int i=0; i<n; i++) { if(flip[i]) ret += v[b[i]]; else ret += v[a[i]]; } printf("%lld",ret); }

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

fortune_telling2.cpp: In function ‘int main()’:
fortune_telling2.cpp:21:27: error: ‘sort’ was not declared in this scope
     sort(v.begin(),v.end());
                           ^
fortune_telling2.cpp:22:38: error: ‘unique’ was not declared in this scope
     v.resize(unique(v.begin(),v.end()) - v.begin());
                                      ^
fortune_telling2.cpp:29:56: error: ‘upper_bound’ was not declared in this scope
         q[i] = (int)(upper_bound(v.begin(),v.end(),q[i]) - v.begin()) - 1;
                                                        ^
fortune_telling2.cpp:11:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&k);
                         ^
fortune_telling2.cpp:13:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&a[i],&b[i]);
                                   ^
fortune_telling2.cpp:28:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&q[i]);
                          ^