結果
| 問題 |
No.1386 Range add Simulation
|
| コンテスト | |
| ユーザー |
maple116
|
| 提出日時 | 2021-02-07 22:36:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,859 bytes |
| コンパイル時間 | 3,856 ms |
| コンパイル使用メモリ | 204,788 KB |
| 最終ジャッジ日時 | 2025-01-18 15:02:38 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 WA * 44 |
ソースコード
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//g++ hoge.cpp (-std=c++17) -I . で実行
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
#define rept(itr,v) for(auto itr=v.begin();itr!=v.end();itr++)
#define rept1(itr,v) for(auto itr=v.begin()+1;itr!=v.end();itr++)
#define rept2(itr,v) for(auto itr=v.begin();itr!=v.end()-1;itr++)
#define print(x) cout << (x) << endl;
#define fprint(x) printf("%.15lf\n",(x));
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define print3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl;
#define YesNo(test) cout << ((test) ? "Yes" : "No") << endl
#define debug cout << "debug_print" << endl
#define Bint boost::multiprecision::cpp_int
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
ll myceil(ll a, ll b) { return (a+b-1) / b; }
//const ll mod = 1e9+7;
//const ll mod = 998244353;
//typedef modint1000000007 mint;
//typedef modint998244353 mint;
//typedef modint mint
//cout << sum.val() << endl;
//mint::set_mod(mod); modが固定でないとき
ll n,q,c[50000],s[50000],a,b,d,x,js[100005];
vector<pair<ll,prl>> vs[10];
int main() {
// your code goes here
cin >> n >> q;
rep(i,1,q){
cin >> c[i] >> s[i];
}
if(n<=10){
rep(i,1,q){
rep(j,1,n){
if(c[i]==1 && j>=s[i]) js[j] += (j-s[i]+1)*(j-s[i]+1);
if(c[i]==2 && j<=s[i]) js[j] += (s[i]-j+1)*(s[i]-j+1);
}
}
//rep(i,1,n) print(js[i]);
rep(i,1,n) x += js[i];
print(x);
rep(i,1,n){
rep(j,1,js[i]) print2(1,i);
}
return 0;
}
rep(i,1,q){
if(c[i]==1){
if(s[i]==1) a += 1;
if(s[i]==1) b += 3;
if(s[i]==2) b += 1;
if(s[i]<=2) d += 2;
if(s[i]==3) d += 1;
if(s[i]>=4){
x++;
vs[1].pb({1,{s[i],0}});
}
if(s[i]>=3 && s[i]<=n-1){
x++;
vs[1].pb({1,{s[i]+1,0}});
}
} else {
a += s[i]*s[i];
b += (3 - 2 * s[i]);
if(s[i]>=2) d += 2;
if(s[i]>=2&&s[i]<=n-2){
x++;
vs[1].pb({2,{s[i]+2,0}});
}
if(s[i]>=1&&s[i]<=n-3){
x++;
vs[1].pb({2,{s[i]+3,0}});
}
}
}
while(a>0){
x++;
if(a%2==0){
vs[2].pb({3,{1,1}});
a /= 2;
} else {
vs[2].pb({1,{1,0}});
a -= 1;
}
}
while(b>0){
x++;
if(b%2==0){
vs[3].pb({3,{2,2}});
b /= 2;
} else {
vs[3].pb({1,{2,0}});
b -= 1;
}
}
while(d>0){
x++;
if(d%2==0){
vs[4].pb({3,{3,3}});
d /= 2;
} else {
vs[4].pb({1,{3,0}});
d -= 1;
}
}
print(x+(n-3)+(n-2)+(n-1));
repr(i,4,1){
if(i>=2) reverse(all(vs[i]));
for(auto to: vs[i]){
if(to.first<=2){
print2(to.first,to.second.first);
} else {
print3(to.first,to.second.first,to.second.second);
}
}
}
repr(i,3,1){
rep(j,i+1,n){
print3(3,j,j-1);
}
}
return 0;
}
maple116