답안 #363718

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
363718 2021-02-07T03:29:32 Z fhvirus 이상적인 도시 (IOI12_city) C++14
컴파일 오류
0 ms 0 KB
// Knapsack DP is harder than FFT.
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef pair<int,int> pii;
#define ff first
#define ss second
#define pb emplace_back
#define FOR(i,n) for(int i=0;i<(n);++i)
#define FOO(i,a,b) for(int i=(a);i<=int(b);++i)
#define OOF(i,a,b) for(int i=(a);i>=int(b);--i)
#define AI(x) (x).begin(),(x).end()
template<class I>bool chmax(I&a,I b){return a<b?(a=b,true):false;}
template<class I>bool chmin(I&a,I b){return b<a?(a=b,true):false;} 
template<class V>void lisan(V&v){sort(AI(v));v.erase(unique(AI(v)),v.end());}
template<class V,class T>int lspos(const V&v,T x){return lower_bound(AI(v),x)-v.begin();}
template<class...T>void RI(T&...t){(...,(cin>>t));}
template<class...T>void PL(T...t){int c=sizeof...(T);if(!c){cout<<'\n';return;}(...,(cout<<t<<(--c?' ':'\n')));}
constexpr inline ll cdiv(ll x,ll m){return x/m+(x%m?(x<0)^(m>0):0);}
constexpr inline ll mpow(ll x,ll e,ll m){ll r=1;for(x%=m;e;e/=2,x=x*x%m)if(e&1)r=r*x%m;return r;}
#ifdef OWO
#define safe cerr<<"\033[1;32m"<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<" JIZZ\033[0m\n"
#define debug(args...) SDF(#args, args)
#define OIU(args...) ostream& operator<<(ostream&O,args)
#define LKJ(S,B,E,F) template<class...T>OIU(S<T...>s){O<<B;int c=0;for(auto i:s)O<<(c++?", ":"")<<F;return O<<E;}
LKJ(vector,'[',']',i)LKJ(deque,'[',']',i)LKJ(set,'{','}',i)LKJ(multiset,'{','}',i)LKJ(unordered_set,'{','}',i)LKJ(map,'{','}',i.ff<<':'<<i.ss)LKJ(unordered_map,'{','}',i.ff<<':'<<i.ss)
template<class...T>OIU(pair<T...>p){return O<<'('<<p.ff<<','<<p.ss<<')';}
template<class T,size_t N>OIU(array<T,N>a){return O<<vector<T>(AI(a));}
template<class...T>OIU(tuple<T...>t){return O<<'(',apply([&O](T...s){int c=0;(...,(O<<(c++?", ":"")<<s));},t),O<<')';}
template<class...T>void SDF(const char* s,T...a){int c=sizeof...(T);if(!c){cerr<<"\033[1;32mvoid\033[0m\n";return;}(cerr<<"\033[1;32m("<<s<<") = (",...,(cerr<<a<<(--c?", ":")\033[0m\n")));}
#else
#pragma GCC optimize("Ofast")
#define safe ((void)0)
#define debug(...) ((void)0)
#endif
constexpr ll inf = 1e9, INF = 4e18;

#ifdef OWO
const int N = 1e5 + 225;
int n, x[N], y[N];
int DistanceSum(int N, int *X, int *Y);
int32_t main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	FOR(i,n) cin >> x[i] >> y[i];
	cout << DistanceSum(n, x, y) << endl;
	return 0;
}
#endif

ll cal(int N, int *X, int *Y){
	map<int,int> mp;
	FOR(i,N) mp[X[i]]++;
	ll ans = 0, lsize = 0;
	for(auto i: mp){
		ans += lsize * (N - lsize);
		lsize += i.ss;
	}
	return ans;
}

int DistanceSum(int N, int *X, int *Y){
	return (cal(n, x, y) + cal(n, y, x)) % 1'000'000'000ll;
}

Compilation message

city.cpp: In function 'void RI(T& ...)':
city.cpp:17:48: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17'
   17 | template<class...T>void RI(T&...t){(...,(cin>>t));}
      |                                                ^
city.cpp: In function 'void PL(T ...)':
city.cpp:18:109: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17'
   18 | template<class...T>void PL(T...t){int c=sizeof...(T);if(!c){cout<<'\n';return;}(...,(cout<<t<<(--c?' ':'\n')));}
      |                                                                                                             ^
city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:63:14: error: 'n' was not declared in this scope
   63 |  return (cal(n, x, y) + cal(n, y, x)) % 1'000'000'000ll;
      |              ^
city.cpp:63:17: error: 'x' was not declared in this scope
   63 |  return (cal(n, x, y) + cal(n, y, x)) % 1'000'000'000ll;
      |                 ^
city.cpp:63:20: error: 'y' was not declared in this scope
   63 |  return (cal(n, x, y) + cal(n, y, x)) % 1'000'000'000ll;
      |                    ^