当前位置:网站首页>CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!)
CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!)
2022-08-02 04:25:00 【一条小小yu】
前缀和之和之我是煞笔
D. Magical Array
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Eric has an array bb of length mm, then he generates nn additional arrays c1,c2,…,cnc1,c2,…,cn, each of length mm, from the array bb, by the following way:
Initially, ci=bci=b for every 1≤i≤n1≤i≤n. Eric secretly chooses an integer kk (1≤k≤n)(1≤k≤n) and chooses ckck to be the special array.
There are two operations that Eric can perform on an array ctct:
- Operation 1: Choose two integers ii and jj (2≤i<j≤m−12≤i<j≤m−1), subtract 11 from both ct[i]ct[i] and ct[j]ct[j], and add 11 to both ct[i−1]ct[i−1] and ct[j+1]ct[j+1]. That operation can only be used on a non-special array, that is when t≠kt≠k.;
- Operation 2: Choose two integers ii and jj (2≤i<j≤m−22≤i<j≤m−2), subtract 11 from both ct[i]ct[i] and ct[j]ct[j], and add 11 to both ct[i−1]ct[i−1] and ct[j+2]ct[j+2]. That operation can only be used on a special array, that is when t=kt=k.
Note that Eric can't perform an operation if any element of the array will become less than 00 after that operation.
Now, Eric does the following:
- For every non-special array cici (i≠ki≠k), Eric uses only operation 1 on it at least once.
- For the special array ckck, Eric uses only operation 2 on it at least once.
Lastly, Eric discards the array bb.
For given arrays c1,c2,…,cnc1,c2,…,cn, your task is to find out the special array, i.e. the value kk. Also, you need to find the number of times of operation 22 was used on it.
Input
The first line contains a single integer tt (1≤t≤1041≤t≤104) — the number of test cases. Description of test cases follows.
The first line of each test case contains two integers nn and mm (3≤n≤1053≤n≤105, 7≤m≤3⋅1057≤m≤3⋅105) — the number of arrays given to you, and the length of each array.
The next nn lines contains mm integers each, ci,1,ci,2,…,ci,mci,1,ci,2,…,ci,m.
It is guaranteed that each element of the discarded array bb is in the range [0,106][0,106], and therefore 0≤ci,j≤3⋅10110≤ci,j≤3⋅1011 for all possible pairs of (i,j)(i,j).
It is guaranteed that the sum of n⋅mn⋅m over all test cases does not exceed 106106.
It is guaranteed that the input is generated according to the procedure above.
Output
For each test case, output one line containing two integers — the index of the special array, and the number of times that Operation 2 was performed on it. It can be shown that under the constraints given in the problem, this value is unique and won't exceed 10181018, so you can represent it as a 6464-bit integer. It can also be shown that the index of the special array is uniquely determined.
In this problem, hacks are disabled.
Example
input
Copy
7 3 9 0 1 2 0 0 2 1 1 0 0 1 1 1 2 0 0 2 0 0 1 2 0 0 1 2 1 0 3 7 25 15 20 15 25 20 20 26 14 20 14 26 20 20 25 15 20 15 20 20 25 3 9 25 15 20 15 25 20 20 20 20 26 14 20 14 26 20 20 20 20 25 15 20 15 25 15 20 20 25 3 11 25 15 20 15 25 20 20 20 20 20 20 26 14 20 14 26 20 20 20 20 20 20 25 15 20 15 25 20 15 20 20 20 25 3 13 25 15 20 15 25 20 20 20 20 20 20 20 20 26 14 20 14 26 20 20 20 20 20 20 20 20 25 15 20 15 25 20 20 15 20 20 20 20 25 3 15 25 15 20 15 25 20 20 20 20 20 20 20 20 20 20 26 14 20 14 26 20 20 20 20 20 20 20 20 20 20 25 15 20 15 25 20 20 20 15 20 20 20 20 20 25 3 9 909459 479492 676924 224197 162866 164495 193268 742456 728277 948845 455424 731850 327890 304150 237351 251763 225845 798316 975446 401170 792914 272263 300770 242037 236619 334316 725899output
Copy
3 1 3 10 3 15 3 20 3 25 3 30 1 1378716Note
In the first test case, the secret array bb is [0,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,0]. Array c1c1 and array c2c2 are generated by using operation 1. Array c3c3 is generated by using operation 2.
For Array c1c1,you can choose i=4i=4 and j=5j=5 perform Operation 1 one time to generate it. For Array c2c2, you can choose i=6i=6 and j=7j=7 perform Operation 1 one time to generate it. For Array c3c3,you can choose i=4i=4 and j=5j=5 perform Operation 2 one time to generate it.
In the second test case, the secret array bb is [20,20,20,20,20,20,20][20,20,20,20,20,20,20]. You can also find that array c1c1 and array c2c2 are generated by using Operation 1. Array c3c3 is generated by using Operation 2.
In the third test case, the secret array bb is [20,20,20,20,20,20,20,20,20][20,20,20,20,20,20,20,20,20]. You can also find that array c1c1 and array c2c2 are generated by using Operation 1. Array c3c3 is generated by using Operation 2.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=3e5+10;
ll sums[N],sum[N],n,m,t;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>t;
while(t--)
{
cin>>n>>m;
for(int i=1;i<=n;i++)
{
sums[i]=0;
sum[i]=0;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
ll x;
cin>>x;
sum[j]=x+sum[j-1];
sums[i]+=sum[j];
}
}
int k=1;
if(sums[n]!=sums[1]&&sums[n]!=sums[2])k=n;
for(int i=2;i<=n-1;i++)
{
if(sums[i]!=sums[1]&&sums[i]!=sums[n])k=i;
}
cout<<k<<" "<<max(sums[1],sums[2])-sums[k]<<"\n";
}
return 0;
}
边栏推荐
猜你喜欢
HyperLynx中层叠设计实例
Deep blue college - handwritten VIO operations - the first chapter
讯飞AIUI智能机器人5-----让器理解你(语音技术综合应用)
1318_将ST link刷成jlink
学内核之五:问题一,关于上下文切换
Minecraft 1.18.1、1.18.2模组开发 23.3D动画盔甲制作
爬虫_爬取wasde月度供需平衡表(实例)
Anatomy of Unreal Playback System (Part 1)
ADSP21489工程中LDF文件配置详解
Camtasia 2022简体中文版屏幕录像和视频编辑软件
随机推荐
P1012 [NOIP1998 提高组] 拼数
翻转(DAY 97)
OpenPCDet environment configuration of 3 d object detection and demo test
6个月测试经验,面试跳槽狮子大开口要18K,只会点点点,给我整无语了。。
Line generation 005
力扣练习——44 路径总和 III
互动投影墙深受展览展示喜爱的原因分析
高等数学(第七版)同济大学 总习题三(后10题) 个人解答
How to save a section of pages in a PDF as a new PDF file
爬虫_爬取wasde月度供需平衡表(实例)
STM32 OLED显示屏--SPI通信知识汇总
Batch normalization (BN) based on deep learning
找倍数(DAY 98)
Arduino框架下STM32F1/F4系列HID模式程序烧录教程
Qt FAQ
Arduino框架下ESP32重启原因串口信息输出示例
W25Q16 存储器(Flash)
线代005
深度剖析-class的几个对象(utlis,component)-瀑布流-懒加载(概念,作用,原理,实现步骤)
A practice arrangement about map GIS (below) GIS practice of Redis