Submission #38194824
Source Code Expand
#include <iostream>
#include <string>
#include <numeric>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cctype>
#include <bitset>
#include <cassert>
#include <sstream>
#include <chrono>
using namespace std;
using namespace chrono;
typedef long long ll;
#define int ll
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define repon(i,x) for(int i=0;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
#define si(x) int(x.size())
#define popcnt(x) __builtin_popcountll(x)
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
template<class T> using vvvc = vector<vector<vector<T>>>;
template<class T> using vvvvc = vector<vector<vector<vector<T>>>>;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
//const ll mod = 998244353;
template<class T> void pval(T s, int pre=0, int zp=0){
if (zp == 0) cout << fixed << setprecision(pre);
else cout << setfill('0') << setw(zp);
cout << s << endl;
}
template<class T> void parrV(vc<T> a){
rep(i, (T)a.size()) pval(a[i]);
}
template<class T> void parrH(vc<T> a){
rep(i, (T)a.size()){
if(i) cout << " ";
cout << a[i];
}
cout << endl;
}
template<class T> void parrV(set<T> a){
rep(i, (T)a.size()) pval(*next(a.begin(), i));
}
template<class T> void parrV(set<pair<T,T>> a){
rep(i, (T)a.size()) cout << next(a.begin(), i)->fi << " " << next(a.begin(), i)->sc << endl;
}
template<class T> void parrH(set<T> a){
rep(i, (T)a.size()){
if(i) cout << " ";
cout << *next(a.begin(), i);
}
cout << endl;
}
template<class T> void parrV(vc<pair<T,T>> a){
rep(i, (T)a.size()){
cout << next(a.begin(), i)->fi << " " << next(a.begin(), i)->sc << endl;
}
}
template<class T> void parrV(vc<pair<char,T>> a){
rep(i, (T)a.size()){
cout << next(a.begin(), i)->fi << " " << next(a.begin(), i)->sc << endl;
}
}
template<class T> void parrV(vc<pair<string,T>> a){
rep(i, (T)a.size()){
cout << next(a.begin(), i)->fi << " " << next(a.begin(), i)->sc << endl;
}
}
template<class T> void parrV(vc<map<T,T>> a){
for(auto x: a){
cout << x.fi << " " << x.sc << endl;
}
}
template<class T> void parrV(vc<map<char,T>> a){
for(auto x: a){
cout << x.fi << " " << x.sc << endl;
}
}
template<class T> void parrV(vc<map<string,T>> a){
for(auto x: a){
cout << x.fi << " " << x.sc << endl;
}
}
template<class T> void parr2s(vvc<T> a, bool setmaxlen=false){
int max_len = 0;
if(setmaxlen){
int max_val = -INF;
rep(i, (T)a.size()){
rep(j, (T)a.size()){
max_val = max(a[i][j], max_val);
}
}
while(max_val!=0){
max_val /= 10;
max_len++;
}
}
rep(i, (T)a.size()){
rep(j, (T)a[0].size()){
if(j) cout << " ";
if(setmaxlen) cout << setw(max_len) << a[i][j];
else cout << a[i][j];
}
cout << endl;
}
cout << endl;
}
template<class T> void parr2(vvc<T> a){
rep(i, (T)a.size()){
rep(j, (T)a[0].size()){
cout << a[i][j];
}
cout << endl;
}
cout << endl;
}
int modpow(int a, int b, int m) {
int p = 1, q = a;
rep(i,63){
if ((b & (1LL << i)) != 0) {
p *= q;
p %= m;
}
q *= q;
q %= m;
}
return p;
}
struct mint {
ll x; //typedef long long ll;
mint(ll x=0):x((x%mod+mod)%mod){}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
// for prime mod
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
};
template<class T> bool chmin(T& a, T b){
if(a > b){
a = b;
return true;
}else return false;
}
template<class T> bool chmax(T& a, T b){
if(a < b){
a = b;
return true;
}else return false;
}
struct Edge{
int to;
long long w;
Edge(int to, long long w): to(to), w(w){}
};
using Graph = vvc<int>;
//using Graph = vvc<Edge>;
/*
int n, m; cin >> n >> m;
Graph G(n);
rep(i,m){
int a, b; cin >> a >> b; a--; b--;
G[a].push_back(b);
G[b].push_back(a);
}
int n, m; cin >> n >> m;
Graph G(n);
rep(i,m){
int a, b; int w; cin >> a >> b >> w; a--; b--;
G[a].push_back(Edge(b, w));
}
rep(bit, (1<<n)){
if(popcnt(bit) >= 5) continue;
rep(i,n){
if(bit & (1<<i)){
}
}
}
*/
signed main(){
int n,p,q,r,s; cin >> n >> p >> q >> r >> s; p--; q--; r--; s--;
vc<int> a(n);
rep(i,n) cin >> a[i];
vc<int> b(q-p);
int j=0;
int k=0;
rep(i,n){
if(i >= p & i <= q){
cout << a[r+j];
j++;
}else if(i >= r && i <= s){
cout << a[p+k];
k++;
}
else cout << a[i];
if(i != n-1) cout << " ";
}
cout << endl;
return 0;
}
Submission Info
Submission Time
2023-01-21 21:06:51+0900
Task
A - Range Swap
User
neustein
Language
C++ (GCC 9.2.1)
Score
100
Code Size
7054 Byte
Status
AC
Exec Time
6 ms
Memory
3524 KiB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:287:14: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
287 | if(i >= p & i <= q){
| ~~^~~~
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
100 / 100
Status
Set Name
Test Cases
Sample
example_00.txt, example_01.txt, example_02.txt, example_03.txt
All
example_00.txt, example_01.txt, example_02.txt, example_03.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt
Case Name
Status
Exec Time
Memory
example_00.txt
AC
6 ms
3372 KiB
example_01.txt
AC
2 ms
3480 KiB
example_02.txt
AC
2 ms
3296 KiB
example_03.txt
AC
3 ms
3476 KiB
hand_00.txt
AC
2 ms
3476 KiB
hand_01.txt
AC
3 ms
3484 KiB
hand_02.txt
AC
2 ms
3436 KiB
hand_03.txt
AC
3 ms
3372 KiB
random_00.txt
AC
2 ms
3360 KiB
random_01.txt
AC
2 ms
3368 KiB
random_02.txt
AC
2 ms
3296 KiB
random_03.txt
AC
2 ms
3464 KiB
random_04.txt
AC
2 ms
3296 KiB
random_05.txt
AC
5 ms
3524 KiB