Submission #74350787
Source Code Expand
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<long long> vll;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
//#define endl '\n'
ll mod = 1e9+7 ;
int p1 = 31 , p2 = 91 ;
ll mod1= 1e9+7 , mod2 = 1e9+9 ;
const double PI = acos(-1) ;
using cd = complex<double> ;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
struct base {
double a, b;
base(double a = 0, double b = 0) : a(a), b(b) {}
const base operator + (const base &c) const
{ return base(a + c.a, b + c.b); }
const base operator - (const base &c) const
{ return base(a - c.a, b - c.b); }
const base operator * (const base &c) const
{ return base(a * c.a - b * c.b, a * c.b + b * c.a); }
};
void fft(vector<base> &p, bool inv = 0) {
int n = p.size(), i = 0;
for(int j = 1; j < n - 1; ++j) {
for(int k = n >> 1; k > (i ^= k); k >>= 1);
if(j < i) swap(p[i], p[j]);
}
for(int l = 1, m; (m = l << 1) <= n; l <<= 1) {
double ang = 2 * PI / m;
base wn = base(cos(ang), (inv ? 1. : -1.) * sin(ang)), w;
for(int i = 0, j, k; i < n; i += m) {
for(w = base(1, 0), j = i, k = i + l; j < k; ++j, w = w * wn) {
base t = w * p[j + l];
p[j + l] = p[j] - t;
p[j] = p[j] + t;
}
}
}
if(inv) for(int i = 0; i < n; ++i) p[i].a /= n, p[i].b /= n;
}
vector<long long> multiply(vector<int> &a, vector<int> &b) {
int n = a.size(), m = b.size(), t = n + m - 1, sz = 1;
while(sz < t) sz <<= 1;
vector<base> x(sz), y(sz), z(sz);
for(int i = 0 ; i < sz; ++i) {
x[i] = i < (int)a.size() ? base(a[i], 0) : base(0, 0);
y[i] = i < (int)b.size() ? base(b[i], 0) : base(0, 0);
}
fft(x), fft(y);
for(int i = 0; i < sz; ++i) z[i] = x[i] * y[i];
fft(z, 1);
vector<long long> ret(sz);
for(int i = 0; i < sz; ++i) ret[i] = (long long) round(z[i].a);
while((int)ret.size() > 1 && ret.back() == 0) ret.pop_back();
return ret;
}
void solve() {
int n ; cin >> n ;
vector<pair<string,int>> v(n) ;
for(int i = 0 ; i < n ;++i) cin >> v[i].first >> v[i].second ;
int m = 1e9 +1 ;
int ind = -1 ;
for(int i = 0 ; i < n ;++i) {
if(v[i].second<m) {
m = v[i].second;
ind = i ;
}
}
for(int i = 0 ; i < n ;++i) {
cout << v[(i+ind)%n].first<< endl;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}
Submission Info
| Submission Time |
|
| Task |
B - First Player |
| User |
Code_Pro |
| Language |
C++23 (GCC 15.2.0) |
| Score |
100 |
| Code Size |
2785 Byte |
| Status |
AC |
| Exec Time |
1 ms |
| Memory |
3680 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
100 / 100 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
example0.txt, example1.txt |
| All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, example0.txt, example1.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 000.txt |
AC |
1 ms |
3632 KiB |
| 001.txt |
AC |
1 ms |
3620 KiB |
| 002.txt |
AC |
1 ms |
3680 KiB |
| 003.txt |
AC |
1 ms |
3648 KiB |
| 004.txt |
AC |
1 ms |
3648 KiB |
| 005.txt |
AC |
1 ms |
3456 KiB |
| 006.txt |
AC |
1 ms |
3464 KiB |
| 007.txt |
AC |
1 ms |
3568 KiB |
| 008.txt |
AC |
1 ms |
3596 KiB |
| 009.txt |
AC |
1 ms |
3548 KiB |
| 010.txt |
AC |
1 ms |
3476 KiB |
| 011.txt |
AC |
1 ms |
3648 KiB |
| example0.txt |
AC |
1 ms |
3632 KiB |
| example1.txt |
AC |
1 ms |
3476 KiB |